mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-20 14:56:17 -04:00
test(mermaid-exporter): added test
This commit is contained in:
parent
6d868f9182
commit
120e63601c
1 changed files with 30 additions and 6 deletions
|
@ -1,15 +1,39 @@
|
||||||
import { test, expect } from '@playwright/test';
|
import { expect, test } from '@playwright/test';
|
||||||
|
|
||||||
test.describe('Tool - Mermaid exporter', () => {
|
test.describe('Mermaid Diagram Renderer', () => {
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
await page.goto('/mermaid-exporter');
|
await page.goto('/mermaid-exporter');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Has correct title', async ({ page }) => {
|
test('should render the initial diagram', async ({ page }) => {
|
||||||
await expect(page).toHaveTitle('Mermaid exporter - IT Tools');
|
const diagramContainer = page.locator('.diagram-container svg');
|
||||||
|
await expect(diagramContainer).toBeVisible();
|
||||||
|
await expect(diagramContainer).toHaveAttribute('xmlns', 'http://www.w3.org/2000/svg');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('', async ({ page }) => {
|
test('should update diagram when user edits Mermaid code', async ({ page }) => {
|
||||||
|
const input = page.getByLabel('Your Mermaid to convert:');
|
||||||
|
const updatedMermaid = `
|
||||||
|
graph LR
|
||||||
|
X[Start] --> Y{Working?}
|
||||||
|
Y -- Yes --> Z[Success!]
|
||||||
|
Y -- No --> W[Fix again!]
|
||||||
|
`;
|
||||||
|
await input.fill(updatedMermaid);
|
||||||
|
await page.waitForTimeout(500);
|
||||||
|
|
||||||
|
const svg = page.locator('.diagram-container svg');
|
||||||
|
await expect(svg).toContainText('Start');
|
||||||
|
await expect(svg).toContainText('Success!');
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
test('should allow exporting in SVG, PNG, and JPG', async ({ page }) => {
|
||||||
|
const formats = ['svg', 'png', 'jpg'];
|
||||||
|
|
||||||
|
for (const format of formats) {
|
||||||
|
const button = page.getByRole('button', { name: new RegExp(`Export as ${format}`, 'i') });
|
||||||
|
await expect(button).toBeVisible();
|
||||||
|
await button.click();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue