group tests using .describe

This commit is contained in:
MarconLP 2023-04-15 23:21:00 +02:00
parent d3723a3e75
commit 141c3e385c
No known key found for this signature in database
GPG key ID: A08A9C8B623F5EA5
4 changed files with 92 additions and 75 deletions

View file

@ -7,7 +7,7 @@
"dev": "next dev",
"postinstall": "prisma generate",
"lint": "next lint",
"test:e2e": "npm run db-seed && playwright test --workers 1 --headed",
"test:e2e": "npm run db-seed && playwright test --headed",
"db-seed": "NODE_ENV=development prisma db seed",
"start": "next start"
},

View file

@ -1,5 +1,6 @@
import { test, expect } from "@playwright/test";
test.describe("landing", () => {
test("should show logged in state on landing page", async ({ page }) => {
await page.goto("http://localhost:3000/");
await expect(
@ -8,3 +9,4 @@ test("should show logged in state on landing page", async ({ page }) => {
)
).toContainText("Logged in as E2E Account");
});
});

View file

@ -1,9 +1,12 @@
import { test, expect } from "@playwright/test";
test.describe("videos", () => {
test("should be able to view videos", async ({ page }) => {
await page.goto("http://localhost:3000/");
await page
.getByRole("link", { name: "Go to Videos → The entire videos collection" })
.getByRole("link", {
name: "Go to Videos → The entire videos collection",
})
.click();
await expect(page).toHaveURL("http://localhost:3000/videos");
});
@ -22,11 +25,17 @@ test("can upload video", async ({ page }) => {
.getByText("Drop files to Attach, or browse")
.setInputFiles("tests/assets/example_video.webm");
await page.getByRole("button", { name: "Upload" }).click();
await expect(page).toHaveURL(/http:\/\/localhost:3000\/share\/[A-Za-z0-9]+/, {
await expect(page).toHaveURL(
/http:\/\/localhost:3000\/share\/[A-Za-z0-9]+/,
{
timeout: 30000,
});
}
);
await page.click('[href="/videos"]');
await page.getByText("example_video.webm").click();
await expect(page).toHaveURL(/http:\/\/localhost:3000\/share\/[A-Za-z0-9]+/);
await expect(page).toHaveURL(
/http:\/\/localhost:3000\/share\/[A-Za-z0-9]+/
);
});
});

View file

@ -1,9 +1,12 @@
import { expect, test } from "@playwright/test";
test.describe("video", () => {
test("should be able to view video", async ({ page }) => {
await page.goto("http://localhost:3000/videos");
await page.locator("div.grid > a:nth-child(1)").click();
await expect(page).toHaveURL(/http:\/\/localhost:3000\/share\/[A-Za-z0-9]+/);
await expect(page).toHaveURL(
/http:\/\/localhost:3000\/share\/[A-Za-z0-9]+/
);
const video = page.locator("video");
expect(video).toBeTruthy();
@ -20,7 +23,9 @@ test("should be able to rename video", async ({ page }) => {
await page.goto("http://localhost:3000/videos");
await page.locator("div.grid > a:nth-child(1)").click();
await expect(page).toHaveURL(/http:\/\/localhost:3000\/share\/[A-Za-z0-9]+/);
await expect(page).toHaveURL(
/http:\/\/localhost:3000\/share\/[A-Za-z0-9]+/
);
await page.locator("button > svg").click();
await page.getByText("Rename").click();
@ -35,10 +40,11 @@ test("should be able to rename video", async ({ page }) => {
test("should be able to share video", async ({ page }) => {
await page.goto("http://localhost:3000/videos");
await page.locator("div.grid > a:nth-child(1)").click();
await expect(page).toHaveURL(/http:\/\/localhost:3000\/share\/[A-Za-z0-9]+/);
await expect(page).toHaveURL(
/http:\/\/localhost:3000\/share\/[A-Za-z0-9]+/
);
await page.getByText("Share").click();
await page.locator('div.mt-6 > button[role="switch"]').click();
await page.waitForTimeout(5000);
});
});