Halte Seiten mit zurückgezogenem Einstieg speicherbar und berechne den Link der Benachrichtigung in der Web-Anfrage
Das Widget prüft nur noch, dass der Einstieg existiert; die Auswahl im Editor bietet weiter nur veröffentlichte an. Der Worker kennt keine Anfrage und APP_URL ist unzuverlässig, daher gibt die Web-Anfrage die Adresse der Anfrage in der Verwaltung an die Aufgabe weiter. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a495b0d740
commit
b9407c2f98
6 files changed
+39
-20
No files matched your search
@@ -8,10 +8,11 @@
|
||||
use App\Domain\Communication\ExampleConfiguration;
|
||||
use App\Domain\Communication\Inquiry;
|
||||
use App\Domain\Communication\InquiryEntry;
|
||||
use App\Domain\Communication\InquiryTemplate;
|
||||
use App\Domain\Communication\Publisher;
|
||||
use App\Jobs\SendInquiryNotification;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Tests\TestCase;
|
||||
@@ -198,22 +199,38 @@ public function test_a_withdrawn_entry_leaves_the_page_valid_and_the_public_view
|
||||
$this->get('/partner')->assertOk()->assertDontSee('data-inquiry', false);
|
||||
}
|
||||
|
||||
public function test_the_page_editor_rejects_an_unpublished_entry_and_accepts_a_published_one(): void
|
||||
public function test_the_page_editor_rejects_an_unknown_entry_but_a_withdrawn_one_never_blocks_saving(): void
|
||||
{
|
||||
$page = Page::query()->create(['path' => '/neu']);
|
||||
$draft = new InquiryEntry(['key' => 'entwurf', 'name' => 'Entwurf', 'template_id' => InquiryTemplate::query()->first()->id, 'config' => InquiryEntry::emptyConfig()]);
|
||||
$draft->save();
|
||||
|
||||
$entry = $this->entry('kooperation');
|
||||
$page = $this->pageWith('/partner', $entry);
|
||||
$widget = fn (int $id): array => [['layout' => 'u4', 'slots' => [['type' => 'inquiry', 'v' => 1, 'variant' => 'standard', 'data' => [], 'refs' => ['entry' => $id]]]]];
|
||||
|
||||
try {
|
||||
app(PageService::class)->saveRevision($page, $widget($draft->id), null, null, null);
|
||||
$this->fail('Erwartet: unveröffentlichter Einstieg abgelehnt.');
|
||||
app(PageService::class)->saveRevision($page, $widget(999999), null, null, null);
|
||||
$this->fail('Erwartet: unbekannter Einstieg abgelehnt.');
|
||||
} catch (ValidationException $e) {
|
||||
$this->assertNotEmpty($e->errors());
|
||||
}
|
||||
|
||||
$this->assertNotNull(app(PageService::class)->saveRevision($page, $widget($this->entry('kooperation')->id), null, null, null));
|
||||
// Zurückgezogen oder archiviert: die Seite bleibt speicherbar (nur die Auswahl im Editor bietet ihn nicht mehr an).
|
||||
app(Publisher::class)->withdrawEntry($entry);
|
||||
$entry->forceFill(['archived_at' => now()])->save();
|
||||
|
||||
$this->assertNotNull(app(PageService::class)->saveRevision($page, $widget($entry->id), 'Anderer Titel', null, null));
|
||||
}
|
||||
|
||||
public function test_the_notification_link_is_built_from_the_web_request_not_inside_the_worker(): void
|
||||
{
|
||||
Queue::fake();
|
||||
$entry = $this->entry('allgemeiner_kontakt');
|
||||
$token = $this->getJson(route('inquiry.definition', $entry))->json('token');
|
||||
|
||||
$this->postJson('http://anfrage-test.example:3011/anfrage/'.$entry->id.'/senden', [
|
||||
'token' => $token,
|
||||
'values' => ['name' => 'Mira', 'email' => 'mira@example.org', 'nachricht' => 'Hallo'],
|
||||
])->assertCreated();
|
||||
|
||||
Queue::assertPushed(SendInquiryNotification::class, fn ($job): bool => str_starts_with((string) $job->adminUrl, 'http://anfrage-test.example:3011/verwaltung/anfragen/'));
|
||||
}
|
||||
|
||||
public function test_the_widget_offers_nothing_but_the_entry_choice_in_the_cms(): void
|
||||
|
||||
Reference in new issue
Block a user