feat: Implement CSRF protection and basic form validation, streamline form data, and add comprehensive unit and E2E tests.
This commit is contained in:
parent
4c435f8e17
commit
197ae8d75b
4 changed files with 120 additions and 19 deletions
29
tests/test_e2e.py
Normal file
29
tests/test_e2e.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import os
|
||||
import re
|
||||
import pytest
|
||||
from playwright.sync_api import Page, expect
|
||||
|
||||
def test_homepage_has_title(page: Page):
|
||||
page.goto("http://localhost:5000/")
|
||||
expect(page).to_have_title(re.compile("Zeilwedstrijden"))
|
||||
|
||||
def test_submission_flow(page: Page):
|
||||
page.goto("http://localhost:5000/zomeravond")
|
||||
|
||||
# Fill required fields
|
||||
page.select_option("select[name='klasse']", label="Kajuitklasse")
|
||||
page.fill("input[name='zeilnummer']", "42")
|
||||
page.fill("input[name='bootnaam']", "Vliegende Hollander")
|
||||
page.fill("input[name='naam']", "Hendrik Test")
|
||||
page.fill("input[name='telefoonmobiel']", "0612345678")
|
||||
page.fill("input[name='email']", "hendrik@example.com")
|
||||
|
||||
# Accept terms
|
||||
page.check("input#terms")
|
||||
|
||||
# Submit
|
||||
page.click("button[type='submit']")
|
||||
|
||||
# Expect success redirect
|
||||
expect(page).to_have_url(re.compile(r".*/zomeravond/success"))
|
||||
expect(page.locator("h1")).to_have_text("Bedankt!")
|
||||
Loading…
Add table
Add a link
Reference in a new issue