feat: new collections (#4530)

Co-authored-by: Peng Xiao <pengxiao@outlook.com>
This commit is contained in:
3720
2023-10-27 17:06:59 +08:00
committed by GitHub
parent 9fc0152cb1
commit ef8024c657
133 changed files with 8382 additions and 3743 deletions

View File

@@ -19,10 +19,7 @@ const monthNames = [
];
export const createFirstFilter = async (page: Page, name: string) => {
await page
.locator('[data-testid="header"]')
.locator('button', { hasText: 'Filter' })
.click();
await page.locator('[data-testid="create-first-filter"]').click();
await page
.locator('[data-testid="variable-select-item"]', { hasText: name })
.click();
@@ -42,9 +39,9 @@ const dateFormat = (date: Date) => {
};
export const checkPagesCount = async (page: Page, count: number) => {
expect((await page.locator('[data-testid="title"]').all()).length).toBe(
count
);
expect(
(await page.locator('[data-testid="page-list-item"]').all()).length
).toBe(count);
};
export const checkDatePicker = async (page: Page, date: Date) => {

View File

@@ -1,4 +1,4 @@
import type { Page } from '@playwright/test';
import type { Locator, Page } from '@playwright/test';
import { expect } from '@playwright/test';
export async function waitForEditorLoad(page: Page) {
@@ -16,7 +16,7 @@ export async function waitForAllPagesLoad(page: Page) {
export async function clickNewPageButton(page: Page) {
// fixme(himself65): if too fast, the page will crash
await page.getByTestId('new-page-button').click({
await page.getByTestId('new-page-button').first().click({
delay: 100,
});
await waitForEditorLoad(page);
@@ -51,3 +51,28 @@ export async function clickPageMoreActions(page: Page) {
.getByTestId('header-dropDownButton')
.click();
}
export const getPageOperationButton = (page: Page, id: string) => {
return getPageItem(page, id).getByTestId('page-list-operation-button');
};
export const getPageItem = (page: Page, id: string) => {
return page.locator(`[data-page-id="${id}"][data-testid="page-list-item"]`);
};
export const getPageByTitle = (page: Page, title: string) => {
return page.getByTestId('page-list-item').getByText(title);
};
export const dragTo = async (page: Page, locator: Locator, target: Locator) => {
await locator.hover();
await page.mouse.down();
await page.waitForTimeout(1000);
const targetElement = await target.boundingBox();
if (!targetElement) {
throw new Error('target element not found');
}
await page.mouse.move(targetElement.x, targetElement.y);
await target.hover();
await page.mouse.up();
};