Skip to content

Commit

Permalink
proper interface for fixture + closing context after test
Browse files Browse the repository at this point in the history
  • Loading branch information
ctot-nondef committed Feb 6, 2024
1 parent d005a43 commit b6ace0a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
16 changes: 11 additions & 5 deletions e2e/fixtures/corpsum.fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ interface Account {
password: string;
}

interface Search {
term: string;
corpus: string;
}

export const login = base.extend<NonNullable<unknown>, { account: Account }>({
account: [{ username: "", password: "" }, { scope: "worker" }],
page: async ({ page, account }, use) => {
page: async ({ page, context,account }, use) => {
const { username, password } = account;
await page.goto("/en/login");
await page.getByLabel("Username").fill(username);
Expand All @@ -18,13 +23,14 @@ export const login = base.extend<NonNullable<unknown>, { account: Account }>({
await page.locator("#main-content").getByRole("button", { name: "Login" }).click();
await loginPromise;
await use(page);
await context.close();
},
});

export const search = login.extend<NonNullable<unknown>, { term: string, corpus: string }>({
term: ["", { scope: "worker" }],
corpus: ["", { scope: "worker" }],
page: async ({ page, term, corpus }, use) => {
export const search = login.extend<NonNullable<unknown>, { search: Search }>({
search: [{term: "", corpus: ""}, { scope: "worker" }],
page: async ({ page, search }, use) => {
const { term, corpus } = search;
await page.getByRole("combobox").first().click();
const corpusPromise = page.waitForResponse(
`https://noskecrystal5corpsum.acdh-dev.oeaw.ac.at/run.cgi/corp_info?corpname=${corpus}&subcorpora=1&format=json`,
Expand Down
3 changes: 2 additions & 1 deletion e2e/pages/results.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { expect } from "@playwright/test";
import { search as test } from "../fixtures/corpsum.fixtures";

const account = { username: process.env.TEST_USER!, password: process.env.TEST_PASSWORD! };
test.use({ account, term: "haus", corpus: "amc_4.2" });
const search = { term: "haus", corpus: "amc_4.2" };
test.use({ account, search });

test.describe("Search Result Display", () => {
test("should be able to display result information on selected searches", async ({ page }) => {
Expand Down

0 comments on commit b6ace0a

Please sign in to comment.