2023-06-15 08:58:43 +03:00
|
|
|
import { test } from '@affine-test/kit/playwright';
|
2023-07-13 12:05:01 +03:00
|
|
|
import { openHomePage } from '@affine-test/kit/utils/load-page';
|
2023-08-05 02:55:28 +03:00
|
|
|
import {
|
2023-09-02 08:57:04 +03:00
|
|
|
clickNewPageButton,
|
2023-08-05 02:55:28 +03:00
|
|
|
getBlockSuiteEditorTitle,
|
2023-09-02 06:31:07 +03:00
|
|
|
waitForEditorLoad,
|
2023-08-05 02:55:28 +03:00
|
|
|
} from '@affine-test/kit/utils/page-logic';
|
2023-06-15 08:58:43 +03:00
|
|
|
import type { Page } from '@playwright/test';
|
|
|
|
import { expect } from '@playwright/test';
|
2023-08-05 02:55:28 +03:00
|
|
|
|
2023-06-15 08:58:43 +03:00
|
|
|
const addDatabase = async (page: Page) => {
|
2023-08-05 02:55:28 +03:00
|
|
|
await page.keyboard.press('/', { delay: 500 });
|
|
|
|
await page.keyboard.press('d', { delay: 500 });
|
|
|
|
await page.keyboard.press('a', { delay: 500 });
|
|
|
|
await page.keyboard.press('t', { delay: 500 });
|
|
|
|
await page.keyboard.press('a', { delay: 500 });
|
|
|
|
await page.getByTestId('Table View').click();
|
2023-06-15 08:58:43 +03:00
|
|
|
};
|
2023-06-30 20:17:31 +03:00
|
|
|
|
2023-06-15 08:58:43 +03:00
|
|
|
test('database is useable', async ({ page }) => {
|
|
|
|
await openHomePage(page);
|
2023-09-02 06:31:07 +03:00
|
|
|
await waitForEditorLoad(page);
|
2023-09-02 08:57:04 +03:00
|
|
|
await clickNewPageButton(page);
|
2023-09-02 06:31:07 +03:00
|
|
|
await waitForEditorLoad(page);
|
2023-08-08 06:01:47 +03:00
|
|
|
const title = getBlockSuiteEditorTitle(page);
|
2023-08-01 21:30:56 +03:00
|
|
|
await title.type('test title');
|
|
|
|
await page.keyboard.press('Enter');
|
2023-06-15 08:58:43 +03:00
|
|
|
expect(await title.innerText()).toBe('test title');
|
|
|
|
await addDatabase(page);
|
2023-08-08 06:01:47 +03:00
|
|
|
const database = page.locator('affine-database');
|
2023-06-30 20:17:31 +03:00
|
|
|
await expect(database).toBeVisible();
|
2023-06-15 08:58:43 +03:00
|
|
|
await page.reload();
|
2023-09-02 06:31:07 +03:00
|
|
|
await waitForEditorLoad(page);
|
2023-09-02 08:57:04 +03:00
|
|
|
await clickNewPageButton(page);
|
2023-09-02 06:31:07 +03:00
|
|
|
await waitForEditorLoad(page);
|
2023-08-08 06:01:47 +03:00
|
|
|
const title2 = getBlockSuiteEditorTitle(page);
|
|
|
|
await title2.type('test title2');
|
2023-07-07 17:15:27 +03:00
|
|
|
await page.waitForTimeout(500);
|
2023-06-15 08:58:43 +03:00
|
|
|
expect(await title2.innerText()).toBe('test title2');
|
2023-08-01 21:30:56 +03:00
|
|
|
await page.keyboard.press('Enter');
|
2023-06-15 08:58:43 +03:00
|
|
|
await addDatabase(page);
|
2023-08-08 06:01:47 +03:00
|
|
|
const database2 = page.locator('affine-database');
|
2023-06-30 20:17:31 +03:00
|
|
|
await expect(database2).toBeVisible();
|
2023-06-15 08:58:43 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
test('link page is useable', async ({ page }) => {
|
|
|
|
await openHomePage(page);
|
2023-09-02 06:31:07 +03:00
|
|
|
await waitForEditorLoad(page);
|
2023-09-02 08:57:04 +03:00
|
|
|
await clickNewPageButton(page);
|
2023-09-02 06:31:07 +03:00
|
|
|
await waitForEditorLoad(page);
|
2023-08-05 02:55:28 +03:00
|
|
|
const title = await getBlockSuiteEditorTitle(page);
|
2023-08-01 21:30:56 +03:00
|
|
|
await title.type('page1');
|
|
|
|
await page.keyboard.press('Enter');
|
2023-06-15 08:58:43 +03:00
|
|
|
expect(await title.innerText()).toBe('page1');
|
2023-09-02 08:57:04 +03:00
|
|
|
await clickNewPageButton(page);
|
2023-09-02 06:31:07 +03:00
|
|
|
await waitForEditorLoad(page);
|
2023-08-05 02:55:28 +03:00
|
|
|
const title2 = await getBlockSuiteEditorTitle(page);
|
2023-08-01 21:30:56 +03:00
|
|
|
await title2.type('page2');
|
|
|
|
await page.keyboard.press('Enter');
|
2023-06-15 08:58:43 +03:00
|
|
|
expect(await title2.innerText()).toBe('page2');
|
|
|
|
await page.keyboard.press('@', { delay: 50 });
|
|
|
|
await page.keyboard.press('p');
|
|
|
|
await page.keyboard.press('a');
|
|
|
|
await page.keyboard.press('g');
|
|
|
|
await page.keyboard.press('e');
|
|
|
|
await page.keyboard.press('1');
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
const link = page.locator('.affine-reference');
|
2023-07-07 17:15:27 +03:00
|
|
|
await page.waitForTimeout(500);
|
|
|
|
await expect(link).toBeVisible();
|
2023-06-15 08:58:43 +03:00
|
|
|
await page.click('.affine-reference');
|
2023-07-07 17:15:27 +03:00
|
|
|
await page.waitForTimeout(500);
|
2023-06-15 08:58:43 +03:00
|
|
|
expect(await title.innerText()).toBe('page1');
|
|
|
|
});
|