2023-06-15 08:58:43 +03:00
|
|
|
import { test } from '@affine-test/kit/playwright';
|
|
|
|
import type { Page } from '@playwright/test';
|
|
|
|
import { expect } from '@playwright/test';
|
|
|
|
|
|
|
|
import { openHomePage } from '../../libs/load-page';
|
|
|
|
import { newPage, waitEditorLoad } from '../../libs/page-logic';
|
|
|
|
const addDatabase = async (page: Page) => {
|
|
|
|
await page.keyboard.press('/', { delay: 50 });
|
|
|
|
await page.keyboard.press('d');
|
|
|
|
await page.keyboard.press('a');
|
|
|
|
await page.keyboard.press('t');
|
|
|
|
await page.keyboard.press('a');
|
|
|
|
await page.keyboard.press('b');
|
|
|
|
await page.keyboard.press('a', { delay: 50 });
|
|
|
|
await page.keyboard.press('Enter', { delay: 50 });
|
|
|
|
};
|
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);
|
|
|
|
await waitEditorLoad(page);
|
|
|
|
await newPage(page);
|
|
|
|
await page.keyboard.insertText('test title');
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
const title = page.locator('.affine-default-page-block-title');
|
|
|
|
expect(await title.innerText()).toBe('test title');
|
|
|
|
await addDatabase(page);
|
|
|
|
const database = page.locator('.affine-database-table');
|
2023-06-30 20:17:31 +03:00
|
|
|
await expect(database).toBeVisible();
|
2023-06-15 08:58:43 +03:00
|
|
|
await page.reload();
|
|
|
|
await waitEditorLoad(page);
|
|
|
|
await newPage(page);
|
|
|
|
await page.keyboard.insertText('test title2');
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
const title2 = page.locator('.affine-default-page-block-title');
|
|
|
|
expect(await title2.innerText()).toBe('test title2');
|
|
|
|
await addDatabase(page);
|
|
|
|
const database2 = page.locator('.affine-database-table');
|
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);
|
|
|
|
await waitEditorLoad(page);
|
|
|
|
await newPage(page);
|
|
|
|
await page.keyboard.insertText('page1');
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
const title = page.locator('.affine-default-page-block-title');
|
|
|
|
expect(await title.innerText()).toBe('page1');
|
|
|
|
await newPage(page);
|
|
|
|
await page.keyboard.insertText('page2');
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
const title2 = page.locator('.affine-default-page-block-title');
|
|
|
|
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');
|
|
|
|
expect(link).toBeVisible();
|
|
|
|
await page.click('.affine-reference');
|
|
|
|
expect(await title.innerText()).toBe('page1');
|
|
|
|
});
|