feat(core): at menu journal entries (#8877) (#8935)

fix AF-1790
fix AF-1774
added `DateSelectorDialog` for selecting a date through blocksuite;
added `AtMenuConfigService` for constructing the at menu config
fix AF-1776
fix PD-1942

resubmitted to replace #8877
This commit is contained in:
pengx17
2024-11-27 03:08:11 +00:00
parent e3a8f1e9bd
commit 83c587f8ad
18 changed files with 965 additions and 272 deletions

View File

@@ -290,7 +290,7 @@ test('The reference links in the shared page should be accessible normally and c
const linkedPagePopover = page.locator('.linked-doc-popover');
await expect(linkedPagePopover).toBeVisible();
await page.keyboard.type('Test linked doc', { delay: 50 });
await page.keyboard.press('Enter');
await page.locator('icon-button:has-text("Test linked doc")').first().click();
// enable share page and copy page link
await enableShare(page);

View File

@@ -54,7 +54,7 @@ test('link page is useable', async ({ page }) => {
await page.keyboard.press('g');
await page.keyboard.press('e');
await page.keyboard.press('1');
await page.keyboard.press('Enter');
await page.locator('icon-button:has-text("page1")').first().click();
const link = page.locator('.affine-reference');
await expect(link).toBeVisible();
await page.click('.affine-reference');

View File

@@ -331,3 +331,90 @@ test('allow switching to embed view when linking to the other document with mode
url2.searchParams.delete('refreshKey');
expect(url.toJSON()).toStrictEqual(url2.toJSON());
});
test('@ popover should show today menu item', async ({ page }) => {
await page.keyboard.press('Enter');
await waitForEmptyEditor(page);
await page.keyboard.press('@');
await expect(page.locator('.linked-doc-popover')).toBeVisible();
const todayMenuItem = page.locator('.linked-doc-popover').getByText('Today');
await expect(todayMenuItem).toBeVisible();
const textContent = await todayMenuItem.locator('span').textContent();
await todayMenuItem.click();
const date = textContent?.trim();
// a affine-reference should be created with name date
await expect(
page.locator('affine-reference:has-text("' + date + '")')
).toBeVisible();
});
test('@ popover with input=tmr', async ({ page }) => {
await page.keyboard.press('Enter');
await waitForEmptyEditor(page);
await page.keyboard.press('@');
await page.keyboard.type('tmr');
await expect(page.locator('.linked-doc-popover')).toBeVisible();
const tomorrowMenuItem = page
.locator('.linked-doc-popover')
.getByText('Tomorrow');
await expect(tomorrowMenuItem).toBeVisible();
const textContent = await tomorrowMenuItem.locator('span').textContent();
await tomorrowMenuItem.click();
// a affine-reference should be created with name date
await expect(
page.locator('affine-reference:has-text("' + textContent + '")')
).toBeVisible();
});
test('@ popover with input=dec should create a reference with a December date', async ({
page,
}) => {
await page.keyboard.press('Enter');
await waitForEmptyEditor(page);
await page.keyboard.press('@');
await page.keyboard.type('dc');
const decemberMenuItem = page.locator(
'.linked-doc-popover icon-button:has-text("Dec")'
);
await expect(decemberMenuItem).toBeVisible();
const textContent = await decemberMenuItem
.locator('.text-container')
.textContent();
await decemberMenuItem.click();
// a affine-reference should be created with name date
await expect(
page.locator('affine-reference:has-text("' + textContent + '")')
).toBeVisible();
});
test('@ popover with click "select a specific date" should show a date picker', async ({
page,
}) => {
await page.keyboard.press('Enter');
await waitForEmptyEditor(page);
await page.keyboard.press('@');
const todayMenuItem = page.locator('.linked-doc-popover').getByText('Today');
await expect(todayMenuItem).toBeVisible();
const textContent = await todayMenuItem.locator('span').textContent();
const date = textContent?.trim();
await page.locator('icon-button:has-text("Select a specific date")').click();
await expect(
page.locator('[data-is-date-cell][data-is-today=true]')
).toBeVisible();
await page.locator('[data-is-date-cell][data-is-today=true]').click();
// a affine-reference should be created with name date
await expect(
page.locator('affine-reference:has-text("' + date + '")')
).toBeVisible();
});