diff --git a/assets/template/fixtures/slide-fixtures.js b/assets/template/fixtures/slide-fixtures.js index c72c0e98..3247ad2e 100644 --- a/assets/template/fixtures/slide-fixtures.js +++ b/assets/template/fixtures/slide-fixtures.js @@ -1119,9 +1119,104 @@ const slideFixtures = [ lastModified: "2024-11-18T08:31:47+00:00", title: "Duis volutpat orci lectus.", publicId: "136880", + link: "https://example.com/news/2", + host: "https://example.com", + elements: [], + medias: [ + { + nodeName: null, + type: null, + url: "/fixtures/template/images/mountain4.jpeg", + length: null, + title: null, + description: null, + thumbnail: "/fixtures/template/images/mountain4.jpeg", + }, + ], + summary: "Summary2", + content: + "Duis volutpat orci lectus, vel fringilla tortor pharetra non. Nunc eget dui quam. Quisque non nulla et ante consequat tempor sit amet ut nisl. Duis volutpat orci lectus, vel fringilla tortor pharetra non. Nunc eget dui quam. Quisque non nulla et ante consequat tempor sit amet ut nisl. Nunc eget dui quam. Quisque non nulla et ante consequat tempor sit amet ut nisl. Nunc eget dui quam. Quisque non nulla et ante consequat tempor sit amet ut nisl. Nunc eget dui quam. Quisque non nulla et ante consequat tempor sit amet ut nisl. Nunc eget dui quam. Quisque non nulla et ante consequat tempor sit amet ut nisl. Nunc eget dui quam. Quisque non nulla et ante consequat tempor sit amet ut nisl. Nunc eget dui quam. Quisque non nulla et ante consequat tempor sit amet ut nisl. Nunc eget dui quam. Quisque non nulla et ante consequat tempor sit amet ut nisl. Nunc eget dui quam. Quisque non nulla et ante consequat tempor sit amet ut nisl. Nunc eget dui quam. Quisque non nulla et ante consequat tempor sit amet ut nisl.", + }, + { + title: "Lorem ipsum dolor sit amet.", + lastModified: "2023-02-13T07:00:00.360Z", + content: + "Aenean scelerisque ligula ante, sed tristique tellus blandit sit amet. Vestibulum sagittis lobortis purus quis tempor. Aliquam pretium vitae risus id condimentum.", + }, + ], + }, + mediaData: { + "/v1/media/00000000000000000000000001": { + assets: { + uri: "/fixtures/template/images/mountain1.jpeg", + }, + }, + }, + content: { + entryDuration: 3, + mediaContain: true, + fallbackImage: ["/v1/media/00000000000000000000000001"], + }, + }, + { + id: "news-feed-no-media-contain", + templateData: { + id: "01JEWPAFF93YSF418TH72W1SBA", + }, + themeFile: null, + // Disable dark mode for slide. + darkModeEnabled: false, + feed: { + configuration: { + numberOfEntries: 5, + entryDuration: 5, + }, + }, + feedData: { + title: "Lorem Ipsum", + entries: [ + { + categories: ["Nyheder"], + author: { + name: "Test Testesen", + uri: null, + email: null, + }, + lastModified: "2024-11-18T08:31:47+00:00", + title: "Aenean scelerisque ligula ante, sed tristique tellus?", + publicId: "136880", link: "https://example.com/news/1", host: "https://example.com", elements: [], + medias: [ + { + nodeName: null, + type: null, + url: "/fixtures/template/images/sunset-full-hd.jpg", + length: null, + title: null, + description: null, + thumbnail: "/fixtures/template/images/sunset-full-hd.jpg", + }, + ], + summary: + "Duis volutpat orci lectus, vel fringilla tortor pharetra non. Nunc eget dui quam. Quisque non nulla et ante consequat tempor sit amet ut nisl.", + content: + "Duis volutpat orci lectus, vel fringilla tortor pharetra non. Nunc eget dui quam. Quisque non nulla et ante consequat tempor sit amet ut nisl. Duis volutpat orci lectus, vel fringilla tortor pharetra non. Nunc eget dui quam. Quisque non nulla et ante consequat tempor sit amet ut nisl. Nunc eget dui quam. Quisque non nulla et ante consequat tempor sit amet ut nisl. Nunc eget dui quam. Quisque non nulla et ante consequat tempor sit amet ut nisl. Nunc eget dui quam. Quisque non nulla et ante consequat tempor sit amet ut nisl. Nunc eget dui quam. Quisque non nulla et ante consequat tempor sit amet ut nisl. Nunc eget dui quam. Quisque non nulla et ante consequat tempor sit amet ut nisl. Nunc eget dui quam. Quisque non nulla et ante consequat tempor sit amet ut nisl. Nunc eget dui quam. Quisque non nulla et ante consequat tempor sit amet ut nisl. Nunc eget dui quam. Quisque non nulla et ante consequat tempor sit amet ut nisl. Nunc eget dui quam. Quisque non nulla et ante consequat tempor sit amet ut nisl.", + }, + { + categories: ["Nyheder"], + author: { + name: "Aenean Scelerisque", + uri: null, + email: null, + }, + lastModified: "2024-11-18T08:31:47+00:00", + title: "Duis volutpat orci lectus.", + publicId: "136880", + link: "https://example.com/news/3", + host: "https://example.com", + elements: [], medias: [ { nodeName: null, @@ -1154,9 +1249,10 @@ const slideFixtures = [ }, }, content: { - fontSize: "font-size-m", + entryDuration: 3, mediaContain: false, fallbackImage: ["/v1/media/00000000000000000000000001"], + readMore: "Read more text", }, }, { diff --git a/assets/tests/template/template-news-feed.spec.js b/assets/tests/template/template-news-feed.spec.js index 42f44449..8ad214d7 100644 --- a/assets/tests/template/template-news-feed.spec.js +++ b/assets/tests/template/template-news-feed.spec.js @@ -1,7 +1,173 @@ import { test, expect } from "@playwright/test"; -test("News Feed 0", async ({ page }) => { - await page.goto("/template/news-feed-0"); +test.describe("news-feed-0: ui tests", async () => { + test.beforeEach(async ({ page }) => { + await page.goto("/template/news-feed-0"); + }); - // TODO + test("Should render template with media", async ({ page }) => { + const slide = page.locator(".slide"); + await expect(slide).toBeVisible(); + + const backgroundImage = slide.locator(".media-section"); + await expect(backgroundImage).toHaveCSS( + "background-image", + new RegExp("/fixtures/template/images/sunset-full-hd.jpg"), + ); + }); + + test("Should render template with title", async ({ page }) => { + const slide = page.locator(".slide"); + + const title = slide.locator(".title"); + await expect(title).toHaveText( + "Aenean scelerisque ligula ante, sed tristique tellus?", + ); + }); + + test("Should render template with author", async ({ page }) => { + const slide = page.locator(".slide"); + + const authorAndDate = slide.locator(".author"); + await expect(authorAndDate).toHaveText("18. nov. 2024 ▪ Test Testesen"); + }); + + test("Should render template with description", async ({ page }) => { + const slide = page.locator(".slide"); + const description = slide.locator(".description"); + await expect(description).toContainText("Duis volutpat orci lectus"); + }); + + test("Should render template with qr code", async ({ page }) => { + const slide = page.locator(".slide"); + + const qrCode = slide.locator("img.qr"); + await expect(qrCode).toBeVisible(); + await expect(qrCode).toHaveAttribute("src", /data:image\/png;base64/); + }); + + test("Should render template with read more link", async ({ page }) => { + const slide = page.locator(".slide"); + + const readMore = slide.locator(".read-more"); + await expect(readMore).toHaveText("Læs hele nyheden"); + + const link = slide.locator(".link"); + await expect(link).toHaveText("https://example.com/news/1"); + }); + + test("Should set media contain", async ({ page }) => { + const mediaContain = page.locator(".media-contain"); + await expect(mediaContain).toHaveCount(1); + }); + test("Should render template with media (after 2100 seconds", async ({ + page, + }) => { + await page.waitForTimeout(2100); + const slide = page.locator(".slide"); + await expect(slide).toBeVisible(); + + const backgroundImage = slide.locator(".media-section"); + await expect(backgroundImage).toHaveCSS( + "background-image", + new RegExp("/fixtures/template/images/mountain4.jpeg"), + ); + }); + + test("Should render template with title (after 2100 seconds", async ({ + page, + }) => { + await page.waitForTimeout(2100); + const slide = page.locator(".slide"); + + const title = slide.locator(".title"); + await expect(title).toHaveText("Duis volutpat orci lectus."); + }); + + test("Should render template with author (after 2100 seconds", async ({ + page, + }) => { + await page.waitForTimeout(2100); + const slide = page.locator(".slide"); + + const authorAndDate = slide.locator(".author"); + await expect(authorAndDate).toHaveText( + "18. nov. 2024 ▪ Aenean Scelerisque", + ); + }); + + test("Should render template with description (after 2100 seconds", async ({ + page, + }) => { + await page.waitForTimeout(2100); + const slide = page.locator(".slide"); + const description = slide.locator(".description"); + await expect(description).toContainText("Summary2"); + }); + + test("Should render template with qr code (after 2100 seconds", async ({ + page, + }) => { + await page.waitForTimeout(2100); + const slide = page.locator(".slide"); + + const qrCode = slide.locator("img.qr"); + await expect(qrCode).toBeVisible(); + await expect(qrCode).toHaveAttribute("src", /data:image\/png;base64/); + }); + + test("Should render template with read more link (after 2100 seconds", async ({ + page, + }) => { + await page.waitForTimeout(2100); + const slide = page.locator(".slide"); + + const readMore = slide.locator(".read-more"); + await expect(readMore).toHaveText("Læs hele nyheden"); + + const link = slide.locator(".link"); + await expect(link).toHaveText("https://example.com/news/2"); + }); + + test("Should set media contain (after 2100 seconds", async ({ page }) => { + await page.waitForTimeout(2100); + const mediaContain = page.locator(".media-contain"); + await expect(mediaContain).toHaveCount(1); + }); + + test("Should use fallbackImage (after 4100 seconds", async ({ page }) => { + await page.waitForTimeout(4100); + const slide = page.locator(".slide"); + await expect(slide).toBeVisible(); + + const backgroundImage = slide.locator(".media-section"); + await expect(backgroundImage).toHaveCSS( + "background-image", + new RegExp("/fixtures/template/images/mountain1.jpeg"), + ); + }); +}); + +test.describe("news-feed-no-media-contain: ui tests", async () => { + test.beforeEach(async ({ page }) => { + await page.goto("/template/news-feed-no-media-contain"); + }); + + test("Should not set media contain", async ({ page }) => { + const mediaContain = page.locator(".media-contain"); + await expect(mediaContain).toHaveCount(0); + }); + + test("Should render template with alternative read more link (after 2100 seconds", async ({ + page, + }) => { + await page.waitForTimeout(2100); + const slide = page.locator(".slide"); + + const readMore = slide.locator(".read-more"); + await expect(readMore).toHaveText("Read more text"); + + const link = slide.locator(".link"); + await expect(link).toHaveText("https://example.com/news/3"); + }); });