* feat(testing): add Playwright E2E infrastructure and stabilize test suite - Add Playwright E2E configuration and ui-navigation / plugin-system tests - Add GitHub Actions workflow for Playwright CI tests - Add test helpers and fixtures (e2e-mock-plugin) - fix(testing): resolve UnverifiedPluginBatchDialog UI blocking issue in E2E tests - fix(testing): limit Playwright to 2 workers locally to avoid Next.js/Prisma exhaustion - fix(api): replace deprecated processAuthCodeResponse with authorizationCodeGrant - test(ui): add data-testid to PanelToggleArrows and AppShell * Potential fix for pull request finding 'CodeQL / Workflow does not contain permissions' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * fix(ci): restrict GITHUB_TOKEN permissions to read contents * docs(e2e): document Playwright infrastructure and mock plugin lifecycle * fix(e2e): explicitly load .env in teardown and fix dev command pathing * fix(ci): resolve playwright environment setup and database initialization Changes: - Patch: Added pnpm run setup step to .github/workflows/playwright.yml to generate .env in CI - Patch: Added explicit loadEnv() helper to ests/global.setup.ts and ests/global.teardown.ts to ensure database credentials are fresh - Patch: Hardened scripts/safe-db-push.mjs to detect missing DATABASE_URL and explicitly prompt for pnpm run setup rather than assuming production - Patch: Updated scripts/dev.mjs to execute pnpm exec next dev instead of raw ext dev to resolve pathing issues - Patch: Bumped version in package.json to 2.14.4 --------- Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
61 lines
2.7 KiB
TypeScript
61 lines
2.7 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('Dynamic Plugin System', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
// Navigate to root and wait for app to be completely booted
|
|
await page.goto('/');
|
|
await page.waitForSelector('[data-testid="app-ready"]', { state: 'attached', timeout: 45000 });
|
|
});
|
|
|
|
test('successfully discovers, loads, and renders a mock dynamic plugin', async ({ page }) => {
|
|
// Log console messages from the browser
|
|
page.on('console', msg => {
|
|
console.log(`[Browser Console] ${msg.type()}: ${msg.text()}`);
|
|
if (msg.type() === 'error') {
|
|
console.log(`[Browser Error] ${msg.location().url}:${msg.location().lineNumber}`);
|
|
}
|
|
});
|
|
|
|
// We expect the mock plugin to register its component in the sidebar.
|
|
// The LeftPanel or RightPanel (depending on how the plugin manager handles generic 'sidebar' capabilities)
|
|
// should render the component returned by getSidebarComponent().
|
|
|
|
// The mock plugin returns: <div data-testid="e2e-mock-panel">Mock Panel (E2E Test)</div>
|
|
const mockPanel = page.locator('[data-testid="e2e-mock-panel"]');
|
|
|
|
// The unverified plugin dialog might appear for the mock plugin.
|
|
const installBtn = page.getByRole('button', { name: /Install Selected/ });
|
|
try {
|
|
// Wait a short time for the dialog to appear
|
|
await installBtn.waitFor({ state: 'visible', timeout: 5000 });
|
|
await installBtn.click();
|
|
console.log('Clicked "Install Selected" in unverified plugin dialog.');
|
|
} catch (e) {
|
|
// Dialog didn't appear, possibly because it's a verified plugin or already approved
|
|
console.log('Unverified plugin dialog did not appear.');
|
|
}
|
|
|
|
// To ensure the UI is in a state where it might be visible,
|
|
// let's check if we need to open the right panel first. Plugins might inject into the right panel.
|
|
const rightToggle = page.locator('[data-testid="panel-toggle-right"]');
|
|
if (await rightToggle.count() > 0) {
|
|
const isInitiallyOpen = await rightToggle.evaluate((node) => node.classList.contains('panel-toggle-btn--open'));
|
|
if (!isInitiallyOpen) {
|
|
await rightToggle.click();
|
|
}
|
|
}
|
|
|
|
// Click the layer item in the left panel to select it and display its config in the right panel
|
|
const layerItem = page.locator('.layer-item', { hasText: 'E2E Mock Plugin' });
|
|
await expect(layerItem).toBeVisible({ timeout: 10000 });
|
|
await layerItem.click();
|
|
|
|
// Wait for the mock panel to be visible or attached.
|
|
// Plugins might take a moment to dynamically load their chunks over HTTP.
|
|
await expect(mockPanel).toBeAttached({ timeout: 10000 });
|
|
|
|
// Assert it contains the expected text
|
|
await expect(mockPanel).toContainText('Mock Panel (E2E Test)');
|
|
});
|
|
});
|