types.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { BrowserContext, ElectronApplication, Locator, Page } from '@playwright/test';
  2. /**
  3. * Block provides helper functions for Logseq's block testing.
  4. */
  5. export interface Block {
  6. /** Must fill some text into a block, use `textarea >> nth=0` as selector. */
  7. mustFill(value: string): Promise<void>;
  8. /**
  9. * Must type input some text into an **empty** block.
  10. * **DO NOT USE** this if there's auto-complete
  11. */
  12. mustType(value: string, options?: { delay?: number, toBe?: string }): Promise<void>;
  13. /**
  14. * Press Enter and go to next block, require cursor to be in current block(editing mode).
  15. * When cursor is not at the end of block, trailing text will be moved to the next block.
  16. */
  17. enterNext(): Promise<Locator>;
  18. /** Click `.add-button-link-wrap` and create the next block. */
  19. clickNext(): Promise<Locator>;
  20. /** Indent block, return whether it's success. */
  21. indent(): Promise<boolean>;
  22. /** Unindent block, return whether it's success. */
  23. unindent(): Promise<boolean>;
  24. /** Await for a certain number of blocks, with default timeout. */
  25. waitForBlocks(total: number): Promise<void>;
  26. /** Await for a certain number of selected blocks, with default timeout. */
  27. waitForSelectedBlocks(total: number): Promise<void>;
  28. /** Escape editing mode, modal popup and selection. */
  29. escapeEditing(): Promise<void>;
  30. /** Active block editing, by click */
  31. activeEditing(nth: number): Promise<void>;
  32. /** Is editing block now? */
  33. isEditing(): Promise<boolean>;
  34. /** Find current selectionStart, i.e. text cursor position. */
  35. selectionStart(): Promise<number>;
  36. /** Find current selectionEnd. */
  37. selectionEnd(): Promise<number>;
  38. }
  39. export interface autocompleteMenu {
  40. // Expect or wait for autocomplete menu to be or become visible
  41. expectVisible(modalName?: string): Promise<void>
  42. // Expect or wait for autocomplete menu to be or become hidden
  43. expectHidden(modalName?: string): Promise<void>
  44. }
  45. export interface LogseqFixtures {
  46. page: Page;
  47. block: Block;
  48. autocompleteMenu: autocompleteMenu;
  49. context: BrowserContext;
  50. app: ElectronApplication;
  51. graphDir: string;
  52. }