From 5f1685627199d57caf92ec693d5784c9695e4780 Mon Sep 17 00:00:00 2001 From: sinejespersen Date: Fri, 26 Sep 2025 13:45:02 +0200 Subject: [PATCH 1/3] 5453: make id on content form work and add id for tests --- assets/admin/components/slide/slide-form.jsx | 2 +- assets/admin/components/util/content-body/content-body.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/admin/components/slide/slide-form.jsx b/assets/admin/components/slide/slide-form.jsx index a6baa7a7..902d86c5 100644 --- a/assets/admin/components/slide/slide-form.jsx +++ b/assets/admin/components/slide/slide-form.jsx @@ -298,7 +298,7 @@ function SlideForm({ )} - +

{t("add-slide-to-playlists")}

Date: Fri, 26 Sep 2025 13:45:49 +0200 Subject: [PATCH 2/3] 5453: add tests of data fetch and fixtures, inject slides into loginTest --- .../tests/admin/admin-fetch-data-hook.spec.js | 103 ++ assets/tests/admin/data-fixtures.js | 1125 ++++++++++++++++- assets/tests/admin/test-helper.js | 4 +- 3 files changed, 1229 insertions(+), 3 deletions(-) create mode 100644 assets/tests/admin/admin-fetch-data-hook.spec.js diff --git a/assets/tests/admin/admin-fetch-data-hook.spec.js b/assets/tests/admin/admin-fetch-data-hook.spec.js new file mode 100644 index 00000000..29100974 --- /dev/null +++ b/assets/tests/admin/admin-fetch-data-hook.spec.js @@ -0,0 +1,103 @@ +import { test, expect } from "@playwright/test"; +import { + fulfillDataRoute, + fulfillEmptyRoutes, + beforeEachTest, + loginTest, +} from "./test-helper.js"; +import { + imageTextTemplate, + onlyImageTextListJson, + slidesJson1, + slideJson, + slidesPlaylist, +} from "./data-fixtures.js"; + +test.describe("Test of admin fetch data hook", () => { + test.beforeEach(async ({ page }) => { + await beforeEachTest(page); + }); + + test.beforeEach(async ({ page }) => { + page.setViewportSize({ width: 600, height: 2600 }); + await fulfillDataRoute( + page, + "**/templates?itemsPerPage*", + onlyImageTextListJson, + ); + + await page.route( + "**/templates/000YR9PMQC0GMC1TP90V9N07WX", + async (route) => { + await route.fulfill(imageTextTemplate); + }, + ); + + await fulfillDataRoute( + page, + "**/templates/01FGC8EXSE1KCC1PTR0NHB0H3R", + imageTextTemplate, + ); + + await fulfillDataRoute( + page, + "**/templates/002BAP34VD1EHG0E4J0D2Y00JW", + imageTextTemplate, + ); + + await fulfillDataRoute( + page, + "**/templates/017BG9P0E0103F0TFS17FM016M", + imageTextTemplate, + ); + + await fulfillDataRoute( + page, + "**/templates/016MHSNKCH1PQW1VY615JC19Y3", + imageTextTemplate, + ); + await fulfillDataRoute( + page, + "**/templates/000BGWFMBS15N807E60HP91JCX", + imageTextTemplate, + ); + + await loginTest(page, slidesJson1); + + await fulfillDataRoute( + page, + "**/templates/01FP2SNGFN0BZQH03KCBXHKYHG", + imageTextTemplate, + ); + + await fulfillDataRoute( + page, + "**/v2/slides/00015Y0ZVC18N407JD07SM0YCF", + slideJson, + ); + + await fulfillEmptyRoutes(page, ["**/playlists*", "**/themes*"]); + await fulfillDataRoute( + page, + "**/slides/00015Y0ZVC18N407JD07SM0YCF/playlists?*", + slidesPlaylist, + ); + + await Promise.all([ + page.waitForURL("**/slide/edit/*"), + await page.locator("#edit_button").first().click({ force: true }), + ]); + + const title = page.getByText("Rediger slide:"); + await title.waitFor(); + + await expect(title).toBeVisible(); + }); + + test("Test of admin fetch data hook", async ({ page }) => { + const title = page.locator("#add-slide-to-playlist-section tr"); + // The max items per page is 30: https://github.com/os2display/display-api-service/blob/develop/config/packages/api_platform.yaml#L11 + // And the header is also a { }); }; -const loginTest = async (page) => { +const loginTest = async (page, slides = null) => { await page.goto("/admin/slides/list"); await page.route("**/token", async (route) => { @@ -41,7 +41,7 @@ const loginTest = async (page) => { }); await page.route("**/slides*", async (route) => { - await route.fulfill({ json: emptyJson }); + await route.fulfill({ json: slides ?? emptyJson }); }); await expect(page).toHaveTitle(/OS2Display Admin/); From de75aaafca9bf340376f24307481e1fa8004a564 Mon Sep 17 00:00:00 2001 From: sinejespersen Date: Fri, 26 Sep 2025 13:55:10 +0200 Subject: [PATCH 3/3] 5453: added to changelog entry --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0dfc492..00cbbd21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ All notable changes to this project will be documented in this file. - Aligned with v. 2.5.2. - Removed themes. - Added command to migrate config.json files. -- Fix data fetching bug +- Fix data fetching bug + tests - Refactored screen layout commands. ### NB! Prior to 3.x the project was split into separate repositories