-
Notifications
You must be signed in to change notification settings - Fork 587
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix return to index page, add index-page e2e spec (#4478)
- Loading branch information
1 parent
9d329ec
commit 1df67c2
Showing
8 changed files
with
126 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { Locator, Page, expect } from "src/oss/fixtures"; | ||
import { EventUtils } from "src/shared/event-utils"; | ||
import { SelectorPom } from "./selector"; | ||
|
||
export class PagePom { | ||
readonly assert: PageAsserter; | ||
readonly datasetSelector: SelectorPom; | ||
readonly locator: Locator; | ||
|
||
constructor( | ||
private readonly page: Page, | ||
private readonly eventUtils: EventUtils | ||
) { | ||
this.assert = new PageAsserter(this); | ||
this.datasetSelector = new SelectorPom(page, eventUtils, "dataset"); | ||
} | ||
|
||
get pathname() { | ||
return this.url.pathname; | ||
} | ||
|
||
get url() { | ||
return new URL(this.page.url()); | ||
} | ||
|
||
getPage(pagename: string) { | ||
return this.page.getByTestId(`${pagename}-page`); | ||
} | ||
|
||
async loadDataset(dataset?: string) { | ||
if (!dataset) { | ||
await this.page.goto("/"); | ||
} else { | ||
await this.datasetSelector.openResults(); | ||
await this.datasetSelector.selectResult(dataset); | ||
} | ||
await this.page.waitForSelector( | ||
`[data-cy=${dataset ? "dataset" : "index"}-page]`, | ||
{ | ||
state: "visible", | ||
} | ||
); | ||
} | ||
} | ||
|
||
class PageAsserter { | ||
constructor(private readonly pagePom: PagePom) {} | ||
|
||
async verifyPage(pagename: string) { | ||
await expect(this.pagePom.getPage(pagename)).toBeVisible(); | ||
} | ||
|
||
async verifyPathname(pathname: string) { | ||
await expect(this.pagePom.pathname).toEqual(pathname); | ||
} | ||
|
||
async verifyDataset(datasetName: string) { | ||
await this.pagePom.datasetSelector.assert.verifyValue(datasetName); | ||
await expect(this.pagePom.pathname).toEqual(`/datasets/${datasetName}`); | ||
} | ||
|
||
async verifyDatasets(datasetNames: string[]) { | ||
await this.pagePom.datasetSelector.assert.verifyResults(datasetNames); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { test as base } from "src/oss/fixtures"; | ||
import { PagePom } from "src/oss/poms/page"; | ||
import { getUniqueDatasetNameWithPrefix } from "src/oss/utils"; | ||
|
||
const datasetName = getUniqueDatasetNameWithPrefix(`index-page`); | ||
|
||
const test = base.extend<{ | ||
pagePom: PagePom; | ||
}>({ | ||
pagePom: async ({ eventUtils, page }, use) => { | ||
await use(new PagePom(page, eventUtils)); | ||
}, | ||
}); | ||
|
||
test.beforeAll(async ({ fiftyoneLoader }) => { | ||
await fiftyoneLoader.executePythonCode(` | ||
import fiftyone as fo | ||
dataset = fo.Dataset("${datasetName}") | ||
dataset.persistent = True`); | ||
}); | ||
|
||
test("index page", async ({ pagePom, page }) => { | ||
await pagePom.loadDataset(); | ||
await pagePom.assert.verifyPage("index"); | ||
await pagePom.assert.verifyPathname("/"); | ||
|
||
await pagePom.loadDataset(datasetName); | ||
await pagePom.assert.verifyPage("dataset"); | ||
await pagePom.assert.verifyPathname(`/datasets/${datasetName}`); | ||
|
||
await page.goBack(); | ||
await pagePom.assert.verifyPage("index"); | ||
await pagePom.assert.verifyPathname("/"); | ||
}); |