Add an editable menu name and reserve billing material numbers on creation
- Company details get an optional "Valikon nimi", shown at the left of the main menu; it falls back to the application name when empty. - A billing material gets its running number (billing_exports.number) only when it is created, so discarded drafts leave no gaps. Drafts have no number; existing created materials are numbered by the migration, and the CSV file name uses the number. - TaskAssigneeMigrationTest rolls back from its own migration onward instead of assuming it is the last one. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -93,7 +93,7 @@ it('downloads a created billing material as a CSV file for Excel', function () {
|
||||
$response = $this->get(route('billing.csv', $exportId))
|
||||
->assertOk()
|
||||
->assertHeader('Content-Type', 'text/csv; charset=UTF-8')
|
||||
->assertDownload("laskuaineisto-{$exportId}.csv");
|
||||
->assertDownload('laskuaineisto-1.csv');
|
||||
|
||||
expect($response->headers->get('Cache-Control'))->toContain('no-store');
|
||||
|
||||
|
||||
@@ -295,3 +295,31 @@ it('does not bill a monthly fee job without a monthly fee', function () {
|
||||
->call('add', $job->id)
|
||||
->assertSet('errorMessage', fn (string $message) => str_contains($message, 'kuukausihinta'));
|
||||
});
|
||||
|
||||
it('numbers created materials without gaps: a draft has no number and a discarded one uses none', function () {
|
||||
$first = doneJob(['name' => 'Esite'], [$this->layout->id => 1]);
|
||||
$second = doneJob(['name' => 'Juliste'], [$this->layout->id => 1]);
|
||||
|
||||
$discarded = openDraft();
|
||||
Livewire::test('billing::export', ['export' => $discarded])
|
||||
->assertSee('Laskuaineiston luonnos')
|
||||
->call('add', $first->id)
|
||||
->call('discard');
|
||||
|
||||
$exportId = openDraft();
|
||||
expect(BillingExportModel::query()->findOrFail($exportId)->number)->toBeNull();
|
||||
|
||||
Livewire::test('billing::export', ['export' => $exportId])
|
||||
->call('add', $first->id)
|
||||
->call('finalize')
|
||||
->assertSee('Laskuaineisto 1');
|
||||
|
||||
$next = openDraft();
|
||||
Livewire::test('billing::export', ['export' => $next])
|
||||
->call('add', $second->id)
|
||||
->call('finalize')
|
||||
->assertSee('Laskuaineisto 2');
|
||||
|
||||
expect(BillingExportModel::query()->orderBy('id')->pluck('number')->all())->toBe([1, 2])
|
||||
->and($next)->toBeGreaterThan($exportId);
|
||||
});
|
||||
|
||||
@@ -12,7 +12,13 @@ it('makes the earlier assignee with most booked time the assignee and the others
|
||||
$booked = TaskModel::factory()->create();
|
||||
$unbooked = TaskModel::factory()->create();
|
||||
|
||||
$this->artisan('migrate:rollback', ['--step' => 1])->assertSuccessful();
|
||||
// Roll back this migration and every one after it, so later migrations don't matter.
|
||||
$steps = count(array_filter(
|
||||
array_map('basename', glob(database_path('migrations/*.php'))),
|
||||
fn (string $file): bool => $file >= '2026_11_24_163029_split_task_assignee_and_members.php',
|
||||
));
|
||||
|
||||
$this->artisan('migrate:rollback', ['--step' => $steps])->assertSuccessful();
|
||||
|
||||
DB::table('task_assignees')->insert([
|
||||
['task_id' => $booked->id, 'user_id' => $eero->id],
|
||||
|
||||
@@ -51,3 +51,38 @@ it('keeps everyone but the admin out', function () {
|
||||
|
||||
$this->get(route('settings.company'))->assertForbidden();
|
||||
});
|
||||
|
||||
it('saves the menu name and shows it at the left of the main menu', function () {
|
||||
$this->actingAs(User::factory()->admin()->create());
|
||||
|
||||
Livewire::test('shared::company')
|
||||
->set('name', 'Mediatalo Oy')
|
||||
->set('menu_name', ' Mediatalo Työt ')
|
||||
->set('business_id', '0737546-2')
|
||||
->call('save')
|
||||
->assertHasNoErrors();
|
||||
|
||||
expect(app(CompanyDetailsStore::class)->menuName())->toBe('Mediatalo Työt');
|
||||
|
||||
Livewire::test('shared::company')->assertSet('menu_name', 'Mediatalo Työt');
|
||||
|
||||
$this->get(route('customers.index'))->assertSee('Mediatalo Työt');
|
||||
});
|
||||
|
||||
it('falls back to the application name when the menu name is empty, even before other details are saved', function () {
|
||||
$store = app(CompanyDetailsStore::class);
|
||||
|
||||
expect($store->get())->toBeNull()
|
||||
->and($store->menuName())->toBe(config('app.name'));
|
||||
});
|
||||
|
||||
it('rejects a menu name over 100 characters', function () {
|
||||
$this->actingAs(User::factory()->admin()->create());
|
||||
|
||||
Livewire::test('shared::company')
|
||||
->set('name', 'Mediatalo Oy')
|
||||
->set('business_id', '0737546-2')
|
||||
->set('menu_name', str_repeat('a', 101))
|
||||
->call('save')
|
||||
->assertHasErrors(['menu_name' => [__('company.errors.menu_name')]]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user