Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

fix(chrome-ext): improve test reliability (#2615)

Elijah Pottercfe45f4e828a
diff --git a/packages/chrome-plugin/tests/slate.spec.ts b/packages/chrome-plugin/tests/slate.spec.ts
index 283dc1b60..90f66cafc 100644
--- a/packages/chrome-plugin/tests/slate.spec.ts
+++ b/packages/chrome-plugin/tests/slate.spec.ts
@@ -27,10 +27,10 @@ test('Can apply basic suggestion.', async ({ page }) => {
// Verify editor state is preserved: arrow keys and backspace must work.
// Position cursor before 's' in 'test', then backspace to delete 'e'.
- await slate.press('End');
- await slate.press('ArrowLeft');
- await slate.press('ArrowLeft');
- await slate.press('Backspace');
+ await page.press('body', 'End');
+ await page.press('body', 'ArrowLeft');
+ await page.press('body', 'ArrowLeft');
+ await page.press('body', 'Backspace');
await expect(slate).toContainText('This is a tst');
// Verify typing still works.
diff --git a/packages/chrome-plugin/tests/testUtils.ts b/packages/chrome-plugin/tests/testUtils.ts
index 2b1afb1a8..27cefef42 100644
--- a/packages/chrome-plugin/tests/testUtils.ts
+++ b/packages/chrome-plugin/tests/testUtils.ts
@@ -246,7 +246,7 @@ export async function testMultipleSuggestionsAndUndo(
export async function assertHarperHighlightBoxes(page: Page, boxes: Box[]): Promise<void> {
const highlights = getHarperHighlights(page);
- expect(await highlights.count()).toBe(boxes.length);
+ await expect(highlights).toHaveCount(boxes.length);
for (let i = 0; i < (await highlights.count()); i++) {
const box = await highlights.nth(i).boundingBox();