snapshot of https://github.com/toeverything/AFFiNE.git (canary, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Build & Test / Analyze (javascript, affine) (push) Failing after 4s
Build & Test / Analyze (typescript, affine) (push) Failing after 3s
Build & Test / Rust test filter (push) Failing after 4s
Build & Test / Check yarn binary (push) Failing after 3s
Build & Test / E2E BlockSuite Test (3) (push) Failing after 3s
Build & Test / Analyze (javascript, blocksuite) (push) Failing after 3s
Build & Test / Analyze (typescript, blocksuite) (push) Failing after 3s
Build & Test / Mobile native build filter (push) Failing after 3s
Build & Test / E2E BlockSuite Test (1) (push) Failing after 4s
Build & Test / E2E BlockSuite Test (2) (push) Failing after 4s
Build & Test / E2E Mobile Test (1) (push) Failing after 3s
Build & Test / Unit Test (1) (push) Has been skipped
Build & Test / Unit Test (2) (push) Has been skipped
Build & Test / Unit Test (3) (push) Has been skipped
Build & Test / Unit Test (4) (push) Has been skipped
Build & Test / Unit Test (5) (push) Has been skipped
Build & Test / Native Unit Test (push) Has been skipped
Build & Test / E2E BlockSuite Test (4) (push) Failing after 3s
Build & Test / E2E BlockSuite Test (5) (push) Failing after 3s
Build & Test / E2E BlockSuite Cross Browser Test (push) Failing after 3s
Build & Test / E2E Mobile Test (2) (push) Failing after 3s
Build & Test / Build AFFiNE native (x86_64-unknown-linux-gnu) (push) Failing after 3s
Build & Test / Build Server native (push) Failing after 3s
Build & Test / Check Git Status (push) Has been skipped
Build & Test / Server Test (0, 4) (push) Has been skipped
Build & Test / Server Test (1, 4) (push) Has been skipped
Build & Test / Server Test (2, 4) (push) Has been skipped
Build & Test / Server Test (3, 4) (push) Has been skipped
Build & Test / Server Test with Elasticsearch (push) Has been skipped
Build & Test / Build @affine/electron renderer (push) Failing after 3s
Build & Test / Copilot test filter (push) Failing after 4s
Build & Test / Lint Rust (push) Has been skipped
Build & Test / Server Test with Embedded Search (push) Has been skipped
Build & Test / Server Test with Manticore Search (push) Has been skipped
Build & Test / Server E2E Test (push) Has been skipped
Build & Test / Cloud Desktop E2E Test (push) Has been skipped
Build & Test / Cloud E2E Test 1/2 (push) Has been skipped
Build & Test / Cloud E2E Test 2/2 (push) Has been skipped
Build & Test / Build Android app (push) Has been skipped
Build & Test / Test Android app (push) Has been skipped
Build & Test / Run native tests (push) Has been skipped
Build & Test / Server Copilot Api Test (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (1, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (2, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (3, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (4, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (5, 5) (push) Has been skipped
Release / Canary Gate (push) Has been skipped
Build & Test / Build AFFiNE native (aarch64-apple-darwin) (push) Has been cancelled
Build & Test / Lint (push) Has been cancelled
Build & Test / Typecheck (push) Has been cancelled
Build & Test / Build AFFiNE native (x86_64-apple-darwin) (push) Has been cancelled
Build & Test / Desktop Test (ubuntu-latest, linux, x64, x86_64-unknown-linux-gnu, true) (push) Has been cancelled
Build & Test / Desktop Test (windows-latest, windows, x64, x86_64-pc-windows-msvc, true) (push) Has been cancelled
Build & Test / E2E Test (1) (push) Has been cancelled
Build & Test / E2E Test (2) (push) Has been cancelled
Build & Test / E2E Test (3) (push) Has been cancelled
Build & Test / E2E Test (4) (push) Has been cancelled
Build & Test / E2E Test (5) (push) Has been cancelled
Build & Test / Build AFFiNE native (aarch64-pc-windows-msvc) (push) Has been cancelled
Build & Test / Build AFFiNE native (x86_64-pc-windows-msvc) (push) Has been cancelled
Build & Test / Desktop Test (macos-latest, macos, arm64, aarch64-apple-darwin, true) (push) Has been cancelled
Build & Test / Desktop Test (macos-latest, macos, x64, x86_64-apple-darwin, false) (push) Has been cancelled
Build & Test / 3, 2, 1 Launch (push) Has been cancelled
Build & Test / Build iOS app (push) Has been cancelled
Copilot Test Automatically / Setup Test (push) Failing after 1s
Release / Prepare (push) Failing after 2s
Release / Release Cloud (push) Has been skipped
Release / Release Desktop (push) Has been skipped
Release / Release Docker Image (push) Has been skipped
Release / Release Mobile (push) Has been skipped
Some checks failed
Build & Test / Analyze (javascript, affine) (push) Failing after 4s
Build & Test / Analyze (typescript, affine) (push) Failing after 3s
Build & Test / Rust test filter (push) Failing after 4s
Build & Test / Check yarn binary (push) Failing after 3s
Build & Test / E2E BlockSuite Test (3) (push) Failing after 3s
Build & Test / Analyze (javascript, blocksuite) (push) Failing after 3s
Build & Test / Analyze (typescript, blocksuite) (push) Failing after 3s
Build & Test / Mobile native build filter (push) Failing after 3s
Build & Test / E2E BlockSuite Test (1) (push) Failing after 4s
Build & Test / E2E BlockSuite Test (2) (push) Failing after 4s
Build & Test / E2E Mobile Test (1) (push) Failing after 3s
Build & Test / Unit Test (1) (push) Has been skipped
Build & Test / Unit Test (2) (push) Has been skipped
Build & Test / Unit Test (3) (push) Has been skipped
Build & Test / Unit Test (4) (push) Has been skipped
Build & Test / Unit Test (5) (push) Has been skipped
Build & Test / Native Unit Test (push) Has been skipped
Build & Test / E2E BlockSuite Test (4) (push) Failing after 3s
Build & Test / E2E BlockSuite Test (5) (push) Failing after 3s
Build & Test / E2E BlockSuite Cross Browser Test (push) Failing after 3s
Build & Test / E2E Mobile Test (2) (push) Failing after 3s
Build & Test / Build AFFiNE native (x86_64-unknown-linux-gnu) (push) Failing after 3s
Build & Test / Build Server native (push) Failing after 3s
Build & Test / Check Git Status (push) Has been skipped
Build & Test / Server Test (0, 4) (push) Has been skipped
Build & Test / Server Test (1, 4) (push) Has been skipped
Build & Test / Server Test (2, 4) (push) Has been skipped
Build & Test / Server Test (3, 4) (push) Has been skipped
Build & Test / Server Test with Elasticsearch (push) Has been skipped
Build & Test / Build @affine/electron renderer (push) Failing after 3s
Build & Test / Copilot test filter (push) Failing after 4s
Build & Test / Lint Rust (push) Has been skipped
Build & Test / Server Test with Embedded Search (push) Has been skipped
Build & Test / Server Test with Manticore Search (push) Has been skipped
Build & Test / Server E2E Test (push) Has been skipped
Build & Test / Cloud Desktop E2E Test (push) Has been skipped
Build & Test / Cloud E2E Test 1/2 (push) Has been skipped
Build & Test / Cloud E2E Test 2/2 (push) Has been skipped
Build & Test / Build Android app (push) Has been skipped
Build & Test / Test Android app (push) Has been skipped
Build & Test / Run native tests (push) Has been skipped
Build & Test / Server Copilot Api Test (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (1, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (2, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (3, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (4, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (5, 5) (push) Has been skipped
Release / Canary Gate (push) Has been skipped
Build & Test / Build AFFiNE native (aarch64-apple-darwin) (push) Has been cancelled
Build & Test / Lint (push) Has been cancelled
Build & Test / Typecheck (push) Has been cancelled
Build & Test / Build AFFiNE native (x86_64-apple-darwin) (push) Has been cancelled
Build & Test / Desktop Test (ubuntu-latest, linux, x64, x86_64-unknown-linux-gnu, true) (push) Has been cancelled
Build & Test / Desktop Test (windows-latest, windows, x64, x86_64-pc-windows-msvc, true) (push) Has been cancelled
Build & Test / E2E Test (1) (push) Has been cancelled
Build & Test / E2E Test (2) (push) Has been cancelled
Build & Test / E2E Test (3) (push) Has been cancelled
Build & Test / E2E Test (4) (push) Has been cancelled
Build & Test / E2E Test (5) (push) Has been cancelled
Build & Test / Build AFFiNE native (aarch64-pc-windows-msvc) (push) Has been cancelled
Build & Test / Build AFFiNE native (x86_64-pc-windows-msvc) (push) Has been cancelled
Build & Test / Desktop Test (macos-latest, macos, arm64, aarch64-apple-darwin, true) (push) Has been cancelled
Build & Test / Desktop Test (macos-latest, macos, x64, x86_64-apple-darwin, false) (push) Has been cancelled
Build & Test / 3, 2, 1 Launch (push) Has been cancelled
Build & Test / Build iOS app (push) Has been cancelled
Copilot Test Automatically / Setup Test (push) Failing after 1s
Release / Prepare (push) Failing after 2s
Release / Release Cloud (push) Has been skipped
Release / Release Desktop (push) Has been skipped
Release / Release Docker Image (push) Has been skipped
Release / Release Mobile (push) Has been skipped
This commit is contained in:
487
tests/blocksuite/e2e/database/calendar.spec.ts
Normal file
487
tests/blocksuite/e2e/database/calendar.spec.ts
Normal file
@@ -0,0 +1,487 @@
|
||||
import type { DatabaseBlockModel } from '@blocksuite/affine/model';
|
||||
import type { DeltaInsert } from '@blocksuite/store';
|
||||
import { expect, type Page } from '@playwright/test';
|
||||
|
||||
import {
|
||||
enterPlaygroundRoom,
|
||||
getEditorHostLocator,
|
||||
waitNextFrame,
|
||||
} from '../utils/actions/index.js';
|
||||
import { scoped, test } from '../utils/playwright.js';
|
||||
|
||||
const currentMonthAnchor = () => {
|
||||
const date = new Date();
|
||||
date.setHours(0, 0, 0, 0);
|
||||
date.setDate(1);
|
||||
return date.getTime();
|
||||
};
|
||||
|
||||
const timestampFromMonthAnchor = ({
|
||||
monthAnchor,
|
||||
day,
|
||||
}: {
|
||||
monthAnchor: number;
|
||||
day: number;
|
||||
}) => {
|
||||
const date = new Date(monthAnchor);
|
||||
date.setDate(day);
|
||||
return date.getTime();
|
||||
};
|
||||
|
||||
const getMonthTimestamp = (page: Page, monthAnchor: number, day: number) =>
|
||||
page.evaluate(timestampFromMonthAnchor, { monthAnchor, day });
|
||||
|
||||
const createCalendarDatabase = async (
|
||||
page: Page,
|
||||
options?: {
|
||||
withDateColumn?: boolean;
|
||||
mapDateColumn?: boolean;
|
||||
readonly?: boolean;
|
||||
rowCount?: number;
|
||||
linkedDocTitle?: string;
|
||||
withEndDateColumn?: boolean;
|
||||
}
|
||||
) => {
|
||||
const monthAnchor = await page.evaluate(currentMonthAnchor);
|
||||
const dateTimestamp = await getMonthTimestamp(page, monthAnchor, 15);
|
||||
const endDateTimestamp = await getMonthTimestamp(page, monthAnchor, 17);
|
||||
|
||||
return page.evaluate(
|
||||
({
|
||||
withDateColumn,
|
||||
mapDateColumn,
|
||||
readonly,
|
||||
rowCount,
|
||||
linkedDocTitle,
|
||||
withEndDateColumn,
|
||||
dateTimestamp,
|
||||
endDateTimestamp,
|
||||
monthAnchor,
|
||||
}) => {
|
||||
const { doc } = window;
|
||||
const rows = rowCount ?? 1;
|
||||
const linkedDocId = linkedDocTitle ? `doc:${linkedDocTitle}` : undefined;
|
||||
doc.captureSync();
|
||||
const rootId = doc.addBlock('affine:page', {
|
||||
title: new window.$blocksuite.store.Text(),
|
||||
});
|
||||
const noteId = doc.addBlock('affine:note', {}, rootId);
|
||||
const databaseId = doc.addBlock(
|
||||
'affine:database',
|
||||
{
|
||||
title: new window.$blocksuite.store.Text('Calendar database'),
|
||||
},
|
||||
noteId
|
||||
);
|
||||
if (linkedDocId && linkedDocTitle) {
|
||||
const linkedDoc = window.collection.createDoc(linkedDocId).getStore();
|
||||
linkedDoc.load();
|
||||
const linkedRootId = linkedDoc.addBlock('affine:page', {
|
||||
title: new window.$blocksuite.store.Text(linkedDocTitle),
|
||||
});
|
||||
linkedDoc.addBlock('affine:surface', {}, linkedRootId);
|
||||
linkedDoc.addBlock('affine:note', {}, linkedRootId);
|
||||
}
|
||||
const rowIds = Array.from({ length: rows }, (_, index) => {
|
||||
const text =
|
||||
index === 0 && linkedDocId
|
||||
? new window.$blocksuite.store.Text([
|
||||
{
|
||||
insert: ' ',
|
||||
attributes: {
|
||||
reference: {
|
||||
type: 'LinkedPage',
|
||||
pageId: linkedDocId,
|
||||
},
|
||||
},
|
||||
},
|
||||
] as unknown as DeltaInsert[])
|
||||
: new window.$blocksuite.store.Text(`Task ${index + 1}`);
|
||||
return doc.addBlock(
|
||||
'affine:paragraph',
|
||||
{
|
||||
type: 'text',
|
||||
text,
|
||||
},
|
||||
databaseId
|
||||
);
|
||||
});
|
||||
const rowId = rowIds[0];
|
||||
const model = doc.getModelById(databaseId) as DatabaseBlockModel;
|
||||
const datasource =
|
||||
new window.$blocksuite.blocks.database.DatabaseBlockDataSource(model);
|
||||
const dateColumnId = withDateColumn
|
||||
? datasource.propertyAdd('end', {
|
||||
type: 'date',
|
||||
name: 'Date',
|
||||
})
|
||||
: undefined;
|
||||
const endDateColumnId = withEndDateColumn
|
||||
? datasource.propertyAdd('end', {
|
||||
type: 'date',
|
||||
name: 'End Date',
|
||||
})
|
||||
: undefined;
|
||||
for (const id of rowIds) {
|
||||
if (dateColumnId) {
|
||||
datasource.cellValueChange(id, dateColumnId, dateTimestamp);
|
||||
}
|
||||
if (endDateColumnId) {
|
||||
datasource.cellValueChange(id, endDateColumnId, endDateTimestamp);
|
||||
}
|
||||
}
|
||||
const viewId = datasource.viewManager.viewAdd('calendar');
|
||||
datasource.viewManager.setCurrentView(viewId);
|
||||
if (dateColumnId && mapDateColumn) {
|
||||
const view = datasource.viewManager.viewGet(viewId) as
|
||||
| {
|
||||
setDateColumn: (propertyId: string) => void;
|
||||
setEndDateColumn: (propertyId: string) => void;
|
||||
}
|
||||
| undefined;
|
||||
view?.setDateColumn(dateColumnId);
|
||||
if (endDateColumnId) {
|
||||
view?.setEndDateColumn(endDateColumnId);
|
||||
}
|
||||
}
|
||||
if (readonly) {
|
||||
doc.readonly = true;
|
||||
}
|
||||
doc.captureSync();
|
||||
return {
|
||||
databaseId,
|
||||
rowId,
|
||||
rowIds,
|
||||
dateColumnId,
|
||||
endDateColumnId,
|
||||
viewId,
|
||||
linkedDocId,
|
||||
monthAnchor,
|
||||
};
|
||||
},
|
||||
{ ...options, dateTimestamp, endDateTimestamp, monthAnchor }
|
||||
);
|
||||
};
|
||||
|
||||
test(scoped`database calendar setup and row interactions`, async ({ page }) => {
|
||||
await enterPlaygroundRoom(page);
|
||||
const ids = await createCalendarDatabase(page, {
|
||||
withDateColumn: true,
|
||||
mapDateColumn: false,
|
||||
});
|
||||
|
||||
const editorHost = getEditorHostLocator(page);
|
||||
await expect(editorHost.getByTestId('dv-calendar-view')).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole('button', { name: 'Select or create date property' })
|
||||
).toBeVisible();
|
||||
|
||||
await page
|
||||
.getByRole('button', { name: 'Select or create date property' })
|
||||
.click();
|
||||
await page.getByText('Date', { exact: true }).click();
|
||||
await expect(
|
||||
page.locator('.calendar-entry').filter({ hasText: 'Task 1' })
|
||||
).toBeVisible();
|
||||
|
||||
await page.locator('.calendar-entry').filter({ hasText: 'Task 1' }).click();
|
||||
await expect(page.locator('affine-data-view-record-detail')).toBeVisible();
|
||||
|
||||
await page.evaluate(({ databaseId, dateColumnId }) => {
|
||||
if (!dateColumnId) {
|
||||
throw new Error('dateColumnId is required');
|
||||
}
|
||||
const model = window.doc.getModelById(databaseId) as DatabaseBlockModel;
|
||||
const datasource =
|
||||
new window.$blocksuite.blocks.database.DatabaseBlockDataSource(model);
|
||||
datasource.propertyDelete(dateColumnId);
|
||||
}, ids);
|
||||
await expect(
|
||||
page.getByRole('button', { name: 'Select or create date property' })
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test(
|
||||
scoped`database calendar creates date property from setup`,
|
||||
async ({ page }) => {
|
||||
await enterPlaygroundRoom(page);
|
||||
await createCalendarDatabase(page);
|
||||
|
||||
await page
|
||||
.getByRole('button', { name: 'Select or create date property' })
|
||||
.click();
|
||||
await page.getByText('Create date property', { exact: true }).click();
|
||||
|
||||
await expect(
|
||||
page.getByRole('button', { name: 'Select or create date property' })
|
||||
).toBeHidden();
|
||||
}
|
||||
);
|
||||
|
||||
test(scoped`database calendar creates row from empty day`, async ({ page }) => {
|
||||
await enterPlaygroundRoom(page);
|
||||
const ids = await createCalendarDatabase(page, {
|
||||
withDateColumn: true,
|
||||
mapDateColumn: true,
|
||||
});
|
||||
|
||||
const targetDay = page
|
||||
.locator('.calendar-day')
|
||||
.filter({ has: page.locator('.calendar-day-number', { hasText: '20' }) })
|
||||
.first();
|
||||
await targetDay.hover();
|
||||
await targetDay.getByRole('button', { name: '+ New row' }).click();
|
||||
|
||||
await expect(page.locator('affine-data-view-record-detail')).toBeVisible();
|
||||
|
||||
const expectedDate = await getMonthTimestamp(page, ids.monthAnchor, 20);
|
||||
await expect
|
||||
.poll(() =>
|
||||
page.evaluate(
|
||||
({ databaseId, dateColumnId, expectedDate }) => {
|
||||
if (!dateColumnId) {
|
||||
throw new Error('dateColumnId is required');
|
||||
}
|
||||
const model = window.doc.getModelById(
|
||||
databaseId
|
||||
) as DatabaseBlockModel;
|
||||
const datasource =
|
||||
new window.$blocksuite.blocks.database.DatabaseBlockDataSource(
|
||||
model
|
||||
);
|
||||
return datasource.rows$.value.some(
|
||||
rowId =>
|
||||
datasource.cellValueGet(rowId, dateColumnId) === expectedDate
|
||||
);
|
||||
},
|
||||
{ ...ids, expectedDate }
|
||||
)
|
||||
)
|
||||
.toBe(true);
|
||||
});
|
||||
|
||||
test(
|
||||
scoped`database calendar opens linked doc row via row detail`,
|
||||
async ({ page }) => {
|
||||
await enterPlaygroundRoom(page);
|
||||
const ids = await createCalendarDatabase(page, {
|
||||
withDateColumn: true,
|
||||
mapDateColumn: true,
|
||||
linkedDocTitle: 'Calendar linked doc',
|
||||
});
|
||||
|
||||
await page.evaluate(({ databaseId }) => {
|
||||
const database = document.querySelector(
|
||||
`affine-database[data-block-id="${databaseId}"]`
|
||||
) as any;
|
||||
database.dataViewRootLogic.value.openDetailPanel = ({
|
||||
rowId,
|
||||
}: {
|
||||
rowId: string;
|
||||
}) => {
|
||||
(window as any).__calendarRowOpen = rowId;
|
||||
};
|
||||
}, ids);
|
||||
|
||||
const entry = page.locator('.calendar-entry.row').first();
|
||||
await expect(entry).toContainText('Calendar linked doc');
|
||||
await entry.click();
|
||||
|
||||
await expect
|
||||
.poll(() => page.evaluate(() => (window as any).__calendarRowOpen))
|
||||
.toBe(ids.rowId);
|
||||
}
|
||||
);
|
||||
|
||||
test(
|
||||
scoped`database calendar hides setup create action in readonly`,
|
||||
async ({ page }) => {
|
||||
await enterPlaygroundRoom(page);
|
||||
await createCalendarDatabase(page, { readonly: true });
|
||||
|
||||
await page
|
||||
.getByRole('button', { name: 'Select or create date property' })
|
||||
.click();
|
||||
|
||||
await expect(
|
||||
page.getByText('Create date property', { exact: true })
|
||||
).toBeHidden();
|
||||
|
||||
await page.evaluate(() => {
|
||||
window.doc.readonly = false;
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
test(scoped`database calendar shows all day entries`, async ({ page }) => {
|
||||
await enterPlaygroundRoom(page);
|
||||
await createCalendarDatabase(page, {
|
||||
withDateColumn: true,
|
||||
mapDateColumn: true,
|
||||
rowCount: 4,
|
||||
});
|
||||
|
||||
const may15 = page
|
||||
.locator('.calendar-day')
|
||||
.filter({ has: page.locator('.calendar-day-number', { hasText: '15' }) })
|
||||
.first();
|
||||
|
||||
await expect(may15.locator('.calendar-entry')).toHaveCount(4);
|
||||
await expect(may15.locator('.calendar-overflow')).toHaveCount(0);
|
||||
});
|
||||
|
||||
test(
|
||||
scoped`database calendar drag updates date cell and readonly disables drag`,
|
||||
async ({ page }) => {
|
||||
await enterPlaygroundRoom(page);
|
||||
const ids = await createCalendarDatabase(page, {
|
||||
withDateColumn: true,
|
||||
mapDateColumn: true,
|
||||
});
|
||||
await waitNextFrame(page);
|
||||
|
||||
const entry = page.locator('.calendar-entry').filter({ hasText: 'Task 1' });
|
||||
const targetDay = page
|
||||
.locator('.calendar-day')
|
||||
.filter({ has: page.locator('.calendar-day-number', { hasText: '20' }) })
|
||||
.first();
|
||||
await entry.dragTo(targetDay);
|
||||
|
||||
const expectedDate = await getMonthTimestamp(page, ids.monthAnchor, 20);
|
||||
await expect
|
||||
.poll(async () =>
|
||||
page.evaluate(({ databaseId, rowId, dateColumnId }) => {
|
||||
if (!dateColumnId) {
|
||||
throw new Error('dateColumnId is required');
|
||||
}
|
||||
const model = window.doc.getModelById(
|
||||
databaseId
|
||||
) as DatabaseBlockModel;
|
||||
const datasource =
|
||||
new window.$blocksuite.blocks.database.DatabaseBlockDataSource(
|
||||
model
|
||||
);
|
||||
return datasource.cellValueGet(rowId, dateColumnId);
|
||||
}, ids)
|
||||
)
|
||||
.toBe(expectedDate);
|
||||
|
||||
const readonlyIds = await createCalendarDatabase(page, {
|
||||
withDateColumn: true,
|
||||
mapDateColumn: true,
|
||||
readonly: true,
|
||||
});
|
||||
await waitNextFrame(page);
|
||||
const readonlyCalendar = page.getByTestId('dv-calendar-view').last();
|
||||
await expect(
|
||||
readonlyCalendar
|
||||
.locator('.calendar-entry')
|
||||
.filter({ hasText: 'Task 1' })
|
||||
.first()
|
||||
).toHaveAttribute('draggable', 'false');
|
||||
|
||||
await page.evaluate(() => {
|
||||
window.doc.readonly = false;
|
||||
});
|
||||
expect(readonlyIds.databaseId).toBeTruthy();
|
||||
}
|
||||
);
|
||||
|
||||
test(
|
||||
scoped`database calendar drags row range preserving duration`,
|
||||
async ({ page }) => {
|
||||
await enterPlaygroundRoom(page);
|
||||
const ids = await createCalendarDatabase(page, {
|
||||
withDateColumn: true,
|
||||
withEndDateColumn: true,
|
||||
mapDateColumn: true,
|
||||
});
|
||||
await waitNextFrame(page);
|
||||
|
||||
const entry = page
|
||||
.locator('.calendar-entry.row')
|
||||
.filter({ hasText: 'Task 1' })
|
||||
.first();
|
||||
const targetDay = page
|
||||
.locator('.calendar-day')
|
||||
.filter({ has: page.locator('.calendar-day-number', { hasText: '20' }) })
|
||||
.first();
|
||||
await entry.dragTo(targetDay);
|
||||
|
||||
const expectedStart = await getMonthTimestamp(page, ids.monthAnchor, 20);
|
||||
const expectedEnd = await getMonthTimestamp(page, ids.monthAnchor, 22);
|
||||
await expect
|
||||
.poll(() =>
|
||||
page.evaluate(
|
||||
({ databaseId, rowId, dateColumnId, endDateColumnId }) => {
|
||||
if (!dateColumnId || !endDateColumnId) {
|
||||
throw new Error('date columns are required');
|
||||
}
|
||||
const model = window.doc.getModelById(
|
||||
databaseId
|
||||
) as DatabaseBlockModel;
|
||||
const datasource =
|
||||
new window.$blocksuite.blocks.database.DatabaseBlockDataSource(
|
||||
model
|
||||
);
|
||||
return [
|
||||
datasource.cellValueGet(rowId, dateColumnId),
|
||||
datasource.cellValueGet(rowId, endDateColumnId),
|
||||
];
|
||||
},
|
||||
ids
|
||||
)
|
||||
)
|
||||
.toEqual([expectedStart, expectedEnd]);
|
||||
}
|
||||
);
|
||||
|
||||
test(scoped`database calendar resizes row range end date`, async ({ page }) => {
|
||||
await enterPlaygroundRoom(page);
|
||||
const ids = await createCalendarDatabase(page, {
|
||||
withDateColumn: true,
|
||||
withEndDateColumn: true,
|
||||
mapDateColumn: true,
|
||||
});
|
||||
await waitNextFrame(page);
|
||||
|
||||
const entry = page
|
||||
.locator('.calendar-entry.row')
|
||||
.filter({ hasText: 'Task 1' })
|
||||
.filter({ has: page.locator('.calendar-resize-handle.right') })
|
||||
.first();
|
||||
await entry.hover();
|
||||
const handle = entry.locator('.calendar-resize-handle.right');
|
||||
const targetDay = page
|
||||
.locator('.calendar-day')
|
||||
.filter({ has: page.locator('.calendar-day-number', { hasText: '20' }) })
|
||||
.first();
|
||||
const handleBox = await handle.boundingBox();
|
||||
const targetBox = await targetDay.boundingBox();
|
||||
if (!handleBox || !targetBox) {
|
||||
throw new Error('resize target is not visible');
|
||||
}
|
||||
|
||||
await page.mouse.move(
|
||||
handleBox.x + handleBox.width / 2,
|
||||
handleBox.y + handleBox.height / 2
|
||||
);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(targetBox.x + targetBox.width / 2, targetBox.y + 16);
|
||||
await page.mouse.up();
|
||||
|
||||
const expectedEnd = await getMonthTimestamp(page, ids.monthAnchor, 20);
|
||||
await expect
|
||||
.poll(() =>
|
||||
page.evaluate(({ databaseId, rowId, endDateColumnId }) => {
|
||||
if (!endDateColumnId) {
|
||||
throw new Error('endDateColumnId is required');
|
||||
}
|
||||
const model = window.doc.getModelById(databaseId) as DatabaseBlockModel;
|
||||
const datasource =
|
||||
new window.$blocksuite.blocks.database.DatabaseBlockDataSource(model);
|
||||
return datasource.cellValueGet(rowId, endDateColumnId);
|
||||
}, ids)
|
||||
)
|
||||
.toBe(expectedEnd);
|
||||
});
|
||||
Reference in New Issue
Block a user