Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

2.3 KB
Raw Blame
import { expect, test } from '@playwright/test';

test.beforeEach(async ({ page }) => {
  // The fixture's providers would otherwise reach the hosted dev backend.
  await page.routeWebSocket('**', (socket) => socket.close());
  await page.route('**/__macro_dev/**', (route) => route.abort());
  await page.route('https://**', (route) => route.abort());
});

for (const composer of ['new', 'reply', 'reply-all', 'forward']) {
  test(`Cmd+Shift+C and Cmd+Shift+B open Cc and Bcc in the ${composer} composer`, async ({
    page,
  }) => {
    await page.goto(
      `/src/features/email-compose/browser-test/recipient-hotkeys.html?composer=${composer}`
    );
    await page.locator('[contenteditable="true"]').click();

    await page.keyboard.press('ControlOrMeta+Shift+C');
    const cc = page
      .getByText('Cc', { exact: true })
      .locator('..')
      .getByRole('combobox');
    await expect(cc).toBeFocused();

    await page.keyboard.press('ControlOrMeta+Shift+B');
    const bcc = page
      .getByText('Bcc', { exact: true })
      .locator('..')
      .getByRole('combobox');
    await expect(bcc).toBeFocused();

    // Once the field is visible the shortcut only moves focus back to it.
    await page.keyboard.press('ControlOrMeta+Shift+C');
    await expect(cc).toBeFocused();
    await expect(page.getByTestId('thread-command')).toHaveText('none');
  });

  test(`clicking Cc and Bcc focuses the revealed field in the ${composer} composer`, async ({
    page,
  }) => {
    await page.goto(
      `/src/features/email-compose/browser-test/recipient-hotkeys.html?composer=${composer}`
    );
    await page.locator('[contenteditable="true"]').waitFor();
    // Replies open with their recipients collapsed into a summary.
    if (composer === 'reply' || composer === 'reply-all') {
      await page.getByRole('button', { name: /^Replying to/ }).click();
    }

    for (const field of ['Cc', 'Bcc']) {
      await page.getByRole('button', { name: field, exact: true }).click();
      const input = page
        .getByText(field, { exact: true })
        .locator('..')
        .getByRole('combobox');
      await expect(input).toBeFocused();
      // Typing lands in the field instead of reaching the app's hotkeys.
      await page.keyboard.type('cq');
      await expect(input).toHaveValue('cq');
    }
  });
}