|  | 
| 1 | 1 | import { test, expect } from "@playwright/test"; | 
| 2 | 2 | 
 | 
| 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 | +  }); | 
| 5 | 7 | 
 | 
| 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 | +  }); | 
| 7 | 90 | }); | 
| 8 | 91 | 
 | 
| 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 | +  }); | 
| 11 | 123 | 
 | 
| 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 | +  }); | 
| 13 | 135 | }); | 
0 commit comments