From b2bcab1027474fce3fb4562dea1a55be925a9738 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Damkj=C3=A6r?= Date: Mon, 2 Sep 2024 13:39:22 +0200 Subject: [PATCH] Make debounce tests pass on mac (#260) * makes tests pass locally * unupdatepkglock --- .../src/e2e_tests/debounce.spec.tsx | 17 +++++++++-------- .../src/e2e_tests/sanityChecks.spec.tsx | 8 ++------ 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/packages/react-codemirror/src/e2e_tests/debounce.spec.tsx b/packages/react-codemirror/src/e2e_tests/debounce.spec.tsx index 1d42f382..2f82fde7 100644 --- a/packages/react-codemirror/src/e2e_tests/debounce.spec.tsx +++ b/packages/react-codemirror/src/e2e_tests/debounce.spec.tsx @@ -3,6 +3,7 @@ import { DEBOUNCE_TIME } from '../constants'; import { CypherEditor } from '../CypherEditor'; import { CypherEditorPage } from './e2eUtils'; +const DEBOUNCE_TIME_WITH_MARGIN = DEBOUNCE_TIME + 100; // value updates from outside onExecute are overwritten by pending updates test.fail( 'external updates should override debounced updates', @@ -21,7 +22,7 @@ test.fail( await editorPage.getEditor().pressSequentially('RETURN 1'); onChange('foo'); - await page.waitForTimeout(DEBOUNCE_TIME); + await page.waitForTimeout(DEBOUNCE_TIME_WITH_MARGIN); await expect(component).toContainText('foo'); }, ); @@ -52,15 +53,15 @@ test('onExecute updates should override debounce updates', async ({ ); await editorPage.getEditor().pressSequentially('RETURN 1'); - await editorPage.getEditor().press('Control+Enter'); - await page.waitForTimeout(DEBOUNCE_TIME); + await editorPage.getEditor().press('Enter'); + await page.waitForTimeout(DEBOUNCE_TIME_WITH_MARGIN); await expect(component).not.toContainText('RETURN 1'); await editorPage.getEditor().pressSequentially('RETURN 1'); await editorPage.getEditor().pressSequentially(''); await editorPage.getEditor().pressSequentially('RETURN 1'); - await editorPage.getEditor().press('Control+Enter'); - await page.waitForTimeout(DEBOUNCE_TIME); + await editorPage.getEditor().press('Enter'); + await page.waitForTimeout(DEBOUNCE_TIME_WITH_MARGIN); await expect(component).not.toContainText('RETURN 1'); }); @@ -91,10 +92,10 @@ test('onExecute should fire after debounced updates', async ({ ); await editorPage.getEditor().fill('RETURN 1'); - await editorPage.getEditor().press('Control+Enter'); + await editorPage.getEditor().press('Enter'); await editorPage.getEditor().fill('RETURN 2'); - await editorPage.getEditor().press('Control+Enter'); - await page.waitForTimeout(DEBOUNCE_TIME); + await editorPage.getEditor().press('Enter'); + await page.waitForTimeout(DEBOUNCE_TIME_WITH_MARGIN); await expect(component).toContainText('RETURN 2'); expect(executedCommand).toBe('RETURN 2'); }); diff --git a/packages/react-codemirror/src/e2e_tests/sanityChecks.spec.tsx b/packages/react-codemirror/src/e2e_tests/sanityChecks.spec.tsx index 8fa867da..24154d6b 100644 --- a/packages/react-codemirror/src/e2e_tests/sanityChecks.spec.tsx +++ b/packages/react-codemirror/src/e2e_tests/sanityChecks.spec.tsx @@ -32,18 +32,14 @@ test('the editor can report changes to the text ', async ({ mount, page }) => { const textField = page.getByRole('textbox'); + await textField.fill(''); await textField.fill('RETURN 12'); + await expect(textField).toHaveText('RETURN 12'); // editor update is debounced, retry wait for debounced await expect(() => { expect(editorValueCopy).toBe('RETURN 12'); }).toPass({ intervals: [300, 300, 1000] }); - - await page.keyboard.type('34'); - - await expect(() => { - expect(editorValueCopy).toBe('RETURN 12'); - }).toPass({ intervals: [300, 300, 1000] }); }); test('can complete RETURN', async ({ page, mount }) => {