diff --git a/priv/repo/seeds_e2e.exs b/priv/repo/seeds_e2e.exs index 2682636b..e6d16ab5 100644 --- a/priv/repo/seeds_e2e.exs +++ b/priv/repo/seeds_e2e.exs @@ -3,6 +3,7 @@ # Run with: mix run priv/repo/seeds_e2e.exs alias Towerops.Accounts +alias Towerops.Organizations alias Towerops.Repo # Test user credentials (must match what's used in e2e/tests/auth.setup.ts) @@ -11,6 +12,12 @@ test_password = "TestPassword123!" # Fixed TOTP secret for reproducible tests (base32 encoded) test_totp_secret = "JBSWY3DPEHPK3PXP" +# Delete existing test user if present (for idempotency) +case Repo.get_by(Towerops.Accounts.User, email: test_email) do + nil -> :ok + existing_user -> Repo.delete!(existing_user) +end + # Create test user {:ok, user} = Accounts.register_user(%{ @@ -31,7 +38,12 @@ test_totp_secret = "JBSWY3DPEHPK3PXP" {:ok, _device, _secret} = Accounts.create_totp_device(user.id, "E2E Test Authenticator", test_totp_secret) +# Create a test organization so user doesn't get redirected to /orgs +{:ok, organization} = + Organizations.create_organization(%{name: "Test Organization"}, user.id) + IO.puts("✅ Created test user: #{test_email}") +IO.puts(" Organization: #{organization.name}") IO.puts(" Password: #{test_password}") IO.puts(" TOTP Secret: #{test_totp_secret}") IO.puts("")