96 SUCCESS tests complet
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
// Helpers to probe canvas by reading pixel colors
|
||||
async function getPixelColor(page: any, selector: string, x: number, y: number) {
|
||||
return await page.$eval(selector, (canvas: HTMLCanvasElement, [x, y]) => {
|
||||
const ctx = canvas.getContext('2d')!;
|
||||
const dpr = window.devicePixelRatio || 1;
|
||||
const data = ctx.getImageData(Math.floor(x), Math.floor(y), 1, 1).data;
|
||||
return Array.from(data);
|
||||
}, [x, y]);
|
||||
}
|
||||
|
||||
// Minimal smoke tests ensuring that UI controls affect the canvas
|
||||
// These assume the app starts with some graph data (test vault bundled)
|
||||
|
||||
test.describe('Graph Canvas', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/');
|
||||
// Open Graph view
|
||||
await page.getByRole('button', { name: /graphe|graph/i }).first().click();
|
||||
// Ensure canvas exists
|
||||
await page.waitForSelector('app-graph-canvas canvas');
|
||||
});
|
||||
|
||||
test('toggle Existing files only reduces node count', async ({ page }) => {
|
||||
// Open settings panel
|
||||
await page.getByRole('button', { name: /settings|param/i }).first().click();
|
||||
// Toggle Existing files only
|
||||
const checkbox = page.getByText(/Existing files only/i).locator('..').locator('input[type="checkbox"]');
|
||||
await checkbox.click({ force: true });
|
||||
// Wait a bit for recompute
|
||||
await page.waitForTimeout(200);
|
||||
// We cannot count nodes directly; instead, ensure simulation tick updates occurred by reading overlay text
|
||||
const stats = await page.locator('text=/Nodes:/').first().innerText();
|
||||
expect(stats).toMatch(/Nodes:/);
|
||||
});
|
||||
|
||||
test('change Link distance affects layout (smoke)', async ({ page }) => {
|
||||
await page.getByRole('button', { name: /settings|param/i }).first().click();
|
||||
// Ensure Forces section is expanded in the settings accordion
|
||||
const forcesHeader = page.getByRole('button', { name: /^Forces$/i }).first();
|
||||
await forcesHeader.click({ force: true });
|
||||
// Slide Link distance; we approximate by focusing input[type=range] with label
|
||||
const slider = page.getByText(/Link distance/i).locator('..').locator('input[type="range"]').first();
|
||||
await slider.evaluate((el: HTMLInputElement) => { el.value = '100'; el.dispatchEvent(new Event('input', { bubbles: true })); });
|
||||
await page.waitForTimeout(300);
|
||||
// No assertion on pixels here; just ensure canvas repaints by checking it remains attached
|
||||
const canvasVisible = await page.isVisible('app-graph-canvas canvas');
|
||||
expect(canvasVisible).toBeTruthy();
|
||||
});
|
||||
|
||||
test('adding group tag:test colors some nodes and legend updates', async ({ page }) => {
|
||||
await page.getByRole('button', { name: /settings|param/i }).first().click();
|
||||
// Add new group
|
||||
await page.getByRole('button', { name: /new group/i }).click({ force: true });
|
||||
const lastGroupInput = page.locator('app-graph-groups-section input[type="text"]').last();
|
||||
await lastGroupInput.fill('tag:test');
|
||||
// Wait for legend to render and reflect the new group
|
||||
await page.waitForSelector('app-graph-legend');
|
||||
const legendItems = page.locator('app-graph-legend button');
|
||||
await legendItems.first().waitFor({ state: 'visible', timeout: 2000 }).catch(() => {});
|
||||
const count = await legendItems.count();
|
||||
expect(count).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user