75 lines
2.5 KiB
PHP
75 lines
2.5 KiB
PHP
<?php
|
|
|
|
use App\Models\Setting;
|
|
use App\Models\User;
|
|
|
|
beforeEach(function () {
|
|
$this->user = User::factory()->create();
|
|
});
|
|
|
|
test('patch namenseinblender macro name and uuid persists settings', function () {
|
|
$this->actingAs($this->user)
|
|
->patchJson(route('settings.update'), [
|
|
'key' => 'namenseinblender_macro_name',
|
|
'value' => 'Namenseinblender',
|
|
])->assertOk()->assertJson(['success' => true]);
|
|
|
|
$this->actingAs($this->user)
|
|
->patchJson(route('settings.update'), [
|
|
'key' => 'namenseinblender_macro_uuid',
|
|
'value' => 'ABC-123',
|
|
])->assertOk()->assertJson(['success' => true]);
|
|
|
|
expect(Setting::get('namenseinblender_macro_name'))->toBe('Namenseinblender');
|
|
expect(Setting::get('namenseinblender_macro_uuid'))->toBe('ABC-123');
|
|
});
|
|
|
|
test('namenseinblender macro shared prop reflects persisted values', function () {
|
|
Setting::set('namenseinblender_macro_name', 'Namenseinblender');
|
|
Setting::set('namenseinblender_macro_uuid', 'ABC-123');
|
|
|
|
$this->actingAs($this->user)
|
|
->withoutVite()
|
|
->get(route('settings.index'))
|
|
->assertInertia(
|
|
fn ($page) => $page
|
|
->where('namenseinblenderMacro.name', 'Namenseinblender')
|
|
->where('namenseinblenderMacro.uuid', 'ABC-123')
|
|
->where('namenseinblenderMacro.collection_name', '--MAIN--')
|
|
);
|
|
});
|
|
|
|
test('current_background setting persists and is shared as prop', function () {
|
|
$this->actingAs($this->user)
|
|
->patchJson(route('settings.update'), [
|
|
'key' => 'current_background',
|
|
'value' => 'slides/bg.jpg',
|
|
])->assertOk()->assertJson(['success' => true]);
|
|
|
|
expect(Setting::get('current_background'))->toBe('slides/bg.jpg');
|
|
|
|
$this->actingAs($this->user)
|
|
->withoutVite()
|
|
->get(route('settings.index'))
|
|
->assertInertia(
|
|
fn ($page) => $page->where('currentBackground', 'slides/bg.jpg')
|
|
);
|
|
});
|
|
|
|
test('current_key_visual setting persists and is shared as prop', function () {
|
|
$this->actingAs($this->user)
|
|
->patchJson(route('settings.update'), [
|
|
'key' => 'current_key_visual',
|
|
'value' => 'slides/key.jpg',
|
|
])->assertOk()->assertJson(['success' => true]);
|
|
|
|
expect(Setting::get('current_key_visual'))->toBe('slides/key.jpg');
|
|
|
|
$this->actingAs($this->user)
|
|
->withoutVite()
|
|
->get(route('settings.index'))
|
|
->assertInertia(
|
|
fn ($page) => $page->where('currentKeyVisual', 'slides/key.jpg')
|
|
);
|
|
});
|