Skip to content

Commit

Permalink
test: login redirect with nested route (#9881)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkim-det authored Sep 3, 2024
1 parent 8cacba6 commit b4209ef
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
16 changes: 16 additions & 0 deletions webui/react/src/e2e/models/pages/Cluster.ts
Original file line number Diff line number Diff line change
@@ -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');
}
14 changes: 11 additions & 3 deletions webui/react/src/e2e/tests/auth.spec.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down Expand Up @@ -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');
});
});

Expand Down

0 comments on commit b4209ef

Please sign in to comment.