Some checks failed
Build & Test / Analyze (javascript, affine) (push) Failing after 4s
Build & Test / Analyze (typescript, affine) (push) Failing after 3s
Build & Test / Rust test filter (push) Failing after 4s
Build & Test / Check yarn binary (push) Failing after 3s
Build & Test / E2E BlockSuite Test (3) (push) Failing after 3s
Build & Test / Analyze (javascript, blocksuite) (push) Failing after 3s
Build & Test / Analyze (typescript, blocksuite) (push) Failing after 3s
Build & Test / Mobile native build filter (push) Failing after 3s
Build & Test / E2E BlockSuite Test (1) (push) Failing after 4s
Build & Test / E2E BlockSuite Test (2) (push) Failing after 4s
Build & Test / E2E Mobile Test (1) (push) Failing after 3s
Build & Test / Unit Test (1) (push) Has been skipped
Build & Test / Unit Test (2) (push) Has been skipped
Build & Test / Unit Test (3) (push) Has been skipped
Build & Test / Unit Test (4) (push) Has been skipped
Build & Test / Unit Test (5) (push) Has been skipped
Build & Test / Native Unit Test (push) Has been skipped
Build & Test / E2E BlockSuite Test (4) (push) Failing after 3s
Build & Test / E2E BlockSuite Test (5) (push) Failing after 3s
Build & Test / E2E BlockSuite Cross Browser Test (push) Failing after 3s
Build & Test / E2E Mobile Test (2) (push) Failing after 3s
Build & Test / Build AFFiNE native (x86_64-unknown-linux-gnu) (push) Failing after 3s
Build & Test / Build Server native (push) Failing after 3s
Build & Test / Check Git Status (push) Has been skipped
Build & Test / Server Test (0, 4) (push) Has been skipped
Build & Test / Server Test (1, 4) (push) Has been skipped
Build & Test / Server Test (2, 4) (push) Has been skipped
Build & Test / Server Test (3, 4) (push) Has been skipped
Build & Test / Server Test with Elasticsearch (push) Has been skipped
Build & Test / Build @affine/electron renderer (push) Failing after 3s
Build & Test / Copilot test filter (push) Failing after 4s
Build & Test / Lint Rust (push) Has been skipped
Build & Test / Server Test with Embedded Search (push) Has been skipped
Build & Test / Server Test with Manticore Search (push) Has been skipped
Build & Test / Server E2E Test (push) Has been skipped
Build & Test / Cloud Desktop E2E Test (push) Has been skipped
Build & Test / Cloud E2E Test 1/2 (push) Has been skipped
Build & Test / Cloud E2E Test 2/2 (push) Has been skipped
Build & Test / Build Android app (push) Has been skipped
Build & Test / Test Android app (push) Has been skipped
Build & Test / Run native tests (push) Has been skipped
Build & Test / Server Copilot Api Test (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (1, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (2, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (3, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (4, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (5, 5) (push) Has been skipped
Release / Canary Gate (push) Has been skipped
Build & Test / Build AFFiNE native (aarch64-apple-darwin) (push) Has been cancelled
Build & Test / Lint (push) Has been cancelled
Build & Test / Typecheck (push) Has been cancelled
Build & Test / Build AFFiNE native (x86_64-apple-darwin) (push) Has been cancelled
Build & Test / Desktop Test (ubuntu-latest, linux, x64, x86_64-unknown-linux-gnu, true) (push) Has been cancelled
Build & Test / Desktop Test (windows-latest, windows, x64, x86_64-pc-windows-msvc, true) (push) Has been cancelled
Build & Test / E2E Test (1) (push) Has been cancelled
Build & Test / E2E Test (2) (push) Has been cancelled
Build & Test / E2E Test (3) (push) Has been cancelled
Build & Test / E2E Test (4) (push) Has been cancelled
Build & Test / E2E Test (5) (push) Has been cancelled
Build & Test / Build AFFiNE native (aarch64-pc-windows-msvc) (push) Has been cancelled
Build & Test / Build AFFiNE native (x86_64-pc-windows-msvc) (push) Has been cancelled
Build & Test / Desktop Test (macos-latest, macos, arm64, aarch64-apple-darwin, true) (push) Has been cancelled
Build & Test / Desktop Test (macos-latest, macos, x64, x86_64-apple-darwin, false) (push) Has been cancelled
Build & Test / 3, 2, 1 Launch (push) Has been cancelled
Build & Test / Build iOS app (push) Has been cancelled
Copilot Test Automatically / Setup Test (push) Failing after 1s
Release / Prepare (push) Failing after 2s
Release / Release Cloud (push) Has been skipped
Release / Release Desktop (push) Has been skipped
Release / Release Docker Image (push) Has been skipped
Release / Release Mobile (push) Has been skipped
122 lines
3.8 KiB
TypeScript
122 lines
3.8 KiB
TypeScript
import { test } from '@affine-test/kit/playwright';
|
|
import {
|
|
createRandomUser,
|
|
enableCloudWorkspace,
|
|
loginUser,
|
|
} from '@affine-test/kit/utils/cloud';
|
|
import {
|
|
clickNewPageButton,
|
|
getBlockSuiteEditorTitle,
|
|
waitForEditorLoad,
|
|
} from '@affine-test/kit/utils/page-logic';
|
|
import { createLocalWorkspace } from '@affine-test/kit/utils/workspace';
|
|
import { expect } from '@playwright/test';
|
|
|
|
test.describe('comments', () => {
|
|
let user: {
|
|
id: string;
|
|
name: string;
|
|
email: string;
|
|
password: string;
|
|
};
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
user = await createRandomUser();
|
|
await loginUser(page, user);
|
|
});
|
|
|
|
test('can create and display a comment on selected text', async ({
|
|
page,
|
|
}) => {
|
|
// Reload page and wait for editor - following the pattern from working collaboration test
|
|
await page.reload();
|
|
await waitForEditorLoad(page);
|
|
|
|
// Create a new workspace
|
|
await createLocalWorkspace(
|
|
{
|
|
name: 'test-comment-workspace',
|
|
},
|
|
page
|
|
);
|
|
|
|
// Enable cloud workspace for comments feature
|
|
await enableCloudWorkspace(page);
|
|
|
|
// Create a new doc
|
|
await clickNewPageButton(page);
|
|
await waitForEditorLoad(page);
|
|
|
|
// Add title and content
|
|
const title = getBlockSuiteEditorTitle(page);
|
|
await title.click();
|
|
await title.fill('Test Comment Document');
|
|
|
|
// Add some text content
|
|
await page.keyboard.press('Enter');
|
|
await page.keyboard.type(
|
|
'This is a test paragraph with some text that we will comment on.',
|
|
{ delay: 50 }
|
|
);
|
|
|
|
for (let i = 0; i < 11; i++) {
|
|
await page.keyboard.press('Shift+ArrowLeft');
|
|
}
|
|
|
|
// Wait for the toolbar to appear after text selection
|
|
const toolbar = page.locator('editor-toolbar');
|
|
await expect(toolbar).toBeVisible({ timeout: 5000 });
|
|
|
|
// Click the comment button in the toolbar
|
|
// The comment button has tooltip "Comment" based on blockCommentToolbarButton
|
|
const commentButton = page.locator(
|
|
'editor-icon-button[aria-label="Comment"]'
|
|
);
|
|
await expect(commentButton).toBeVisible();
|
|
await commentButton.click();
|
|
|
|
// Verify comment sidebar is opened by checking comment editor is visible
|
|
await page.waitForTimeout(300); // Wait for sidebar animation
|
|
|
|
// Find the comment editor
|
|
const commentEditor = page.locator(
|
|
'.comment-editor-viewport .page-editor-container'
|
|
);
|
|
await expect(commentEditor).toBeVisible();
|
|
|
|
// Enter comment text
|
|
await commentEditor.click();
|
|
await commentEditor.focus();
|
|
await page.keyboard.type('This is my first comment on this text', {
|
|
delay: 50,
|
|
});
|
|
|
|
// Commit the comment (click the commit button or press Cmd/Ctrl+Enter)
|
|
// The commit button is in the footer with an arrow icon
|
|
const commitButton = page.locator('.comment-editor-viewport button').last();
|
|
await expect(commitButton).toBeVisible();
|
|
await commitButton.click();
|
|
|
|
// Wait for comment to be saved
|
|
await page.waitForTimeout(500);
|
|
|
|
// Verify the comment appears in the sidebar
|
|
await expect(page.locator('text=Comments')).toBeVisible();
|
|
await expect(
|
|
page.locator('text=This is my first comment on this text')
|
|
).toBeVisible();
|
|
|
|
// Verify the preview text appears in the sidebar
|
|
// The preview should show the selected text that was commented on
|
|
// Target specifically the sidebar tab content to avoid conflicts with editor content
|
|
const sidebarTab = page.getByTestId('sidebar-tab-content-comment');
|
|
await expect(sidebarTab.locator('text=comment on.')).toBeVisible();
|
|
|
|
// This text should appear in the sidebar as the preview of what was commented on
|
|
|
|
// Verify the comment is successfully created by checking the sidebar content
|
|
const commentSidebar = page.locator('text=Comments').locator('..');
|
|
await expect(commentSidebar).toBeVisible();
|
|
});
|
|
});
|