Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AyushAgrawal-A2 committed Jan 23, 2024
1 parent e6971a3 commit 45d6126
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -990,8 +990,10 @@ export class EdgelessClipboardController extends PageClipboard {
block: TopLevelBlockModel,
isInFrame = false
) => {
let blockElement = blockElementGetter(block, this.std.view)
?.parentElement;
let blockElement = blockElementGetter(
block,
this.std.view
)?.parentElement;
const blockPortalSelector = block.flavour.replace(
'affine:',
'.edgeless-block-portal-'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,8 @@ export class EdgelessPageBlockComponent extends BlockElement<
_disposables.add(this.tools);
_disposables.add(this.service.selection);
_disposables.add(
slots.zoomUpdated.on(
(action: ZoomAction) =>
this.components.zoomToolbar?.setZoomByAction(action)
slots.zoomUpdated.on((action: ZoomAction) =>
this.components.zoomToolbar?.setZoomByAction(action)
)
);
_disposables.add(
Expand Down
33 changes: 25 additions & 8 deletions tests/attachment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function getAttachment(page: Page) {
};

const getName = () =>
attachment.locator('.affine-attachment-name').innerText();
attachment.locator('.affine-attachment-content-title-text').innerText();

return {
// locators
Expand All @@ -82,7 +82,8 @@ function getAttachment(page: Page) {
*/
waitLoading: () => loading.waitFor({ state: 'hidden' }),
getName,
getSize: () => attachment.locator('.affine-attachment-desc').innerText(),
getSize: () =>
attachment.locator('.affine-attachment-content-info').innerText(),

turnToEmbed: async () => {
await expect(turnToEmbedBtn).toBeVisible();
Expand Down Expand Up @@ -151,9 +152,12 @@ test('can insert attachment from slash menu', async ({ page }) => {
>
<affine:attachment
prop:embed={false}
prop:index="a0"
prop:name="${FILE_NAME}"
prop:rotate={0}
prop:size={${FILE_SIZE}}
prop:sourceId="${FILE_ID}"
prop:style="horizontalThin"
prop:type="image/png"
/>
</affine:note>`,
Expand Down Expand Up @@ -193,9 +197,12 @@ test('should undo/redo works for attachment', async ({ page }) => {
>
<affine:attachment
prop:embed={false}
prop:index="a0"
prop:name="${FILE_NAME}"
prop:rotate={0}
prop:size={${FILE_SIZE}}
prop:sourceId="${FILE_ID}"
prop:style="horizontalThin"
prop:type="image/png"
/>
</affine:note>`,
Expand Down Expand Up @@ -252,9 +259,12 @@ test('should undo/redo works for attachment', async ({ page }) => {
>
<affine:attachment
prop:embed={false}
prop:index="a0"
prop:name="${FILE_NAME}"
prop:rotate={0}
prop:size={${FILE_SIZE}}
prop:sourceId="${FILE_ID}"
prop:style="horizontalThin"
prop:type="image/png"
/>
</affine:note>`,
Expand Down Expand Up @@ -368,9 +378,12 @@ test('should turn attachment to image works', async ({ page }) => {
<affine:attachment
prop:caption=""
prop:embed={false}
prop:index="a0"
prop:name="${FILE_NAME}"
prop:rotate={0}
prop:size={${FILE_SIZE}}
prop:sourceId="${FILE_ID}"
prop:style="horizontalThin"
prop:type="image/png"
/>
</affine:note>`,
Expand Down Expand Up @@ -453,9 +466,12 @@ test(`support dragging attachment block directly`, async ({ page }) => {
>
<affine:attachment
prop:embed={false}
prop:index="a0"
prop:name="${FILE_NAME}"
prop:rotate={0}
prop:size={${FILE_SIZE}}
prop:sourceId="${FILE_ID}"
prop:style="horizontalThin"
prop:type="image/png"
/>
</affine:note>`,
Expand Down Expand Up @@ -504,9 +520,12 @@ test(`support dragging attachment block directly`, async ({ page }) => {
>
<affine:attachment
prop:embed={false}
prop:index="a0"
prop:name="${FILE_NAME}"
prop:rotate={0}
prop:size={${FILE_SIZE}}
prop:sourceId="${FILE_ID}"
prop:style="horizontalThin"
prop:type="image/png"
/>
<affine:paragraph
Expand All @@ -528,13 +547,8 @@ test(`support dragging attachment block directly`, async ({ page }) => {
// drag bookmark block
await page.mouse.move(rect.x + 20, rect.y + 20);
await page.mouse.down();
await page.waitForTimeout(200);

await page.mouse.move(rect.x + 40, rect.y + rect.height + 80);
await page.waitForTimeout(200);

await page.mouse.move(rect.x + 40, rect.y + rect.height + 80, { steps: 20 });
await page.mouse.up();
await page.waitForTimeout(200);

const rects = page.locator('affine-block-selection');
await expect(rects).toHaveCount(1);
Expand Down Expand Up @@ -568,9 +582,12 @@ test(`support dragging attachment block directly`, async ({ page }) => {
/>
<affine:attachment
prop:embed={false}
prop:index="a0"
prop:name="${FILE_NAME}"
prop:rotate={0}
prop:size={${FILE_SIZE}}
prop:sourceId="${FILE_ID}"
prop:style="horizontalThin"
prop:type="image/png"
/>
<affine:paragraph
Expand Down

0 comments on commit 45d6126

Please sign in to comment.