Skip to content

Commit f3a977d

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 6290590 commit f3a977d

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

e2e-tests/tests/headlampPage.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export class HeadlampPage {
2222
this.page.click('button:has-text("Authenticate")'),
2323
]);
2424
}
25+
26+
await this.page.waitForLoadState('load');
2527
}
2628

2729
async navigateToCluster(name: string, token?: string) {
@@ -77,11 +79,16 @@ export class HeadlampPage {
7779

7880
async logout() {
7981
// Click on the account button to open the user menu
80-
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();
8187

8288
// Wait for the logout option to be visible and click on it
83-
await this.page.waitForSelector('a.MuiMenuItem-root:has-text("Log out")');
84-
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+
8592
await this.page.waitForLoadState('load');
8693

8794
// 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)