Skip to content

Commit a2a48c8

Browse files
authored
Tests: Add tests to mermaid grid (#413)
1 parent c24da4f commit a2a48c8

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

tests/src/mermaid.spec.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { expect, test } from '@playwright/test';
2+
import { handleConsentPopup, waitFor } from './util';
3+
4+
async function getPropertyValue(element, property) {
5+
return element.evaluate(
6+
(el, property) => window.getComputedStyle(el).getPropertyValue(property),
7+
property
8+
);
9+
}
10+
11+
async function validateDiagramsGrid(diagrams, expectedGridColumn) {
12+
for (const diagram of diagrams) {
13+
const gridColumn = await getPropertyValue(diagram, 'grid-column');
14+
expect(gridColumn.trim()).toBe(expectedGridColumn);
15+
}
16+
}
17+
18+
test.describe('Testing for mermaid', () => {
19+
test.beforeEach(async ({ page }) => {
20+
const mermaidUrl = 'test-product/mermaid/mermaid-grid';
21+
await page.goto(`/${mermaidUrl}`);
22+
await page.waitForLoadState('load');
23+
await waitFor(async () => await handleConsentPopup(page));
24+
});
25+
26+
test('options', async ({ page }) => {
27+
// Wide
28+
let expectedGridColumn = '1 / -1';
29+
const wideDiagrams = await page.locator('[data-grid="wide"]').all();
30+
await validateDiagramsGrid(wideDiagrams, expectedGridColumn);
31+
32+
// Last third
33+
expectedGridColumn = '8 / -1';
34+
const lastThirdDiagrams = await page
35+
.locator('[data-grid="last-third"]')
36+
.all();
37+
await validateDiagramsGrid(lastThirdDiagrams, expectedGridColumn);
38+
39+
// First third
40+
expectedGridColumn = '1 / 4';
41+
const firstThirdDiagrams = await page
42+
.locator('[data-grid="first-third"]')
43+
.all();
44+
await validateDiagramsGrid(firstThirdDiagrams, expectedGridColumn);
45+
46+
// First two thirds
47+
expectedGridColumn = '1 / 8';
48+
const firstTwoThirdsDiagrams = await page
49+
.locator('[data-grid="first-two-third"]')
50+
.all();
51+
await validateDiagramsGrid(firstTwoThirdsDiagrams, expectedGridColumn);
52+
});
53+
});

0 commit comments

Comments
 (0)