travelTo(CarbonImmutable::parse('2026-10-22 10:00')); $this->seed([PropertySeeder::class, WebsiteContentSeeder::class, SiteSeeder::class]); $this->withoutVite(); $this->site = Site::sole(); $this->property = Property::sole(); Notice::query()->delete(); } public function test_the_highest_priority_wins_and_seasonal_banners_show_only_in_their_appearances(): void { $christmas = $this->appearance('Weihnachten'); $silvester = $this->appearance('Silvester'); Notice::factory()->create(['text' => 'Ganzjährig geöffnet', 'priority' => 10]); Notice::factory()->create(['text' => 'Festtage am Meer', 'priority' => 20, 'appearance_ids' => [$christmas->id, $silvester->id]]); Notice::factory()->create(['text' => 'Andere Website', 'priority' => 99, 'site_id' => Site::factory()->create()->id]); $this->get('/')->assertOk()->assertSee('Ganzjährig geöffnet')->assertDontSee('Festtage am Meer')->assertDontSee('Andere Website'); $this->travelTo(CarbonImmutable::parse('2026-12-20 10:00')); $this->get('/')->assertOk()->assertSee('Festtage am Meer')->assertDontSee('Ganzjährig geöffnet'); $this->travelTo(CarbonImmutable::parse('2026-12-30 10:00')); $this->get('/')->assertOk()->assertSee('Festtage am Meer'); } public function test_a_banner_for_an_offer_takes_text_and_link_from_the_offer_while_it_is_advertised(): void { $offer = SpecialOffer::factory()->for($this->property)->create(['name' => 'Herbstwochen', 'discount_value' => 15]); Notice::factory()->create(['text' => 'Allgemeiner Hinweis', 'priority' => 10]); Notice::factory()->create(['text' => null, 'special_offer_id' => $offer->id, 'priority' => 30, 'tone' => NoticeTone::Offer]); $this->get('/')->assertOk()->assertSee('Herbstwochen · −15 %', false)->assertSee('Zum Angebot')->assertDontSee('Allgemeiner Hinweis'); $offer->update(['is_active' => false]); $this->get('/')->assertOk()->assertDontSee('Herbstwochen')->assertSee('Allgemeiner Hinweis'); } public function test_offer_becomes_a_banner_with_one_click(): void { $this->actingAs(User::factory()->create()); $offer = SpecialOffer::factory()->for($this->property)->create(['name' => 'Herbstwochen']); Livewire::test(SpecialOffersRelationManager::class, ['ownerRecord' => $this->property, 'pageClass' => EditProperty::class]) ->callTableAction('banner', $offer); $notice = Notice::query()->sole(); $this->assertSame($offer->id, $notice->special_offer_id); $this->assertSame($this->site->id, $notice->site_id); $this->assertSame(NoticeTone::Offer, $notice->tone); $this->assertNull($notice->text); } public function test_banner_list_names_the_banner_shown_today_and_a_text_banner_needs_a_text(): void { $this->actingAs(User::factory()->create()); Notice::factory()->create(['text' => 'Neue Betten im Schlafzimmer', 'priority' => 10]); Notice::factory()->create(['text' => 'Abgelaufen', 'ends_on' => '2026-10-01']); $this->get(NoticeResource::getUrl('index'))->assertOk()->assertSee('Heute sichtbar: „Neue Betten im Schlafzimmer“', false); Livewire::test(CreateNotice::class) ->fillForm(['text' => null, 'special_offer_id' => null]) ->call('create') ->assertHasFormErrors(['text' => 'required']); Livewire::test(ListNotices::class)->assertSuccessful(); } public function test_banner_texts_of_appearances_become_seasonal_banners(): void { $migration = require database_path('migrations/2026_10_29_185454_turn_notices_into_banners.php'); $migration->down(); $summer = $this->appearance('Sommer'); DB::table('appearances')->where('id', $summer->id)->update(['overrides' => json_encode([ 'banner' => ['text' => 'Sommer an der Ostsee', 'link_label' => 'Termine ansehen', 'link_url' => null], 'hero' => ['eyebrow' => 'Sommer in Kühlungsborn'], ])]); $migration->up(); $notice = Notice::query()->sole(); $this->assertSame('Sommer an der Ostsee', $notice->text); $this->assertSame([$summer->id], $notice->appearance_ids); $this->assertSame($this->site->id, $notice->site_id); $this->assertSame(20 + $summer->priority, $notice->priority); $this->assertSame(['hero' => ['eyebrow' => 'Sommer in Kühlungsborn']], $summer->fresh()->overrides); $this->travelTo(CarbonImmutable::parse('2026-07-10 10:00')); $this->get('/')->assertOk()->assertSee('Sommer an der Ostsee')->assertSee('Termine ansehen'); } public function test_appearance_names_are_kept_apart_per_landlord(): void { $this->assertContains('Winter', Appearance::names()); $other = Tenant::factory()->create(); app(TenantContext::class)->run($other, function (): void { $this->assertSame([], Appearance::names()); }); } private function appearance(string $name): Appearance { return $this->site->appearances()->where('name', $name)->sole(); } }