From b4209efbc6125a269531acf5e6dd59d2ee693df1 Mon Sep 17 00:00:00 2001 From: johnkim-det <97752292+johnkim-det@users.noreply.github.com> Date: Tue, 3 Sep 2024 11:24:01 -0400 Subject: [PATCH] test: login redirect with nested route (#9881) --- webui/react/src/e2e/models/pages/Cluster.ts | 16 ++++++++++++++++ webui/react/src/e2e/tests/auth.spec.ts | 14 +++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 webui/react/src/e2e/models/pages/Cluster.ts diff --git a/webui/react/src/e2e/models/pages/Cluster.ts b/webui/react/src/e2e/models/pages/Cluster.ts new file mode 100644 index 00000000000..a365248988f --- /dev/null +++ b/webui/react/src/e2e/models/pages/Cluster.ts @@ -0,0 +1,16 @@ +import { DeterminedPage } from 'e2e/models/common/base/BasePage'; +import { DynamicTabs } from 'e2e/models/components/DynamicTabs'; +import { PageComponent } from 'e2e/models/components/Page'; + +/** + * Represents the Cluster page from src/pages/Cluster.tsx + */ +export class Cluster extends DeterminedPage { + readonly title = 'Cluster'; + readonly url = 'clusters'; + readonly pageComponent = new PageComponent({ parent: this }); + readonly dynamicTabs = new DynamicTabs({ parent: this.pageComponent }); + readonly overviewTab = this.dynamicTabs.pivot.tab('overview'); + readonly historicalUsageTab = this.dynamicTabs.pivot.tab('historical-usage'); + readonly logsTab = this.dynamicTabs.pivot.tab('logs'); +} diff --git a/webui/react/src/e2e/tests/auth.spec.ts b/webui/react/src/e2e/tests/auth.spec.ts index 60bafd94088..01cbe901266 100644 --- a/webui/react/src/e2e/tests/auth.spec.ts +++ b/webui/react/src/e2e/tests/auth.spec.ts @@ -1,4 +1,5 @@ import { expect, test } from 'e2e/fixtures/global-fixtures'; +import { Cluster } from 'e2e/models/pages/Cluster'; import { SignIn } from 'e2e/models/pages/SignIn'; test.describe('Authentication', () => { @@ -26,13 +27,20 @@ test.describe('Authentication', () => { test('Login Redirect', async ({ page, auth }) => { await test.step('Attempt to Visit a Page', async () => { - await page.goto('./models'); + await page.goto('./clusters/logs'); await expect(page).toHaveURL(/login/); }); await test.step('Login and Redirect', async () => { - await auth.login({ expectedURL: /models/ }); - await expect(page).toHaveDeterminedTitle('Model Registry'); + await auth.login({ expectedURL: /clusters\/logs/ }); + const clusterPage = new Cluster(page); + await expect(page).toHaveDeterminedTitle(clusterPage.title); + await expect(clusterPage.overviewTab.pwLocator).toHaveAttribute('aria-selected', 'false'); + await expect(clusterPage.historicalUsageTab.pwLocator).toHaveAttribute( + 'aria-selected', + 'false', + ); + await expect(clusterPage.logsTab.pwLocator).toHaveAttribute('aria-selected', 'true'); }); });