Skip to content

Commit 22383e8

Browse files
authored
Merge pull request #279 from os2display/feature/5317-slideshow-template-test
Add fixture data and test of slideshow
2 parents 2965c4b + e3a79f6 commit 22383e8

File tree

2 files changed

+78
-15
lines changed

2 files changed

+78
-15
lines changed

assets/template/fixtures/slide-fixtures.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,9 +1399,10 @@ const slideFixtures = [
13991399
showLogo: true,
14001400
logoSize: "l",
14011401
mediaContain: true,
1402-
logoPosition: "bottom right",
1402+
logoPosition: "logo-position-bottom-right",
14031403
transition: "fade",
1404-
animation: "random",
1404+
logoMargin: true,
1405+
animation: "zoom-out-middle",
14051406
},
14061407
},
14071408
{
@@ -1449,8 +1450,7 @@ const slideFixtures = [
14491450
],
14501451
transition: null,
14511452
animation: null,
1452-
showLogo: true,
1453-
logoMargin: true,
1453+
showLogo: false,
14541454
logoSize: "logo-size-l",
14551455
logoPosition: "logo-position-bottom-left",
14561456
},
@@ -1500,10 +1500,10 @@ const slideFixtures = [
15001500
"/v1/media/00000000000000000000000003",
15011501
"/v1/media/00000000000000000000000004",
15021502
],
1503-
showLogo: false,
1503+
showLogo: true,
15041504
logoSize: "l",
15051505
mediaContain: true,
1506-
logoPosition: "bottom right",
1506+
logoPosition: "logo-position-top-right",
15071507
transition: "fade",
15081508
animation: "none",
15091509
},
Lines changed: 72 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,82 @@
11
import { test, expect } from "@playwright/test";
22

3-
test("Slideshow 0", async ({ page }) => {
4-
await page.goto("/template/slideshow-0");
3+
test.describe("slideshow-0: UI tests", () => {
4+
test.beforeEach(async ({ page }) => {
5+
await page.goto("/template/slideshow-0");
6+
});
57

6-
// TODO
8+
test("Slides/image change every 5 seconds", async ({ page }) => {
9+
const slideChangeInterval = 6000;
10+
const imagePaths = [
11+
"/fixtures/template/images/mountain1.jpeg",
12+
"/fixtures/template/images/mountain2.jpeg",
13+
"/fixtures/template/images/mountain3.jpeg",
14+
"/fixtures/template/images/mountain4.jpeg",
15+
];
16+
17+
const getActiveSlide = () =>
18+
page.locator('.fade-container[data-active="true"]');
19+
const getInactiveSlides = () =>
20+
page.locator('.fade-container[data-active="false"]');
21+
22+
let previousIndex = null;
23+
24+
for (const expectedImage of imagePaths) {
25+
const activeSlide = await getActiveSlide();
26+
const activeIndex = await activeSlide.getAttribute("data-index");
27+
28+
if (previousIndex !== null) {
29+
expect(activeIndex).not.toBe(previousIndex);
30+
}
31+
previousIndex = activeIndex;
32+
33+
await expect(activeSlide).toHaveCSS("opacity", "1");
34+
35+
const image = activeSlide.locator(".image");
36+
await expect(image).toHaveCSS(
37+
"background-image",
38+
new RegExp(expectedImage),
39+
);
40+
41+
const inactiveSlides = getInactiveSlides();
42+
const count = await inactiveSlides.count();
43+
for (let i = 0; i < count; i++) {
44+
await expect(inactiveSlides.nth(i)).toHaveCSS("opacity", "0");
45+
}
46+
47+
if (expectedImage !== imagePaths[imagePaths.length - 1]) {
48+
await page.waitForTimeout(slideChangeInterval);
49+
}
50+
}
51+
});
52+
53+
test("Should apply logo classes", async ({ page }) => {
54+
const img = page.locator("img");
55+
expect(img).toHaveAttribute(
56+
"class",
57+
"logo logo-margin l logo-position-bottom-right",
58+
);
59+
});
760
});
861

9-
test("Slideshow 1", async ({ page }) => {
10-
await page.goto("/template/slideshow-1-no-stuff");
62+
test.describe("slideshow-1-no-stuff: UI Tests", async () => {
63+
test.beforeEach(async ({ page }) => {
64+
await page.goto("/template/slideshow-1-no-stuff");
65+
});
1166

12-
// TODO
67+
test("Should not show logo", async ({ page }) => {
68+
const img = page.locator("img");
69+
expect(img).toHaveCount(0);
70+
});
1371
});
1472

15-
test("Slideshow 2", async ({ page }) => {
16-
await page.goto("/template/slideshow-2");
73+
test.describe("slideshow-2: UI Tests", async () => {
74+
test.beforeEach(async ({ page }) => {
75+
await page.goto("/template/slideshow-2");
76+
});
1777

18-
// TODO
78+
test("Should apply logo classes", async ({ page }) => {
79+
const img = page.locator("img");
80+
expect(img).toHaveAttribute("class", "logo l logo-position-top-right");
81+
});
1982
});

0 commit comments

Comments
 (0)