Implement sinnbeck/laravel-dom-assertions

This commit is contained in:
Matt Young 2024-07-04 02:08:43 -05:00
parent c373995039
commit 3fc4d13675
3 changed files with 102 additions and 32 deletions

View File

@ -25,6 +25,7 @@
"nunomaduro/collision": "^8.0",
"pestphp/pest": "^2.34",
"pestphp/pest-plugin-laravel": "^2.4",
"sinnbeck/laravel-dom-assertions": "^1.5",
"spatie/laravel-ignition": "^2.4"
},
"autoload": {

72
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "a21ed75b45b3f61cbc76446701fbc3ce",
"content-hash": "7aab57ef52f0152526434decd76ef1e1",
"packages": [
{
"name": "bacon/bacon-qr-code",
@ -9379,6 +9379,76 @@
],
"time": "2023-02-07T11:34:05+00:00"
},
{
"name": "sinnbeck/laravel-dom-assertions",
"version": "v1.5.3",
"source": {
"type": "git",
"url": "https://github.com/sinnbeck/laravel-dom-assertions.git",
"reference": "a2ce7540023fac4e6e010cbe5396b7aad9d22765"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sinnbeck/laravel-dom-assertions/zipball/a2ce7540023fac4e6e010cbe5396b7aad9d22765",
"reference": "a2ce7540023fac4e6e010cbe5396b7aad9d22765",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-libxml": "*",
"illuminate/testing": "^9.0|^10.0|^11.0",
"php": "^8.0",
"symfony/css-selector": "^6.0|^7.0"
},
"require-dev": {
"laravel/pint": "^1.2",
"nunomaduro/larastan": "^2.2",
"orchestra/testbench": "^7.0|^8.0|^9.0",
"pestphp/pest": "^1.0|^2.34",
"phpstan/extension-installer": "^1.2",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.1",
"vimeo/psalm": "^4.29|^5.22"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Sinnbeck\\DomAssertions\\DomAssertionsServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Sinnbeck\\DomAssertions\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "René Sinnbeck",
"email": "rene.sinnbeck@gmail.com",
"homepage": "https://sinnbeck.dev",
"role": "Developer"
}
],
"homepage": "https://github.com/sinnbeck/laravel-dom-assertions",
"keywords": [
"assertions",
"blade",
"dom",
"laravel",
"view"
],
"support": {
"issues": "https://github.com/sinnbeck/laravel-dom-assertions/issues",
"source": "https://github.com/sinnbeck/laravel-dom-assertions/tree/v1.5.3"
},
"time": "2024-06-17T12:30:14+00:00"
},
{
"name": "spatie/backtrace",
"version": "1.6.1",

View File

@ -4,6 +4,7 @@ use App\Models\Audition;
use App\Models\Entry;
use App\Settings;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Sinnbeck\DomAssertions\Asserts\AssertElement;
use function Pest\Laravel\get;
@ -70,8 +71,8 @@ it('has a dropdown for all auditions', function () {
it('shows checkboxes for entry types only if advancement is enabled', function () {
actAsAdmin();
get(route('admin.entries.edit', $this->entry))
->assertSee('Enter for '.auditionSetting('auditionAbbreviation'))
->assertSee('Enter for '.auditionSetting('advanceTo'));
->assertElementExists('#for_seating')
->assertElementExists('#for_advancement');
Settings::set('advanceTo', '');
get(route('admin.entries.edit', $this->entry))
->assertDontSee('Enter for '.auditionSetting('auditionAbbreviation'))
@ -80,36 +81,34 @@ it('shows checkboxes for entry types only if advancement is enabled', function (
it('properly checks boxes based on entries settings', function () {
actAsAdmin();
get(route('admin.entries.edit', $this->entry))
->assertSeeInOrder([
'input',
'name=',
'for_seating',
'checked',
auditionSetting('auditionAbbreviation'),
])
->assertSeeInOrder([
'input',
'name=',
'for_advancement',
'checked',
auditionSetting('advanceTo'),
]);
$entry2 = Entry::factory()->advanceOnly()->create();
->assertElementExists('#for_seating', function (AssertElement $element) {
$element->is('input')
->has('checked');
})
->assertElementExists('#for_advancement', function (AssertElement $element) {
$element->is('input')
->has('checked');
});
$entry2 = Entry::factory()->seatingOnly()->create();
get(route('admin.entries.edit', $entry2))
->assertSeeInOrder([
'input',
'name=',
'for_seating',
'checked',
auditionSetting('auditionAbbreviation'),
])
->assertSeeInOrder([
'input',
'name=',
'for_advancement',
'checked',
auditionSetting('advanceTo'),
]);
->assertElementExists('#for_seating', function (AssertElement $element) {
$element->is('input')
->has('checked');
})
->assertElementExists('#for_advancement', function (AssertElement $element) {
$element->is('input')
->doesntHave('checked');
});
$entry3 = Entry::factory()->advanceOnly()->create();
get(route('admin.entries.edit', $entry3))
->assertElementExists('#for_seating', function (AssertElement $element) {
$element->is('input')
->doesntHave('checked');
})
->assertElementExists('#for_advancement', function (AssertElement $element) {
$element->is('input')
->has('checked');
});
});
// Submission tests