mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-09-04 14:21:03 +00:00
test: add the behavioral spec suites (pilot + ten domains)
98 tests pinning observable behavior ahead of the authorship rewrite.
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
// Pilot behavioural suite — installation state and wizard progress.
|
||||
// Spec: platform-operations-spec.md §2–3.
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
use function Pest\Laravel\getJson;
|
||||
use function Pest\Laravel\postJson;
|
||||
|
||||
beforeEach(function () {
|
||||
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
|
||||
// DatabaseSeeder leaves profile_complete at 0: database created, NOT installed.
|
||||
});
|
||||
|
||||
function pilotSetSetting(string $key, $value): void
|
||||
{
|
||||
DB::table('settings')->updateOrInsert(['option' => $key], ['option' => $key, 'value' => $value]);
|
||||
}
|
||||
|
||||
it('caches the created-database probe for the lifetime of the process', function () {
|
||||
// The first probe in this PHP process ran at boot, before the schema
|
||||
// existed, and the answer is cached per process — so the wizard reports
|
||||
// the pre-database defaults even though the tables exist by now. This is
|
||||
// deliberate current behaviour; the stored-values branch and the
|
||||
// redirect-once-completed behaviour are pinned by the sandbox scenarios
|
||||
// (see the suite README).
|
||||
pilotSetSetting('profile_complete', 'STEP_2');
|
||||
pilotSetSetting('profile_language', 'de');
|
||||
|
||||
getJson('/api/v1/installation/wizard-step')
|
||||
->assertOk()
|
||||
->assertJson(['profile_complete' => 0, 'profile_language' => 'en']);
|
||||
});
|
||||
|
||||
it('stores a wizard step and echoes the stored value', function () {
|
||||
postJson('/api/v1/installation/wizard-step', ['profile_complete' => 'STEP_3'])
|
||||
->assertOk()
|
||||
->assertJson(['profile_complete' => 'STEP_3']);
|
||||
|
||||
expect(DB::table('settings')->where('option', 'profile_complete')->value('value'))
|
||||
->toBe('STEP_3');
|
||||
});
|
||||
|
||||
it('refuses to overwrite a completed wizard state', function () {
|
||||
pilotSetSetting('profile_complete', 'COMPLETED');
|
||||
|
||||
postJson('/api/v1/installation/wizard-step', ['profile_complete' => 'STEP_1'])
|
||||
->assertOk()
|
||||
->assertJson(['profile_complete' => 'COMPLETED']);
|
||||
|
||||
expect(DB::table('settings')->where('option', 'profile_complete')->value('value'))
|
||||
->toBe('COMPLETED');
|
||||
});
|
||||
|
||||
it('stores the wizard language and echoes it', function () {
|
||||
postJson('/api/v1/installation/wizard-language', ['profile_language' => 'fr'])
|
||||
->assertOk()
|
||||
->assertJson(['profile_language' => 'fr']);
|
||||
|
||||
expect(DB::table('settings')->where('option', 'profile_language')->value('value'))
|
||||
->toBe('fr');
|
||||
});
|
||||
|
||||
it('lists the supported languages as code and name pairs', function () {
|
||||
$response = getJson('/api/v1/installation/languages')->assertOk()->json();
|
||||
|
||||
expect($response['languages'])->toBeArray()->not->toBeEmpty();
|
||||
expect(collect($response['languages'])->firstWhere('code', 'en')['name'])->toBe('English');
|
||||
});
|
||||
Reference in New Issue
Block a user