forked from logseq/logseq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flashcards.spec.ts
52 lines (39 loc) · 1.72 KB
/
flashcards.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { expect } from '@playwright/test'
import { test } from './fixtures'
import { createRandomPage } from './utils'
test('flashcard demo', async ({ page, block }) => {
await createRandomPage(page)
await block.mustFill('Why do you add cards? #card #logseq')
await block.enterNext()
expect(await block.indent()).toBe(true)
await block.mustFill('To augment our minds')
await block.enterNext()
expect(await block.unindent()).toBe(true)
expect(await block.unindent()).toBe(false)
await block.mustFill('How do you create clozes? #card #logseq')
await block.enterNext()
expect(await block.indent()).toBe(true)
await block.mustType('/clo')
const popupMenuItem = page.locator('.absolute >> text=Cloze')
await popupMenuItem.waitFor({ timeout: 1000 }) // wait for electric-input
await popupMenuItem.click({ delay: 10 })
await page.waitForTimeout(500)
await page.type('textarea >> nth=0', 'Something')
await page.keyboard.press('ArrowRight')
await page.keyboard.press('ArrowRight')
await page.type('textarea >> nth=0', ' like this')
await block.enterNext()
expect(await block.unindent()).toBe(true)
// navigate to another page, query cards
await createRandomPage(page)
await block.mustFill('{{cards [[logseq]]}}')
await page.keyboard.press('Enter')
const queryCards = page.locator('text="No matched cards"')
await queryCards.waitFor({ state: 'hidden', timeout: 6000 })
const numberLabel = page.locator('.cards-title')
await numberLabel.waitFor({ state: 'visible' })
expect(await numberLabel.innerText()).toMatch(/\[\[logseq\]\]\s+2\/2/)
// DO NOT check number label for now
//const cardsNum = page.locator('.flashcards-nav span >> nth=1')
//expect(await cardsNum.innerText()).toBe('2')
})