Spaces:
Build error
Build error
File size: 955 Bytes
cce8120 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | import { test, expect } from '@playwright/test';
test('register, login and create item', async ({ page }) => {
const email = `test${Date.now()}@example.com`;
const password = 'test1234';
// Register via backend API
const registerResponse = await page.request.post('http://localhost:8000/auth/register', {
data: { email, password },
});
expect(registerResponse.ok()).toBeTruthy();
// Open the React app
await page.goto('/');
await page.fill('input[type="email"]', email);
await page.fill('input[type="password"]', password);
await page.click('button:has-text("Login")');
// Verify dashboard appears
await expect(page.locator('text=Dashboard')).toBeVisible();
// Create a new item
const title = 'Playwright Item';
await page.fill('input[placeholder="Title"]', title);
await page.click('button:has-text("Add Item")');
// Verify the item is listed
await expect(page.locator(`text=${title}`)).toBeVisible();
});
|