Add browser and unit test suite with Pest + Playwright
Add comprehensive test coverage for core site features (content, navigation, language, FAQ, news, petition, newsletter) using Pest browser tests and unit tests for custom plugins. Includes test infrastructure (Containerfile.test, compose.test.yaml), test documentation, and test files covering petition form logic, CSV handling, translation, date formatting, rate limiting, and map data building.
This commit is contained in:
parent
0b61643ec5
commit
b8e6d2537d
20 changed files with 1331 additions and 33 deletions
46
tests/Browser/ContentTest.php
Normal file
46
tests/Browser/ContentTest.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
it('about page shows organization history', function () {
|
||||
$this->visit(BASE_URL . '/om-oss')
|
||||
->assertSee('Vår historie');
|
||||
});
|
||||
|
||||
it('about page mentions the organization name', function () {
|
||||
$this->visit(BASE_URL . '/om-oss')
|
||||
->assertSourceHas('Stopp lidelsen');
|
||||
});
|
||||
|
||||
it('privacy page loads with correct heading', function () {
|
||||
$this->visit(BASE_URL . '/personvern')
|
||||
->assertSee('Personvernerklæring');
|
||||
});
|
||||
|
||||
it('contact page loads with content', function () {
|
||||
$this->visit(BASE_URL . '/kontakt')
|
||||
->assertSourceHas('<main');
|
||||
});
|
||||
|
||||
it('brochures page loads with intro text', function () {
|
||||
$this->visit(BASE_URL . '/brosjyrer')
|
||||
->assertSee('Brosjyrer');
|
||||
});
|
||||
|
||||
it('articles section loads', function () {
|
||||
$this->visit(BASE_URL . '/artikler')
|
||||
->assertSourceHas('<main');
|
||||
});
|
||||
|
||||
it('patient info article loads', function () {
|
||||
$this->visit(BASE_URL . '/artikler/pasientinfo')
|
||||
->assertSee('pasienter');
|
||||
});
|
||||
|
||||
it('homepage shows goals section heading', function () {
|
||||
$this->visit(BASE_URL . '/')
|
||||
->assertSee('oppnå');
|
||||
});
|
||||
|
||||
it('homepage shows intro text about the organization', function () {
|
||||
$this->visit(BASE_URL . '/')
|
||||
->assertSee('frivillig');
|
||||
});
|
||||
26
tests/Browser/FaqTest.php
Normal file
26
tests/Browser/FaqTest.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
it('FAQ listing page loads', function () {
|
||||
$this->visit(BASE_URL . '/faq')
|
||||
->assertSee('Ofte stilte spørsmål');
|
||||
});
|
||||
|
||||
it('FAQ listing shows question items', function () {
|
||||
$this->visit(BASE_URL . '/faq')
|
||||
->assertSee('medisinsk cannabis');
|
||||
});
|
||||
|
||||
it('individual FAQ article loads', function () {
|
||||
$this->visit(BASE_URL . '/faq/Hva-er-MC')
|
||||
->assertSourceHas('<main');
|
||||
});
|
||||
|
||||
it('individual FAQ article shows content', function () {
|
||||
$this->visit(BASE_URL . '/faq/Hva-er-MC')
|
||||
->assertSee('medisinsk cannabis');
|
||||
});
|
||||
|
||||
it('FAQ article about driving license loads', function () {
|
||||
$this->visit(BASE_URL . '/faq/forerkort')
|
||||
->assertSourceHas('<main');
|
||||
});
|
||||
21
tests/Browser/HomepageTest.php
Normal file
21
tests/Browser/HomepageTest.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
it('loads the Norwegian homepage', function () {
|
||||
$this->visit(BASE_URL . '/')
|
||||
->assertSourceHas('Stopp lidelsen');
|
||||
});
|
||||
|
||||
it('shows the news section', function () {
|
||||
$this->visit(BASE_URL . '/')
|
||||
->assertSee('Nyheter');
|
||||
});
|
||||
|
||||
it('shows the petition section', function () {
|
||||
$this->visit(BASE_URL . '/')
|
||||
->assertSee('underskrift');
|
||||
});
|
||||
|
||||
it('shows the newsletter section', function () {
|
||||
$this->visit(BASE_URL . '/')
|
||||
->assertSee('nyhetsbrev');
|
||||
});
|
||||
11
tests/Browser/LanguageTest.php
Normal file
11
tests/Browser/LanguageTest.php
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
it('serves the Norwegian homepage by default', function () {
|
||||
$this->visit(BASE_URL . '/')
|
||||
->assertSourceHas('lang="no"');
|
||||
});
|
||||
|
||||
it('english news section is accessible', function () {
|
||||
$this->visit(BASE_URL . '/en/nyheter')
|
||||
->assertSourceHas('<main');
|
||||
});
|
||||
31
tests/Browser/NavigationTest.php
Normal file
31
tests/Browser/NavigationTest.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
it('navigates to the news section', function () {
|
||||
$this->visit(BASE_URL . '/nyheter')
|
||||
->assertSee('Nyheter');
|
||||
});
|
||||
|
||||
it('navigates to the FAQ section', function () {
|
||||
$this->visit(BASE_URL . '/faq')
|
||||
->assertSourceHas('<main');
|
||||
});
|
||||
|
||||
it('navigates to the about page', function () {
|
||||
$this->visit(BASE_URL . '/om-oss')
|
||||
->assertSourceHas('<main');
|
||||
});
|
||||
|
||||
it('navigates to the petition page', function () {
|
||||
$this->visit(BASE_URL . '/underskriftskampanje')
|
||||
->assertSourceHas('<main');
|
||||
});
|
||||
|
||||
it('navigates to the contact page', function () {
|
||||
$this->visit(BASE_URL . '/kontakt')
|
||||
->assertSourceHas('<main');
|
||||
});
|
||||
|
||||
it('navigates to the privacy page', function () {
|
||||
$this->visit(BASE_URL . '/personvern')
|
||||
->assertSourceHas('<main');
|
||||
});
|
||||
31
tests/Browser/NewsTest.php
Normal file
31
tests/Browser/NewsTest.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
it('news listing page loads', function () {
|
||||
$this->visit(BASE_URL . '/nyheter')
|
||||
->assertSourceHas('<main');
|
||||
});
|
||||
|
||||
it('news listing shows article titles', function () {
|
||||
$this->visit(BASE_URL . '/nyheter')
|
||||
->assertSee('Banebrytende');
|
||||
});
|
||||
|
||||
it('individual news article loads', function () {
|
||||
$this->visit(BASE_URL . '/nyheter/2025-09-26-banebrytende-studie')
|
||||
->assertSourceHas('<main');
|
||||
});
|
||||
|
||||
it('individual news article shows content', function () {
|
||||
$this->visit(BASE_URL . '/nyheter/2025-09-26-banebrytende-studie')
|
||||
->assertSee('medisinsk cannabis');
|
||||
});
|
||||
|
||||
it('news article about podcast loads', function () {
|
||||
$this->visit(BASE_URL . '/nyheter/2026-03-08-podcast-paradigmepodden')
|
||||
->assertSourceHas('<main');
|
||||
});
|
||||
|
||||
it('returns 404 for non-existent news article', function () {
|
||||
$this->visit(BASE_URL . '/nyheter/finnes-ikke')
|
||||
->assertSourceHas('404');
|
||||
});
|
||||
19
tests/Browser/PetitionTest.php
Normal file
19
tests/Browser/PetitionTest.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
it('loads the petition page with a form', function () {
|
||||
$this->visit(BASE_URL . '/underskriftskampanje/medisinsk-cannabis-pa-resept/')
|
||||
->assertPresent('input[name="firstname"]');
|
||||
});
|
||||
|
||||
it('shows required form fields', function () {
|
||||
$this->visit(BASE_URL . '/underskriftskampanje/medisinsk-cannabis-pa-resept/')
|
||||
->assertPresent('input[name="firstname"]')
|
||||
->assertPresent('input[name="email"]')
|
||||
->assertPresent('button[type="submit"]');
|
||||
});
|
||||
|
||||
it('does not submit empty form', function () {
|
||||
$this->visit(BASE_URL . '/underskriftskampanje/medisinsk-cannabis-pa-resept/')
|
||||
->press('button[type="submit"]')
|
||||
->assertPresent('input[name="firstname"]');
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue