-
-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: keyboard controller should attach event on document (#8801)
- Loading branch information
Showing
4 changed files
with
76 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { expect } from '@playwright/test'; | ||
|
||
import { | ||
switchMultipleEditorsMode, | ||
toggleMultipleEditors, | ||
} from '../utils/actions/edgeless.js'; | ||
import { | ||
enterPlaygroundRoom, | ||
initEmptyEdgelessState, | ||
initThreeParagraphs, | ||
waitNextFrame, | ||
} from '../utils/actions/misc.js'; | ||
import { test } from '../utils/playwright.js'; | ||
|
||
test('the shift pressing status should effect all editors', async ({ | ||
page, | ||
}) => { | ||
await enterPlaygroundRoom(page); | ||
await initEmptyEdgelessState(page); | ||
await initThreeParagraphs(page); | ||
await toggleMultipleEditors(page); | ||
await switchMultipleEditorsMode(page); | ||
|
||
await waitNextFrame(page, 5000); | ||
|
||
const getShiftPressedStatus = async () => { | ||
return page.evaluate(() => { | ||
const edgelessBlocks = document.querySelectorAll('affine-edgeless-root'); | ||
|
||
return Array.from(edgelessBlocks).map(edgelessRoot => { | ||
return edgelessRoot.gfx.keyboard.shiftKey$.peek(); | ||
}); | ||
}); | ||
}; | ||
|
||
await page.keyboard.down('Shift'); | ||
const pressed = await getShiftPressedStatus(); | ||
expect(pressed).toEqual([true, true]); | ||
|
||
await page.keyboard.up('Shift'); | ||
const released = await getShiftPressedStatus(); | ||
expect(released).toEqual([false, false]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters