Skip to content

Commit 0161e01

Browse files
committed
e2e: Fix authenticate token hang up and cluster navigation
since we now use a multi cluster structure to run our tests, the cluster navigation step must be its own full nav step, different from navigateToPage, if it is tied to an auth step. Signed-off-by: Vincent T <[email protected]>
1 parent 1747906 commit 0161e01

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

e2e-tests/tests/headlampPage.ts

+15-6
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ export class HeadlampPage {
99
}
1010

1111
async authenticate(token?: string) {
12-
await this.page.waitForSelector('h1:has-text("Authentication")');
13-
1412
// Check to see if already authenticated
1513
if (await this.page.isVisible('button:has-text("Authenticate")')) {
1614
this.hasToken(token || '');
@@ -24,10 +22,16 @@ export class HeadlampPage {
2422
this.page.click('button:has-text("Authenticate")'),
2523
]);
2624
}
25+
26+
await this.page.waitForLoadState('load');
2727
}
2828

2929
async navigateToCluster(name: string, token?: string) {
30-
await this.navigateTopage(`/c/${name}`);
30+
// Since we are using multi cluster structure we need to have a full reset navigation
31+
await this.page.goto(`${this.testURL}`);
32+
await this.page.waitForLoadState('load');
33+
await this.page.getByRole('link', { name: name, exact: true }).click();
34+
await this.page.waitForLoadState('load');
3135
await this.authenticate(token);
3236
}
3337

@@ -75,11 +79,16 @@ export class HeadlampPage {
7579

7680
async logout() {
7781
// Click on the account button to open the user menu
78-
await this.page.click('button[aria-label="Account of current user"]');
82+
const userButton = await this.page.waitForSelector('[data-testid="user-account-button"]', {
83+
state: 'visible',
84+
});
85+
86+
await userButton.click();
7987

8088
// Wait for the logout option to be visible and click on it
81-
await this.page.waitForSelector('a.MuiMenuItem-root:has-text("Log out")');
82-
await this.page.click('a.MuiMenuItem-root:has-text("Log out")');
89+
await this.page.waitForSelector('[data-testid="logout-menu-item"]');
90+
await this.page.click('[data-testid="logout-menu-item"]');
91+
8392
await this.page.waitForLoadState('load');
8493

8594
// Expects the URL to contain c/test/token

frontend/src/components/App/TopBar.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ export const PureTopBar = memo(
269269
<Icon icon="mdi:logout" />
270270
</ListItemIcon>
271271
<ListItemText
272+
data-testid="logout-menu-item"
272273
primary={t('Log out')}
273274
secondary={hasToken ? null : t('(No token set up)')}
274275
/>
@@ -328,6 +329,7 @@ export const PureTopBar = memo(
328329
action: !!isClusterContext && (
329330
<MenuItem>
330331
<IconButton
332+
data-testid="user-account-button"
331333
aria-label={t('Account of current user')}
332334
aria-controls={userMenuId}
333335
aria-haspopup="true"
@@ -386,6 +388,7 @@ export const PureTopBar = memo(
386388
id: DefaultAppBarAction.USER,
387389
action: !!isClusterContext && (
388390
<IconButton
391+
data-testid="user-account-button"
389392
aria-label={t('Account of current user')}
390393
aria-controls={userMenuId}
391394
aria-haspopup="true"

frontend/src/components/App/__snapshots__/TopBar.OneCluster.stories.storyshot

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
aria-haspopup="true"
125125
aria-label="Account of current user"
126126
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-colorInherit MuiIconButton-sizeMedium css-1jcv3fz-MuiButtonBase-root-MuiIconButton-root"
127+
data-testid="user-account-button"
127128
tabindex="0"
128129
type="button"
129130
>

frontend/src/components/App/__snapshots__/TopBar.TwoCluster.stories.storyshot

+1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
aria-haspopup="true"
144144
aria-label="Account of current user"
145145
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-colorInherit MuiIconButton-sizeMedium css-1jcv3fz-MuiButtonBase-root-MuiIconButton-root"
146+
data-testid="user-account-button"
146147
tabindex="0"
147148
type="button"
148149
>

0 commit comments

Comments
 (0)