Skip to content

Commit

Permalink
Optimize I e2e tests + bug fix subtitle
Browse files Browse the repository at this point in the history
RISDEV-0000
  • Loading branch information
VictorDelCampo committed Mar 1, 2024
1 parent 050859c commit 50f6057
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@ for (const amendingLaw of amendingLaws) {
page,
}) => {
// Navigation
await page.goto("/")
await page.click(`a[href*="${amendingLaw.eli}"]`)
await page.click("text=Betroffene Normenkomplexe")
await expect(page).toHaveURL(
`/amending-laws/${amendingLaw.eli}/affected-documents`,
)
await expect(
page.locator(
'a.router-link-active:has-text("Betroffene Normenkomplexe")',
),
).toHaveAttribute("class", expect.stringContaining("bg-blue-200"))
await page.goto(`/amending-laws/${amendingLaw.eli}/affected-documents`)

// Menu
const locator = page.locator(`a:has-text("Betroffene Normenkomplexe")`)
await expect(locator).toHaveClass(/router-link-active/)
await expect(locator).toHaveClass(/bg-blue-200/)

// Content
// eslint-disable-next-line playwright/no-conditional-in-test
Expand All @@ -26,11 +21,11 @@ for (const amendingLaw of amendingLaws) {
).toBeVisible()
await expect(page.getByText(article.eli)).toBeVisible()
}
const editMetadataButton = page.locator('text="Metadaten editieren"')
await expect(editMetadataButton).toBeVisible()

await expect(page.getByText("Metadaten editieren")).toBeVisible()

// Back
await page.click("text=Zurück")
await page.getByText("Zurück").click()
await expect(page).toHaveURL("/amending-laws")
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ for (const amendingLaw of amendingLaws) {
page,
}) => {
// Navigation
await page.goto("/")
await page.click(`a[href*="${amendingLaw.eli}"]`)
await expect(page).toHaveURL(`/amending-laws/${amendingLaw.eli}/articles`)
await expect(
page.locator('a.router-link-active:has-text("Artikelübersicht")'),
).toHaveAttribute("class", expect.stringContaining("bg-blue-200"))
await page.goto(`/amending-laws/${amendingLaw.eli}/articles`)

// Menu
const locator = page.locator(`a:has-text("Artikelübersicht")`)
await expect(locator).toHaveClass(/router-link-active/)
await expect(locator).toHaveClass(/bg-blue-200/)

// Content
// eslint-disable-next-line playwright/no-conditional-in-test
Expand Down
6 changes: 3 additions & 3 deletions frontend/e2e/navigate-to-detail-page-and-test-header.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ for (const amendingLaw of amendingLaws) {
test(`navigate and verify header for ${amendingLaw.eli}`, async ({
page,
}) => {
await page.goto("/")

await page.click(`a[href*="${amendingLaw.eli}"]`)
await page.goto(`/amending-laws/${amendingLaw.eli}`)

await expect(page.locator(".ds-heading-03-reg")).toHaveText(
getExpectedHeading(amendingLaw),
)

// TODO
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { test, expect } from "@playwright/test"
import { amendingLaws, getExpectedHeading } from "@e2e/testData/testData"

for (const amendingLaw of amendingLaws) {
test(`redirect to amending laws page and test content for ${amendingLaw.eli}`, async ({
page,
}) => {
await page.goto("/")
await expect(page).toHaveURL("/amending-laws")

await expect(page.getByText(getExpectedHeading(amendingLaw))).toBeVisible()
await expect(
page.getByText(convertToGermanDate(amendingLaw.publicationDate)),
).toBeVisible()
})
}

function convertToGermanDate(isoDate: string): string {
const options: Intl.DateTimeFormatOptions = {
day: "2-digit",
month: "2-digit",
year: "numeric",
}
return new Date(isoDate).toLocaleDateString("de-DE", options)
}
8 changes: 0 additions & 8 deletions frontend/e2e/redirect-to-amendinglaws-page.spec.ts

This file was deleted.

2 changes: 1 addition & 1 deletion frontend/src/views/AmendingLaw.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const heading = computed(() => {

<template>
<div class="flex min-h-screen flex-col bg-gray-100">
<RisInfoHeader :heading="heading" :title="loadedAmendingLaw?.title" />
<RisInfoHeader :heading="heading" :subtitle="loadedAmendingLaw?.title" />
<div class="flex">
<RisNavbarSide
class="min-h-screen flex-none border-r border-gray-400 bg-white"
Expand Down

0 comments on commit 50f6057

Please sign in to comment.