Skip to content

Commit 7fdf818

Browse files
authored
Merge pull request #274 from os2display/feature/5317-travel-template-tests
Travel template tests
2 parents 43796f0 + fc4a379 commit 7fdf818

File tree

3 files changed

+158
-19
lines changed

3 files changed

+158
-19
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ TODO
6969
To run tests, use the script:
7070

7171
```shell
72-
./scripts/test.sh
72+
./scripts/test
7373
```
7474

7575
This script will stop the node container, build the javascript/css assets, and run tests with playwright,

assets/template/fixtures/slide-fixtures.js

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,7 +1559,7 @@ const slideFixtures = [
15591559
},
15601560
},
15611561
{
1562-
id: "travel-0",
1562+
id: "travel-multiple-stations",
15631563
templateData: {
15641564
id: "01FZD7K807VAKZ99BGSSCHRJM6",
15651565
},
@@ -1583,19 +1583,36 @@ const slideFixtures = [
15831583
{ id: "813041802", name: "Rolykkevej (Sæbygårdvej / Sæby)" },
15841584
],
15851585
iframeTitle: "Titel til iframe",
1586-
title: "Overskrift",
1587-
text: "<p>Tekst på slide</p>",
1588-
distance: "2 km",
1589-
timeModerate: "5-7 minutter",
1590-
timeFast: "3-23 minutter",
15911586
image: ["/v1/media/00000000000000000000000001"],
15921587
mediaContain: true,
15931588
},
15941589
},
15951590
{
1596-
id: "travel-1",
1591+
id: "travel-spacious-info-box",
15971592
templateData: {
1598-
id: "01FQBJFKM0YFX1VW5K94VBSNCP",
1593+
id: "01FZD7K807VAKZ99BGSSCHRJM6",
1594+
},
1595+
content: {
1596+
numberOfJourneys: 1,
1597+
station: [
1598+
{ id: "41565", name: "Rolfsvej (Maribovej)" },
1599+
{ id: "813041802", name: "Rolykkevej (Sæbygårdvej / Sæby)" },
1600+
],
1601+
busOrTram: "tram",
1602+
iframeTitle: "Aarhus H (Letbane)",
1603+
title: "Stor infoboks!",
1604+
text: "<p>Tekst på slide med stor infoboks!</p>",
1605+
distance: "43 km",
1606+
timeModerate: "15-37 minutter",
1607+
timeFast: "3-23 minutter",
1608+
monitorLayout: "night",
1609+
disableIcons: true,
1610+
},
1611+
},
1612+
{
1613+
id: "travel-one-station",
1614+
templateData: {
1615+
id: "01FZD7K807VAKZ99BGSSCHRJM6",
15991616
},
16001617
mediaData: {
16011618
"/v1/media/00000000000000000000000001": {
@@ -1616,10 +1633,10 @@ const slideFixtures = [
16161633
],
16171634
busOrTram: "tram",
16181635
iframeTitle: "Aarhus H (Letbane)",
1619-
title: "Overskrift",
1620-
text: "<p>Tekst på slide</p>",
1621-
distance: "2 km",
1622-
timeModerate: "5-7 minutter",
1636+
title: "Én station",
1637+
text: "<p>Tekst på slide med én station</p>",
1638+
distance: "43 km",
1639+
timeModerate: "15-37 minutter",
16231640
timeFast: "3-23 minutter",
16241641
image: ["/v1/media/00000000000000000000000001"],
16251642
monitorLayout: "night",
Lines changed: 128 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,135 @@
11
import { test, expect } from "@playwright/test";
22

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

6-
// TODO
8+
test("Should display the correct heading", async ({ page }) => {
9+
const heading = page.locator(".info-box .header h1");
10+
await expect(heading).toHaveText("Én station");
11+
});
12+
13+
test("Should display the info text", async ({ page }) => {
14+
const text = page.locator(".info-box .text p");
15+
await expect(text).toHaveText("Tekst på slide med én station");
16+
});
17+
18+
test("Should display the distance correctly", async ({ page }) => {
19+
const label = page.locator(".info-box .distance div:first-child");
20+
const value = page.locator(".info-box .distance .text");
21+
await expect(label).toHaveText("Afstand");
22+
await expect(value).toHaveText("43 km");
23+
});
24+
25+
test("Should display fast time correctly", async ({ page }) => {
26+
const label = page.locator(".info-box .time-fast div:first-child");
27+
const value = page.locator(".info-box .time-fast .text");
28+
await expect(label).toHaveText("Tid (hurtig)");
29+
await expect(value).toHaveText("3-23 minutter");
30+
});
31+
32+
test("Should display moderate time correctly", async ({ page }) => {
33+
const label = page.locator(".info-box .time-moderat div:first-child");
34+
const value = page.locator(".info-box .time-moderat .text");
35+
await expect(label).toHaveText("Tid (moderat)");
36+
await expect(value).toHaveText("15-37 minutter");
37+
});
38+
39+
test("Should display the map with correct background image", async ({
40+
page,
41+
}) => {
42+
const backgroundImage = page.locator(".map");
43+
await expect(backgroundImage).toHaveCSS(
44+
"background-image",
45+
new RegExp("/fixtures/template/images/mountain1.jpeg"),
46+
);
47+
});
48+
49+
test("Should load the iframe with correct title and src", async ({
50+
page,
51+
}) => {
52+
const iframe = page.locator("iframe");
53+
await expect(iframe).toHaveAttribute("title", "iframe title");
54+
await expect(iframe).toHaveAttribute(
55+
"src",
56+
"https://webapp.rejseplanen.dk/bin/help.exe/mn?L=vs_tus.vs_new&station=860005301&tpl=monitor&stopFrequency=low&preview=50&offsetTime=1&maxJourneys=6&p1=letbane&p1title=Aarhus+H+%28Letbane%29&p1icons=null&monitorLayout=night",
57+
);
58+
});
59+
});
60+
61+
test.describe("Travel-multiple-stations: UI tests", () => {
62+
test.beforeEach(async ({ page }) => {
63+
await page.goto("/template/travel-multiple-stations");
64+
});
65+
66+
test("Infobox not displayed", async ({ page }) => {
67+
const infoBox = page.locator(".info-box");
68+
// Test that it does not exists
69+
await expect(infoBox).toHaveCount(0);
70+
});
71+
72+
test("Should not display background image", async ({ page }) => {
73+
const backgroundImage = page.locator(".map");
74+
// Test that it does not exists
75+
await expect(backgroundImage).toHaveCount(0);
76+
});
77+
78+
test("Should load the iframe with correct title and src", async ({
79+
page,
80+
}) => {
81+
const iframe = page.locator("iframe");
82+
const growClass = page.locator(".iframe.grow");
83+
await expect(growClass).toBeVisible();
84+
await expect(iframe).toHaveAttribute("title", "iframe title");
85+
await expect(iframe).toHaveAttribute(
86+
"src",
87+
"https://webapp.rejseplanen.dk/bin/help.exe/mn?L=vs_tus.vs_new&station=751434104%40503000201%4053014%4044061%403342%403269%4041565%40813041802&tpl=monitor&stopFrequency=low&preview=50&offsetTime=1&maxJourneys=13&p1=bus&p1title=Titel+til+iframe",
88+
);
89+
});
790
});
891

9-
test("Travel 1", async ({ page }) => {
10-
await page.goto("/template/travel-1");
92+
test.describe("Travel-spacious-info-box: UI tests", () => {
93+
test.beforeEach(async ({ page }) => {
94+
await page.goto("/template/travel-spacious-info-box");
95+
});
96+
97+
test("Infobox class grow displayed", async ({ page }) => {
98+
const growClass = page.locator(".info-box.grow");
99+
await expect(growClass).toBeVisible();
100+
});
101+
test("Should display the correct heading", async ({ page }) => {
102+
const heading = page.locator(".info-box .header h1");
103+
await expect(heading).toHaveText("Stor infoboks!");
104+
});
105+
test("Should display the info text", async ({ page }) => {
106+
const text = page.locator(".info-box .text p");
107+
await expect(text).toHaveText("Tekst på slide med stor infoboks!");
108+
});
109+
110+
test("Should display the distance correctly", async ({ page }) => {
111+
const label = page.locator(".info-box .distance div:first-child");
112+
const value = page.locator(".info-box .distance .text");
113+
await expect(label).toHaveText("Afstand");
114+
await expect(value).toHaveText("43 km");
115+
});
116+
117+
test("Should display fast time correctly", async ({ page }) => {
118+
const label = page.locator(".info-box .time-fast div:first-child");
119+
const value = page.locator(".info-box .time-fast .text");
120+
await expect(label).toHaveText("Tid (hurtig)");
121+
await expect(value).toHaveText("3-23 minutter");
122+
});
11123

12-
// TODO
124+
test("Should display moderate time correctly", async ({ page }) => {
125+
const label = page.locator(".info-box .time-moderat div:first-child");
126+
const value = page.locator(".info-box .time-moderat .text");
127+
await expect(label).toHaveText("Tid (moderat)");
128+
await expect(value).toHaveText("15-37 minutter");
129+
});
130+
test("Should not display background image", async ({ page }) => {
131+
const backgroundImage = page.locator(".map");
132+
// Test that it does not exists
133+
await expect(backgroundImage).toBeEmpty();
134+
});
13135
});

0 commit comments

Comments
 (0)