super-productivity/e2e/tests/plugins/enable-plugin-test.spec.ts
Johannes Millan 77f83c5687
test(e2e): harden failure signals and provider gates (#7753)
* test: harden e2e failure signals

Fail otherwise-passing E2E tests on browser runtime errors, keep Playwright retries disabled, preserve Docker E2E exit codes, and make plugin/WebDAV setup failures hard failures instead of logged or skipped conditions.

* test: harden provider e2e runners

Make WebDAV and SuperSync runner scripts require provider readiness, preserve cleanup and argument forwarding, and fail manual sync clients on uncaught page errors.

* ci: require providers for scheduled e2e

Set required-provider flags in scheduled WebDAV and SuperSync jobs, and remove the duplicate provider runner scripts while keeping local npm aliases inline.

* test: catch e2e teardown pageerrors and tighten fixture

- closeClient now asserts runtime errors AFTER context.close() so
  pageerrors emitted during teardown (Angular destroy hooks, late RxJS
  errors) are captured instead of dropped. Matches the pattern in
  guardContextCloseWithRuntimeErrorCheck.
- test.fixture.ts isolatedContext now spreads Playwright's merged
  contextOptions instead of destructuring 23 fields by hand. Future
  option additions propagate automatically; the page fixture uses the
  shared attachPageErrorCollector and only fails on pageerror (not
  console.error, which is too noisy). Guards against a configured 0
  timeout being treated as undefined.
- plugin-loading.spec.ts second test now hard-asserts that the plugin
  menu entry reappears after re-enable, matching the first test instead
  of silently logging when not visible.

* test(sync): stabilize ImmediateUploadService spec

Two complementary fixes for flaky failures observed under full-suite
random-order runs where the upload pipeline silently never fires:

- Pin navigator.onLine = true in beforeEach (restored in afterEach).
  isOnline() inside _canUpload reads navigator.onLine directly. The
  keyboard-layout spec replaces the whole navigator and the is-online
  spec spies on it; if order or restoration ever drifts, every "should
  fire upload" test fails trivially while the "should NOT" tests pass.
- Replace tick(2100) with tick(2000); flush(). The await chain inside
  withSession() (provider.isReady, withSession entry, uploadPendingOps,
  optional LWW re-upload) requires more microtask drain than tick's
  fixed-time window reliably provides under load. flush() drains the
  pipeline regardless.

* test(e2e): guard skipOnboarding init script against data: frames

The new page-error collector started failing plugin specs because
addInitScript runs in every frame — including the empty data:text/html
iframe that plugin-index swaps in on destroy — and localStorage access
in a data: URL throws SecurityError. Wrap the four setItem calls in
try/catch so the helper noops in storage-less frames.
2026-05-23 20:33:04 +02:00

86 lines
2.9 KiB
TypeScript

import { expect, test } from '../../fixtures/test.fixture';
import {
getCITimeoutMultiplier,
waitForPluginAssets,
waitForPluginManagementInit,
} from '../../helpers/plugin-test.helpers';
test.describe('Enable Plugin Test', () => {
test('navigate to plugin settings and enable API Test Plugin', async ({
page,
workViewPage,
}) => {
const timeoutMultiplier = getCITimeoutMultiplier();
test.setTimeout(30000 * timeoutMultiplier);
// First, ensure plugin assets are available
const assetsAvailable = await waitForPluginAssets(page);
if (!assetsAvailable) {
throw new Error('Plugin assets not available - cannot proceed with test');
}
await workViewPage.waitForTaskList();
// Navigate to settings and initialize plugin management
// This navigates to settings, selects plugin tab, and expands plugin section
await waitForPluginManagementInit(page);
await expect(page.locator('plugin-management')).toBeVisible({ timeout: 10000 });
// Wait for plugin cards to be loaded
await page
.locator('plugin-management mat-card')
.first()
.waitFor({ state: 'attached', timeout: 10000 });
// Try to find and enable the API Test Plugin
const enableResult = await page.evaluate(() => {
const pluginCards = document.querySelectorAll('plugin-management mat-card');
let foundApiTestPlugin = false;
let toggleClicked = false;
for (const card of Array.from(pluginCards)) {
const title = card.querySelector('mat-card-title')?.textContent || '';
if (title.includes('API Test Plugin') || title.includes('api-test-plugin')) {
foundApiTestPlugin = true;
const toggle = card.querySelector(
'mat-slide-toggle button[role="switch"]',
) as HTMLButtonElement;
if (toggle && toggle.getAttribute('aria-checked') !== 'true') {
toggle.click();
toggleClicked = true;
break;
}
}
}
return {
totalPluginCards: pluginCards.length,
foundApiTestPlugin,
toggleClicked,
};
});
expect(enableResult.foundApiTestPlugin).toBe(true);
// Wait for toggle state to change to enabled
if (enableResult.toggleClicked) {
await page.waitForFunction(
() => {
const cards = Array.from(
document.querySelectorAll('plugin-management mat-card'),
);
const apiTestCard = cards.find((card) => {
const title = card.querySelector('mat-card-title')?.textContent || '';
return title.includes('API Test Plugin');
});
const toggle = apiTestCard?.querySelector(
'mat-slide-toggle button[role="switch"]',
) as HTMLButtonElement;
return toggle?.getAttribute('aria-checked') === 'true';
},
{ timeout: 10000 },
);
}
});
});