Skip to content

Commit

Permalink
test(e2e): update e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Stéphane authored and stephane-r committed Dec 8, 2023
1 parent 0deb3eb commit a82b098
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 27 deletions.
2 changes: 0 additions & 2 deletions e2e/colorScheme.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@ test("colorscheme interface", async ({ page }) => {
await expect(
page.locator("html[data-mantine-color-scheme=dark]"),
).toBeVisible();

await expect(page).toHaveScreenshot();
});
2 changes: 0 additions & 2 deletions e2e/dashboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@ test("default blocks are visible", async ({ page }) => {
await expect(
page.getByRole("list", { name: "Moods & genres" }).getByRole("listitem"),
).toHaveCount(113);

await expect(page).toHaveScreenshot();
});
3 changes: 2 additions & 1 deletion e2e/favorites.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { expect, test } from "@playwright/test";

import { navigateTo } from "./utils";
import { navigateTo, selectedInstance } from "./utils";

test("save card in favorites", async ({ page }) => {
await page.goto("localhost:3000");
await selectedInstance(page, "invidious.fdn.fr");

// Go to Trending page
await page.getByRole("button", { name: "Trending" }).click();
Expand Down
10 changes: 5 additions & 5 deletions e2e/playlists.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import {
navigateTo,
search,
selectSearchType,
selectedInstance,
} from "./utils";

const createPlaylist = async (page, title: string) => {
await selectedInstance(page, "invidious.fdn.fr");
await navigateTo(page, "Playlists", "Playlists");

// Open modal to create playlist
Expand Down Expand Up @@ -85,7 +87,7 @@ test.describe.serial("playlists", () => {
.getByRole("form", { name: "Form add to playlist" })
.getByPlaceholder("Your playlist")
.click();
await page.getByRole("option", { name: "My first playlist" }).click();
await page.locator('[value="My first playlist"]').click();
await expect(
page
.getByRole("form", { name: "Form add to playlist" })
Expand All @@ -105,7 +107,7 @@ test.describe.serial("playlists", () => {
await expect(page.getByRole("listitem")).toContainText("1 videos");

// Save remote playlist to user playlists
await selectSearchType(page, "Playlists");
await selectSearchType(page, "playlist");
await search(page, "Tomorrowland 2018");

await page
Expand Down Expand Up @@ -167,9 +169,7 @@ test.describe.serial("playlists", () => {
.click();

// Verify notification visibility
await expect(page.getByRole("alert")).toContainText(
/Awesome playlist updated has been updated/,
);
await checkNotification(page, /Awesome playlist updated has been updated/);

await page.reload();

Expand Down
6 changes: 4 additions & 2 deletions e2e/search.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { expect, test } from "@playwright/test";

import { search } from "./utils";
import { listVisibility, search, selectSearchType, selectedInstance } from "./utils";

test.describe.serial("search", () => {
test("search an artist", async ({ page }) => {
await page.goto("localhost:3000");

await selectedInstance(page, "invidious.fdn.fr");

await search(page, "Eminem");
await search(page, "Dubstep");

Expand Down Expand Up @@ -43,7 +45,7 @@ test.describe.serial("search", () => {
await page.goto("localhost:3000");

await search(page, "Defqon 2018");
await selectSearchType(page, "Playlists");
await selectSearchType(page, "playlist");
await listVisibility(page, "Defqon 2018");
});
});
13 changes: 7 additions & 6 deletions e2e/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ export const selectSearchType = async (
.getByRole("menu", { name: "Search filters" })
.getByRole("textbox", { name: "Type filter" })
.click();
await expect(page.getByRole("listbox")).toBeVisible();
await expect(
page.getByRole("listbox").getByRole("option", { selected: true }),
).toContainText(currentType);
await page.getByRole("listbox").getByRole("option", { name: type }).click();
// await expect(
// page.getByRole("listbox").getByRole("option", { selected: true }),
// ).toContainText(currentType);
// await page.getByRole("listbox").getByRole("option", { name: type }).click();
await expect(page.locator('[role="option"][value="video"][aria-selected="true"]')).toContainText(currentType);
await page.locator(`[role="option"][value=${type}]`).click();
};

const listVisibility = async (page: Page, label: string) => {
export const listVisibility = async (page: Page, label: string) => {
await expect(
page.getByRole("heading", { name: `Search results : ${label}` }),
).toBeVisible();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"license": "MIT",
"private": true,
"scripts": {
"postinstall": "cp .env.dist .env",
"postinstall": "cp .env.dist .env && playwright install",
"start": "craco start",
"build": "craco build",
"ts:check": "tsc",
Expand Down
16 changes: 8 additions & 8 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ export default defineConfig({
use: { ...devices["Desktop Chrome"] },
},

{
name: "firefox",
use: { ...devices["Desktop Firefox"] },
},
// {
// name: "firefox",
// use: { ...devices["Desktop Firefox"] },
// },

{
name: "webkit",
use: { ...devices["Desktop Safari"] },
},
// {
// name: "webkit",
// use: { ...devices["Desktop Safari"] },
// },

/* Test against mobile viewports. */
// {
Expand Down

0 comments on commit a82b098

Please sign in to comment.