Skip to content

Commit 218a76d

Browse files
committed
test: update fit-to-container e2e expectations
1 parent e9dce6e commit 218a76d

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

tests/e2e/examples.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,11 @@ test.describe('examples pages', () => {
4646
test('zooming one diagram does not affect sibling diagrams', async ({
4747
page,
4848
}) => {
49+
await page.setViewportSize({ width: 1280, height: 2400 });
4950
await page.goto('/examples/basic');
5051
const diagrams = page.locator('.mermaid-container');
5152
await expect(diagrams.first()).toBeVisible();
5253

53-
// Scroll the page to trigger IntersectionObserver for offscreen diagrams.
54-
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
55-
5654
await expect
5755
.poll(async () => diagrams.count(), { timeout: 15_000 })
5856
.toBeGreaterThanOrEqual(2);

tests/e2e/toolbar.spec.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ test.describe('toolbar interactions', () => {
4242
test('reset view restores the original transform', async ({ page }) => {
4343
const diagram = page.locator('.mermaid-container').first();
4444
const inner = diagram.locator('.mermaid').first();
45+
const initialTransform = await inner.evaluate(
46+
(el) => (el as HTMLElement).style.transform,
47+
);
4548

4649
await diagram
4750
.locator('.desktop-controls [data-mermaid-control="zoomIn"]')
@@ -57,7 +60,7 @@ test.describe('toolbar interactions', () => {
5760
.poll(async () =>
5861
inner.evaluate((el) => (el as HTMLElement).style.transform),
5962
)
60-
.toMatch(/scale\(1\)/);
63+
.toEqual(initialTransform);
6164
});
6265

6366
test('copy button writes mermaid source to the clipboard', async ({
@@ -162,6 +165,9 @@ test.describe('toolbar interactions', () => {
162165
}) => {
163166
const diagram = page.locator('.mermaid-container').first();
164167
const inner = diagram.locator('.mermaid').first();
168+
const initialTransform = await inner.evaluate(
169+
(el) => (el as HTMLElement).style.transform,
170+
);
165171
const zoomIn = diagram.locator(
166172
'.desktop-controls [data-mermaid-control="zoomIn"]',
167173
);
@@ -188,11 +194,6 @@ test.describe('toolbar interactions', () => {
188194
.poll(async () =>
189195
inner.evaluate((el) => (el as HTMLElement).style.transform),
190196
)
191-
.toMatch(/scale\(1\)/);
192-
193-
const finalTransform = await inner.evaluate(
194-
(el) => (el as HTMLElement).style.transform,
195-
);
196-
expect(finalTransform).toMatch(/translate\(0px,\s?0px\)|matrix\(1,/);
197+
.toEqual(initialTransform);
197198
});
198199
});

0 commit comments

Comments
 (0)