Skip to content

Commit

Permalink
Create folder fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
joonashak committed Dec 24, 2024
1 parent ab5c0b6 commit a888c0a
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 11 deletions.
18 changes: 9 additions & 9 deletions testing/e2e/fixtures/auth.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ export const authFixture = test.extend<{}, { account: Account }>({
`http://localhost:4001/clone-bay-mocking/login?eveId=${eveId}`,
);

const folderName = `E2E Folder ${account.eveId}`;
await page.goto("/system/J100001");
await page.getByLabel("Open Settings Menu").click();
await page.getByRole("menuitem", { name: "Folder Options" }).click();
await page.getByRole("button", { name: "New Folder" }).click();
await page.getByLabel("Name").fill(folderName);
await page.getByRole("button", { name: "Create" }).click();
await page.getByLabel("Active Folder").click();
await page.getByRole("option", { name: folderName, exact: true }).click();
// const folderName = `E2E Folder ${account.eveId}`;
// await page.goto("/system/J100001");
// await page.getByLabel("Open Settings Menu").click();
// await page.getByRole("menuitem", { name: "Folder Options" }).click();
// await page.getByRole("button", { name: "New Folder" }).click();
// await page.getByLabel("Name").fill(folderName);
// await page.getByRole("button", { name: "Create" }).click();
// await page.getByLabel("Active Folder").click();
// await page.getByRole("option", { name: folderName, exact: true }).click();

await use(page);
},
Expand Down
3 changes: 2 additions & 1 deletion testing/e2e/fixtures/fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { mergeTests } from "@playwright/test";
import { authFixture } from "./auth.fixture";
import { folderFixture } from "./folder/folder.fixture";
import { mapFixture } from "./map/map.fixture";

export const test = mergeTests(authFixture, mapFixture);
export const test = mergeTests(authFixture, mapFixture, folderFixture);
9 changes: 9 additions & 0 deletions testing/e2e/fixtures/folder/folder.fixture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import test from "@playwright/test";
import { Folder } from "./folder";

export const folderFixture = test.extend<{ folder: Folder }>({
folder: async ({ page }, use) => {
const folder = new Folder(page);
await use(folder);
},
});
21 changes: 21 additions & 0 deletions testing/e2e/fixtures/folder/folder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Page } from "@playwright/test";

export class Folder {
constructor(public readonly page: Page) {}

async create(name?: string) {
const hash = crypto.randomUUID().slice(9, 13);
const folderName = name || `E2E Folder ${hash}`;

await this.page.goto("/system/J100001");
await this.page.getByLabel("Open Settings Menu").click();
await this.page.getByRole("menuitem", { name: "Folder Options" }).click();
await this.page.getByRole("button", { name: "New Folder" }).click();
await this.page.getByLabel("Name").fill(folderName);
await this.page.getByRole("button", { name: "Create" }).click();
await this.page.getByLabel("Active Folder").click();
await this.page
.getByRole("option", { name: folderName, exact: true })
.click();
}
}
3 changes: 2 additions & 1 deletion testing/e2e/tests/example.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ test("test if map fixture breaks", async ({ map }) => {
map.asd();
});

test("Create unknown signature", async ({ page }) => {
test("Create unknown signature", async ({ page, folder }) => {
await folder.create();
await page.goto("/system/J100001");
await page.getByRole("button", { name: "Add Signature" }).click();
await page.getByLabel("ID").fill("ASD-123");
Expand Down

0 comments on commit a888c0a

Please sign in to comment.