Skip to content

Commit

Permalink
1541: remvoe media tests, and two failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sinejespersen committed May 31, 2024
1 parent c5b534a commit e8244a4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 170 deletions.
22 changes: 22 additions & 0 deletions e2e/content-string.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { test, expect } from "@playwright/test";
import contentString from "../src/components/util/helpers/content-string";

test.describe("Content string", () => {
test("It creates a string: 'test and test'", async ({ page }) => {
expect(contentString([{ name: "test" }, { name: "test" }], "and")).toBe(
"test and test"
);
});

test("It creates a string: 'test, hest or test'", async ({ page }) => {
expect(
contentString(
[{ name: "test" }, { label: "hest" }, { name: "test" }],
"or"
)
).toBe("test, hest or test");
});
test("It creates a string: 'test'", async ({ page }) => {
expect(contentString([{ name: "test" }], "or")).toBe("test");
});
});
121 changes: 0 additions & 121 deletions e2e/slides.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,127 +229,6 @@ test.describe("Create slide page works", () => {
await page.locator("#cancel_slide").click();
await expect(page.locator("#cancel_slide")).not.toBeVisible();
});

test("It shows and hides preview", async ({ page }) => {
await page.goto("/admin/slide/create");

// Neither the sidebar or overlay should be displayed
await expect(page.locator(".responsive-side")).not.toBeVisible();
await expect(page.locator("#checkbox-show-preview")).not.toBeVisible();

// Pick a template
// Check that no template is picked
await expect(
page
.locator(".single-select")
.first()
.getByText("Vælg en af mulighederne")
).toBeVisible();
// Open dropdown with templates
await page.locator(".dropdown-container").nth(0).press("Enter");
// Check a checkbox
await page.locator('[type="checkbox"]').nth(1).check();
await page.locator(".dropdown-container").nth(0).press("Escape");
// Now a template has been picked.
await expect(
page
.locator(".single-select")
.first()
.getByText("Ut exercitationem est quia ad quas.")
).toBeVisible();

// Preview checkbox cheked and sidebar should be displayed
await page.locator("#checkbox-show-preview").check();
await expect(page.locator(".responsive-side")).toBeVisible();
await expect(page.locator(".preview-overlay")).not.toBeVisible();

// Open preview overlay
await page.locator("#preview_slide").click();
await expect(page.locator(".preview-overlay")).toBeVisible();
await page.locator("#close_preview_button").click({ force: true });

// Redirects, goes back and responsive side is opened due to local storage
await page.locator("#cancel_slide").click();
await page
.getByText("Opret nyt slide").click();
await expect(page.locator(".responsive-side")).toBeVisible();
});

test("It saves theme in localstorage", async ({ page }) => {
await page.route("**/themes*", async (route) => {
const json = {
"hydra:member": [
{
"@id": "/v2/themes/01FPFH3WX93S4575W6Q9T8K0Y8",
title: "Consequatur quisquam recusandae asperiores accusamus.",
description:
"Occaecati debitis et saepe eum sint dolorem. Enim ipsum inventore sed libero et velit qui suscipit. Deserunt laudantium quibusdam enim nostrum soluta qui ipsam non.",
created: "2021-12-09T12:01:33+01:00",
modified: "2021-12-09T12:01:33+01:00",
modifiedBy: "",
createdBy: "",
css: "",
},
],
};
await route.fulfill({ json });
});

// Go to bottom of page
await page.keyboard.press("End");

// The theme dropdown should not have a selected
await expect(
page.locator("#theme-section").getByText("Vælg en af mulighederne")
).toBeVisible();

// Select a theme
await page
.locator("#theme-section")
.locator(".dropdown-container")
.nth(0)
.press("Enter");
await page.locator("#theme-section").locator('[type="checkbox"]').check();

// Mock successful response on post
await page.route("**/slides", async (route) => {
const json = {
"@id": "/v2/slides/000622HP9N1G5P1CMD035H159G",
title: "Aut consequatur excepturi ut totam aspernatur.",
description:
"Et aut harum aut est. Et hic et totam. Possimus veritatis nemo sit repellat dolorem. Distinctio id voluptates laborum voluptas voluptas repellat.",
created: "1970-03-17T08:57:16.000Z",
modified: "2022-01-30T15:42:42.000Z",
modifiedBy: "",
createdBy: "",
templateInfo: {
"@id": "/v2/templates/00EPSCBVJS0TB0118C1JPM1VPM",
options: [],
},
theme: "/v2/themes/01FTNTE789TEPTT7MC3TYM91JJ",
onPlaylists: [],
duration: 9834,
published: {
from: "2021-06-02T16:19:12.000Z",
to: "2021-06-14T01:24:17.000Z",
},
media: ["/v2/media/014BH0252D18481TYB050J1WD9"],
content: [],
feed: null,
};
await route.fulfill({ json });
});
await page.locator("#save_slide").click();

const themeId = await page.evaluate(() =>
localStorage.getItem("prev-used-theme-id")
);

// Check if theme is saved in localstorage
await expect(themeId).toBe(
'{"ABC":"/v2/themes/01FPFH3WX93S4575W6Q9T8K0Y8"}'
);
});
});

test.describe("Slides list works", () => {
Expand Down
28 changes: 0 additions & 28 deletions src/components/media/media.spec.js

This file was deleted.

21 changes: 0 additions & 21 deletions src/components/util/helpers/content-string.spec.js

This file was deleted.

0 comments on commit e8244a4

Please sign in to comment.