🐛(frontend) Fixed side effects between comments and versionning

We fixed 2 side effects between comments and versionning:
- When going from a version, it was not possible
to add a comment anymore. This was due to the fact
that the versionning was resetting the comment store.
- When restoring a version, we now reset the comment
store to avoid having comments that are not relevant
anymore.
This commit is contained in:
Anthony LC
2026-04-07 16:39:03 +02:00
parent 563a6d0e08
commit dba762759e
7 changed files with 74 additions and 7 deletions

View File

@@ -133,14 +133,20 @@ test.describe('Doc Version', () => {
const [randomDoc] = await createDoc(page, 'doc-version', browserName, 1);
await verifyDocName(page, randomDoc);
await page.locator('.bn-block-outer').last().click();
await page.locator('.bn-block-outer').last().fill('Hello');
const editor = await writeInEditor({ page, text: 'Hello' });
// Add a comment
await editor.getByText('Hello').selectText();
await page.getByRole('button', { name: 'Add comment' }).click();
const thread = page.locator('.bn-thread');
await thread.getByRole('paragraph').first().fill('This is a comment');
await thread.locator('[data-test="save"]').click();
await goToGridDoc(page, {
title: randomDoc,
});
const editor = page.locator('.ProseMirror');
await expect(editor.getByText('Hello')).toBeVisible();
await page.locator('.bn-block-outer').last().click();
await page.keyboard.press('Enter');
@@ -152,6 +158,11 @@ test.describe('Doc Version', () => {
await expect(page.getByText('World')).toBeVisible();
await editor.getByText('Hello').click();
await thread.getByText('This is a comment').first().hover();
await thread.locator('[data-test="resolve"]').click();
await expect(thread).toBeHidden();
await page.getByLabel('Open the document options').click();
await page.getByRole('menuitem', { name: 'Version history' }).click();
@@ -175,7 +186,21 @@ test.describe('Doc Version', () => {
await page.waitForTimeout(500);
await expect(page.getByText('Hello')).toBeVisible();
await expect(page.getByText('World')).toBeHidden();
await expect(editor.getByText('Hello')).toBeVisible();
await expect(editor.getByText('World')).toBeHidden();
// The old comment is not restored
await expect(editor.getByText('Hello')).toHaveCSS(
'background-color',
'rgba(0, 0, 0, 0)',
);
// We can add a new comment
await editor.getByText('Hello').selectText();
await page.getByRole('button', { name: 'Add comment' }).click();
await thread.getByRole('paragraph').first().fill('This is a comment');
await thread.locator('[data-test="save"]').click();
await expect(editor.getByText('Hello')).toHaveClass('bn-thread-mark');
});
});