Skip to content

Commit

Permalink
fix(core): add ai send button test (#9685)
Browse files Browse the repository at this point in the history
  • Loading branch information
akumatus committed Jan 14, 2025
1 parent a24630b commit c8e5501
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions tests/affine-cloud-copilot/e2e/copilot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,14 @@ const openChat = async (page: Page) => {
await page.getByTestId('sidebar-tab-chat').click();
};

const makeChat = async (page: Page, content: string) => {
await openChat(page);
const typeChat = async (page: Page, content: string) => {
await page.getByTestId('chat-panel-input').focus();
await page.keyboard.type(content);
};

const makeChat = async (page: Page, content: string) => {
await openChat(page);
await typeChat(page, content);
await page.keyboard.press('Enter');
};

Expand Down Expand Up @@ -199,6 +203,30 @@ test.describe('chat panel', () => {
expect((await collectChat(page)).length).toBe(0);
});

test('chat send button', async ({ page }) => {
await page.reload();
await clickSideBarAllPageButton(page);
await page.waitForTimeout(200);
await createLocalWorkspace({ name: 'test' }, page);
await clickNewPageButton(page);
const sendButton = await page.getByTestId('chat-panel-send');
// oxlint-disable-next-line unicorn/prefer-dom-node-dataset
await openChat(page);
expect(await sendButton.getAttribute('aria-disabled')).toBe('true');
await typeChat(page, 'hello');
// oxlint-disable-next-line unicorn/prefer-dom-node-dataset
expect(await sendButton.getAttribute('aria-disabled')).toBe('false');
await sendButton.click();
// oxlint-disable-next-line unicorn/prefer-dom-node-dataset
expect(await sendButton.getAttribute('aria-disabled')).toBe('true');

const history = await collectChat(page);
expect(history[0]).toEqual({ name: 'You', content: 'hello' });
expect(history[1].name).toBe('AFFiNE AI');
await clearChat(page);
expect((await collectChat(page)).length).toBe(0);
});

test('chat actions', async ({ page }) => {
await page.reload();
await clickSideBarAllPageButton(page);
Expand Down

0 comments on commit c8e5501

Please sign in to comment.