mascarpone/e2e/pages/index.spec.ts

37 lines
1 KiB
TypeScript

import { test, expect } from '@playwright/test';
test('has title', async ({ page }) => {
await page.goto('/');
await expect(page).toHaveTitle(/Mascarpone/);
});
test('disbles submit button with empty fields', async ({ page }) => {
await page.goto('/');
// Submit button should require both fields
// to be non-empty
await expect(page.getByRole("button")).toBeDisabled();
await page.getByLabel("Username").fill("bogus");
await expect(page.getByRole("button")).toBeDisabled();
await page.getByLabel("Username").clear();
await page.getByLabel("Password").fill("bogus");
await expect(page.getByRole("button")).toBeDisabled();
await page.getByLabel("Username").fill("bogus");
await expect(page.getByRole("button")).not.toBeDisabled();
});
test('has error message for invalid login', async ({ page }) => {
await page.goto('/');
await page.getByLabel("Username").fill("bogus");
await page.getByLabel("Password").fill("bogus");
await page.getByRole("button").click();
await expect(page.getByText(/do not match/i)).toBeVisible();
});