Skip to content

Commit c7ded08

Browse files
authored
Merge pull request #310 from os2display/feature/5317-booking-calendar-template
Booking calendar template
2 parents abb1d26 + 95a9652 commit c7ded08

File tree

3 files changed

+82
-5
lines changed

3 files changed

+82
-5
lines changed

assets/template/fixtures/slide-fixtures.js

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ const slideFixtures = [
695695
},
696696
},
697697
{
698-
id: "calendar-4-single-booking",
698+
id: "calendar-0-single-booking",
699699
"@id": "/v1/slides/1",
700700
templateData: {
701701
id: "01FRJPF4XATRN8PBZ35XN84PS6",
@@ -761,6 +761,42 @@ const slideFixtures = [
761761
fontSize: "font-size-lg",
762762
},
763763
},
764+
{
765+
id: "calendar-1-single-booking",
766+
"@id": "/v1/slides/1",
767+
templateData: {
768+
id: "01FRJPF4XATRN8PBZ35XN84PS6",
769+
},
770+
themeFile: null,
771+
feed: {
772+
resources: ["[email protected]"],
773+
},
774+
feedData: [
775+
{
776+
id: "uniqueEvent0",
777+
title: "There will be cake",
778+
startTime: dayjs().add(1, "seconds").unix(),
779+
endTime: dayjs().add(1, "hour").unix(),
780+
resourceTitle: "Det tomme rum",
781+
resourceId: "M0",
782+
},
783+
],
784+
mediaData: {},
785+
// Disable dark mode for slide.
786+
darkModeEnabled: false,
787+
content: {
788+
duration: 11000,
789+
instantBookingEnabled: true,
790+
layout: "singleBooking",
791+
title: "M2.3",
792+
subTitle: "Mødelokale",
793+
resourceAvailableText: "Lokalet er frit.",
794+
displayHeaders: true,
795+
resourceUnavailableText: "Det er optaget",
796+
footerText: "Se mere på localhost/events",
797+
fontSize: "font-size-lg",
798+
},
799+
},
764800
{
765801
id: "contacts-underlined",
766802
templateData: {

assets/tests/template/template-calendar.spec.js

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ const fixTime = async (page) => {
88
await page.clock.install({ time: newDate });
99
};
1010

11+
const fixTimeToNow = async (page) => {
12+
const newDate = new Date();
13+
await page.clock.install({ time: newDate });
14+
};
15+
1116
test("calendar-0-multiple-days: ui tests", async ({ page }) => {
1217
await fixTime(page);
1318

@@ -197,10 +202,45 @@ test("calendar-1-single: ui tests", async ({ page }) => {
197202
await expect(page.locator(".media-contain")).toHaveCount(0);
198203
});
199204

200-
test("Calendar 4", async ({ page }) => {
205+
test("calendar-0-single-booking: ui tests", async ({ page }) => {
201206
await fixTime(page);
202207

203-
await page.goto("/template/calendar-4-single-booking");
208+
await page.goto("/template/calendar-0-single-booking");
209+
const title = page.locator(".room-info .title");
210+
await expect(title).toHaveText("M2.3");
211+
const status = page.locator(".status");
212+
await expect(status).toHaveText("Ledigt");
213+
expect(page.locator("h3")).toContainText("Kommende begivenheder");
214+
const date = page.locator(".date-time > :nth-child(1)");
215+
const time = page.locator(".date-time > :nth-child(2)");
216+
217+
await expect(date).toContainText("september");
218+
await expect(time).not.toBeEmpty();
219+
await expect(page.locator(".content-item p")).toHaveText(
220+
"Straksbooking ikke tilgængeligt",
221+
);
222+
await expect(page.locator(".content-item div").first()).toHaveText(
223+
"Mindre end et minut til næste begivenhed",
224+
);
225+
await expect(page.locator(".content-item").nth(1)).toHaveCSS(
226+
"border-left",
227+
"2px solid rgb(0, 0, 0)",
228+
);
229+
const events = page.locator(".content .content-item");
230+
231+
await expect(events.nth(1)).toContainText("There will be cake");
232+
await expect(events.nth(2)).toContainText("The cake is a lie");
233+
await expect(events.nth(3)).toContainText("Det er optaget");
234+
});
235+
236+
test("calendar-1-single-booking: ui tests", async ({ page }) => {
237+
await fixTimeToNow(page);
238+
await page.goto("/template/calendar-1-single-booking");
239+
await expect(page.getByText("Ledigt")).toHaveCount(1);
240+
await expect(page.getByText("Ledigt")).toBeVisible();
241+
242+
await page.waitForTimeout(5500);
204243

205-
// TODO
244+
await expect(page.getByText("Optaget")).toHaveCount(1);
245+
await expect(page.getByText("Optaget")).toBeVisible();
206246
});

assets/tests/template/template-main.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ test.describe("Template Links", () => {
2323
"calendar-0-single",
2424
"calendar-1-single",
2525
"calendar-3-multiple-days",
26-
"calendar-4-single-booking",
26+
"calendar-0-single-booking",
27+
"calendar-1-single-booking",
2728
"contacts-underlined",
2829
"contacts-not-underlined",
2930
"iframe-0",

0 commit comments

Comments
 (0)