: Kontakt-Links oeffnen das Widget
// ========================================
it('marks links to the contact pages as widget triggers', function (string $href) {
$html = Blade::render('Termin', ['href' => $href]);
expect($html)->toContain('data-open-appointment')
->toContain('href="'.$href.'"')
->toContain('class="btn"');
})->with([
'interior' => '/contact',
'immobilien' => '/immobilien/kontakt',
'absolute' => 'https://b2in.test/contact',
]);
it('leaves links to other pages as plain links', function () {
$html = Blade::render('Marken');
expect($html)->not->toContain('data-open-appointment')
->toContain('href="/marken"');
});
it('hands over the topic that should be preselected', function () {
$html = Blade::render('Termin');
expect($html)->toContain('data-appointment-topic="cabinet"');
});
// ========================================
// Sektionen auf der Seite
// ========================================
it('opens the widget from the appointment buttons of the homepage', function () {
$html = $this->get('/')->assertSuccessful()->getContent();
// Hero (zweiter Button), Weiche (beide Karten) und Abschluss-CTA
expect(substr_count($html, 'data-open-appointment'))->toBeGreaterThanOrEqual(4);
});
it('preselects the brand when the widget is opened from a brand page', function () {
$html = $this->get('/marken/cabinet')->assertSuccessful()->getContent();
expect($html)->toContain('data-appointment-topic="cabinet"');
});
it('opens the widget from the real estate calls to action too', function () {
$html = $this->get('/immobilien')->assertSuccessful()->getContent();
expect($html)->toContain('data-open-appointment');
});
it('keeps the contact button in the header as a link to the contact page', function () {
$html = $this->get('/')->assertSuccessful()->getContent();
$header = substr($html, (int) strpos($html, '') - (int) strpos($html, 'toContain('href="'.route('contact').'"')
->not->toContain('data-open-appointment');
});
it('listens for the open event in the widget and intercepts the links in the frontend script', function () {
expect($this->get('/')->assertSuccessful()->getContent())->toContain('open-appointment.window');
expect(file_get_contents(resource_path('js/app.js')))->toContain('a[data-open-appointment]')
->toContain("new CustomEvent('open-appointment'");
});
// ========================================
// Formularfelder
// ========================================
it('styles the selects of the widget and the contact page with the shared field classes', function () {
expect($this->get('/')->assertSuccessful()->getContent())->toMatch('/