Skip to content

Commit

Permalink
tests: add regression tests
Browse files Browse the repository at this point in the history
Adds regression tests for arnog#1975, arnog#1978, and arnog#1981

Also skip webkit iframe test in CI only since this test fails most of the time in CI even though it passes locally
  • Loading branch information
mgreminger committed May 23, 2023
1 parent fa2d614 commit 76836e5
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
49 changes: 49 additions & 0 deletions test/playwright-tests/physical-keyboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,3 +325,52 @@ test('nested paranthesis', async ({ page }) => {
await page.locator('#mf-1').evaluate((e: MathfieldElement) => e.value)
).toBe(String.raw`\left(\left(\left(x+y\right)-r\right)-1\right)+30`);
});

test('sqrt inline shortcut (#1975)', async ({ page }) => {
await page.goto('/dist/playwright-test-page/');

// use latex mode for math field with default settings
await page.locator('#mf-1').type('sqrt22');
await page.locator('#mf-1').press('ArrowRight');
await page.locator('#mf-1').type('=x');

// check latex of result
expect(
await page.locator('#mf-1').evaluate((e: MathfieldElement) => e.value)
).toBe(String.raw`\sqrt{22}=x`);
});

test('inline shortcut after long expression (#1978)', async ({ page }) => {
await page.goto('/dist/playwright-test-page/');

const startingLatex = String.raw`x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}`;

await page.locator('#mf-1').evaluate((e: MathfieldElement, latex: string) => e.value = latex, startingLatex);

// use latex mode for math field with default settings
await page.locator('#mf-1').type('+alpha');

// check latex of result
expect(
await page.locator('#mf-1').evaluate((e: MathfieldElement) => e.value)
).toBe(String.raw`x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}+\alpha`);
});

test('keyboard select than divide (#1981)', async ({ page }) => {
await page.goto('/dist/playwright-test-page/');

// use latex mode for math field with default settings
await page.locator('#mf-1').type('x+y');
await page.locator('#mf-1').press('Shift+ArrowLeft');
await page.locator('#mf-1').press('Shift+ArrowLeft');
await page.locator('#mf-1').press('Shift+ArrowLeft');
await page.locator('#mf-1').type('/2');

// check latex of result
expect(
await page.locator('#mf-1').evaluate((e: MathfieldElement) => e.value)
).toBe(String.raw`\frac{x+y}{2}`);
});



4 changes: 3 additions & 1 deletion test/playwright-tests/virtual-keyboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ test('virtual keyboard with two math fields', async ({ page }) => {
.waitFor({ state: 'detached' });
});

test('math fields in iframe with virtual keyboard', async ({ page }) => {
test('math fields in iframe with virtual keyboard', async ({ page, browserName, context }) => {
test.skip(browserName === "webkit" && Boolean(process.env.CI), "Iframe test is flaky in webkit on GH actions");

await page.goto('/dist/playwright-test-page/');

const frame = page.frame('mathlive-iframe');
Expand Down

0 comments on commit 76836e5

Please sign in to comment.