create(['role' => 'user']); $page = $this->makePageForUser($user); $response = $this->actingAs($user)->get(route('admin.pages.mailwizz.edit', $page)); $response->assertOk(); $response->assertSee('Mailwizz', escape: false); } public function test_other_user_cannot_view_mailwizz_wizard(): void { $owner = User::factory()->create(['role' => 'user']); $intruder = User::factory()->create(['role' => 'user']); $page = $this->makePageForUser($owner); $response = $this->actingAs($intruder)->get(route('admin.pages.mailwizz.edit', $page)); $response->assertForbidden(); } public function test_connected_mailwizz_shows_overview_until_wizard_requested(): void { $user = User::factory()->create(['role' => 'user']); $page = $this->makePageForUser($user); MailwizzConfig::query()->create([ 'preregistration_page_id' => $page->id, 'api_key' => 'test-key', 'list_uid' => 'list-uid-1', 'list_name' => 'Main list', 'field_email' => 'EMAIL', 'field_first_name' => 'FNAME', 'field_last_name' => 'LNAME', 'field_phone' => null, 'field_coupon_code' => null, 'tag_field' => 'TAGS', 'tag_value' => 'preregister-source', ]); $overview = $this->actingAs($user)->get(route('admin.pages.mailwizz.edit', $page)); $overview->assertOk(); $overview->assertSee('Current configuration', escape: false); $overview->assertSee('Change settings (wizard)', escape: false); $overview->assertDontSee('Step 1: API key', escape: false); $wizard = $this->actingAs($user)->get(route('admin.pages.mailwizz.edit', [ 'page' => $page, 'wizard' => 1, 'step' => 1, ])); $wizard->assertOk(); $wizard->assertSee('Step 1: API key', escape: false); $wizard->assertSee('Cancel and return to overview', escape: false); } public function test_mailwizz_wizard_redirects_to_step_one_when_no_config_and_step_gt_one(): void { $user = User::factory()->create(['role' => 'user']); $page = $this->makePageForUser($user); $this->actingAs($user) ->get(route('admin.pages.mailwizz.edit', ['page' => $page, 'wizard' => 1, 'step' => 3])) ->assertRedirect(route('admin.pages.mailwizz.edit', ['page' => $page, 'wizard' => 1, 'step' => 1])); } private function makePageForUser(User $user): PreregistrationPage { return PreregistrationPage::query()->create([ 'slug' => (string) Str::uuid(), 'user_id' => $user->id, 'title' => 'Fest', 'heading' => 'Join', 'intro_text' => null, 'thank_you_message' => null, 'expired_message' => null, 'ticketshop_url' => null, 'start_date' => now()->addDay(), 'end_date' => now()->addMonth(), 'phone_enabled' => false, 'is_active' => true, ]); } }