Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions tests/behavior/tests/comments/nested-comments.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { assertDocumentApiReady, listComments } from '../../helpers/document-api
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const GDOCS_PATH = path.resolve(__dirname, '../../test-data/comments-tcs/nested-comments-gdocs.docx');
const WORD_PATH = path.resolve(__dirname, '../../test-data/comments-tcs/nested-comments-word.docx');
const ACTIVE_COMMENT_DIALOG_SELECTOR =
'.comment-placeholder .comments-dialog.is-active, #comments-panel .comments-dialog.is-active';

test.use({ config: { toolbar: 'full', comments: 'panel' } });

Expand All @@ -33,7 +35,7 @@ test.describe('nested comments from Google Docs', () => {
await superdoc.clickOnCommentedText('Licensee');
await superdoc.waitForStable();

const licenseeDialog = superdoc.page.locator('.comment-placeholder .comments-dialog.is-active').last();
const licenseeDialog = superdoc.page.locator(ACTIVE_COMMENT_DIALOG_SELECTOR).last();
await expect(licenseeDialog).toBeVisible({ timeout: 5_000 });
const licenseeComments = licenseeDialog.locator('.comment-body .comment');
await expect(licenseeComments).toHaveCount(2);
Expand All @@ -44,15 +46,15 @@ test.describe('nested comments from Google Docs', () => {
await superdoc.clickOnCommentedText('proprietary');
await superdoc.waitForStable();

const proprietaryDialog = superdoc.page.locator('.comment-placeholder .comments-dialog.is-active').last();
const proprietaryDialog = superdoc.page.locator(ACTIVE_COMMENT_DIALOG_SELECTOR).last();
await expect(proprietaryDialog).toBeVisible({ timeout: 5_000 });
await expect(proprietaryDialog.locator('.comment-body .comment').first()).toContainText('proprietary notices');

// Click "labels" — shows comment with reply
await superdoc.clickOnCommentedText('labels');
await superdoc.waitForStable();

const labelsDialog = superdoc.page.locator('.comment-placeholder .comments-dialog.is-active').last();
const labelsDialog = superdoc.page.locator(ACTIVE_COMMENT_DIALOG_SELECTOR).last();
await expect(labelsDialog).toBeVisible({ timeout: 5_000 });
const labelsComments = labelsDialog.locator('.comment-body .comment');
await expect(labelsComments).toHaveCount(2);
Expand All @@ -62,7 +64,7 @@ test.describe('nested comments from Google Docs', () => {
// Click away to deselect — no active dialog
await superdoc.clickOnLine(1, 50);
await superdoc.waitForStable();
await expect(superdoc.page.locator('.comment-placeholder .comments-dialog.is-active')).toHaveCount(0);
await expect(superdoc.page.locator(ACTIVE_COMMENT_DIALOG_SELECTOR)).toHaveCount(0);

await superdoc.snapshot('nested-comments-gdocs');
});
Expand Down Expand Up @@ -91,15 +93,15 @@ test.describe('nested comments from MS Word', () => {
await superdoc.clickOnCommentedText('modify');
await superdoc.waitForStable();

const modifyDialog = superdoc.page.locator('.comment-placeholder .comments-dialog.is-active').last();
const modifyDialog = superdoc.page.locator(ACTIVE_COMMENT_DIALOG_SELECTOR).last();
await expect(modifyDialog).toBeVisible({ timeout: 5_000 });
await expect(modifyDialog.locator('.comment-body .comment').first()).toContainText('comment on modify');

// Click "Licensee" — different, broader comment activates
await superdoc.clickOnCommentedText('Licensee');
await superdoc.waitForStable();

const licenseeDialog = superdoc.page.locator('.comment-placeholder .comments-dialog.is-active').last();
const licenseeDialog = superdoc.page.locator(ACTIVE_COMMENT_DIALOG_SELECTOR).last();
await expect(licenseeDialog).toBeVisible({ timeout: 5_000 });
await expect(licenseeDialog.locator('.comment-body .comment').first()).toContainText(
'comment from licensee to distribute',
Expand All @@ -109,15 +111,15 @@ test.describe('nested comments from MS Word', () => {
await superdoc.clickOnCommentedText('proprietary');
await superdoc.waitForStable();

const proprietaryDialog = superdoc.page.locator('.comment-placeholder .comments-dialog.is-active').last();
const proprietaryDialog = superdoc.page.locator(ACTIVE_COMMENT_DIALOG_SELECTOR).last();
await expect(proprietaryDialog).toBeVisible({ timeout: 5_000 });
await expect(proprietaryDialog.locator('.comment-body .comment').first()).toContainText('proprietary notices');

// Click "labels" — comment with reply thread
await superdoc.clickOnCommentedText('labels');
await superdoc.waitForStable();

const labelsDialog = superdoc.page.locator('.comment-placeholder .comments-dialog.is-active').last();
const labelsDialog = superdoc.page.locator(ACTIVE_COMMENT_DIALOG_SELECTOR).last();
await expect(labelsDialog).toBeVisible({ timeout: 5_000 });
const labelsComments = labelsDialog.locator('.comment-body .comment');
await expect(labelsComments).toHaveCount(2);
Expand All @@ -127,7 +129,7 @@ test.describe('nested comments from MS Word', () => {
// Click away to deselect — no active dialog
await superdoc.clickOnLine(1, 50);
await superdoc.waitForStable();
await expect(superdoc.page.locator('.comment-placeholder .comments-dialog.is-active')).toHaveCount(0);
await expect(superdoc.page.locator(ACTIVE_COMMENT_DIALOG_SELECTOR)).toHaveCount(0);

await superdoc.snapshot('nested-comments-word');
});
Expand Down
Loading