seed(RolesAndPermissionsSeeder::class); }); function draftForGate(): array { $customer = User::factory()->create(['is_active' => true]); $customer->assignRole('customer'); $company = Company::factory()->presseecho()->create(); $customer->companies()->attach($company->id, ['role' => 'owner']); $pr = PressRelease::factory()->create([ 'user_id' => $customer->id, 'company_id' => $company->id, 'category_id' => Category::factory()->create()->id, 'portal' => $company->portal->value, 'status' => 'draft', ]); return compact('customer', 'pr'); } test('with the gate on a draft without a booking shows the notice and links to bookings', function () { /** @var TestCase $this */ config()->set('billing.enforce_booking', true); ['customer' => $customer, 'pr' => $pr] = draftForGate(); $this->actingAs($customer); LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id]) ->assertSee('Noch keine Buchung') ->assertSee('Buchung wählen') ->assertSee(route('me.bookings.index'), false) ->assertDontSee('Zur Prüfung einreichen'); }); test('with the gate on a paid single purchase unlocks the submission action', function () { /** @var TestCase $this */ config()->set('billing.enforce_booking', true); ['customer' => $customer, 'pr' => $pr] = draftForGate(); SinglePurchase::factory()->paid()->create(['user_id' => $customer->id]); $this->actingAs($customer); LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id]) ->assertDontSee('Noch keine Buchung') ->assertSee('Zur Prüfung einreichen'); }); test('with the gate off the notice never shows', function () { /** @var TestCase $this */ config()->set('billing.enforce_booking', false); ['customer' => $customer, 'pr' => $pr] = draftForGate(); $this->actingAs($customer); LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id]) ->assertDontSee('Noch keine Buchung') ->assertSee('Zur Prüfung einreichen'); });