diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml new file mode 100644 index 0000000..90b6b70 --- /dev/null +++ b/.github/workflows/playwright.yml @@ -0,0 +1,27 @@ +name: Playwright Tests +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] +jobs: + test: + timeout-minutes: 60 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install dependencies + run: npm ci + - name: Install Playwright Browsers + run: npx playwright install --with-deps + - name: Run Playwright tests + run: npx playwright test + - uses: actions/upload-artifact@v3 + if: always() + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 diff --git a/.gitignore b/.gitignore index 6f6110a..8fbcb20 100644 --- a/.gitignore +++ b/.gitignore @@ -281,3 +281,7 @@ dist-ssr *.njsproj *.sln *.sw? +/test-results/ +/playwright-report/ +/blob-report/ +/playwright/.cache/ diff --git a/package-lock.json b/package-lock.json index 753aac7..24f79c6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,8 @@ "zustand": "4.4.6" }, "devDependencies": { + "@playwright/test": "1.40.1", + "@types/node": "20.11.4", "@types/react": "18.2.37", "@types/react-dom": "18.2.15", "@typescript-eslint/eslint-plugin": "6.10.0", @@ -950,6 +952,21 @@ "node": ">= 8" } }, + "node_modules/@playwright/test": { + "version": "1.40.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.40.1.tgz", + "integrity": "sha512-EaaawMTOeEItCRvfmkI9v6rBkF1svM8wjl/YPRrg2N2Wmp+4qJYkWtJsbew1szfKKDm6fPLy4YAanBhIlf9dWw==", + "dev": true, + "dependencies": { + "playwright": "1.40.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=16" + } + }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.6.0.tgz", @@ -1153,6 +1170,15 @@ "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", "dev": true }, + "node_modules/@types/node": { + "version": "20.11.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.4.tgz", + "integrity": "sha512-6I0fMH8Aoy2lOejL3s4LhyIYX34DPwY8bl5xlNjBvUEk8OHrcuzsFt+Ied4LvJihbtXPM+8zUqdydfIti86v9g==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, "node_modules/@types/prop-types": { "version": "15.7.11", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.11.tgz", @@ -2974,6 +3000,50 @@ "node": ">= 6" } }, + "node_modules/playwright": { + "version": "1.40.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.40.1.tgz", + "integrity": "sha512-2eHI7IioIpQ0bS1Ovg/HszsN/XKNwEG1kbzSDDmADpclKc7CyqkHw7Mg2JCz/bbCxg25QUPcjksoMW7JcIFQmw==", + "dev": true, + "dependencies": { + "playwright-core": "1.40.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=16" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright-core": { + "version": "1.40.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.40.1.tgz", + "integrity": "sha512-+hkOycxPiV534c4HhpfX6yrlawqVUzITRKwHAmYfmsVreltEl6fAZJ3DPfLMOODw0H3s1Itd6MDCWmP1fl/QvQ==", + "dev": true, + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/playwright/node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/postcss": { "version": "8.4.31", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", @@ -3710,6 +3780,12 @@ "node": ">=14.17" } }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + }, "node_modules/update-browserslist-db": { "version": "1.0.13", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", diff --git a/package.json b/package.json index 5f27d8b..a416aed 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "dev": "vite", "build": "tsc && vite build", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", - "preview": "vite preview" + "preview": "vite preview", + "test:e2e": "playwright test" }, "dependencies": { "react": "18.2.0", @@ -16,6 +17,8 @@ "zustand": "4.4.6" }, "devDependencies": { + "@playwright/test": "1.40.1", + "@types/node": "20.11.4", "@types/react": "18.2.37", "@types/react-dom": "18.2.15", "@typescript-eslint/eslint-plugin": "6.10.0", diff --git a/playwright.config.ts b/playwright.config.ts new file mode 100644 index 0000000..72dc6ae --- /dev/null +++ b/playwright.config.ts @@ -0,0 +1,77 @@ +import { defineConfig, devices } from "@playwright/test"; + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +// require('dotenv').config(); + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + testDir: "./tests", + /* Run tests in files in parallel */ + fullyParallel: true, + /* Fail the build on CI if you accidentally left test.only in the source code. */ + forbidOnly: !!process.env.CI, + /* Retry on CI only */ + retries: process.env.CI ? 2 : 0, + /* Opt out of parallel tests on CI. */ + workers: process.env.CI ? 1 : undefined, + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: "html", + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + /* Base URL to use in actions like `await page.goto('/')`. */ + // baseURL: 'http://127.0.0.1:3000', + + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: "on-first-retry", + }, + + /* Configure projects for major browsers */ + projects: [ + { + name: "chromium", + use: { ...devices["Desktop Chrome"] }, + }, + + { + name: "firefox", + use: { ...devices["Desktop Firefox"] }, + }, + + { + name: "webkit", + use: { ...devices["Desktop Safari"] }, + }, + + /* Test against mobile viewports. */ + // { + // name: 'Mobile Chrome', + // use: { ...devices['Pixel 5'] }, + // }, + // { + // name: 'Mobile Safari', + // use: { ...devices['iPhone 12'] }, + // }, + + /* Test against branded browsers. */ + // { + // name: 'Microsoft Edge', + // use: { ...devices['Desktop Edge'], channel: 'msedge' }, + // }, + // { + // name: 'Google Chrome', + // use: { ...devices['Desktop Chrome'], channel: 'chrome' }, + // }, + ], + + /* Run your local dev server before starting the tests */ + webServer: { + command: "npm run dev", + url: "http://localhost:5173", + reuseExistingServer: !process.env.CI, + }, +}); diff --git a/tests/first-registration.spec.ts b/tests/first-registration.spec.ts new file mode 100644 index 0000000..85ca9fa --- /dev/null +++ b/tests/first-registration.spec.ts @@ -0,0 +1,468 @@ +import { test, expect } from "@playwright/test"; + +test("should have 3 documents in their checklist: registrationForm, movingInConfirmation, germanIdOrPassport", async ({ + page, +}) => { + await page.goto("http://localhost:5173/"); + + const nextButton = page.getByRole("button", { name: "Weiter" }); + + await nextButton.click(); + + let noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + + await noRadio.click(); // first registration in berlin? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // are you married? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // do you have kids under 18? + await nextButton.click(); + + const yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // do you have the german nationality? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // Are you under 16? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // Do you stay registered in another flat? + await nextButton.click(); + + const registrationForm = page + .locator("div") + .filter({ hasText: /^Anmeldeformular$/ }); + const movingInConfirmation = page + .locator("div") + .filter({ hasText: /^Einzugsbestätigung des Wohnungsgebers\/Vermieters$/ }); + const germanIdOrPassport = page + .locator("div") + .filter({ hasText: /^Dein eigener Personalausweis oder Reisepass$/ }); + + await expect(registrationForm).toBeVisible(); + await expect(movingInConfirmation).toBeVisible(); + await expect(germanIdOrPassport).toBeVisible(); +}); + +test("should have 4 documents in their checklist: registrationForm, movingInConfirmation, germanIdOrPassport, birthCertificate", async ({ + page, +}) => { + await page.goto("http://localhost:5173/"); + + const nextButton = page.getByRole("button", { name: "Weiter" }); + + await nextButton.click(); + + let noRadio; + let yesRadio = page.getByLabel("Ja"); + + await yesRadio.click(); // first registration in berlin? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // are you married? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // do you have kids under 18? + await nextButton.click(); + + yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // do you have the german nationality? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // Are you under 16? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // Do you stay registered in another flat? + await nextButton.click(); + + const registrationForm = page + .locator("div") + .filter({ hasText: /^Anmeldeformular$/ }); + const movingInConfirmation = page + .locator("div") + .filter({ hasText: /^Einzugsbestätigung des Wohnungsgebers\/Vermieters$/ }); + const birthCertificate = page + .locator("div") + .filter({ hasText: /^Geburtsurkunde$/ }); + const germanIdOrPassport = page + .locator("div") + .filter({ hasText: /^Dein eigener Personalausweis oder Reisepass$/ }); + + await expect(registrationForm).toBeVisible(); + await expect(movingInConfirmation).toBeVisible(); + await expect(birthCertificate).toBeVisible(); + await expect(germanIdOrPassport).toBeVisible(); +}); + +test("should have 5 documents in their checklist: registrationForm, movingInConfirmation, germanIdOrPassport, birthCertificate, marriageCertificate", async ({ + page, +}) => { + await page.goto("http://localhost:5173/"); + + const nextButton = page.getByRole("button", { name: "Weiter" }); + + await nextButton.click(); + + let noRadio; + let yesRadio = page.getByLabel("Ja"); + + await yesRadio.click(); // first registration in berlin? + await nextButton.click(); + + yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // are you married? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // do you want to register your spouse? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // do you have kids under 18? + await nextButton.click(); + + yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // do you have the german nationality? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // Are you under 16? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // Do you stay registered in another flat? + await nextButton.click(); + + const registrationForm = page + .locator("div") + .filter({ hasText: /^Anmeldeformular$/ }); + const movingInConfirmation = page + .locator("div") + .filter({ hasText: /^Einzugsbestätigung des Wohnungsgebers\/Vermieters$/ }); + const germanIdOrPassport = page + .locator("div") + .filter({ hasText: /^Dein eigener Personalausweis oder Reisepass$/ }); + const birthCertificate = page + .locator("div") + .filter({ hasText: /^Geburtsurkunde$/ }); + const marriageCertificate = page + .locator("div") + .filter({ hasText: /^Heiratsurkunde$/ }); + + await expect(registrationForm).toBeVisible(); + await expect(movingInConfirmation).toBeVisible(); + await expect(germanIdOrPassport).toBeVisible(); + await expect(birthCertificate).toBeVisible(); + await expect(marriageCertificate).toBeVisible(); +}); + +test("should have 6 documents in their checklist: registrationForm, movingInConfirmation, germanIdOrPassport, birthCertificate, marriageCertificate, idDocumentForSpouse", async ({ + page, +}) => { + await page.goto("http://localhost:5173/"); + + const nextButton = page.getByRole("button", { name: "Weiter" }); + + await nextButton.click(); + + let noRadio; + let yesRadio = page.getByLabel("Ja"); + + await yesRadio.click(); // first registration in berlin? + await nextButton.click(); + + yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // are you married? + await nextButton.click(); + + yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // do you want to register your spouse? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // do you have kids under 18? + await nextButton.click(); + + yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // do you have the german nationality? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // Are you under 16? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // Do you stay registered in another flat? + await nextButton.click(); + + const registrationForm = page + .locator("div") + .filter({ hasText: /^Anmeldeformular$/ }); + const movingInConfirmation = page + .locator("div") + .filter({ hasText: /^Einzugsbestätigung des Wohnungsgebers\/Vermieters$/ }); + const germanIdOrPassport = page + .locator("div") + .filter({ hasText: /^Dein eigener Personalausweis oder Reisepass$/ }); + const birthCertificate = page + .locator("div") + .filter({ hasText: /^Geburtsurkunde$/ }); + const marriageCertificate = page + .locator("div") + .filter({ hasText: /^Heiratsurkunde$/ }); + const idDocumentForSpouse = page.locator("div").filter({ + hasText: + /^Personalausweis oder Reisepass Deiner Ehepartnerin\/Deines Ehepartners$/, + }); + + await expect(registrationForm).toBeVisible(); + await expect(movingInConfirmation).toBeVisible(); + await expect(germanIdOrPassport).toBeVisible(); + await expect(birthCertificate).toBeVisible(); + await expect(marriageCertificate).toBeVisible(); + await expect(idDocumentForSpouse).toBeVisible(); +}); + +test("should have 8 documents in their checklist: registrationForm, movingInConfirmation, germanIdOrPassport, birthCertificate, marriageCertificate, idDocumentForSpouse, childBirthCertificate, custodyDeclaration", async ({ + page, +}) => { + await page.goto("http://localhost:5173/"); + + const nextButton = page.getByRole("button", { name: "Weiter" }); + + await nextButton.click(); + + let noRadio; + let yesRadio = page.getByLabel("Ja"); + + await yesRadio.click(); // first registration in berlin? + await nextButton.click(); + + yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // are you married? + await nextButton.click(); + + yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // do you want to register your spouse? + await nextButton.click(); + + yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // do you have kids under 18? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // is a child moving with you? + await nextButton.click(); + + yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // do you have the german nationality? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // Are you under 16? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // Do you stay registered in another flat? + await nextButton.click(); + + const registrationForm = page + .locator("div") + .filter({ hasText: /^Anmeldeformular$/ }); + const movingInConfirmation = page + .locator("div") + .filter({ hasText: /^Einzugsbestätigung des Wohnungsgebers\/Vermieters$/ }); + const germanIdOrPassport = page + .locator("div") + .filter({ hasText: /^Dein eigener Personalausweis oder Reisepass$/ }); + const birthCertificate = page + .locator("div") + .filter({ hasText: /^Geburtsurkunde$/ }); + const marriageCertificate = page + .locator("div") + .filter({ hasText: /^Heiratsurkunde$/ }); + const idDocumentForSpouse = page.locator("div").filter({ + hasText: + /^Personalausweis oder Reisepass Deiner Ehepartnerin\/Deines Ehepartners$/, + }); + const childBirthCertificate = page + .locator("div") + .filter({ hasText: /^Geburtsurkunde Deines Kindes\/Deiner Kinder$/ }); + const custodyDeclaration = page + .locator("div") + .filter({ hasText: /^Sorgerechtserklärung$/ }); + + await expect(registrationForm).toBeVisible(); + await expect(movingInConfirmation).toBeVisible(); + await expect(germanIdOrPassport).toBeVisible(); + await expect(birthCertificate).toBeVisible(); + await expect(marriageCertificate).toBeVisible(); + await expect(idDocumentForSpouse).toBeVisible(); + await expect(childBirthCertificate).toBeVisible(); + await expect(custodyDeclaration).toBeVisible(); +}); + +test("should have 11 documents in their checklist: registrationForm, movingInConfirmation, germanIdOrPassport, birthCertificate, marriageCertificate, idDocumentForSpouse, childBirthCertificate, custodyDeclaration, idDocumentForChild, guardianConsent, additionalRegistrationForm", async ({ + page, +}) => { + await page.goto("http://localhost:5173/"); + + const nextButton = page.getByRole("button", { name: "Weiter" }); + + await nextButton.click(); + + let noRadio; + let yesRadio = page.getByLabel("Ja"); + + await yesRadio.click(); // first registration in berlin? + await nextButton.click(); + + yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // are you married? + await nextButton.click(); + + yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // do you want to register your spouse? + await nextButton.click(); + + yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // do you have kids under 18? + await nextButton.click(); + + yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // is a child moving with you? + await nextButton.click(); + + yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // do you have the german nationality? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // Are you under 16? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // Do you stay registered in another flat? + await nextButton.click(); + + const registrationForm = page + .locator("div") + .filter({ hasText: /^Anmeldeformular$/ }); + const movingInConfirmation = page + .locator("div") + .filter({ hasText: /^Einzugsbestätigung des Wohnungsgebers\/Vermieters$/ }); + const germanIdOrPassport = page + .locator("div") + .filter({ hasText: /^Dein eigener Personalausweis oder Reisepass$/ }); + const birthCertificate = page + .locator("div") + .filter({ hasText: /^Geburtsurkunde$/ }); + const marriageCertificate = page + .locator("div") + .filter({ hasText: /^Heiratsurkunde$/ }); + const idDocumentForSpouse = page.locator("div").filter({ + hasText: + /^Personalausweis oder Reisepass Deiner Ehepartnerin\/Deines Ehepartners$/, + }); + const childBirthCertificate = page + .locator("div") + .filter({ hasText: /^Geburtsurkunde Deines Kindes\/Deiner Kinder$/ }); + const custodyDeclaration = page + .locator("div") + .filter({ hasText: /^Sorgerechtserklärung$/ }); + const idDocumentForChild = page.locator("div").filter({ + hasText: + /^Personalausweis, Reisepass oder Kinderpass des Kindes\/der Kinder$/, + }); + const guardianConsent = page.locator("div").filter({ + hasText: + /^Einverständniserklärung der Sorgeberechtigten des Kinder\/der Kinder$/, + }); + const additionalRegistrationForm = page + .locator("div") + .filter({ hasText: /^Weiteres Anmeldeformular$/ }); + + await expect(registrationForm).toBeVisible(); + await expect(movingInConfirmation).toBeVisible(); + await expect(germanIdOrPassport).toBeVisible(); + await expect(birthCertificate).toBeVisible(); + await expect(marriageCertificate).toBeVisible(); + await expect(idDocumentForSpouse).toBeVisible(); + await expect(childBirthCertificate).toBeVisible(); + await expect(custodyDeclaration).toBeVisible(); + await expect(idDocumentForChild).toBeVisible(); + await expect(guardianConsent).toBeVisible(); + await expect(additionalRegistrationForm).toBeVisible(); +}); diff --git a/tests/nationality.spec.ts b/tests/nationality.spec.ts new file mode 100644 index 0000000..85b36b5 --- /dev/null +++ b/tests/nationality.spec.ts @@ -0,0 +1,305 @@ +import { test, expect } from "@playwright/test"; + +test("should have 4 documents in their checklist: registrationForm, movingInConfirmation, germanIdOrPassportOrChildPassport, confirmationOfCustodian", async ({ + page, +}) => { + await page.goto("http://localhost:5173/"); + + const nextButton = page.getByRole("button", { name: "Weiter" }); + + await nextButton.click(); + + let noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + + await noRadio.click(); // first registration in berlin? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // are you married? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // do you have kids under 18? + await nextButton.click(); + + let yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // do you have the german nationality? + await nextButton.click(); + + yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // Are you under 16? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // Do you stay registered in another flat? + await nextButton.click(); + + const registrationForm = page + .locator("div") + .filter({ hasText: /^Anmeldeformular$/ }); + const movingInConfirmation = page + .locator("div") + .filter({ hasText: /^Einzugsbestätigung des Wohnungsgebers\/Vermieters$/ }); + const germanIdOrPassportOrChildPassport = page.locator("div").filter({ + hasText: /^Dein eigener Personalausweis, Reisepass oder Kinderpass$/, + }); + const confirmationOfCustodian = page + .locator("div") + .filter({ hasText: /^Einverständniserklärung Deiner Sorgeberechtigten$/ }); + + await expect(registrationForm).toBeVisible(); + await expect(movingInConfirmation).toBeVisible(); + await expect(germanIdOrPassportOrChildPassport).toBeVisible(); + await expect(confirmationOfCustodian).toBeVisible(); +}); + +test("should have 3 documents in their checklist: registrationForm, movingInConfirmation, euIdOrPassportOrReplacement", async ({ + page, +}) => { + await page.goto("http://localhost:5173/"); + + const nextButton = page.getByRole("button", { name: "Weiter" }); + + await nextButton.click(); + + let noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + + await noRadio.click(); // first registration in berlin? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // are you married? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // do you have kids under 18? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // do you have the german nationality? + await nextButton.click(); + + let yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // do you have an EU nationality? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // Are you under 16? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // Are you a political refugee? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // Do you stay registered in another flat? + await nextButton.click(); + + const registrationForm = page + .locator("div") + .filter({ hasText: /^Anmeldeformular$/ }); + const movingInConfirmation = page + .locator("div") + .filter({ hasText: /^Einzugsbestätigung des Wohnungsgebers\/Vermieters$/ }); + const euIdOrPassportOrReplacement = page.locator("div").filter({ + hasText: /^Europäische ID-Card, Reisepass oder Passersatzpapiere$/, + }); + + await expect(registrationForm).toBeVisible(); + await expect(movingInConfirmation).toBeVisible(); + await expect(euIdOrPassportOrReplacement).toBeVisible(); +}); + +test("should have 4 documents in their checklist: registrationForm, movingInConfirmation, euIdOrPassportOrReplacement, confirmationOfCustodian", async ({ + page, +}) => { + await page.goto("http://localhost:5173/"); + + const nextButton = page.getByRole("button", { name: "Weiter" }); + + await nextButton.click(); + + let noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + + await noRadio.click(); // first registration in berlin? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // are you married? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // do you have kids under 18? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // do you have the german nationality? + await nextButton.click(); + + let yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // do you have an EU nationality? + await nextButton.click(); + + yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // Are you under 16? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // Are you a political refugee? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // Do you stay registered in another flat? + await nextButton.click(); + + const registrationForm = page + .locator("div") + .filter({ hasText: /^Anmeldeformular$/ }); + const movingInConfirmation = page + .locator("div") + .filter({ hasText: /^Einzugsbestätigung des Wohnungsgebers\/Vermieters$/ }); + const euIdOrPassportOrReplacement = page.locator("div").filter({ + hasText: /^Europäische ID-Card, Reisepass oder Passersatzpapiere$/, + }); + const confirmationOfCustodian = page + .locator("div") + .filter({ hasText: /^Einverständniserklärung Deiner Sorgeberechtigten$/ }); + + await expect(registrationForm).toBeVisible(); + await expect(movingInConfirmation).toBeVisible(); + await expect(euIdOrPassportOrReplacement).toBeVisible(); + await expect(confirmationOfCustodian).toBeVisible(); +}); + +test("should have 4 documents in their checklist: registrationForm, movingInConfirmation, nonEuIdOrPassportOrReplacement, confirmationOfCustodian", async ({ + page, +}) => { + await page.goto("http://localhost:5173/"); + + const nextButton = page.getByRole("button", { name: "Weiter" }); + + await nextButton.click(); + + let noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + + await noRadio.click(); // first registration in berlin? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // are you married? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // do you have kids under 18? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // do you have the german nationality? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // do you have an EU nationality? + await nextButton.click(); + + let yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // Are you under 16? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // Are you a political refugee? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // Do you stay registered in another flat? + await nextButton.click(); + + const registrationForm = page + .locator("div") + .filter({ hasText: /^Anmeldeformular$/ }); + const movingInConfirmation = page + .locator("div") + .filter({ hasText: /^Einzugsbestätigung des Wohnungsgebers\/Vermieters$/ }); + const confirmationOfCustodian = page + .locator("div") + .filter({ hasText: /^Einverständniserklärung Deiner Sorgeberechtigten$/ }); + const nonEuIdOrPassportOrReplacement = page.locator("div").filter({ + hasText: /^Reisepass oder Passersatzpapiere$/, + }); + + await expect(registrationForm).toBeVisible(); + await expect(movingInConfirmation).toBeVisible(); + await expect(confirmationOfCustodian).toBeVisible(); + await expect(nonEuIdOrPassportOrReplacement).toBeVisible(); +}); diff --git a/tests/other-residence.spec.ts b/tests/other-residence.spec.ts new file mode 100644 index 0000000..f240391 --- /dev/null +++ b/tests/other-residence.spec.ts @@ -0,0 +1,150 @@ +import { expect, test } from "@playwright/test"; + +test("should have 4 documents in their checklist: registrationForm, movingInConfirmation, germanIdOrPassport, supplement (abroad)", async ({ + page, +}) => { + await page.goto("http://localhost:5173/"); + + const nextButton = page.getByRole("button", { name: "Weiter" }); + + await nextButton.click(); + + let noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + + await noRadio.click(); // first registration in berlin? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // are you married? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // do you have kids under 18? + await nextButton.click(); + + let yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // do you have the german nationality? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // Are you under 16? + await nextButton.click(); + + yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // Do you stay registered in another flat? + await nextButton.click(); + + yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // Do you live abroad? + await nextButton.click(); + + yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // Do you want to stay more than 3 months in Berlin? + await nextButton.click(); + + const registrationForm = page + .locator("div") + .filter({ hasText: /^Anmeldeformular$/ }); + const movingInConfirmation = page + .locator("div") + .filter({ hasText: /^Einzugsbestätigung des Wohnungsgebers\/Vermieters$/ }); + const germanIdOrPassport = page + .locator("div") + .filter({ hasText: /^Dein eigener Personalausweis oder Reisepass$/ }); + const supplement = page.locator("div").filter({ + hasText: /^Beiblatt zur Anmeldung\/Hauptwohnungserklärung$/, + }); + + await expect(registrationForm).toBeVisible(); + await expect(movingInConfirmation).toBeVisible(); + await expect(germanIdOrPassport).toBeVisible(); + await expect(supplement).toBeVisible(); +}); + +test("should have 4 documents in their checklist: registrationForm, movingInConfirmation, germanIdOrPassport, supplement (inland)", async ({ + page, +}) => { + await page.goto("http://localhost:5173/"); + + const nextButton = page.getByRole("button", { name: "Weiter" }); + + await nextButton.click(); + + let noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + + await noRadio.click(); // first registration in berlin? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // are you married? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // do you have kids under 18? + await nextButton.click(); + + let yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // do you have the german nationality? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // Are you under 16? + await nextButton.click(); + + yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // Do you stay registered in another flat? + await nextButton.click(); + + noRadio = page + .locator("div") + .filter({ hasText: /^Nein$/ }) + .getByRole("radio"); + await noRadio.click(); // Do you live abroad? + await nextButton.click(); + + yesRadio = page.getByLabel("Ja"); + await yesRadio.click(); // Do you want to stay more than 6 months in Berlin? + await nextButton.click(); + + const registrationForm = page + .locator("div") + .filter({ hasText: /^Anmeldeformular$/ }); + const movingInConfirmation = page + .locator("div") + .filter({ hasText: /^Einzugsbestätigung des Wohnungsgebers\/Vermieters$/ }); + const germanIdOrPassport = page + .locator("div") + .filter({ hasText: /^Dein eigener Personalausweis oder Reisepass$/ }); + const supplement = page.locator("div").filter({ + hasText: /^Beiblatt zur Anmeldung\/Hauptwohnungserklärung$/, + }); + + await expect(registrationForm).toBeVisible(); + await expect(movingInConfirmation).toBeVisible(); + await expect(germanIdOrPassport).toBeVisible(); + await expect(supplement).toBeVisible(); +});