editor.spec.ts 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. import { expect } from '@playwright/test'
  2. import { test } from './fixtures'
  3. import { createRandomPage, enterNextBlock, modKey } from './utils'
  4. import { dispatch_kb_events } from './util/keyboard-events'
  5. import * as kb_events from './util/keyboard-events'
  6. test('hashtag and quare brackets in same line #4178', async ({ page }) => {
  7. await createRandomPage(page)
  8. await page.type('textarea >> nth=0', '#foo bar')
  9. await enterNextBlock(page)
  10. await page.type('textarea >> nth=0', 'bar [[blah]]', { delay: 100 })
  11. for (let i = 0; i < 12; i++) {
  12. await page.press('textarea >> nth=0', 'ArrowLeft')
  13. }
  14. await page.type('textarea >> nth=0', ' ')
  15. await page.press('textarea >> nth=0', 'ArrowLeft')
  16. await page.type('textarea >> nth=0', '#')
  17. await page.waitForSelector('text="Search for a page"', { state: 'visible' })
  18. await page.type('textarea >> nth=0', 'fo')
  19. await page.click('.absolute >> text=' + 'foo')
  20. expect(await page.inputValue('textarea >> nth=0')).toBe(
  21. '#foo bar [[blah]]'
  22. )
  23. })
  24. test('hashtag search page auto-complete', async ({ page, block }) => {
  25. await createRandomPage(page)
  26. await block.activeEditing(0)
  27. await page.type('textarea >> nth=0', '#', { delay: 100 })
  28. await page.waitForSelector('text="Search for a page"', { state: 'visible' })
  29. await page.keyboard.press('Escape', { delay: 50 })
  30. await block.mustFill("done")
  31. await enterNextBlock(page)
  32. await page.type('textarea >> nth=0', 'Some #', { delay: 100 })
  33. await page.waitForSelector('text="Search for a page"', { state: 'visible' })
  34. await page.keyboard.press('Escape', { delay: 50 })
  35. await block.mustFill("done")
  36. })
  37. test('hashtag search #[[ page auto-complete', async ({ page, block }) => {
  38. await createRandomPage(page)
  39. await block.activeEditing(0)
  40. await page.type('textarea >> nth=0', '#[[', { delay: 100 })
  41. await page.waitForSelector('text="Search for a page"', { state: 'visible' })
  42. await page.keyboard.press('Escape', { delay: 50 })
  43. })
  44. test('disappeared children #4814', async ({ page, block }) => {
  45. await createRandomPage(page)
  46. await block.mustType('parent')
  47. await block.enterNext()
  48. expect(await block.indent()).toBe(true)
  49. for (let i = 0; i < 5; i++) {
  50. await block.mustType(i.toString())
  51. await block.enterNext()
  52. }
  53. // collapse
  54. await page.click('.block-control >> nth=0')
  55. // expand
  56. await page.click('.block-control >> nth=0')
  57. await block.waitForBlocks(7) // 1 + 5 + 1 empty
  58. // Ensures there's no active editor
  59. await expect(page.locator('.editor-inner')).toHaveCount(0, { timeout: 500 })
  60. })
  61. test('create new page from bracketing text #4971', async ({ page, block }) => {
  62. let title = 'Page not Exists yet'
  63. await createRandomPage(page)
  64. await block.mustType(`[[${title}]]`)
  65. await page.keyboard.press(modKey + '+o')
  66. // Check page title equals to `title`
  67. await page.waitForTimeout(100)
  68. expect(await page.locator('h1.title').innerText()).toContain(title)
  69. // Check there're linked references
  70. await page.waitForSelector(`.references .ls-block >> nth=1`, { state: 'detached', timeout: 100 })
  71. })
  72. test.skip('backspace and cursor position #4897', async ({ page, block }) => {
  73. await createRandomPage(page)
  74. // Delete to previous block, and check cursor position, with markup
  75. await block.mustFill('`012345`')
  76. await block.enterNext()
  77. await block.mustType('`abcdef', { toBe: '`abcdef`' }) // "`" auto-completes
  78. expect(await block.selectionStart()).toBe(7)
  79. expect(await block.selectionEnd()).toBe(7)
  80. for (let i = 0; i < 7; i++) {
  81. await page.keyboard.press('ArrowLeft')
  82. }
  83. expect(await block.selectionStart()).toBe(0)
  84. await page.keyboard.press('Backspace')
  85. await block.waitForBlocks(1) // wait for delete and re-render
  86. expect(await block.selectionStart()).toBe(8)
  87. })
  88. test.skip('next block and cursor position', async ({ page, block }) => {
  89. await createRandomPage(page)
  90. // Press Enter and check cursor position, with markup
  91. await block.mustType('abcde`12345', { toBe: 'abcde`12345`' }) // "`" auto-completes
  92. for (let i = 0; i < 7; i++) {
  93. await page.keyboard.press('ArrowLeft')
  94. }
  95. expect(await block.selectionStart()).toBe(5) // after letter 'e'
  96. await block.enterNext()
  97. expect(await block.selectionStart()).toBe(0) // should at the beginning of the next block
  98. const locator = page.locator('textarea >> nth=0')
  99. await expect(locator).toHaveText('`12345`', { timeout: 1000 })
  100. })
  101. test(
  102. "Press CJK Left Black Lenticular Bracket `【` by 2 times #3251 should trigger [[]], " +
  103. "but dont trigger RIME #3440 ",
  104. // cases should trigger [[]] #3251
  105. async ({ page, block }) => {
  106. // This test requires dev mode
  107. test.skip(process.env.RELEASE === 'true', 'not available for release version')
  108. for (let [idx, events] of [
  109. kb_events.win10_pinyin_left_full_square_bracket,
  110. kb_events.macos_pinyin_left_full_square_bracket
  111. // TODO: support #3741
  112. // kb_events.win10_legacy_pinyin_left_full_square_bracket,
  113. ].entries()) {
  114. await createRandomPage(page)
  115. let check_text = "#3251 test " + idx
  116. await block.mustFill(check_text + "【")
  117. await dispatch_kb_events(page, ':nth-match(textarea, 1)', events)
  118. expect(await page.inputValue(':nth-match(textarea, 1)')).toBe(check_text + '【')
  119. await block.mustFill(check_text + "【【")
  120. await dispatch_kb_events(page, ':nth-match(textarea, 1)', events)
  121. expect(await page.inputValue(':nth-match(textarea, 1)')).toBe(check_text + '[[]]')
  122. };
  123. // dont trigger RIME #3440
  124. for (let [idx, events] of [
  125. kb_events.macos_pinyin_selecting_candidate_double_left_square_bracket,
  126. kb_events.win10_RIME_selecting_candidate_double_left_square_bracket
  127. ].entries()) {
  128. await createRandomPage(page)
  129. let check_text = "#3440 test " + idx
  130. await block.mustFill(check_text)
  131. await dispatch_kb_events(page, ':nth-match(textarea, 1)', events)
  132. expect(await page.inputValue(':nth-match(textarea, 1)')).toBe(check_text)
  133. await dispatch_kb_events(page, ':nth-match(textarea, 1)', events)
  134. expect(await page.inputValue(':nth-match(textarea, 1)')).toBe(check_text)
  135. }
  136. })
  137. test('copy & paste block ref and replace its content', async ({ page, block }) => {
  138. await createRandomPage(page)
  139. await block.mustType('Some random text')
  140. await page.keyboard.press(modKey + '+c')
  141. await page.press('textarea >> nth=0', 'Enter')
  142. await block.waitForBlocks(2)
  143. await page.waitForTimeout(100)
  144. await page.keyboard.press(modKey + '+v')
  145. await page.waitForTimeout(100)
  146. await page.keyboard.press('Enter')
  147. // Check if the newly created block-ref has the same referenced content
  148. await expect(page.locator('.block-ref >> text="Some random text"')).toHaveCount(1);
  149. // Move cursor into the block ref
  150. for (let i = 0; i < 4; i++) {
  151. await page.press('textarea >> nth=0', 'ArrowLeft')
  152. }
  153. await expect(page.locator('textarea >> nth=0')).not.toHaveValue('Some random text')
  154. // FIXME: Sometimes the cursor is in the end of the editor
  155. for (let i = 0; i < 4; i++) {
  156. await page.press('textarea >> nth=0', 'ArrowLeft')
  157. }
  158. // Trigger replace-block-reference-with-content-at-point
  159. await page.keyboard.press(modKey + '+Shift+r')
  160. await expect(page.locator('textarea >> nth=0')).toHaveValue('Some random text')
  161. await block.escapeEditing()
  162. await expect(page.locator('.block-ref >> text="Some random text"')).toHaveCount(0);
  163. await expect(page.locator('text="Some random text"')).toHaveCount(2);
  164. })
  165. test('copy and paste block after editing new block #5962', async ({ page, block }) => {
  166. await createRandomPage(page)
  167. // Create a block and copy it in block-select mode
  168. await block.mustType('Block being copied')
  169. await page.keyboard.press('Escape')
  170. await expect(page.locator('.ls-block.selected')).toHaveCount(1)
  171. await page.keyboard.press(modKey + '+c', { delay: 10 })
  172. await page.keyboard.press('Enter')
  173. await expect(page.locator('.ls-block.selected')).toHaveCount(0)
  174. await expect(page.locator('textarea >> nth=0')).toBeVisible()
  175. await page.keyboard.press('Enter')
  176. await block.waitForBlocks(2)
  177. await block.mustType('Typed block')
  178. await page.keyboard.press(modKey + '+v')
  179. await expect(page.locator('text="Typed block"')).toHaveCount(1)
  180. await block.waitForBlocks(3)
  181. })
  182. test('undo and redo after starting an action should not destroy text #6267', async ({ page, block }) => {
  183. await createRandomPage(page)
  184. // Get one piece of undo state onto the stack
  185. await block.mustType('text1 ')
  186. await page.waitForTimeout(500) // Wait for 500ms autosave period to expire
  187. // Then type more, start an action prompt, and undo
  188. await page.keyboard.type('text2 ', { delay: 50 })
  189. await page.keyboard.type('[[', { delay: 50 })
  190. await expect(page.locator(`[data-modal-name="page-search"]`)).toBeVisible()
  191. await page.keyboard.press(modKey + '+z')
  192. await page.waitForTimeout(100)
  193. // Should close the action menu when we undo the action prompt
  194. await expect(page.locator(`[data-modal-name="page-search"]`)).not.toBeVisible()
  195. // It should undo to the last saved state, and not erase the previous undo action too
  196. await expect(page.locator('text="text1"')).toHaveCount(1)
  197. // And it should keep what was undone as a redo action
  198. await page.keyboard.press(modKey + '+Shift+z')
  199. await expect(page.locator('text="text2"')).toHaveCount(1)
  200. })
  201. test('undo after starting an action should close the action menu #6269', async ({ page, block }) => {
  202. for (const [commandTrigger, modalName] of [['/', 'commands'], ['[[', 'page-search']]) {
  203. await createRandomPage(page)
  204. // Open the action modal
  205. await block.mustType('text1 ')
  206. await page.waitForTimeout(550)
  207. await page.keyboard.type(commandTrigger, { delay: 20 })
  208. await page.waitForTimeout(100) // Tolerable delay for the action menu to open
  209. await expect(page.locator(`[data-modal-name="${modalName}"]`)).toBeVisible()
  210. // Undo, removing "/today", and closing the action modal
  211. await page.keyboard.press(modKey + '+z')
  212. await page.waitForTimeout(100)
  213. await expect(page.locator('text="/today"')).toHaveCount(0)
  214. await expect(page.locator(`[data-modal-name="${modalName}"]`)).not.toBeVisible()
  215. }
  216. })
  217. test('#6266 moving cursor outside of brackets should close autocomplete menu', async ({ page, block, autocompleteMenu }) => {
  218. for (const [commandTrigger, modalName] of [['[[', 'page-search'], ['((', 'block-search']]) {
  219. // First, left arrow
  220. await createRandomPage(page)
  221. await block.mustFill('t ')
  222. await page.keyboard.type(commandTrigger, { delay: 20 })
  223. await page.waitForTimeout(100) // Sometimes it doesn't trigger without this
  224. await autocompleteMenu.expectVisible(modalName)
  225. await page.keyboard.press('ArrowLeft')
  226. await page.waitForTimeout(100)
  227. await autocompleteMenu.expectHidden(modalName)
  228. // Then, right arrow
  229. await createRandomPage(page)
  230. await block.mustFill('t ')
  231. await page.keyboard.type(commandTrigger, { delay: 20 })
  232. await autocompleteMenu.expectVisible(modalName)
  233. await page.waitForTimeout(100)
  234. // Move cursor outside of the space strictly between the double brackets
  235. await page.keyboard.press('ArrowRight')
  236. await page.waitForTimeout(100)
  237. await autocompleteMenu.expectHidden(modalName)
  238. }
  239. })
  240. // Old logic would fail this because it didn't do the check if @search-timeout was set
  241. test('#6266 moving cursor outside of parens immediately after searching should still close autocomplete menu', async ({ page, block, autocompleteMenu }) => {
  242. for (const [commandTrigger, modalName] of [['((', 'block-search']]) {
  243. await createRandomPage(page)
  244. // Open the autocomplete menu
  245. await block.mustFill('t ')
  246. await page.keyboard.type(commandTrigger, { delay: 20 })
  247. await page.waitForTimeout(100)
  248. await page.keyboard.type("some block search text")
  249. await page.waitForTimeout(100) // Sometimes it doesn't trigger without this
  250. await autocompleteMenu.expectVisible(modalName)
  251. // Move cursor outside of the space strictly between the double parens
  252. await page.keyboard.press('ArrowRight')
  253. await page.waitForTimeout(100)
  254. await autocompleteMenu.expectHidden(modalName)
  255. }
  256. })
  257. test('pressing up and down should NOT close autocomplete menu', async ({ page, block, autocompleteMenu }) => {
  258. for (const [commandTrigger, modalName] of [['[[', 'page-search'], ['((', 'block-search']]) {
  259. await createRandomPage(page)
  260. // Open the autocomplete menu
  261. await block.mustFill('t ')
  262. await page.keyboard.type(commandTrigger, { delay: 20 })
  263. await autocompleteMenu.expectVisible(modalName)
  264. const cursorPos = await block.selectionStart()
  265. await page.keyboard.press('ArrowUp')
  266. await page.waitForTimeout(100)
  267. await autocompleteMenu.expectVisible(modalName)
  268. await expect(await block.selectionStart()).toEqual(cursorPos)
  269. await page.keyboard.press('ArrowDown')
  270. await page.waitForTimeout(100)
  271. await autocompleteMenu.expectVisible(modalName)
  272. await expect(await block.selectionStart()).toEqual(cursorPos)
  273. }
  274. })
  275. test('moving cursor inside of brackets should NOT close autocomplete menu', async ({ page, block, autocompleteMenu }) => {
  276. for (const [commandTrigger, modalName] of [['[[', 'page-search'], ['((', 'block-search']]) {
  277. await createRandomPage(page)
  278. // Open the autocomplete menu
  279. await block.mustType('test ')
  280. await page.keyboard.type(commandTrigger, { delay: 20 })
  281. await page.waitForTimeout(100)
  282. if (commandTrigger === '[[') {
  283. await autocompleteMenu.expectVisible(modalName)
  284. }
  285. await page.keyboard.type("search", { delay: 20 })
  286. await autocompleteMenu.expectVisible(modalName)
  287. // Move cursor, still inside the brackets
  288. await page.keyboard.press('ArrowLeft')
  289. await page.waitForTimeout(100)
  290. await autocompleteMenu.expectVisible(modalName)
  291. }
  292. })
  293. test('moving cursor inside of brackets when autocomplete menu is closed should NOT open autocomplete menu', async ({ page, block, autocompleteMenu }) => {
  294. // Note: (( behaves differently and doesn't auto-trigger when typing in it after exiting the search prompt once
  295. for (const [commandTrigger, modalName] of [['[[', 'page-search']]) {
  296. await createRandomPage(page)
  297. // Open the autocomplete menu
  298. await block.mustFill('')
  299. await page.keyboard.type(commandTrigger, { delay: 20 })
  300. await page.waitForTimeout(100) // Sometimes it doesn't trigger without this
  301. await autocompleteMenu.expectVisible(modalName)
  302. await block.escapeEditing()
  303. await autocompleteMenu.expectHidden(modalName)
  304. // Move cursor left until it's inside the brackets; shouldn't open autocomplete menu
  305. await page.locator('.block-content').click()
  306. await page.waitForTimeout(100)
  307. await autocompleteMenu.expectHidden(modalName)
  308. await page.keyboard.press('ArrowLeft', { delay: 50 })
  309. await autocompleteMenu.expectHidden(modalName)
  310. await page.keyboard.press('ArrowLeft', { delay: 50 })
  311. await autocompleteMenu.expectHidden(modalName)
  312. // Type a letter, this should open the autocomplete menu
  313. await page.keyboard.type('z', { delay: 20 })
  314. await page.waitForTimeout(100)
  315. await autocompleteMenu.expectVisible(modalName)
  316. }
  317. })
  318. test('selecting text inside of brackets should NOT close autocomplete menu', async ({ page, block, autocompleteMenu }) => {
  319. for (const [commandTrigger, modalName] of [['[[', 'page-search'], ['((', 'block-search']]) {
  320. await createRandomPage(page)
  321. // Open the autocomplete menu
  322. await block.mustFill('')
  323. await page.keyboard.type(commandTrigger, { delay: 20 })
  324. await page.waitForTimeout(100)
  325. await autocompleteMenu.expectVisible(modalName)
  326. await page.keyboard.type("some page search text", { delay: 10 })
  327. await page.waitForTimeout(100)
  328. await autocompleteMenu.expectVisible(modalName)
  329. // Select some text within the brackets
  330. await page.keyboard.press('Shift+ArrowLeft')
  331. await page.waitForTimeout(100)
  332. await autocompleteMenu.expectVisible(modalName)
  333. }
  334. })
  335. test('pressing backspace and remaining inside of brackets should NOT close autocomplete menu', async ({ page, block, autocompleteMenu }) => {
  336. for (const [commandTrigger, modalName] of [['[[', 'page-search'], ['((', 'block-search']]) {
  337. await createRandomPage(page)
  338. // Open the autocomplete menu
  339. await block.mustFill('test ')
  340. await page.keyboard.type(commandTrigger, { delay: 20 })
  341. await page.waitForTimeout(100)
  342. await autocompleteMenu.expectVisible(modalName)
  343. await page.keyboard.type("some page search text", { delay: 10 })
  344. await page.waitForTimeout(100)
  345. await autocompleteMenu.expectVisible(modalName)
  346. // Delete one character inside the brackets
  347. await page.keyboard.press('Backspace')
  348. await page.waitForTimeout(100)
  349. await autocompleteMenu.expectVisible(modalName)
  350. }
  351. })
  352. test('press escape when autocomplete menu is open, should close autocomplete menu only #6270', async ({ page, block }) => {
  353. for (const [commandTrigger, modalName] of [['[[', 'page-search'], ['/', 'commands']]) {
  354. await createRandomPage(page)
  355. // Open the action modal
  356. await block.mustFill('text ')
  357. await page.waitForTimeout(550)
  358. await page.keyboard.type(commandTrigger, { delay: 20 })
  359. await page.waitForTimeout(100)
  360. await expect(page.locator(`[data-modal-name="${modalName}"]`)).toBeVisible()
  361. await page.waitForTimeout(100)
  362. // Press escape; should close action modal instead of exiting edit mode
  363. await page.keyboard.press('Escape')
  364. await page.waitForTimeout(100)
  365. await expect(page.locator(`[data-modal-name="${modalName}"]`)).not.toBeVisible()
  366. await page.waitForTimeout(1000)
  367. expect(await block.isEditing()).toBe(true)
  368. }
  369. })
  370. test('press escape when link/image dialog is open, should restore focus to input', async ({ page, block }) => {
  371. for (const [commandTrigger, modalName] of [['/link', 'commands']]) {
  372. await createRandomPage(page)
  373. // Open the action modal
  374. await block.mustFill('')
  375. await page.waitForTimeout(550)
  376. await page.keyboard.type(commandTrigger, { delay: 20 })
  377. await page.waitForTimeout(100)
  378. await expect(page.locator(`[data-modal-name="${modalName}"]`)).toBeVisible()
  379. await page.waitForTimeout(100)
  380. // Press enter to open the link dialog
  381. await page.keyboard.press('Enter')
  382. await expect(page.locator(`[data-modal-name="input"]`)).toBeVisible()
  383. // Press escape; should close link dialog and restore focus to the block textarea
  384. await page.keyboard.press('Escape')
  385. await page.waitForTimeout(100)
  386. await expect(page.locator(`[data-modal-name="input"]`)).not.toBeVisible()
  387. await page.waitForTimeout(1000)
  388. expect(await block.isEditing()).toBe(true)
  389. }
  390. })
  391. test('should show text after soft return when node is collapsed #5074', async ({ page, block }) => {
  392. const delay = 300
  393. await createRandomPage(page)
  394. await page.type('textarea >> nth=0', 'Before soft return', { delay: 10 })
  395. await page.keyboard.press('Shift+Enter', { delay: 10 })
  396. await page.type('textarea >> nth=0', 'After soft return', { delay: 10 })
  397. await block.enterNext()
  398. expect(await block.indent()).toBe(true)
  399. await block.mustType('Child text')
  400. // collapse
  401. await page.click('.block-control >> nth=0')
  402. await block.waitForBlocks(1)
  403. // select the block that has the soft return
  404. await page.keyboard.press('ArrowDown')
  405. await page.waitForTimeout(delay)
  406. await page.keyboard.press('Enter')
  407. await page.waitForTimeout(delay)
  408. await expect(page.locator('textarea >> nth=0')).toHaveText('Before soft return\nAfter soft return')
  409. // zoom into the block
  410. page.click('a.block-control + a')
  411. await page.waitForNavigation()
  412. await page.waitForTimeout(delay * 3)
  413. // select the block that has the soft return
  414. await page.keyboard.press('ArrowDown')
  415. await page.waitForTimeout(delay)
  416. await page.keyboard.press('Enter')
  417. await page.waitForTimeout(delay)
  418. await expect(page.locator('textarea >> nth=0')).toHaveText('Before soft return\nAfter soft return')
  419. })
  420. test('should not erase typed text when expanding block quickly after typing #3891', async ({ page, block }) => {
  421. await createRandomPage(page)
  422. await block.mustFill('initial text,')
  423. await page.waitForTimeout(500)
  424. await page.type('textarea >> nth=0', ' then expand', { delay: 10 })
  425. // A quick cmd-down must not destroy the typed text
  426. await page.keyboard.press(modKey + '+ArrowDown')
  427. await page.waitForTimeout(500)
  428. expect(await page.inputValue('textarea >> nth=0')).toBe(
  429. 'initial text, then expand'
  430. )
  431. // First undo should delete the last typed information, not undo a no-op expand action
  432. await page.keyboard.press(modKey + '+z')
  433. expect(await page.inputValue('textarea >> nth=0')).toBe(
  434. 'initial text,'
  435. )
  436. await page.keyboard.press(modKey + '+z')
  437. expect(await page.inputValue('textarea >> nth=0')).toBe(
  438. ''
  439. )
  440. })
  441. test('should keep correct undo and redo seq after indenting or outdenting the block #7615',async({page,block}) => {
  442. await createRandomPage(page)
  443. await block.mustFill("foo")
  444. await page.keyboard.press("Enter")
  445. await expect(page.locator('textarea >> nth=0')).toHaveText("")
  446. await block.indent()
  447. await block.mustFill("bar")
  448. await expect(page.locator('textarea >> nth=0')).toHaveText("bar")
  449. await page.keyboard.press(modKey + '+z')
  450. // should undo "bar" input
  451. await expect(page.locator('textarea >> nth=0')).toHaveText("")
  452. await page.keyboard.press(modKey + '+Shift+z')
  453. // should redo "bar" input
  454. await expect(page.locator('textarea >> nth=0')).toHaveText("bar")
  455. await page.keyboard.press("Shift+Tab")
  456. await page.keyboard.press("Enter")
  457. await expect(page.locator('textarea >> nth=0')).toHaveText("")
  458. // swap input seq
  459. await block.mustFill("baz")
  460. await block.indent()
  461. await page.keyboard.press(modKey + '+z')
  462. // should undo indention
  463. await expect(page.locator('textarea >> nth=0')).toHaveText("baz")
  464. await page.keyboard.press("Shift+Tab")
  465. await page.keyboard.press("Enter")
  466. await expect(page.locator('textarea >> nth=0')).toHaveText("")
  467. // #7615
  468. await page.keyboard.type("aaa")
  469. await block.indent()
  470. await page.keyboard.type(" bbb")
  471. await expect(page.locator('textarea >> nth=0')).toHaveText("aaa bbb")
  472. await page.keyboard.press(modKey + '+z')
  473. await expect(page.locator('textarea >> nth=0')).toHaveText("aaa")
  474. await page.keyboard.press(modKey + '+z')
  475. await expect(page.locator('textarea >> nth=0')).toHaveText("aaa")
  476. await page.keyboard.press(modKey + '+z')
  477. await expect(page.locator('textarea >> nth=0')).toHaveText("")
  478. await page.keyboard.press(modKey + '+Shift+z')
  479. await expect(page.locator('textarea >> nth=0')).toHaveText("aaa")
  480. await page.keyboard.press(modKey + '+Shift+z')
  481. await expect(page.locator('textarea >> nth=0')).toHaveText("aaa")
  482. await page.keyboard.press(modKey + '+Shift+z')
  483. await expect(page.locator('textarea >> nth=0')).toHaveText("aaa bbb")
  484. })