mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
Two causes behind most of EVERYTHING's WebKit failures so far, both in the test pages rather than in WeKan: - 94 specs switch language with setLanguage and then click at once. The client loads that language afterwards and draws everything again, which closes a popup opened before that: the board view popup of the flow and report help specs (Latin monte-carlo in WebKit; Corsican and Scottish Gaelic in earlier Firefox runs) had no entry left to click. The fixture's context now wraps Meteor.callAsync in each page so that a setLanguage call resolves once <html lang> - which client/lib/i18n.js sets in the same flush that redraws - names the language. It waits at most 10 s and then resolves anyway, so it can only make a spec patient, never fail one. A page of a context a spec makes itself uses untilLanguageShown(). - Playwright's WebKit freezes the page's main thread on PushManager.getSubscription(): after it not even a timer runs. Member Notification Settings asks it on opening, to show whether this device gets push (client/lib/webPush.js), so every WebKit spec that opened it hung in its next click - notification-activity-mute and the member scope of notification-delivery-settings, in every language. In WebKit the page now answers as a device with no subscription does. Chromium, Firefox and Safari answer the real call; no spec subscribes. WebKit: those notification specs 10 of 10, and the Latin, Corsican and Product Backlog specs 13 of 13; Chromium and Firefox 11 of 11 each with the same subset. playwrightPageInit.test.cjs runs both page scripts on a fake page: setLanguage waits for the language and keeps its result, other methods are not held, a page whose Meteor arrives later is wrapped, the wait is capped; WebKit's getSubscription answers null and Chromium's and Firefox's are left alone; the fixture installs both. Thanks to xet7 !
76 lines
2.4 KiB
JavaScript
76 lines
2.4 KiB
JavaScript
'use strict';
|
|
|
|
const { test: base } = require('@playwright/test');
|
|
const db = require('./helpers/db');
|
|
const { loginWithToken, openBoard } = require('./helpers/auth');
|
|
const { waitForLanguageOnSetLanguage } = require('./helpers/language.cjs');
|
|
const { noPushSubscriptionInWebKit } = require('./helpers/webkit-push.cjs');
|
|
|
|
/**
|
|
* Extended Playwright test fixture that seeds a fresh user + board for every
|
|
* test and cleans up automatically on teardown.
|
|
*
|
|
* Usage:
|
|
* const { test } = require('../fixtures');
|
|
* test('my test', async ({ page, user, board }) => { ... });
|
|
*/
|
|
const test = base.extend({
|
|
// Every page of the test's context: a setLanguage call resolves once the
|
|
// page shows that language (helpers/language.cjs), so a spec that switches
|
|
// language and then clicks does not click into the redraw that follows.
|
|
context: async ({ context }, use) => {
|
|
await context.addInitScript(waitForLanguageOnSetLanguage);
|
|
// And WebKit does not freeze on asking for a push subscription.
|
|
await context.addInitScript(noPushSubscriptionInWebKit);
|
|
await use(context);
|
|
},
|
|
|
|
// A freshly-seeded admin user available for every test.
|
|
adminUser: async ({}, use) => {
|
|
const user = db.seedUser({ isAdmin: true });
|
|
await use(user);
|
|
db.cleanup({ userIds: [user.id] });
|
|
},
|
|
|
|
// A freshly-seeded non-admin user.
|
|
user: async ({}, use) => {
|
|
const user = db.seedUser();
|
|
await use(user);
|
|
db.cleanup({ userIds: [user.id] });
|
|
},
|
|
|
|
// A second non-admin user (for multi-user tests).
|
|
user2: async ({}, use) => {
|
|
const user = db.seedUser();
|
|
await use(user);
|
|
db.cleanup({ userIds: [user.id] });
|
|
},
|
|
|
|
// A board owned by `user`, with 3 lists and one card per list.
|
|
board: async ({ user }, use) => {
|
|
const b = db.seedBoard({
|
|
ownerId: user.id,
|
|
cardTitlesPerList: [['Alpha Card'], ['Beta Card'], ['Gamma Card']],
|
|
});
|
|
await use({ ...b, owner: user });
|
|
db.cleanup({ boardIds: [b.boardId] });
|
|
},
|
|
|
|
// Convenience: logged-in page as `user`.
|
|
loggedInPage: async ({ page, user }, use) => {
|
|
await loginWithToken(page, user.id, user.token);
|
|
await use(page);
|
|
},
|
|
|
|
// Convenience: logged-in page already on the board.
|
|
boardPage: async ({ page, user, board }, use) => {
|
|
await loginWithToken(page, user.id, user.token);
|
|
await openBoard(page, board.boardId, board.slug);
|
|
await use(page);
|
|
},
|
|
});
|
|
|
|
const { expect } = base;
|
|
|
|
module.exports = { test, expect };
|