|
|
|
|
@ -37,4 +37,66 @@ class ParticipantApplicationSaveTest extends TestCase
|
|
|
|
|
->assertJsonPath('player_name', '张三')
|
|
|
|
|
->assertJsonPath('project_name', '测试项目');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function test_second_draft_save_rejects_invalid_email_and_keeps_previous_value(): void
|
|
|
|
|
{
|
|
|
|
|
$user = User::query()->create(['mobile' => '13800138089']);
|
|
|
|
|
$competition = Competition::query()->create([
|
|
|
|
|
'slug' => 'xxf-email',
|
|
|
|
|
'name' => '测试赛',
|
|
|
|
|
'published' => true,
|
|
|
|
|
]);
|
|
|
|
|
Application::query()->create([
|
|
|
|
|
'user_id' => $user->id,
|
|
|
|
|
'competition_id' => $competition->id,
|
|
|
|
|
'status' => 'draft',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
Sanctum::actingAs($user);
|
|
|
|
|
|
|
|
|
|
$this->postJson('/api/applications/current/save?competition_slug=xxf-email', [
|
|
|
|
|
'player_name' => '张三',
|
|
|
|
|
'contact_email' => 'ok@example.com',
|
|
|
|
|
])
|
|
|
|
|
->assertOk()
|
|
|
|
|
->assertJsonPath('contact_email', 'ok@example.com');
|
|
|
|
|
|
|
|
|
|
$this->postJson('/api/applications/current/save?competition_slug=xxf-email', [
|
|
|
|
|
'player_name' => '李四',
|
|
|
|
|
'contact_email' => 'bad-email',
|
|
|
|
|
])
|
|
|
|
|
->assertUnprocessable()
|
|
|
|
|
->assertJsonValidationErrors(['contact_email']);
|
|
|
|
|
|
|
|
|
|
$this->getJson('/api/applications/current?competition_slug=xxf-email')
|
|
|
|
|
->assertOk()
|
|
|
|
|
->assertJsonPath('player_name', '张三')
|
|
|
|
|
->assertJsonPath('contact_email', 'ok@example.com');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function test_draft_save_response_does_not_prefill_blank_email_from_user_profile(): void
|
|
|
|
|
{
|
|
|
|
|
$user = User::query()->create([
|
|
|
|
|
'mobile' => '13800138090',
|
|
|
|
|
'email' => 'profile@example.com',
|
|
|
|
|
]);
|
|
|
|
|
$competition = Competition::query()->create([
|
|
|
|
|
'slug' => 'xxf-prefill',
|
|
|
|
|
'name' => '测试赛',
|
|
|
|
|
'published' => true,
|
|
|
|
|
]);
|
|
|
|
|
Application::query()->create([
|
|
|
|
|
'user_id' => $user->id,
|
|
|
|
|
'competition_id' => $competition->id,
|
|
|
|
|
'status' => 'draft',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
Sanctum::actingAs($user);
|
|
|
|
|
|
|
|
|
|
$this->postJson('/api/applications/current/save?competition_slug=xxf-prefill', [
|
|
|
|
|
'contact_email' => '',
|
|
|
|
|
])
|
|
|
|
|
->assertOk()
|
|
|
|
|
->assertJsonPath('contact_email', null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|