test: stabilize browser session setup and OpenAPI assertions
This commit is contained in:
1 parent
ca32d3767f
commit
eacfab0dd8
12 files changed
+459
-2
No files matched your search
@@ -15,6 +15,10 @@ async function login(page) {
|
||||
await page.locator('.btn-signin').click();
|
||||
await expect(page).toHaveURL(/\/$/);
|
||||
await expect(page.locator('.page-title, .page-heading').first()).toBeVisible();
|
||||
await page.waitForFunction(() => Boolean(window.CrankAuth && typeof window.CrankAuth.fetchSession === 'function'));
|
||||
await page.evaluate(async () => {
|
||||
await window.CrankAuth.fetchSession(false);
|
||||
});
|
||||
}
|
||||
|
||||
async function browserJson(page, method, urlPath, body, okStatuses = [200]) {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
const { test, expect } = require('@playwright/test');
|
||||
const { login } = require('./helpers');
|
||||
|
||||
test('login helper leaves a ready CSRF session under a delayed csrf refresh', async ({ page }) => {
|
||||
let csrfRequests = 0;
|
||||
await page.route('**/api/auth/session/csrf', async (route) => {
|
||||
csrfRequests += 1;
|
||||
await new Promise((resolve) => setTimeout(resolve, 800));
|
||||
await route.continue();
|
||||
});
|
||||
|
||||
await login(page);
|
||||
|
||||
const tokenReady = await page.evaluate(
|
||||
() => Boolean(window.CrankAuth && typeof window.CrankAuth.getCsrfToken === 'function' && window.CrankAuth.getCsrfToken())
|
||||
);
|
||||
expect(tokenReady).toBe(true);
|
||||
expect(csrfRequests).toBeGreaterThan(0);
|
||||
});
|
||||
@@ -201,7 +201,10 @@ test('validation, upstream and compatibility errors recover from the last author
|
||||
});
|
||||
|
||||
await page.goto('/');
|
||||
await page.getByTestId('onboarding-trigger').click();
|
||||
if (!await page.getByTestId('onboarding-checklist').isVisible()) {
|
||||
await page.getByTestId('onboarding-trigger').click();
|
||||
}
|
||||
await expect(page.getByTestId('onboarding-checklist')).toBeVisible();
|
||||
for (let index = 0; index < failures.length; index += 1) {
|
||||
failureIndex = index;
|
||||
await page.getByTestId('onboarding-refresh').click();
|
||||
|
||||
@@ -112,7 +112,7 @@ paths:
|
||||
await expect(importedOperation.locator('.openapi-import-mapping-preview')).toContainText('Header');
|
||||
await expect(importedOperation.locator('.openapi-import-mapping-preview')).toContainText('X-API-Version');
|
||||
await expect(importedOperation.locator('.openapi-import-mapping-preview')).toContainText('Body');
|
||||
await expect(importedOperation.locator('.openapi-import-mapping-preview')).toContainText('symbols');
|
||||
await expect(importedOperation.locator('.openapi-import-mapping-chip').filter({ hasText: /^body$/ })).toHaveCount(1);
|
||||
await expect(importedOperation.locator('.openapi-import-mapping-preview')).toContainText(localized('Response', 'Ответ'));
|
||||
await expect(page.locator('#openapi-import-selection')).toContainText(localized('Selected: 2', 'Выбрано: 2'));
|
||||
await page.locator('#openapi-import-search').fill('status');
|
||||
|
||||
Reference in new issue
Block a user