Skip to content

Commit

Permalink
Make debounce tests pass on mac (#260)
Browse files Browse the repository at this point in the history
* makes tests pass locally

* unupdatepkglock
  • Loading branch information
OskarDamkjaer committed Sep 2, 2024
1 parent 01d23d2 commit b2bcab1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
17 changes: 9 additions & 8 deletions packages/react-codemirror/src/e2e_tests/debounce.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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');
},
);
Expand Down Expand Up @@ -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');
});

Expand Down Expand Up @@ -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');
});
8 changes: 2 additions & 6 deletions packages/react-codemirror/src/e2e_tests/sanityChecks.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down

0 comments on commit b2bcab1

Please sign in to comment.