diff --git a/ui/playwright.config.ts b/ui/playwright.config.ts index b987efb907..fa77a30016 100644 --- a/ui/playwright.config.ts +++ b/ui/playwright.config.ts @@ -4,6 +4,7 @@ import { defineConfig, devices } from "@playwright/test"; * See https://playwright.dev/docs/test-configuration. */ export default defineConfig({ + timeout: 60 * 1000, testDir: "./tests/e2e", /* Run tests in files in parallel */ fullyParallel: true, diff --git a/ui/tests/e2e/auth/authentication.spec.ts b/ui/tests/e2e/auth/authentication.spec.ts index 9dcb9854ad..0f0fdbe869 100644 --- a/ui/tests/e2e/auth/authentication.spec.ts +++ b/ui/tests/e2e/auth/authentication.spec.ts @@ -1,10 +1,26 @@ -import { test } from '@playwright/test'; +import { test, expect } from '@playwright/test'; // Test credentials from environment variables const TEST_USER_EMAIL = process.env.TEST_USER_EMAIL || 'dev@prowler.com'; const TEST_USER_PASSWORD = process.env.TEST_USER_PASSWORD || 'thisisapassword123'; -test('should login successfully and redirect to home page', async ({ page }) => { +test('should render login page with expected elements', async ({ page }) => { + await page.goto('/login'); + await expect(page.locator('input[name="email"]')).toBeVisible(); + await expect(page.locator('input[name="password"]')).toBeVisible(); + await expect(page.getByRole('button', { name: 'Log In' })).toBeVisible(); +}); + +test('should show error for invalid login', async ({ page }) => { + await page.goto('/login'); + await page.fill('input[name="email"]', 'test@example.com'); + await page.fill('input[name="password"]', 'password'); + await page.click('button[type="submit"]'); + + await expect(page.getByText(/invalid email or password/i)).toBeVisible(); +}); + +test('should login and show "No results" message on Findings page search', async ({ page }) => { await page.goto('/login'); const title = await page.title(); @@ -12,4 +28,9 @@ test('should login successfully and redirect to home page', async ({ page }) => await page.fill('input[name="password"]', TEST_USER_PASSWORD); await page.click('button[type="submit"]'); await page.waitForURL('/'); + await page.goto('/findings'); + await page.waitForSelector('input[type="text"]'); + await page.fill('input[type="text"]', 'findingsTest'); + await page.waitForSelector('table'); + await expect(page.getByText('No results.')).toBeVisible(); }); \ No newline at end of file