Skip to content

Commit 324eebb

Browse files
committed
5316: fix test, inject slides into logintest, fix *templates* routes
1 parent 203b7cd commit 324eebb

File tree

2 files changed

+59
-34
lines changed

2 files changed

+59
-34
lines changed

assets/tests/admin/admin-form.spec.js

Lines changed: 56 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
onlyImageTextListJson,
1111
slideJson,
1212
slidesJson1,
13-
tokenAdminJson,
1413
} from "./data-fixtures.js";
1514

1615
test.describe("Admin form ui tests", () => {
@@ -276,17 +275,49 @@ test.describe("Admin slide values depending on other values", () => {
276275
});
277276

278277
test.beforeEach(async ({ page }) => {
279-
await page.goto("/admin/slides/list");
278+
await fulfillDataRoute(
279+
page,
280+
"**/templates?itemsPerPage*",
281+
onlyImageTextListJson,
282+
);
280283

281-
await page.route("**/token", async (route) => {
282-
await route.fulfill({ json: tokenAdminJson });
283-
});
284+
await page.route(
285+
"**/templates/000YR9PMQC0GMC1TP90V9N07WX",
286+
async (route) => {
287+
await route.fulfill(imageTextTemplate);
288+
},
289+
);
284290

285-
await page.route("**/slides*", async (route) => {
286-
await route.fulfill({ json: slidesJson1 });
287-
});
291+
await fulfillDataRoute(
292+
page,
293+
"**/templates/01FGC8EXSE1KCC1PTR0NHB0H3R",
294+
imageTextTemplate,
295+
);
288296

289-
await fulfillDataRoute(page, "**/templates*", onlyImageTextListJson);
297+
await fulfillDataRoute(
298+
page,
299+
"**/templates/002BAP34VD1EHG0E4J0D2Y00JW",
300+
imageTextTemplate,
301+
);
302+
303+
await fulfillDataRoute(
304+
page,
305+
"**/templates/017BG9P0E0103F0TFS17FM016M",
306+
imageTextTemplate,
307+
);
308+
309+
await fulfillDataRoute(
310+
page,
311+
"**/templates/016MHSNKCH1PQW1VY615JC19Y3",
312+
imageTextTemplate,
313+
);
314+
await fulfillDataRoute(
315+
page,
316+
"**/templates/000BGWFMBS15N807E60HP91JCX",
317+
imageTextTemplate,
318+
);
319+
320+
await loginTest(page, slidesJson1);
290321

291322
await fulfillDataRoute(
292323
page,
@@ -299,17 +330,16 @@ test.describe("Admin slide values depending on other values", () => {
299330
"**/v2/slides/00015Y0ZVC18N407JD07SM0YCF",
300331
slideJson,
301332
);
302-
303333
await fulfillEmptyRoutes(page, ["**/playlists*", "**/themes*"]);
304-
305-
await page.getByLabel("Email").fill("[email protected]");
306-
await page.getByLabel("Kodeord").fill("password");
307-
await page.locator("#login").click();
308-
309334
await Promise.all([
310335
page.waitForURL("**/slide/edit/*"),
311336
await page.locator("#edit_button").first().click({ force: true }),
312337
]);
338+
339+
const title = page.getByText("Rediger slide:");
340+
await title.waitFor();
341+
342+
await expect(title).toBeVisible();
313343
});
314344

315345
test("Should have filled title", async ({ page }) => {
@@ -325,7 +355,7 @@ test.describe("Admin slide values depending on other values", () => {
325355

326356
test("Should pick font size", async ({ page }) => {
327357
await page.route("**/v2/slides", async (route, request) => {
328-
if (request.method() === "POST") {
358+
if (request.method() === "PUT") {
329359
const postData = request.postDataJSON(); // Parses JSON body
330360
expect(postData.content).toMatchObject({
331361
fontSize: "font-size-m",
@@ -351,8 +381,8 @@ test.describe("Admin slide values depending on other values", () => {
351381

352382
test("Should have media contain visible and checkable", async ({ page }) => {
353383
await page.route("**/v2/slides", async (route, request) => {
354-
if (request.method() === "POST") {
355-
const postData = request.postDataJSON(); // Parses JSON body
384+
if (request.method() === "PUT") {
385+
const postData = request.postDataJSON();
356386
expect(postData.content).toMatchObject({
357387
mediaContain: true,
358388
});
@@ -370,8 +400,8 @@ test.describe("Admin slide values depending on other values", () => {
370400

371401
test("Should have duration visible and interactable", async ({ page }) => {
372402
await page.route("**/v2/slides", async (route, request) => {
373-
if (request.method() === "POST") {
374-
const postData = request.postDataJSON(); // Parses JSON body
403+
if (request.method() === "PUT") {
404+
const postData = request.postDataJSON();
375405
expect(postData.content).toMatchObject({
376406
duration: 10000,
377407
});
@@ -388,7 +418,7 @@ test.describe("Admin slide values depending on other values", () => {
388418

389419
test("Should have box align visible and checkable", async ({ page }) => {
390420
await page.route("**/v2/slides", async (route, request) => {
391-
if (request.method() === "POST") {
421+
if (request.method() === "PUT") {
392422
const postData = request.postDataJSON(); // Parses JSON body
393423
expect(postData.content).toMatchObject({
394424
boxAlign: "right",
@@ -407,7 +437,7 @@ test.describe("Admin slide values depending on other values", () => {
407437

408438
test("Should have box margin visible and checkable", async ({ page }) => {
409439
await page.route("**/v2/slides", async (route, request) => {
410-
if (request.method() === "POST") {
440+
if (request.method() === "PUT") {
411441
const postData = request.postDataJSON(); // Parses JSON body
412442
expect(postData.content).toMatchObject({
413443
boxMargin: true,
@@ -428,7 +458,7 @@ test.describe("Admin slide values depending on other values", () => {
428458
page,
429459
}) => {
430460
await page.route("**/v2/slides", async (route, request) => {
431-
if (request.method() === "POST") {
461+
if (request.method() === "PUT") {
432462
const postData = request.postDataJSON(); // Parses JSON body
433463
expect(postData.content).toMatchObject({
434464
separator: true,
@@ -453,7 +483,7 @@ test.describe("Admin slide values depending on other values", () => {
453483

454484
test("Should have halfsize visible and checkable", async ({ page }) => {
455485
await page.route("**/v2/slides", async (route, request) => {
456-
if (request.method() === "POST") {
486+
if (request.method() === "PUT") {
457487
const postData = request.postDataJSON(); // Parses JSON body
458488
expect(postData.content).toMatchObject({
459489
halfSize: true,
@@ -472,7 +502,7 @@ test.describe("Admin slide values depending on other values", () => {
472502

473503
test("Should have shadow visible and checkable", async ({ page }) => {
474504
await page.route("**/v2/slides", async (route, request) => {
475-
if (request.method() === "POST") {
505+
if (request.method() === "PUT") {
476506
const postData = request.postDataJSON(); // Parses JSON body
477507
expect(postData.content).toMatchObject({
478508
shadow: true,
@@ -492,7 +522,7 @@ test.describe("Admin slide values depending on other values", () => {
492522
page,
493523
}) => {
494524
await page.route("**/v2/slides", async (route, request) => {
495-
if (request.method() === "POST") {
525+
if (request.method() === "PUT") {
496526
const postData = request.postDataJSON();
497527
expect(postData.content).toMatchObject({
498528
showLogo: true,

assets/tests/admin/test-helper.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
import {
2-
adminConfigJson,
3-
emptyJson,
4-
slidesJson1,
5-
tokenAdminJson,
6-
} from "./data-fixtures.js";
1+
import { adminConfigJson, emptyJson, tokenAdminJson } from "./data-fixtures.js";
72
import { expect } from "@playwright/test";
83

94
const beforeEachTest = async (page) => {
@@ -38,15 +33,15 @@ const fulfillDataRoute = async (page, routePattern, data, status) => {
3833
});
3934
};
4035

41-
const loginTest = async (page) => {
36+
const loginTest = async (page, slides = null) => {
4237
await page.goto("/admin/slides/list");
4338

4439
await page.route("**/token", async (route) => {
4540
await route.fulfill({ json: tokenAdminJson });
4641
});
4742

4843
await page.route("**/slides*", async (route) => {
49-
await route.fulfill({ json: emptyJson });
44+
await route.fulfill({ json: slides ?? emptyJson });
5045
});
5146

5247
await expect(page).toHaveTitle(/OS2Display Admin/);

0 commit comments

Comments
 (0)