manager = User::factory()->management()->create(['name' => 'Maija Johtaja']); $this->actingAs($this->manager); $layout = WorkTypeModel::factory()->create(['name' => 'Taitto', 'hourly_rate_cents' => 8000]); $customer = CustomerModel::factory()->company()->create(['name' => 'Asiakas Oy']); $this->jobs = []; foreach (['Esite', 'Juliste'] as $name) { $job = CustomerJobModel::factory()->create(['name' => $name, 'customer_id' => $customer->id, 'status' => JobStatus::Done, 'payment_basis' => 'hourly']); $task = TaskModel::factory()->create(['customer_job_id' => $job->id, 'work_type_id' => $layout->id]); TimeEntryModel::factory()->approved()->create(['task_id' => $task->id, 'hours' => 2.5]); TimeEntryModel::factory()->create(['task_id' => TaskModel::factory()->create(['customer_job_id' => $job->id, 'work_type_id' => $layout->id])->id, 'hours' => 1]); $this->jobs[] = $job; } ExpenseModel::factory()->create(['customer_job_id' => $this->jobs[0]->id, 'description' => 'Paperi']); CustomerJobModel::factory()->create([ 'name' => 'Ylläpito', 'customer_id' => $customer->id, 'status' => JobStatus::InProduction, 'payment_basis' => 'monthly_fee', 'monthly_fee_cents' => 9900, 'starts_on' => now()->subMonths(2)->toDateString(), ]); // Opening the draft adds the monthly fee job. $this->exportId = app(OpenBillingDraft::class)->execute($this->manager->id); }); it('has no accessibility issues on the billing pages', function (string $page, string $device, string $colorScheme) { $url = $page === 'index' ? route('billing.index') : route('billing.export', $this->exportId); $visit = visit($url); $visit = $device === 'mobile' ? $visit->on()->mobile() : $visit->on()->desktop(); $visit = $colorScheme === 'dark' ? $visit->inDarkMode() : $visit->inLightMode(); $visit->assertSee($page === 'index' ? 'Jatka luonnosta' : 'Esite') ->assertNoJavaScriptErrors() ->assertNoAccessibilityIssues(level: 2); })->with(['index', 'export'])->with([ 'desktop, light' => ['desktop', 'light'], 'desktop, dark' => ['desktop', 'dark'], 'mobile, light' => ['mobile', 'light'], 'mobile, dark' => ['mobile', 'dark'], ]); it('adds and combines jobs and creates the material', function () { [$first, $second] = $this->jobs; $page = visit(route('billing.export', $this->exportId)); $page->click('[wire\\:click="add('.$first->id.')"]') ->assertSee('lisätty aineistoon') ->click('[wire\\:click="add('.$second->id.')"]') ->assertSee('Lasku 3: Asiakas Oy') ->assertSee('Laskutettavat kuukaudet') ->assertSee('Hyväksymättömiä tunteja 1 h') ->assertNoAccessibilityIssues(level: 2) ->select('[wire\\:model="moveTargets.'.$second->id.'"]', (string) $first->id) ->click('[wire\\:click="move('.$second->id.')"]') ->assertSee('siirretty laskulle') ->assertDontSee('Lasku 3: Asiakas Oy') ->click('Muodosta aineisto') ->assertSee('Muodostetaanko laskuaineisto?') ->assertNoAccessibilityIssues(level: 2) ->click('#finalize-dialog button:last-child') ->assertSee('Laskuaineisto muodostettu: 2 laskua.') ->assertSee('Laskutetut h') ->assertNoAccessibilityIssues(level: 2); expect($first->refresh()->status)->toBe(JobStatus::Invoiced); });