Skip to content

Commit

Permalink
Add describe to e2e tests
Browse files Browse the repository at this point in the history
RISDEV-0000
  • Loading branch information
VictorDelCampo committed Mar 1, 2024
1 parent b37155c commit 53d6aea
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 76 deletions.
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
import { test, expect } from "@playwright/test"
import { amendingLaws } from "@e2e/testData/testData"

for (const amendingLaw of amendingLaws) {
test(`navigate and verify navigation to affected standard for ${amendingLaw.eli}`, async ({
page,
}) => {
// Navigation
await page.goto(`/amending-laws/${amendingLaw.eli}/affected-documents`)
test.describe("Affected documents page", () => {
for (const amendingLaw of amendingLaws) {
test(`navigate and verify navigation to affected documents for ${amendingLaw.eli}`, async ({
page,
}) => {
// Navigation
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/)
// 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
for (const article of amendingLaw.articles ?? []) {
await expect(
page.getByText(`Artikel ${article.enumeration}`),
).toBeVisible()
await expect(page.getByText(article.eli)).toBeVisible()
}
// Content
// eslint-disable-next-line playwright/no-conditional-in-test
for (const article of amendingLaw.articles ?? []) {
await expect(
page.getByText(`Artikel ${article.enumeration}`),
).toBeVisible()
await expect(page.getByText(article.eli)).toBeVisible()
}

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

// Back
await page.getByText("Zurück").click()
await expect(page).toHaveURL("/amending-laws")
})
}
// Back
await page.getByText("Zurück").click()
await expect(page).toHaveURL("/amending-laws")
})
}
})
64 changes: 33 additions & 31 deletions frontend/e2e/navigate-to-article-overview-and-test-content.spec.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
import { test, expect } from "@playwright/test"
import { amendingLaws } from "@e2e/testData/testData"

for (const amendingLaw of amendingLaws) {
test(`navigate and verify navigation to articles page for ${amendingLaw.eli}`, async ({
page,
}) => {
// Navigation
await page.goto(`/amending-laws/${amendingLaw.eli}/articles`)
test.describe("Articles page", () => {
for (const amendingLaw of amendingLaws) {
test(`navigate and verify navigation to articles page for ${amendingLaw.eli}`, async ({
page,
}) => {
// Navigation
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/)
// 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
for (const article of amendingLaw.articles ?? []) {
await expect(
page.getByText(`Artikel ${article.enumeration}`),
).toBeVisible()
await expect(
page.getByText(article.title, {
exact: true,
}),
).toBeVisible()
}
// Content
// eslint-disable-next-line playwright/no-conditional-in-test
for (const article of amendingLaw.articles ?? []) {
await expect(
page.getByText(`Artikel ${article.enumeration}`),
).toBeVisible()
await expect(
page.getByText(article.title, {
exact: true,
}),
).toBeVisible()
}

const checkChangeCommandButton = page.locator(
'text="Änderungsbefehl prüfen"',
)
await expect(checkChangeCommandButton).toBeVisible()
const checkChangeCommandButton = page.locator(
'text="Änderungsbefehl prüfen"',
)
await expect(checkChangeCommandButton).toBeVisible()

// Back
await page.click("text=Zurück")
await expect(page).toHaveURL("/amending-laws")
})
}
// Back
await page.click("text=Zurück")
await expect(page).toHaveURL("/amending-laws")
})
}
})
22 changes: 13 additions & 9 deletions frontend/e2e/navigate-to-detail-page-and-test-header.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { test, expect } from "@playwright/test"
import { amendingLaws, getExpectedHeading } from "@e2e/testData/testData"

for (const amendingLaw of amendingLaws) {
test(`navigate and verify header for ${amendingLaw.eli}`, async ({
page,
}) => {
await page.goto(`/amending-laws/${amendingLaw.eli}`)
test.describe("Info header", () => {
for (const amendingLaw of amendingLaws) {
test(`navigate and verify header for ${amendingLaw.eli}`, async ({
page,
}) => {
await page.goto(`/amending-laws/${amendingLaw.eli}`)

await expect(page.getByText(getExpectedHeading(amendingLaw))).toBeVisible()
await expect(page.getByText(amendingLaw.title ?? "")).toBeVisible()
})
}
await expect(
page.getByText(getExpectedHeading(amendingLaw)),
).toBeVisible()
await expect(page.getByText(amendingLaw.title ?? "")).toBeVisible()
})
}
})
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
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")
test.describe("Redirect and start page content", () => {
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()
})
}
await expect(
page.getByText(getExpectedHeading(amendingLaw)),
).toBeVisible()
await expect(
page.getByText(convertToGermanDate(amendingLaw.publicationDate)),
).toBeVisible()
})
}
})

function convertToGermanDate(isoDate: string): string {
const options: Intl.DateTimeFormatOptions = {
Expand Down

0 comments on commit 53d6aea

Please sign in to comment.