mirror of https://github.com/logseq/logseq
add e2e test
parent
b69087c30a
commit
3a93799958
|
@ -85,33 +85,113 @@ test('delete and backspace', async ({ page, block }) => {
|
|||
})
|
||||
|
||||
|
||||
test('selection', async ({ page, block }) => {
|
||||
test('block selection', async ({ page, block }) => {
|
||||
await createRandomPage(page)
|
||||
|
||||
// add 5 blocks
|
||||
await block.mustFill('line 1')
|
||||
await block.mustFill('1')
|
||||
await block.enterNext()
|
||||
await block.mustFill('line 2')
|
||||
await block.enterNext()
|
||||
expect(await block.indent()).toBe(true)
|
||||
await block.mustFill('line 3')
|
||||
await block.enterNext()
|
||||
await block.mustFill('line 4')
|
||||
await block.mustFill('2')
|
||||
expect(await block.indent()).toBe(true)
|
||||
await block.enterNext()
|
||||
await block.mustFill('line 5')
|
||||
await block.mustFill('3')
|
||||
await block.enterNext()
|
||||
await block.mustFill('4')
|
||||
expect(await block.unindent()).toBe(true)
|
||||
await block.enterNext()
|
||||
await block.mustFill('5')
|
||||
expect(await block.indent()).toBe(true)
|
||||
await block.enterNext()
|
||||
await block.mustFill('6')
|
||||
await block.enterNext()
|
||||
await block.mustFill('7')
|
||||
expect(await block.unindent()).toBe(true)
|
||||
await block.enterNext()
|
||||
await block.mustFill('8')
|
||||
expect(await block.indent()).toBe(true)
|
||||
await block.enterNext()
|
||||
await block.mustFill('9')
|
||||
expect(await block.unindent()).toBe(true)
|
||||
|
||||
// shift+up select 3 blocks
|
||||
// shift+up/down
|
||||
await page.keyboard.down('Shift')
|
||||
await page.keyboard.press('ArrowUp')
|
||||
await block.waitForSelectedBlocks(1)
|
||||
var locator = page.locator('.ls-block >> nth=8')
|
||||
await expect(locator).toHaveAttribute('level', '1')
|
||||
await expect(locator).toHaveCSS('border-radius', '2px')
|
||||
await page.keyboard.press('ArrowUp')
|
||||
await block.waitForSelectedBlocks(2)
|
||||
locator = page.locator('.ls-block >> nth=7')
|
||||
await expect(locator).toHaveAttribute('level', '2')
|
||||
await expect(locator).toHaveCSS('border-radius', '2px')
|
||||
await page.keyboard.press('ArrowUp')
|
||||
await block.waitForSelectedBlocks(3)
|
||||
locator = page.locator('.ls-block >> nth=6')
|
||||
await expect(locator).toHaveAttribute('level', '1')
|
||||
locator = page.locator('.block-main-container >> nth=6')
|
||||
await expect(locator).toHaveCSS('border-radius', '2px')
|
||||
await page.keyboard.press('ArrowDown')
|
||||
await block.waitForSelectedBlocks(2)
|
||||
locator = page.locator('.block-main-container >> nth=6')
|
||||
await expect(locator).toHaveCSS('border-radius', '0px')
|
||||
await page.keyboard.up('Shift')
|
||||
|
||||
await block.waitForSelectedBlocks(3)
|
||||
await page.keyboard.press('Backspace')
|
||||
// mod+click select or deselect
|
||||
await page.keyboard.down(modKey)
|
||||
await page.click('.ls-block >> nth=7')
|
||||
await block.waitForSelectedBlocks(1)
|
||||
locator = page.locator('.ls-block >> nth=7')
|
||||
await expect(locator).toHaveCSS('border-radius', '0px')
|
||||
await page.click('.block-main-container >> nth=6')
|
||||
await block.waitForSelectedBlocks(2)
|
||||
locator = page.locator('.block-main-container >> nth=6')
|
||||
await expect(locator).toHaveCSS('border-radius', '2px')
|
||||
|
||||
await block.waitForBlocks(2)
|
||||
// mod+shift+click
|
||||
await page.click('.ls-block >> nth=4')
|
||||
await block.waitForSelectedBlocks(3)
|
||||
locator = page.locator('.ls-block >> nth=4')
|
||||
await expect(locator).toHaveAttribute('level', '2')
|
||||
await expect(locator).toHaveCSS('border-radius', '2px')
|
||||
await page.keyboard.down('Shift')
|
||||
await page.click('.ls-block >> nth=1')
|
||||
await block.waitForSelectedBlocks(6)
|
||||
locator = page.locator('.ls-block >> nth=3')
|
||||
await expect(locator).toHaveAttribute('level', '1')
|
||||
locator = page.locator('.block-main-container >> nth=3')
|
||||
await expect(locator).toHaveCSS('border-radius', '2px')
|
||||
locator = page.locator('.ls-block >> nth=2')
|
||||
await expect(locator).toHaveAttribute('level', '2')
|
||||
await expect(locator).toHaveCSS('border-radius', '2px')
|
||||
locator = page.locator('.ls-block >> nth=1')
|
||||
await expect(locator).toHaveAttribute('level', '2')
|
||||
await expect(locator).toHaveCSS('border-radius', '2px')
|
||||
await page.keyboard.up('Shift')
|
||||
await page.keyboard.up(modKey)
|
||||
await page.keyboard.press('Escape')
|
||||
|
||||
// shift+click
|
||||
await page.keyboard.down('Shift')
|
||||
await page.click('.block-main-container >> nth=0')
|
||||
await expect(page.locator('.block-main-container >> nth=0')).toHaveCSS('border-radius', '0px')
|
||||
await page.click('.block-main-container >> nth=3')
|
||||
await block.waitForSelectedBlocks(4)
|
||||
await expect(page.locator('.block-main-container >> nth=0')).toHaveCSS('border-radius', '2px')
|
||||
await expect(page.locator('.ls-block >> nth=1')).toHaveCSS('border-radius', '2px')
|
||||
await expect(page.locator('.ls-block >> nth=2')).toHaveCSS('border-radius', '2px')
|
||||
await expect(page.locator('.block-main-container >> nth=3')).toHaveCSS('border-radius', '2px')
|
||||
await page.click('.ls-block >> nth=8')
|
||||
await block.waitForSelectedBlocks(9)
|
||||
await expect(page.locator('.ls-block >> nth=4')).toHaveCSS('border-radius', '2px')
|
||||
await expect(page.locator('.ls-block >> nth=5')).toHaveCSS('border-radius', '2px')
|
||||
await expect(page.locator('.block-main-container >> nth=6')).toHaveCSS('border-radius', '2px')
|
||||
await expect(page.locator('.ls-block >> nth=7')).toHaveCSS('border-radius', '2px')
|
||||
await expect(page.locator('.ls-block >> nth=8')).toHaveCSS('border-radius', '2px')
|
||||
await page.click('.ls-block >> nth=5')
|
||||
await block.waitForSelectedBlocks(6)
|
||||
await expect(page.locator('.block-main-container >> nth=6')).toHaveCSS('border-radius', '0px')
|
||||
await expect(page.locator('.ls-block >> nth=7')).toHaveCSS('border-radius', '0px')
|
||||
await expect(page.locator('.ls-block >> nth=8')).toHaveCSS('border-radius', '0px')
|
||||
})
|
||||
|
||||
test('template', async ({ page, block }) => {
|
||||
|
|
Loading…
Reference in New Issue