mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-10-20 18:34:20 +00:00
54 lines
1.6 KiB
TypeScript
54 lines
1.6 KiB
TypeScript
import { test, expect, request } from '@playwright/test';
|
|
|
|
// Test credentials
|
|
const testEmail = 'test@gmail.com';
|
|
const testPassword = 'Testt@123456';
|
|
|
|
test.beforeAll(async () => {
|
|
const apiContext = await request.newContext();
|
|
|
|
await apiContext.post(`${process.env.API_BASE_URL}users`, {
|
|
headers: {
|
|
'Content-Type': 'application/vnd.api+json',
|
|
'Accept': 'application/vnd.api+json',
|
|
},
|
|
data: {
|
|
data: {
|
|
type: 'users',
|
|
attributes: {
|
|
name: 'testuser',
|
|
email: testEmail,
|
|
password: testPassword,
|
|
company_name: 'test',
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
await apiContext.dispose();
|
|
});
|
|
|
|
test('should show error for invalid credentials', async ({ page }) => {
|
|
await page.goto('/sign-in');
|
|
|
|
await page.fill('input[name="email"]', 'wrong@gmail.com');
|
|
await page.fill('input[name="password"]', 'WrongPassword123');
|
|
await page.getByRole('button', { name: /log in/i }).click();
|
|
|
|
await expect(page.getByText(/Invalid email or password/i)).toBeVisible();
|
|
});
|
|
|
|
test('should sign in successfully', async ({ page }) => {
|
|
// Go to login page
|
|
await page.goto('/sign-in');
|
|
|
|
// Fill login form
|
|
await page.fill('input[name="email"]', testEmail);
|
|
await page.fill('input[name="password"]', testPassword);
|
|
|
|
// Submit the form
|
|
await page.getByRole('button', { name: /log in/i }).click();
|
|
await page.waitForURL('/', { timeout: 15000 });
|
|
await expect(page).toHaveURL('/');
|
|
});
|