refactor: migrate graph canvas to use web worker for force layout computation
This commit is contained in:
@@ -62,4 +62,41 @@ test.describe('Graph Canvas', () => {
|
||||
const count = await legendItems.count();
|
||||
expect(count).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
test('open/close Graph 10x remains responsive (no freeze)', async ({ page }) => {
|
||||
// Capture console errors during the whole test
|
||||
const errors: string[] = [];
|
||||
page.on('console', (msg) => {
|
||||
if (msg.type() === 'error') errors.push(msg.text());
|
||||
});
|
||||
|
||||
// Buttons in header/sidebar
|
||||
const graphButtons = [
|
||||
page.getByRole('button', { name: /graph|graphe/i }).first(),
|
||||
];
|
||||
const filesButtons = [
|
||||
page.getByRole('button', { name: /files|fichiers/i }).first(),
|
||||
];
|
||||
|
||||
// Perform 10 rapid toggles
|
||||
for (let i = 0; i < 10; i++) {
|
||||
await graphButtons[0].click({ timeout: 2000 });
|
||||
// Canvas should be present quickly
|
||||
await page.waitForSelector('app-graph-canvas canvas', { timeout: 3000 });
|
||||
|
||||
// Evaluate a trivial script to ensure main thread is not locked
|
||||
const val = await page.evaluate(() => 21 + 21);
|
||||
expect(val).toBe(42);
|
||||
|
||||
// Switch back to files
|
||||
await filesButtons[0].click({ timeout: 2000 });
|
||||
|
||||
// Quick evaluation again
|
||||
const val2 = await page.evaluate(() => 1 + 1);
|
||||
expect(val2).toBe(2);
|
||||
}
|
||||
|
||||
// Ensure no console errors during toggles
|
||||
expect(errors.length).toBeLessThan(2); // allow transient warnings but not repeated errors
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user