flashcards.spec.ts 1.7 KB

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