QA: unit tests for API logic, Playwright smoke tests, pre-push check, manual QA checklist
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { test as base, expect, type Page } from '@playwright/test';
|
||||
|
||||
type Problems = { list: string[] };
|
||||
|
||||
/** هر خطای جاوااسکریپت یا پاسخ 5xx از API در طول تست، تست را رد میکند */
|
||||
export const test = base.extend<{ problems: Problems }>({
|
||||
problems: [
|
||||
async ({ page }, use) => {
|
||||
const problems: Problems = { list: [] };
|
||||
page.on('pageerror', (err) => problems.list.push(`JS error: ${err.message}`));
|
||||
page.on('response', (res) => {
|
||||
if (res.url().includes('/api/') && res.status() >= 500) {
|
||||
problems.list.push(`API ${res.status()}: ${res.request().method()} ${res.url()}`);
|
||||
}
|
||||
});
|
||||
await use(problems);
|
||||
expect(problems.list, 'خطا در صفحه').toEqual([]);
|
||||
},
|
||||
{ auto: true },
|
||||
],
|
||||
});
|
||||
|
||||
export { expect };
|
||||
|
||||
export async function waitForIdle(page: Page) {
|
||||
await page.waitForLoadState('networkidle', { timeout: 20_000 }).catch(() => undefined);
|
||||
}
|
||||
Reference in New Issue
Block a user