Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

857 B
Raw Blame
import type { Page } from '@playwright/test';

import { Path } from '../playwright';

const fixturesDir = Path.dir(import.meta.url).join('../../../fixtures');

export async function importFile(
  page: Page,
  file: string,
  fn?: (page: Page) => Promise<void>
) {
  await page.evaluate(() => {
    // Force fallback to input[type=file] in tests
    // See https://github.com/microsoft/playwright/issues/8850
    window.showOpenFilePicker = undefined;
  });

  const fileChooser = page.waitForEvent('filechooser');

  if (fn) await fn(page);

  await (await fileChooser).setFiles(fixturesDir.join(file).value);
}

export async function importAttachment(page: Page, file: string) {
  // open slash menu
  await importFile(page, file, async page => {
    await page.keyboard.type('/attachment', { delay: 50 });
    await page.keyboard.press('Enter');
  });
}