Skip to content

Commit 3d38698

Browse files
authored
Merge pull request #305 from os2display/feature/5317-news-template-tests
5317 news template tests
2 parents 6ff64fe + a91a3a5 commit 3d38698

File tree

2 files changed

+266
-4
lines changed

2 files changed

+266
-4
lines changed

assets/template/fixtures/slide-fixtures.js

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1119,9 +1119,104 @@ const slideFixtures = [
11191119
lastModified: "2024-11-18T08:31:47+00:00",
11201120
title: "Duis volutpat orci lectus.",
11211121
publicId: "136880",
1122+
link: "https://example.com/news/2",
1123+
host: "https://example.com",
1124+
elements: [],
1125+
medias: [
1126+
{
1127+
nodeName: null,
1128+
type: null,
1129+
url: "/fixtures/template/images/mountain4.jpeg",
1130+
length: null,
1131+
title: null,
1132+
description: null,
1133+
thumbnail: "/fixtures/template/images/mountain4.jpeg",
1134+
},
1135+
],
1136+
summary: "Summary2",
1137+
content:
1138+
"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.",
1139+
},
1140+
{
1141+
title: "Lorem ipsum dolor sit amet.",
1142+
lastModified: "2023-02-13T07:00:00.360Z",
1143+
content:
1144+
"Aenean scelerisque ligula ante, sed tristique tellus blandit sit amet. Vestibulum sagittis lobortis purus quis tempor. Aliquam pretium vitae risus id condimentum.",
1145+
},
1146+
],
1147+
},
1148+
mediaData: {
1149+
"/v1/media/00000000000000000000000001": {
1150+
assets: {
1151+
uri: "/fixtures/template/images/mountain1.jpeg",
1152+
},
1153+
},
1154+
},
1155+
content: {
1156+
entryDuration: 3,
1157+
mediaContain: true,
1158+
fallbackImage: ["/v1/media/00000000000000000000000001"],
1159+
},
1160+
},
1161+
{
1162+
id: "news-feed-no-media-contain",
1163+
templateData: {
1164+
id: "01JEWPAFF93YSF418TH72W1SBA",
1165+
},
1166+
themeFile: null,
1167+
// Disable dark mode for slide.
1168+
darkModeEnabled: false,
1169+
feed: {
1170+
configuration: {
1171+
numberOfEntries: 5,
1172+
entryDuration: 5,
1173+
},
1174+
},
1175+
feedData: {
1176+
title: "Lorem Ipsum",
1177+
entries: [
1178+
{
1179+
categories: ["Nyheder"],
1180+
author: {
1181+
name: "Test Testesen",
1182+
uri: null,
1183+
email: null,
1184+
},
1185+
lastModified: "2024-11-18T08:31:47+00:00",
1186+
title: "Aenean scelerisque ligula ante, sed tristique tellus?",
1187+
publicId: "136880",
11221188
link: "https://example.com/news/1",
11231189
host: "https://example.com",
11241190
elements: [],
1191+
medias: [
1192+
{
1193+
nodeName: null,
1194+
type: null,
1195+
url: "/fixtures/template/images/sunset-full-hd.jpg",
1196+
length: null,
1197+
title: null,
1198+
description: null,
1199+
thumbnail: "/fixtures/template/images/sunset-full-hd.jpg",
1200+
},
1201+
],
1202+
summary:
1203+
"Duis volutpat orci lectus, vel fringilla tortor pharetra non. Nunc eget dui quam. Quisque non nulla et ante consequat tempor sit amet ut nisl.",
1204+
content:
1205+
"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.",
1206+
},
1207+
{
1208+
categories: ["Nyheder"],
1209+
author: {
1210+
name: "Aenean Scelerisque",
1211+
uri: null,
1212+
email: null,
1213+
},
1214+
lastModified: "2024-11-18T08:31:47+00:00",
1215+
title: "Duis volutpat orci lectus.",
1216+
publicId: "136880",
1217+
link: "https://example.com/news/3",
1218+
host: "https://example.com",
1219+
elements: [],
11251220
medias: [
11261221
{
11271222
nodeName: null,
@@ -1154,9 +1249,10 @@ const slideFixtures = [
11541249
},
11551250
},
11561251
content: {
1157-
fontSize: "font-size-m",
1252+
entryDuration: 3,
11581253
mediaContain: false,
11591254
fallbackImage: ["/v1/media/00000000000000000000000001"],
1255+
readMore: "Read more text",
11601256
},
11611257
},
11621258
{
Lines changed: 169 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,173 @@
11
import { test, expect } from "@playwright/test";
22

3-
test("News Feed 0", async ({ page }) => {
4-
await page.goto("/template/news-feed-0");
3+
test.describe("news-feed-0: ui tests", async () => {
4+
test.beforeEach(async ({ page }) => {
5+
await page.goto("/template/news-feed-0");
6+
});
57

6-
// TODO
8+
test("Should render template with media", async ({ page }) => {
9+
const slide = page.locator(".slide");
10+
await expect(slide).toBeVisible();
11+
12+
const backgroundImage = slide.locator(".media-section");
13+
await expect(backgroundImage).toHaveCSS(
14+
"background-image",
15+
new RegExp("/fixtures/template/images/sunset-full-hd.jpg"),
16+
);
17+
});
18+
19+
test("Should render template with title", async ({ page }) => {
20+
const slide = page.locator(".slide");
21+
22+
const title = slide.locator(".title");
23+
await expect(title).toHaveText(
24+
"Aenean scelerisque ligula ante, sed tristique tellus?",
25+
);
26+
});
27+
28+
test("Should render template with author", async ({ page }) => {
29+
const slide = page.locator(".slide");
30+
31+
const authorAndDate = slide.locator(".author");
32+
await expect(authorAndDate).toHaveText("18. nov. 2024 ▪ Test Testesen");
33+
});
34+
35+
test("Should render template with description", async ({ page }) => {
36+
const slide = page.locator(".slide");
37+
const description = slide.locator(".description");
38+
await expect(description).toContainText("Duis volutpat orci lectus");
39+
});
40+
41+
test("Should render template with qr code", async ({ page }) => {
42+
const slide = page.locator(".slide");
43+
44+
const qrCode = slide.locator("img.qr");
45+
await expect(qrCode).toBeVisible();
46+
await expect(qrCode).toHaveAttribute("src", /data:image\/png;base64/);
47+
});
48+
49+
test("Should render template with read more link", async ({ page }) => {
50+
const slide = page.locator(".slide");
51+
52+
const readMore = slide.locator(".read-more");
53+
await expect(readMore).toHaveText("Læs hele nyheden");
54+
55+
const link = slide.locator(".link");
56+
await expect(link).toHaveText("https://example.com/news/1");
57+
});
58+
59+
test("Should set media contain", async ({ page }) => {
60+
const mediaContain = page.locator(".media-contain");
61+
await expect(mediaContain).toHaveCount(1);
62+
});
63+
test("Should render template with media (after 2100 seconds", async ({
64+
page,
65+
}) => {
66+
await page.waitForTimeout(2100);
67+
const slide = page.locator(".slide");
68+
await expect(slide).toBeVisible();
69+
70+
const backgroundImage = slide.locator(".media-section");
71+
await expect(backgroundImage).toHaveCSS(
72+
"background-image",
73+
new RegExp("/fixtures/template/images/mountain4.jpeg"),
74+
);
75+
});
76+
77+
test("Should render template with title (after 2100 seconds", async ({
78+
page,
79+
}) => {
80+
await page.waitForTimeout(2100);
81+
const slide = page.locator(".slide");
82+
83+
const title = slide.locator(".title");
84+
await expect(title).toHaveText("Duis volutpat orci lectus.");
85+
});
86+
87+
test("Should render template with author (after 2100 seconds", async ({
88+
page,
89+
}) => {
90+
await page.waitForTimeout(2100);
91+
const slide = page.locator(".slide");
92+
93+
const authorAndDate = slide.locator(".author");
94+
await expect(authorAndDate).toHaveText(
95+
"18. nov. 2024 ▪ Aenean Scelerisque",
96+
);
97+
});
98+
99+
test("Should render template with description (after 2100 seconds", async ({
100+
page,
101+
}) => {
102+
await page.waitForTimeout(2100);
103+
const slide = page.locator(".slide");
104+
const description = slide.locator(".description");
105+
await expect(description).toContainText("Summary2");
106+
});
107+
108+
test("Should render template with qr code (after 2100 seconds", async ({
109+
page,
110+
}) => {
111+
await page.waitForTimeout(2100);
112+
const slide = page.locator(".slide");
113+
114+
const qrCode = slide.locator("img.qr");
115+
await expect(qrCode).toBeVisible();
116+
await expect(qrCode).toHaveAttribute("src", /data:image\/png;base64/);
117+
});
118+
119+
test("Should render template with read more link (after 2100 seconds", async ({
120+
page,
121+
}) => {
122+
await page.waitForTimeout(2100);
123+
const slide = page.locator(".slide");
124+
125+
const readMore = slide.locator(".read-more");
126+
await expect(readMore).toHaveText("Læs hele nyheden");
127+
128+
const link = slide.locator(".link");
129+
await expect(link).toHaveText("https://example.com/news/2");
130+
});
131+
132+
test("Should set media contain (after 2100 seconds", async ({ page }) => {
133+
await page.waitForTimeout(2100);
134+
const mediaContain = page.locator(".media-contain");
135+
await expect(mediaContain).toHaveCount(1);
136+
});
137+
138+
test("Should use fallbackImage (after 4100 seconds", async ({ page }) => {
139+
await page.waitForTimeout(4100);
140+
const slide = page.locator(".slide");
141+
await expect(slide).toBeVisible();
142+
143+
const backgroundImage = slide.locator(".media-section");
144+
await expect(backgroundImage).toHaveCSS(
145+
"background-image",
146+
new RegExp("/fixtures/template/images/mountain1.jpeg"),
147+
);
148+
});
149+
});
150+
151+
test.describe("news-feed-no-media-contain: ui tests", async () => {
152+
test.beforeEach(async ({ page }) => {
153+
await page.goto("/template/news-feed-no-media-contain");
154+
});
155+
156+
test("Should not set media contain", async ({ page }) => {
157+
const mediaContain = page.locator(".media-contain");
158+
await expect(mediaContain).toHaveCount(0);
159+
});
160+
161+
test("Should render template with alternative read more link (after 2100 seconds", async ({
162+
page,
163+
}) => {
164+
await page.waitForTimeout(2100);
165+
const slide = page.locator(".slide");
166+
167+
const readMore = slide.locator(".read-more");
168+
await expect(readMore).toHaveText("Read more text");
169+
170+
const link = slide.locator(".link");
171+
await expect(link).toHaveText("https://example.com/news/3");
172+
});
7173
});

0 commit comments

Comments
 (0)