Skip to content

Commit

Permalink
test(core): a simple e2e case for linked doc preview
Browse files Browse the repository at this point in the history
  • Loading branch information
pengx17 committed Nov 28, 2024
1 parent 64ed27f commit b5ce9ea
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export const title = style({
});

export const showButton = style({
width: '56px',
height: '28px',
borderRadius: '8px',
border: '1px solid ' + cssVar('--affine-border-color'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createReactComponentFromLit } from '@affine/component';
import { Button, createReactComponentFromLit } from '@affine/component';
import { TextRenderer } from '@affine/core/blocksuite/presets';
import {
type Backlink,
Expand Down Expand Up @@ -132,9 +132,11 @@ export const BiDirectionalLinkPanel = () => {

<div className={styles.titleLine}>
<div className={styles.title}>Bi-Directional Links</div>
<div className={styles.showButton} onClick={handleClickShow}>
{show ? 'Hide' : 'Show'}
</div>
<Button className={styles.showButton} onClick={handleClickShow}>
{show
? t['com.affine.editor.bi-directional-link-panel.hide']()
: t['com.affine.editor.bi-directional-link-panel.show']()}
</Button>
</div>

{show && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ async function crawlingDocData({
content: block.get('prop:latex')?.toString() ?? '',
yblock: block,
});
} else if (bookmarkFlavours.includes(flavour)) {
} else if (bookmarkFlavours.has(flavour)) {
blockDocuments.push({
docId,
flavour,
Expand Down
4 changes: 3 additions & 1 deletion packages/frontend/i18n/src/resources/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1486,5 +1486,7 @@
"com.affine.editor.at-menu.import": "Import",
"com.affine.editor.at-menu.more-docs-hint": "{{count}} more docs",
"com.affine.editor.at-menu.journal": "Journal",
"com.affine.editor.at-menu.date-picker": "Select a specific date"
"com.affine.editor.at-menu.date-picker": "Select a specific date",
"com.affine.editor.bi-directional-link-panel.show": "Show",
"com.affine.editor.bi-directional-link-panel.hide": "Hide"
}
29 changes: 29 additions & 0 deletions tests/affine-local/e2e/links.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { coreUrl, openHomePage } from '@affine-test/kit/utils/load-page';
import {
clickNewPageButton,
createLinkedPage,
getBlockSuiteEditorTitle,
waitForEmptyEditor,
} from '@affine-test/kit/utils/page-logic';
import { expect, type Locator } from '@playwright/test';
Expand Down Expand Up @@ -418,3 +419,31 @@ test('@ popover with click "select a specific date" should show a date picker',
page.locator('affine-reference:has-text("' + date + '")')
).toBeVisible();
});

test('linked doc should show markdown preview in the backlink section', async ({
page,
}) => {
await waitForEmptyEditor(page);
await page.keyboard.type('source page');
await page.keyboard.press('Enter');

await page.keyboard.type('some inline content');
await page.keyboard.press('Enter');

await createLinkedPage(page, 'Test Page');
await page.locator('affine-reference:has-text("Test Page")').click();

await expect(getBlockSuiteEditorTitle(page)).toHaveText('Test Page');
await page
.getByRole('button', {
name: 'Show',
})
.click();

await page.getByRole('button', { name: 'source page' }).click();

await expect(page.locator('text-renderer')).toContainText(
'some inline content'
);
await expect(page.locator('text-renderer')).toContainText('Test Page');
});

0 comments on commit b5ce9ea

Please sign in to comment.