- smartauth-login.spec.ts: Google Sign-In button presence, MFA challenge not shown initially - smartauth-mfa-settings.spec.ts: MFA status, setup/disable flows with API mocking - smartauth-security-dashboard.spec.ts: stats cards, login events table, suspicious filter - smartauth-devices.spec.ts: device list, trust badges, revoke all button - smartauth-passkeys.spec.ts: passkey list, add button, empty state, device type labels
43 lines
1.7 KiB
TypeScript
43 lines
1.7 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('SmartAuth: Login with Google Sign-In', () => {
|
|
test('shows Google Sign-In button when GOOGLE_CLIENT_ID is set', async ({ page }) => {
|
|
// This test validates UI presence — button only renders when env var is set
|
|
await page.goto('/login');
|
|
// The button may or may not be present depending on env
|
|
const googleBtn = page.getByRole('button', { name: /sign in with google/i });
|
|
// If the env var is not set, the button should not exist — this is expected in CI
|
|
const count = await googleBtn.count();
|
|
expect(count).toBeLessThanOrEqual(1);
|
|
});
|
|
|
|
test('login form still works without Google button', async ({ page }) => {
|
|
await page.goto('/login');
|
|
await expect(page.getByLabel('Email')).toBeVisible();
|
|
await expect(page.getByLabel('Password')).toBeVisible();
|
|
await expect(page.getByRole('button', { name: 'Sign In' })).toBeVisible();
|
|
});
|
|
|
|
test('"or" divider appears only when Google button is present', async ({ page }) => {
|
|
await page.goto('/login');
|
|
const googleBtn = page.getByRole('button', { name: /sign in with google/i });
|
|
const hasGoogle = (await googleBtn.count()) > 0;
|
|
if (hasGoogle) {
|
|
await expect(page.getByText('or')).toBeVisible();
|
|
}
|
|
});
|
|
});
|
|
|
|
test.describe('SmartAuth: MFA Challenge Flow', () => {
|
|
test('MFA challenge view is not shown on initial load', async ({ page }) => {
|
|
await page.goto('/login');
|
|
await expect(page.getByText('Two-Factor Authentication')).not.toBeVisible();
|
|
});
|
|
|
|
test('login form shows email and password fields', async ({ page }) => {
|
|
await page.goto('/login');
|
|
await expect(page.getByLabel('Email')).toBeVisible();
|
|
await expect(page.getByLabel('Password')).toBeVisible();
|
|
});
|
|
});
|