Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 33 additions & 7 deletions cypress/e2e/tests/pages/user-menu/preferences.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ProductNavPo from '@/cypress/e2e/po/side-bars/product-side-nav.po';
import { HeaderPo } from '@/cypress/e2e/po/components/header.po';
import ResourceYamlEditorPagePo from '@/cypress/e2e/po/pages/explorer/yaml-editor.po';
import { CLUSTER_REPOS_BASE_URL } from '@/cypress/support/utils/api-endpoints';
import { MEDIUM_TIMEOUT_OPT } from '@/cypress/support/utils/timeouts';
// import ClusterManagerListPagePo from '@/cypress/e2e/po/pages/cluster-manager/cluster-manager-list.po';
// import TooltipPo from '@/cypress/e2e/po/components/tooltip.po'; // Used in the below commented test

Expand Down Expand Up @@ -467,15 +468,30 @@ describe('User can update their preferences', () => {

// Verify that an auth redirect works (a user visits a page while not authorized and will be redirect to that page after loggin in, only active when "Take me to the area I last visited" is selected)
if (key.index === '1') {
userMenu.clickMenuItem('Log Out');
cy.url().should('contain', 'auth/login?logged-out');

const redirectUrl = '/c/local/explorer/node';

cy.visit(redirectUrl);
cy.url().should('contain', 'auth/login?timed-out');

cy.login(undefined, undefined, false, true);
const attemptAuthRedirect = () => {
userMenu.clickMenuItem('Log Out');
cy.url().should('contain', 'auth/login?logged-out');

cy.visit(redirectUrl);
cy.url().should('contain', 'auth/login?timed-out');

cy.login(undefined, undefined, false, true);
cy.url().should('not.contain', 'auth/login');
};

attemptAuthRedirect();
// Wait for the redirect chain to settle on either the expected page or the home page.
// A transient failure fetching preferences after login lands the user on the home page
// instead - retry the flow once to recover (authRedirect only lives in the store, so
// the whole timed-out flow needs to run again)
cy.location('pathname', MEDIUM_TIMEOUT_OPT).should('match', new RegExp(`(/home|${ redirectUrl })`));
cy.location('pathname').then((pathname) => {
if (pathname.endsWith('/home')) {
attemptAuthRedirect();
}
});
cy.url().should('contain', redirectUrl);
prefPage.goTo();
prefPage.landingPageRadioBtn().checkVisible();
Expand All @@ -485,6 +501,16 @@ describe('User can update their preferences', () => {
userMenu.clickMenuItem('Log Out');
cy.url().should('contain', 'auth/login?logged-out');
cy.login(undefined, undefined, false);
// Wait for the redirect chain to settle on either the expected landing page or the home
// page. A transient failure fetching preferences after login lands the user on the home
// page instead - re-navigating to the root re-runs a full app bootstrap which fetches the
// preferences again and re-runs the landing page redirect.
cy.location('pathname', MEDIUM_TIMEOUT_OPT).should('match', new RegExp(`(/home|${ key.page })`));
cy.location('pathname').then((pathname) => {
if (key.page !== '/home' && pathname.endsWith('/home')) {
cy.visit('/');
}
});
cy.url().should('contain', key.page);
}

Expand Down