Checkout: minimize registration data
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled

This commit is contained in:
Codex Agent
2026-01-06 09:23:01 +01:00
parent 29c3c42134
commit 33af04db1b
9 changed files with 105 additions and 157 deletions

View File

@@ -15,14 +15,11 @@ class CheckoutAuthTest extends TestCase
private function registrationPayload(Package $package, array $overrides = []): array
{
return array_merge([
'username' => 'testuser',
'email' => 'test@example.com',
'password' => 'password123',
'password_confirmation' => 'password123',
'first_name' => 'Test',
'last_name' => 'User',
'address' => 'Test Address 123',
'phone' => '+49123456789',
'terms' => true,
'privacy_consent' => true,
'package_id' => $package->id,
@@ -169,7 +166,7 @@ class CheckoutAuthTest extends TestCase
]);
$this->assertDatabaseHas('users', [
'username' => 'testuser',
'username' => 'test@example.com',
'email' => 'test@example.com',
'first_name' => 'Test',
'last_name' => 'User',
@@ -202,7 +199,7 @@ class CheckoutAuthTest extends TestCase
]);
$this->assertDatabaseHas('users', [
'username' => 'testuser',
'username' => 'test@example.com',
'email' => 'test@example.com',
'pending_purchase' => true,
]);
@@ -215,14 +212,11 @@ class CheckoutAuthTest extends TestCase
$package = Package::factory()->create();
$response = $this->postJson(route('checkout.register'), $this->registrationPayload($package, [
'username' => '',
'email' => 'invalid-email',
'password' => '123',
'password_confirmation' => '456',
'first_name' => '',
'last_name' => '',
'address' => '',
'phone' => '',
'terms' => false,
'privacy_consent' => false,
]));
@@ -230,13 +224,10 @@ class CheckoutAuthTest extends TestCase
$response->assertStatus(422)
->assertJsonStructure([
'errors' => [
'username' => [],
'email' => [],
'password' => [],
'first_name' => [],
'last_name' => [],
'address' => [],
'phone' => [],
'terms' => [],
'privacy_consent' => [],
],
@@ -256,14 +247,12 @@ class CheckoutAuthTest extends TestCase
$package = Package::factory()->create();
$response = $this->postJson(route('checkout.register'), $this->registrationPayload($package, [
'username' => 'existinguser',
'email' => 'existing@example.com',
]));
$response->assertStatus(422)
->assertJsonStructure([
'errors' => [
'username' => [],
'email' => [],
],
]);
@@ -274,14 +263,11 @@ class CheckoutAuthTest extends TestCase
public function test_checkout_register_without_package()
{
$response = $this->postJson(route('checkout.register'), [
'username' => 'testuser',
'email' => 'test@example.com',
'password' => 'password123',
'password_confirmation' => 'password123',
'first_name' => 'Test',
'last_name' => 'User',
'address' => 'Test Address 123',
'phone' => '+49123456789',
'terms' => true,
'privacy_consent' => true,
'locale' => 'de',
@@ -368,13 +354,10 @@ class CheckoutAuthTest extends TestCase
$response->assertStatus(422)
->assertJsonStructure([
'errors' => [
'username' => [],
'email' => [],
'password' => [],
'first_name' => [],
'last_name' => [],
'address' => [],
'phone' => [],
'package_id' => [],
'terms' => [],
'privacy_consent' => [],
@@ -457,18 +440,23 @@ class CheckoutAuthTest extends TestCase
$this->assertGuest();
}
public function test_checkout_register_username_too_long()
public function test_checkout_register_email_conflicts_with_existing_username()
{
User::factory()->create([
'username' => 'taken@example.com',
'email' => 'other@example.com',
]);
$package = Package::factory()->create();
$response = $this->postJson(route('checkout.register'), $this->registrationPayload($package, [
'username' => str_repeat('a', 256),
'email' => 'taken@example.com',
]));
$response->assertStatus(422)
->assertJsonStructure([
'errors' => [
'username' => [],
'email' => [],
],
]);

View File

@@ -20,13 +20,10 @@ class CheckoutRegisterRoleTest extends TestCase
$payload = [
'email' => 'buyer@example.test',
'username' => 'buyer',
'password' => 'Password!123',
'password_confirmation' => 'Password!123',
'first_name' => 'Soren',
'last_name' => 'Eberhardt',
'address' => 'Example Street 1',
'phone' => '123456789',
'package_id' => $package->id,
'terms' => true,
'privacy_consent' => true,
@@ -41,5 +38,6 @@ class CheckoutRegisterRoleTest extends TestCase
$this->assertNotNull($user);
$this->assertSame('user', $user->role);
$this->assertSame('buyer@example.test', $user->username);
}
}

View File

@@ -26,14 +26,11 @@ class FullUserFlowTest extends TestCase
$freePackage = Package::factory()->endcustomer()->create(['price' => 0]);
$registrationData = [
'username' => 'flowuser',
'email' => 'flow@example.com',
'password' => 'Password123!',
'password_confirmation' => 'Password123!',
'first_name' => 'Max',
'last_name' => 'Mustermann',
'address' => 'Musterstr. 1',
'phone' => '+49123456789',
'privacy_consent' => true,
'terms' => true,
'package_id' => $freePackage->id,
@@ -132,14 +129,11 @@ class FullUserFlowTest extends TestCase
// Schritt 1: Fehlgeschlagene Registrierung (kein Consent)
$response = $this->post('/de/register', [
'name' => 'Error User',
'username' => 'erroruser',
'email' => 'error@example.com',
'password' => 'Password123!',
'password_confirmation' => 'Password123!',
'first_name' => 'Max',
'last_name' => 'Mustermann',
'address' => 'Musterstr. 1',
'phone' => '+49123456789',
'privacy_consent' => false,
]);

View File

@@ -171,12 +171,20 @@ async function completeRegistrationOrLogin(page: Page, credentials: { email: str
await page.fill('input[name="first_name"]', 'Play');
await page.fill('input[name="last_name"]', 'Wright');
await page.fill('input[name="email"]', credentials.email);
await page.fill('input[name="address"]', 'Teststrasse 1, 12345 Berlin');
await page.fill('input[name="phone"]', '+49123456789');
const addressInput = page.locator('input[name="address"]');
if (await addressInput.isVisible()) {
await addressInput.fill('Teststrasse 1, 12345 Berlin');
}
const username = credentials.email.split('@')[0]?.replace(/[^a-z0-9]+/gi, '-') ?? `playwright-${Date.now()}`;
await page.fill('input[name="username"]', username);
const phoneInput = page.locator('input[name="phone"]');
if (await phoneInput.isVisible()) {
await phoneInput.fill('+49123456789');
}
const usernameInput = page.locator('input[name="username"]');
if (await usernameInput.isVisible()) {
await usernameInput.fill(credentials.email);
}
await page.fill('input[name="password"]', credentials.password);
await page.fill('input[name="password_confirmation"]', credentials.password);

View File

@@ -18,8 +18,6 @@ test.describe('Standard package checkout with Paddle completion', () => {
const unique = Date.now();
const email = `checkout+${unique}@example.test`;
const password = 'Password123!';
const username = `playwright-${unique}`;
await page.addInitScript(() => {
window.__openedWindows = [];
const originalOpen = window.open;
@@ -87,9 +85,20 @@ test.describe('Standard package checkout with Paddle completion', () => {
await page.fill('input[name="first_name"]', 'Playwright');
await page.fill('input[name="last_name"]', 'Tester');
await page.fill('input[name="email"]', email);
await page.fill('input[name="phone"]', '+49123456789');
await page.fill('input[name="address"]', 'Teststr. 1, 12345 Berlin');
await page.fill('input[name="username"]', username);
const addressInput = page.locator('input[name="address"]');
if (await addressInput.isVisible()) {
await addressInput.fill('Teststr. 1, 12345 Berlin');
}
const phoneInput = page.locator('input[name="phone"]');
if (await phoneInput.isVisible()) {
await phoneInput.fill('+49123456789');
}
const usernameInput = page.locator('input[name="username"]');
if (await usernameInput.isVisible()) {
await usernameInput.fill(email);
}
await page.fill('input[name="password"]', password);
await page.fill('input[name="password_confirmation"]', password);
await page.check('input[name="privacy_consent"]');