Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace the search for texts in the html text with testcafe sele… #306

Merged
merged 1 commit into from
Oct 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions testcafe/introScreens.spec.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
import { Selector } from "testcafe";
import { Config } from "./testcafe.config";
import { buttonWithText, textExists } from "./testUtils";

fixture`Intro screens test`.page`${Config.baseUrl}`;

test("Finish intro screens", async (t) => {
const nextButton = Selector("a").withAttribute("role", "button").child().withText("Weiter");
const websiteText = Selector("html").textContent;
const nextButton = buttonWithText("Weiter");

const titleForIntro1 = "Willkommen bei der CovMap";
const titleForIntro2 = "Was ist die CovMap?";
const titleForIntro3 = "Was zeigt mir die CovMap an?";
const titleTextForPostalCode = "Für Dein regionales Risiko brauchen wir noch die Postleitzahl Deines Wohnortes";

await t.expect(websiteText).contains(titleForIntro1).click(nextButton);
await t.expect(textExists(titleForIntro1)).ok();
await t.click(nextButton);

await t.expect(websiteText).contains(titleForIntro2).click(nextButton);
await t.expect(textExists(titleForIntro2)).ok();
await t.click(nextButton);

await t.expect(websiteText).contains(titleForIntro3).click(nextButton);
await t.expect(textExists(titleForIntro3)).ok();
await t.click(nextButton);

await t.expect(websiteText).contains(titleTextForPostalCode).pressKey("1 2 3 4 5 tab space tab tab enter");
await t.expect(textExists(titleTextForPostalCode)).ok();
await t.pressKey("1 2 3 4 5 tab space tab tab enter");

await t.expect(websiteText).notContains(titleTextForPostalCode);
await t.expect(textExists(titleTextForPostalCode)).notOk();
});
11 changes: 11 additions & 0 deletions testcafe/testUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Selector } from "testcafe";

// This should work with text inside a Material-UI <Typography>
export function textExists(titleForIntro1: string) {
return Selector("p").withText(titleForIntro1).exists;
}

// This should work with the label of a Material-UI <Button>
export function buttonWithText(nextButtonText: string) {
return Selector("a").withAttribute("role", "button").child().withText(nextButtonText);
}