feat: add basic Playwright tests for login and findings page

This commit is contained in:
sumit_chaturvedi
2025-06-23 15:17:04 +05:30
parent bd0749daa8
commit d68a798d25
2 changed files with 24 additions and 2 deletions
+1
View File
@@ -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,
+23 -2
View File
@@ -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();
});