Skip to content

Commit

Permalink
Move filling title to beforeEach
Browse files Browse the repository at this point in the history
  • Loading branch information
mpanne committed Jan 23, 2025
1 parent 06432af commit 4da7bc4
Showing 1 changed file with 31 additions and 44 deletions.
75 changes: 31 additions & 44 deletions packages/dito/tests/e2e/resultForm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async function registerMailInterceptionHandlerAndExpect(

test.describe("test positive result for digital and interoperability", () => {
test.beforeEach(
"answer all pre-check questions with yes and go to result page",
"answer all pre-check questions with yes, go to result page and fill title",
async ({ page }) => {
await page.goto(questions[0].url);
for (const question of questions) {
Expand All @@ -68,6 +68,7 @@ test.describe("test positive result for digital and interoperability", () => {
await page.getByRole("button", { name: "Übernehmen" }).click();
}
await page.waitForURL(ROUTE_RESULT.url);
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
},
);

Expand All @@ -84,7 +85,7 @@ test.describe("test positive result for digital and interoperability", () => {
});

test("error is shown if title is empty", async ({ page }) => {
// not filling title
await page.getByLabel("Arbeitstitel des Vorhabens").clear();
await registerMailInterceptionHandlerAndExpect(page);
await page.getByRole("button", { name: "E-Mail erstellen" }).click();
await expect(page.getByTestId(TITLE_INPUT_ERROR)).toBeVisible();
Expand All @@ -94,6 +95,7 @@ test.describe("test positive result for digital and interoperability", () => {
});

test("error is shown if title is too long", async ({ page }) => {
await page.getByLabel("Arbeitstitel des Vorhabens").clear();
await page.getByLabel("Arbeitstitel des Vorhabens").fill("A".repeat(101));
await registerMailInterceptionHandlerAndExpect(page);
await page.getByRole("button", { name: "E-Mail erstellen" }).click();
Expand All @@ -102,7 +104,6 @@ test.describe("test positive result for digital and interoperability", () => {
});

test("no error is shown if optional email is empty", async ({ page }) => {
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
// not filling email
await registerMailInterceptionHandlerAndExpect(page);
await page.getByRole("button", { name: "E-Mail erstellen" }).click();
Expand All @@ -111,24 +112,20 @@ test.describe("test positive result for digital and interoperability", () => {

test("no error shown when email and title are filled", async ({ page }) => {
await page.getByLabel("Ihre E-Mail Adresse").fill("[email protected]");
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
await registerMailInterceptionHandlerAndExpect(page);
await page.getByRole("button", { name: "E-Mail erstellen" }).click();
await expect(page.getByTestId(EMAIL_INPUT_ERROR)).not.toBeVisible();
await expect(page.getByTestId(TITLE_INPUT_ERROR)).not.toBeVisible();
});

test("email subject includes title", async ({ page }) => {
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");

await registerMailInterceptionHandlerAndExpect(page, {
subject: "Digitalcheck Vorprüfung: „Policy ABC“",
});
await page.getByRole("button", { name: "E-Mail erstellen" }).click();
});

test("email recipients include nkr", async ({ page }) => {
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
await registerMailInterceptionHandlerAndExpect(page, {
recipients: ["[email protected]"],
});
Expand All @@ -138,15 +135,13 @@ test.describe("test positive result for digital and interoperability", () => {
test("email recipients include digitalcheck team if interoperability is positive", async ({
page,
}) => {
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
await registerMailInterceptionHandlerAndExpect(page, {
recipients: ["[email protected]"],
});
await page.getByRole("button", { name: "E-Mail erstellen" }).click();
});

test("email cc includes email from email input", async ({ page }) => {
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
await page.getByLabel("Ihre E-Mail Adresse").fill("[email protected]");
await registerMailInterceptionHandlerAndExpect(page, {
cc: ["[email protected]"],
Expand All @@ -155,7 +150,6 @@ test.describe("test positive result for digital and interoperability", () => {
});

test("email body contains result title", async ({ page }) => {
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
await registerMailInterceptionHandlerAndExpect(page, {
body: [
"Das Regelungsvorhaben hat einen Digitalbezug und enthält Anforderungen der Interoperabilität.",
Expand All @@ -165,7 +159,6 @@ test.describe("test positive result for digital and interoperability", () => {
});

test("email body contains all answers in positive form", async ({ page }) => {
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
const bodyContains = [
"In Bezug auf digitale Aspekte führt ihr Regelungsvorhaben zu...",
"In Bezug auf Interoperabilität führt ihr Regelungsvorhaben zu...",
Expand All @@ -181,7 +174,6 @@ test.describe("test positive result for digital and interoperability", () => {
});

test("email body does not contain negative reasoning", async ({ page }) => {
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
await registerMailInterceptionHandlerAndExpect(page, undefined, {
body: ["Begründung:"],
});
Expand All @@ -191,7 +183,7 @@ test.describe("test positive result for digital and interoperability", () => {

test.describe("test positive result for digital and negative for interoperability", () => {
test.beforeEach(
"answer all digital questions with yes and all interoperability questions with no and go to result page",
"answer all digital questions with yes and all interoperability questions with no, go to result page and fill title",
async ({ page }) => {
await page.goto(questions[0].url);
for (const question of questions) {
Expand All @@ -201,6 +193,7 @@ test.describe("test positive result for digital and negative for interoperabilit
.click();
await page.getByRole("button", { name: "Übernehmen" }).click();
}
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
},
);

Expand All @@ -211,7 +204,6 @@ test.describe("test positive result for digital and negative for interoperabilit
test("email recipients do not include digitalcheck team if interoperability is negative", async ({
page,
}) => {
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
// set expected to undefined to set notExpected
await registerMailInterceptionHandlerAndExpect(page, undefined, {
recipients: ["[email protected]"],
Expand All @@ -220,7 +212,6 @@ test.describe("test positive result for digital and negative for interoperabilit
});

test("email body contains result title", async ({ page }) => {
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
await registerMailInterceptionHandlerAndExpect(page, {
body: [
"Das Regelungsvorhaben hat einen Digitalbezug und keine Anforderungen der Interoperabilität.",
Expand All @@ -232,7 +223,7 @@ test.describe("test positive result for digital and negative for interoperabilit

test.describe("test positive result for digital and unsure for interoperability", () => {
test.beforeEach(
"answer all digital questions with yes and all interoperability questions with unsure and go to result page",
"answer all digital questions with yes and all interoperability questions with unsure, go to result page and fill title",
async ({ page }) => {
await page.goto(questions[0].url);
for (const question of questions) {
Expand All @@ -242,6 +233,7 @@ test.describe("test positive result for digital and unsure for interoperability"
.click();
await page.getByRole("button", { name: "Übernehmen" }).click();
}
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
},
);

Expand All @@ -252,15 +244,13 @@ test.describe("test positive result for digital and unsure for interoperability"
test("email recipients include digitalcheck team if interoperability is unsure", async ({
page,
}) => {
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
await registerMailInterceptionHandlerAndExpect(page, {
recipients: ["[email protected]"],
});
await page.getByRole("button", { name: "E-Mail erstellen" }).click();
});

test("email body contains result title", async ({ page }) => {
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
await registerMailInterceptionHandlerAndExpect(page, {
body: [
"Das Regelungsvorhaben hat einen Digitalbezug und keine eindeutigen Anforderungen der Interoperabilität.",
Expand All @@ -272,7 +262,6 @@ test.describe("test positive result for digital and unsure for interoperability"
test("email body contains all answers for interoperability in unsure form", async ({
page,
}) => {
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
const bodyContains = [
"In Bezug auf Interoperabilität ist nicht sicher, ob Ihr Regelungsvorhaben zu Folgendem führt...",
];
Expand All @@ -291,14 +280,15 @@ test.describe("test positive result for digital and unsure for interoperability"

test.describe("test negative result for digital and interoperability", () => {
test.beforeEach(
"answer all pre-check questions with no and go to result page",
"answer all pre-check questions with no, go to result page and fill title",
async ({ page }) => {
await page.goto(questions[0].url);
for (const question of questions) {
await page.waitForURL(question.url);
await page.getByLabel("Nein").click();
await page.getByRole("button", { name: "Übernehmen" }).click();
}
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
},
);

Expand All @@ -315,7 +305,6 @@ test.describe("test negative result for digital and interoperability", () => {
});

test("error is shown if negative reasoning is empty", async ({ page }) => {
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
await registerMailInterceptionHandlerAndExpect(page);
await page.getByRole("button", { name: "E-Mail erstellen" }).click();
await expect(page.getByTestId(NEGATIVE_REASONING_ERROR)).toBeVisible();
Expand All @@ -326,15 +315,13 @@ test.describe("test negative result for digital and interoperability", () => {

test("error is shown if negative reasoning is too long", async ({ page }) => {
await page.getByLabel("Begründung").fill("A".repeat(501));
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
await registerMailInterceptionHandlerAndExpect(page);
await page.getByRole("button", { name: "E-Mail erstellen" }).click();
await expect(page.getByTestId(NEGATIVE_REASONING_ERROR)).toBeVisible();
await expect(page.locator("main")).toContainText("kürzere Begründung");
});

test("email body contains all answers in negative form", async ({ page }) => {
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
const bodyContains = [
"In Bezug auf digitale Aspekte führt ihr Regelungsvorhaben zu...",
"In Bezug auf Interoperabilität führt ihr Regelungsvorhaben zu...",
Expand All @@ -350,7 +337,6 @@ test.describe("test negative result for digital and interoperability", () => {
});

test("email body contains result title", async ({ page }) => {
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
await registerMailInterceptionHandlerAndExpect(page, {
body: [
"Das Regelungsvorhaben hat keinen Digitalbezug und keine Anforderungen der Interoperabilität.",
Expand All @@ -360,7 +346,6 @@ test.describe("test negative result for digital and interoperability", () => {
});

test("email body contains negative reasoning", async ({ page }) => {
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
await page
.getByLabel("Begründung")
.fill(
Expand All @@ -378,7 +363,7 @@ test.describe("test negative result for digital and interoperability", () => {

test.describe("test negative result for digital and positive for interoperability", () => {
test.beforeEach(
"answer all digital questions with no and all interoperability questions with yes and go to result page",
"answer all digital questions with no and all interoperability questions with yes, go to result page and fill title",
async ({ page }) => {
await page.goto(questions[0].url);
for (const question of questions) {
Expand All @@ -388,6 +373,7 @@ test.describe("test negative result for digital and positive for interoperabilit
.click();
await page.getByRole("button", { name: "Übernehmen" }).click();
}
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
},
);

Expand All @@ -396,7 +382,6 @@ test.describe("test negative result for digital and positive for interoperabilit
});

test("email body contains result title", async ({ page }) => {
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
await registerMailInterceptionHandlerAndExpect(page, {
body: [
"Das Regelungsvorhaben hat keinen Digitalbezug und keine Anforderungen der Interoperabilität.",
Expand All @@ -408,7 +393,6 @@ test.describe("test negative result for digital and positive for interoperabilit
test("email body contains hint that interoperability is not possible if digital is negative", async ({
page,
}) => {
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
await registerMailInterceptionHandlerAndExpect(page, {
body: [
"Bitte beachten Sie: Wenn Ihr Vorhaben keinen Digitalbezug aufweist, können die Anforderungen der Interoperabilität nicht erfüllt werden",
Expand All @@ -420,7 +404,7 @@ test.describe("test negative result for digital and positive for interoperabilit

test.describe("test negative result for digital and unsure for interoperability", () => {
test.beforeEach(
"answer all digital questions with no and all interoperability questions with unsure and go to result page",
"answer all digital questions with no and all interoperability questions with unsure, go to result page and fill title",
async ({ page }) => {
await page.goto(questions[0].url);
for (const question of questions) {
Expand All @@ -430,6 +414,7 @@ test.describe("test negative result for digital and unsure for interoperability"
.click();
await page.getByRole("button", { name: "Übernehmen" }).click();
}
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
},
);

Expand All @@ -438,7 +423,6 @@ test.describe("test negative result for digital and unsure for interoperability"
});

test("email body contains result title", async ({ page }) => {
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
await registerMailInterceptionHandlerAndExpect(page, {
body: [
"Das Regelungsvorhaben hat keinen Digitalbezug und keine eindeutigen Anforderungen der Interoperabilität.",
Expand All @@ -449,25 +433,28 @@ test.describe("test negative result for digital and unsure for interoperability"
});

test.describe("test positive result with mixed answers", () => {
test.beforeEach("Go to assessment page", async ({ page }) => {
await page.goto(questions[0].url);
await page.getByLabel("Nein").click();
await page.getByRole("button", { name: "Übernehmen" }).click();
await page.waitForURL(questions[1].url);
await page.getByLabel("Ich bin unsicher").click();
await page.getByRole("button", { name: "Übernehmen" }).click();
for (const question of questions.slice(2)) {
await page.waitForURL(question.url);
await page.getByLabel("Ja").click();
test.beforeEach(
"answer questions with mixed answers, go to result page and fill title",
async ({ page }) => {
await page.goto(questions[0].url);
await page.getByLabel("Nein").click();
await page.getByRole("button", { name: "Übernehmen" }).click();
}
await page.waitForURL(ROUTE_RESULT.url);
});
await page.waitForURL(questions[1].url);
await page.getByLabel("Ich bin unsicher").click();
await page.getByRole("button", { name: "Übernehmen" }).click();
for (const question of questions.slice(2)) {
await page.waitForURL(question.url);
await page.getByLabel("Ja").click();
await page.getByRole("button", { name: "Übernehmen" }).click();
}
await page.waitForURL(ROUTE_RESULT.url);
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
},
);

test("answers in email body are prefixed by a special character indicating the type of answer", async ({
page,
}) => {
await page.getByLabel("Arbeitstitel des Vorhabens").fill("Policy ABC");
const bodyContains = [
`- ${questions[0].negativeResult}`,
`? ${questions[1].positiveResult}`,
Expand Down

0 comments on commit 4da7bc4

Please sign in to comment.