Skip to content

Commit

Permalink
Add e2e test for duplicate files
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Jun 8, 2024
1 parent f2ab09d commit fec4d30
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/mock.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,43 @@ describe('Blocknotes', () => {
await page.keyboard.type('d');
await expect(redo).toBeDisabled();
});

test('existing filename', async ({ page }) => {
await page.getByRole('button', { name: 'Pick Folder' }).click();

await page.keyboard.type('a');
await page.keyboard.press('Enter');
await page.keyboard.type('1');

const notesButton = page.getByRole('button', { name: 'Notes' });

await notesButton.click();
await page.getByRole('menuitem', { name: 'New Note' }).click();

await page.keyboard.type('a');
await page.keyboard.press('Enter');
await page.keyboard.type('2');

await notesButton.click();
await page.getByRole('menuitem', { name: 'a' }).nth(1).click();

await expect(
canvas(page)
.getByRole('document', { name: 'Block: Paragraph' })
.nth(1)
).toHaveText('1');

// The original file should be intact.
expect(await getPaths(page)).toEqual([
'a.html',
expect.stringMatching(/^a\.\d+\.html$/),
]);
expect(await getContents(page, 'a.html')).toBe(`<!-- wp:paragraph -->
<p>a</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>1</p>
<!-- /wp:paragraph -->`);
});
});

0 comments on commit fec4d30

Please sign in to comment.