Files
worldwideview/tests/plugin-system.spec.ts
T
SilvertakanaandCopilot Autofix powered by AI fc7dd02ee2 refactor(core): harden typescript and fix linting violations (#146)
* chore(merge): resolve conflicts, fix mockWs error, and apply refactor standards

* Potential fix for pull request finding 'CodeQL / Incomplete URL substring sanitization'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Potential fix for pull request finding 'CodeQL / Incomplete URL substring sanitization'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Potential fix for pull request finding 'CodeQL / Incomplete URL substring sanitization'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* fix(ci): Stabilize github actions and resolve test failures

- fix(tests): update WsClient mock to use standard function for Vitest constructor compatibility

- fix(db): correct PrismaClient import path to use generated output directory

- fix(e2e): add predev database boot step to playwright CI workflow

- chore: sync pnpm-lock.yaml after merge conflict resolution

* refactor(plugins): decouple GeoJSON plugin and implement data bus lifecycle

- feat(sdk): [Minor] Added dynamicPluginCreate, dynamicPluginRemove, and pluginUnregistered to DataBusEvents.

- feat(core): [Minor] Implemented unregisterPlugin in PluginManager.ts for automated IndexedDB caching cleanup and polling teardown.

- feat(core): [Minor] Added removeLayer to layersSlice.ts to support safe removal of plugin states.

- refactor(plugins): [Patch] Refactored useGeoJsonImport.ts and ImportedLayerList.tsx to decouple from direct manager imports, utilizing DataBus for lifecycle events.

- refactor(core): [Patch] Added pluginUnregistered listener to DataBusSubscriber.tsx to handle state and cache cleanup synchronously via event.

* fix(types): resolve PluginManager type errors

* refactor(core): decouple PluginManager and fix rendering invariants

- refactor(core): Replace Zustand mutations in PluginManager with DataBus events (Patch)
- refactor(sdk): Add layerLoadingChanged, pluginError, pluginUnregistered to DataBusEvents (Patch)
- refactor(ui): Subscribe to new DataBus events in DataBusSubscriber (Patch)
- fix(plugins): Remove size from BaseAviationPlugin to fix model rendering clipping (Patch)
- fix(plugins): Migrate BaseIncidentPlugin from size to iconScale to fix billboard clipping (Patch)

* chore: resolve lockfile conflict

* fix: restore BottomPanelManager in AppShell and fix vitest config

* fix(layout): restore bottom panel positioning and transition styling

This commit corrects the missing bottom panel issue by resolving CSS aggregation errors and fixing transition logic. The version is bumped to 2.15.5.

* refactor(core): harden typescript and fix linting violations

This commit addresses the remaining any types and linting errors across the core engine.

* fix(eslint): resolve react-hook immutability and cascading render violations

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-05-17 17:36:33 +12:00

62 lines
2.8 KiB
TypeScript

/* eslint-disable no-console */
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 {
// 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)');
});
});