mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-29 16:19:43 +08:00
feat(editor): improve status display in attachment embed view (#12180)
Closes: [BS-3438](https://linear.app/affine-design/issue/BS-3438/attachment-embed-view-中的-status-组件) Closes: [BS-3447](https://linear.app/affine-design/issue/BS-3447/触发-litportal-re-render) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a visual status indicator for embedded attachments with reload capability. - Added a new resource status component to display error messages and reload actions. - **Improvements** - Enhanced attachment rendering flow with reactive state and unified embed handling. - Simplified resource state and blob URL lifecycle management. - Added status visibility flags for PDF and video embeds. - **Bug Fixes** - Improved error handling and refresh support for embedded content including PDFs, videos, and audio. - **Style** - Added styles for the attachment embed status indicator positioning. - **Refactor** - Streamlined attachment and resource controller implementations for better maintainability. - **Tests** - Added end-to-end test verifying PDF viewer reload and re-rendering in embed mode. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -347,3 +347,42 @@ test('should enable pointer event in pdf viewer', async ({ page }) => {
|
||||
|
||||
await expect(attachmentSelection).toBeHidden();
|
||||
});
|
||||
|
||||
test('should re-render pdf viewer', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await clickNewPageButton(page);
|
||||
await waitForEmptyEditor(page);
|
||||
|
||||
const title = getBlockSuiteEditorTitle(page);
|
||||
await title.click();
|
||||
await page.keyboard.type('PDF preview');
|
||||
|
||||
await page.keyboard.press('Enter');
|
||||
|
||||
await importAttachment(page, 'lorem-ipsum.pdf');
|
||||
|
||||
const attachment = page.locator('affine-attachment');
|
||||
await attachment.click();
|
||||
|
||||
const toolbar = locateToolbar(page);
|
||||
|
||||
// Switches to embed view
|
||||
await toolbar.getByLabel('Switch view').click();
|
||||
await toolbar.getByLabel('Embed view').click();
|
||||
|
||||
const portal = attachment.locator('lit-react-portal');
|
||||
await expect(portal).toBeVisible();
|
||||
|
||||
const portalId = await portal.getAttribute('portalid');
|
||||
expect(portalId).not.toBeNull();
|
||||
|
||||
const moreMenu = toolbar.getByLabel('More menu');
|
||||
await moreMenu.click();
|
||||
|
||||
await toolbar.getByRole('button', { name: 'Reload' }).click();
|
||||
|
||||
const newPortalId = await portal.getAttribute('portalid');
|
||||
expect(newPortalId).not.toBeNull();
|
||||
|
||||
expect(portalId).not.toEqual(newPortalId);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user