Skip to content

Commit

Permalink
test(editor): playwright test for kanban drag and drop
Browse files Browse the repository at this point in the history
  • Loading branch information
alsuren committed Dec 30, 2024
1 parent b380a2b commit 979df78
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/affine-local/e2e/blocksuite/editor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page';
import {
addDatabase,
addKanban,
clickNewPageButton,
getBlockSuiteEditorTitle,
waitForEditorLoad,
Expand Down Expand Up @@ -33,6 +34,38 @@ test('database is useable', async ({ page }) => {
await expect(database2).toBeVisible();
});


test('kanban drag and drop is useable', async ({ page }) => {
await openHomePage(page);
await waitForEditorLoad(page);
await clickNewPageButton(page);

await page.locator('[data-testid=page-editor-blank]').click();
await addKanban(page);

const database = page.locator('affine-database');
await expect(database).toBeVisible();

// find the card in the 0th group
const cardId = await page.locator("affine-data-view-kanban-group").nth(0).locator('affine-data-view-kanban-card').getAttribute("data-card-id")
expect(cardId).toBeTruthy()

// drag the card across by one group
await page.locator(`[data-card-id="${cardId}"]`).hover()
await page.mouse.down();
await page.locator(".group-header").nth(1).hover()

// drag preview of card should be visible
await expect(page.locator(".with-data-view-css-variable .card-body")).toBeVisible()

// wiggle the card a bit and then drop it (not sure how to do this in a non-racey way)
await page.locator(".group-body").nth(1).hover({ force: true })
await page.mouse.up()

// assert that it is in the intended column
await expect(page.locator(".group-body").nth(1).locator(`[data-card-id="${cardId}"]`)).toBeVisible()
});

test('link page is useable', async ({ page }) => {
await openHomePage(page);
await waitForEditorLoad(page);
Expand Down
8 changes: 8 additions & 0 deletions tests/kit/utils/page-logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,11 @@ export const addDatabaseRow = async (page: Page, databaseTitle: string) => {
});
await db.locator('.data-view-table-group-add-row-button').click();
};


export const addKanban = async (page: Page, title?: string) => {
await page.keyboard.press('/');
await expect(page.locator('affine-slash-menu .slash-menu')).toBeVisible();
await page.keyboard.type('kanban');
await page.getByTestId('Kanban View').click();
}

0 comments on commit 979df78

Please sign in to comment.