How to use page.keyboard.press method in qawolf

Best JavaScript code snippet using qawolf

writing-flow.test.js

Source:writing-flow.test.js Github

copy

Full Screen

...17const addParagraphsAndColumnsDemo = async () => {18 // Add demo content19 await clickBlockAppender();20 await page.keyboard.type( 'First paragraph' );21 await page.keyboard.press( 'Enter' );22 await page.keyboard.type( '/columns' );23 await page.waitForXPath(24 `//*[contains(@class, "components-autocomplete__result") and contains(@class, "is-selected") and contains(text(), 'Columns')]`25 );26 await page.keyboard.press( 'Enter' );27 await page.click( ':focus [aria-label="Two columns; equal split"]' );28 await page.click( ':focus .block-editor-button-block-appender' );29 await page.waitForSelector( '.block-editor-inserter__search input:focus' );30 await page.keyboard.type( 'Paragraph' );31 await pressKeyTimes( 'Tab', 2 ); // Tab to paragraph result.32 await page.keyboard.press( 'Enter' ); // Insert paragraph.33 await page.keyboard.type( '1st col' ); // If this text is too long, it may wrap to a new line and cause test failure. That's why we're using "1st" instead of "First" here.34 // TODO: ArrowDown should traverse into the second column. In slower35 // CPUs, it can sometimes remain in the first column paragraph. This36 // is a temporary solution.37 await page.focus( '.wp-block[data-type="core/column"]:nth-child(2)' );38 await page.click( ':focus .block-editor-button-block-appender' );39 await page.waitForSelector( '.block-editor-inserter__search input:focus' );40 await page.keyboard.type( 'Paragraph' );41 await pressKeyTimes( 'Tab', 2 ); // Tab to paragraph result.42 await page.keyboard.press( 'Enter' ); // Insert paragraph.43 await page.keyboard.type( '2nd col' ); // If this text is too long, it may wrap to a new line and cause test failure. That's why we're using "2nd" instead of "Second" here.44 await page.keyboard.press( 'Escape' ); // Enter navigation mode45 await page.keyboard.press( 'ArrowLeft' ); // move to the column block46 await page.keyboard.press( 'ArrowLeft' ); // move to the columns block47 await page.keyboard.press( 'Enter' ); // Enter edit mode with the columns block selected48 await page.keyboard.press( 'Enter' ); // Creates a paragraph after the columns block.49 await page.keyboard.type( 'Second paragraph' );50};51describe( 'Writing Flow', () => {52 beforeEach( async () => {53 await createNewPost();54 } );55 it( 'Should navigate inner blocks with arrow keys', async () => {56 // TODO: The `waitForSelector` calls in this function should ultimately57 // not be necessary for interactions, and exist as a stop-gap solution58 // where rendering delays in slower CPU can cause intermittent failure.59 // Assertions are made both against the active DOM element and the60 // editor state, in order to protect against potential disparities.61 //62 // See: https://github.com/WordPress/gutenberg/issues/1892863 let activeElementText, activeBlockName;64 // Add demo content65 await addParagraphsAndColumnsDemo();66 // Arrow up into nested context focuses last text input67 await page.keyboard.press( 'ArrowUp' );68 activeBlockName = await getActiveBlockName();69 expect( activeBlockName ).toBe( 'core/paragraph' );70 activeElementText = await page.evaluate(71 () => document.activeElement.textContent72 );73 expect( activeElementText ).toBe( '2nd col' );74 // Arrow up in inner blocks should navigate through (1) column wrapper,75 // (2) text fields.76 await page.keyboard.press( 'ArrowUp' );77 activeBlockName = await getActiveBlockName();78 expect( activeBlockName ).toBe( 'core/column' );79 await page.keyboard.press( 'ArrowUp' );80 const activeElementBlockType = await page.evaluate( () =>81 document.activeElement.getAttribute( 'data-type' )82 );83 expect( activeElementBlockType ).toBe( 'core/columns' );84 activeBlockName = await getActiveBlockName();85 expect( activeBlockName ).toBe( 'core/columns' );86 // Arrow up from focused (columns) block wrapper exits nested context87 // to prior text input.88 await page.keyboard.press( 'ArrowUp' );89 activeBlockName = await getActiveBlockName();90 expect( activeBlockName ).toBe( 'core/paragraph' );91 activeElementText = await page.evaluate(92 () => document.activeElement.textContent93 );94 expect( activeElementText ).toBe( 'First paragraph' );95 expect( await getEditedPostContent() ).toMatchSnapshot();96 } );97 it( 'Should navigate between inner and root blocks in navigation mode', async () => {98 // In navigation mode the active element is the block name button, so we can't easily check the block content.99 let activeBlockName;100 // Add demo content101 await addParagraphsAndColumnsDemo();102 // Switch to navigation mode103 await page.keyboard.press( 'Escape' );104 // Arrow up to Columns block105 await page.keyboard.press( 'ArrowUp' );106 activeBlockName = await getActiveBlockName();107 expect( activeBlockName ).toBe( 'core/columns' );108 // Arrow right into Column block109 await page.keyboard.press( 'ArrowRight' );110 activeBlockName = await getActiveBlockName();111 expect( activeBlockName ).toBe( 'core/column' );112 // Arrow down to reach second Column block113 await page.keyboard.press( 'ArrowDown' );114 // Arrow right again into Paragraph block115 await page.keyboard.press( 'ArrowRight' );116 activeBlockName = await getActiveBlockName();117 expect( activeBlockName ).toBe( 'core/paragraph' );118 // Arrow left back to Column block119 await page.keyboard.press( 'ArrowLeft' );120 activeBlockName = await getActiveBlockName();121 expect( activeBlockName ).toBe( 'core/column' );122 // Arrow left back to Columns block123 await page.keyboard.press( 'ArrowLeft' );124 activeBlockName = await getActiveBlockName();125 expect( activeBlockName ).toBe( 'core/columns' );126 // Arrow up to first paragraph127 await page.keyboard.press( 'ArrowUp' );128 activeBlockName = await getActiveBlockName();129 expect( activeBlockName ).toBe( 'core/paragraph' );130 } );131 it( 'should navigate around inline boundaries', async () => {132 // Add demo content133 await clickBlockAppender();134 await page.keyboard.type( 'First' );135 await page.keyboard.press( 'Enter' );136 await page.keyboard.type( 'Second' );137 await page.keyboard.press( 'Enter' );138 await page.keyboard.type( 'Third' );139 // Navigate to second paragraph140 await pressKeyTimes( 'ArrowLeft', 6 );141 // Bold second paragraph text142 await page.keyboard.down( 'Shift' );143 await pressKeyTimes( 'ArrowLeft', 6 );144 await page.keyboard.up( 'Shift' );145 await pressKeyWithModifier( 'primary', 'b' );146 // Arrow left from selected bold should collapse to before the inline147 // boundary. Arrow once more to traverse into first paragraph.148 await page.keyboard.press( 'ArrowLeft' );149 await page.keyboard.press( 'ArrowLeft' );150 await page.keyboard.type( 'After' );151 // Arrow right from end of first should traverse to second, *BEFORE*152 // the bolded text. Another press should move within inline boundary.153 await pressKeyTimes( 'ArrowRight', 2 );154 await page.keyboard.type( 'Inside' );155 // Arrow left from end of beginning of inline boundary should move to156 // the outside of the inline boundary.157 await pressKeyTimes( 'ArrowLeft', 6 );158 await page.keyboard.press( 'ArrowLeft' ); // Separate for emphasis.159 await page.keyboard.type( 'Before' );160 // Likewise, test at the end of the inline boundary for same effect.161 await page.keyboard.press( 'ArrowRight' ); // Move inside162 await pressKeyTimes( 'ArrowRight', 12 );163 await page.keyboard.type( 'Inside' );164 await page.keyboard.press( 'ArrowRight' );165 // Edge case: Verify that workaround to test for ZWSP at beginning of166 // focus node does not take effect when on the right edge of inline167 // boundary (thus preventing traversing to the next block by arrow).168 await page.keyboard.press( 'ArrowRight' );169 await page.keyboard.press( 'ArrowLeft' );170 // Should be after the inline boundary again.171 await page.keyboard.type( 'After' );172 // Finally, ensure that ArrowRight from end of unbolded text moves to173 // the last paragraph174 await page.keyboard.press( 'ArrowRight' );175 await page.keyboard.type( 'Before' );176 expect( await getEditedPostContent() ).toMatchSnapshot();177 } );178 it( 'should navigate around nested inline boundaries', async () => {179 await clickBlockAppender();180 await pressKeyWithModifier( 'primary', 'b' );181 await page.keyboard.type( '1 2' );182 await page.keyboard.down( 'Shift' );183 await page.keyboard.press( 'ArrowLeft' );184 await page.keyboard.up( 'Shift' );185 await pressKeyWithModifier( 'primary', 'i' );186 await page.keyboard.press( 'ArrowLeft' );187 await page.keyboard.press( 'ArrowLeft' );188 await page.keyboard.down( 'Shift' );189 await page.keyboard.press( 'ArrowLeft' );190 await page.keyboard.up( 'Shift' );191 await pressKeyWithModifier( 'primary', 'i' );192 await page.keyboard.press( 'ArrowLeft' );193 expect( await getEditedPostContent() ).toMatchSnapshot();194 await page.keyboard.type( 'a' );195 await page.keyboard.press( 'ArrowRight' );196 await page.keyboard.type( 'b' );197 await page.keyboard.press( 'ArrowRight' );198 await page.keyboard.type( 'c' );199 await page.keyboard.press( 'ArrowRight' );200 await page.keyboard.type( 'd' );201 await page.keyboard.press( 'ArrowRight' );202 await page.keyboard.type( 'e' );203 await page.keyboard.press( 'ArrowRight' );204 await page.keyboard.type( 'f' );205 await page.keyboard.press( 'ArrowRight' );206 await page.keyboard.type( 'g' );207 await page.keyboard.press( 'ArrowRight' );208 await page.keyboard.type( 'h' );209 await page.keyboard.press( 'ArrowRight' );210 await page.keyboard.type( 'i' );211 await page.keyboard.press( 'ArrowRight' );212 await page.keyboard.type( 'j' );213 expect( await getEditedPostContent() ).toMatchSnapshot();214 } );215 it( 'should insert line break at end', async () => {216 await clickBlockAppender();217 await page.keyboard.type( 'a' );218 await pressKeyWithModifier( 'shift', 'Enter' );219 expect( await getEditedPostContent() ).toMatchSnapshot();220 } );221 it( 'should insert line break at end and continue writing', async () => {222 await clickBlockAppender();223 await page.keyboard.type( 'a' );224 await pressKeyWithModifier( 'shift', 'Enter' );225 await page.keyboard.type( 'b' );226 expect( await getEditedPostContent() ).toMatchSnapshot();227 } );228 it( 'should insert line break mid text', async () => {229 await clickBlockAppender();230 await page.keyboard.type( 'ab' );231 await page.keyboard.press( 'ArrowLeft' );232 await pressKeyWithModifier( 'shift', 'Enter' );233 expect( await getEditedPostContent() ).toMatchSnapshot();234 } );235 it( 'should insert line break at start', async () => {236 await clickBlockAppender();237 await page.keyboard.type( 'a' );238 await page.keyboard.press( 'ArrowLeft' );239 await pressKeyWithModifier( 'shift', 'Enter' );240 expect( await getEditedPostContent() ).toMatchSnapshot();241 } );242 it( 'should insert line break in empty container', async () => {243 await clickBlockAppender();244 await pressKeyWithModifier( 'shift', 'Enter' );245 expect( await getEditedPostContent() ).toMatchSnapshot();246 } );247 it( 'should not create extra line breaks in multiline value', async () => {248 await insertBlock( 'Quote' );249 await page.keyboard.type( 'a' );250 await page.keyboard.press( 'Backspace' );251 expect( await getEditedPostContent() ).toMatchSnapshot();252 } );253 it( 'should navigate native inputs vertically, not horizontally', async () => {254 // See: https://github.com/WordPress/gutenberg/issues/9626255 await insertBlock( 'Shortcode' );256 await insertBlock( 'Paragraph' );257 await await page.click( '.wp-block-shortcode' );258 // Should remain in title upon ArrowRight:259 await page.keyboard.press( 'ArrowRight' );260 let isInShortcodeBlock = await page.evaluate(261 () => !! document.activeElement.closest( '.wp-block-shortcode' )262 );263 expect( isInShortcodeBlock ).toBe( true );264 // Should remain in title upon modifier + ArrowDown:265 await pressKeyWithModifier( 'primary', 'ArrowDown' );266 isInShortcodeBlock = await page.evaluate(267 () => !! document.activeElement.closest( '.wp-block-shortcode' )268 );269 expect( isInShortcodeBlock ).toBe( true );270 // Should navigate to the next block.271 await page.keyboard.press( 'ArrowDown' );272 const isInParagraphBlock = await page.evaluate(273 () => !! document.activeElement.closest( '.wp-block-paragraph' )274 );275 expect( isInParagraphBlock ).toBe( true );276 } );277 it( 'should not delete surrounding space when deleting a word with Backspace', async () => {278 await clickBlockAppender();279 await page.keyboard.type( '1 2 3' );280 await pressKeyTimes( 'ArrowLeft', ' 3'.length );281 await page.keyboard.press( 'Backspace' );282 expect( await getEditedPostContent() ).toMatchSnapshot();283 await page.keyboard.type( '2' );284 expect( await getEditedPostContent() ).toMatchSnapshot();285 } );286 it( 'should not delete surrounding space when deleting a word with Alt+Backspace', async () => {287 await clickBlockAppender();288 await page.keyboard.type( 'alpha beta gamma' );289 await pressKeyTimes( 'ArrowLeft', ' gamma'.length );290 if ( process.platform === 'darwin' ) {291 await pressKeyWithModifier( 'alt', 'Backspace' );292 } else {293 await pressKeyWithModifier( 'primary', 'Backspace' );294 }295 expect( await getEditedPostContent() ).toMatchSnapshot();296 await page.keyboard.type( 'beta' );297 expect( await getEditedPostContent() ).toMatchSnapshot();298 } );299 it( 'should not delete surrounding space when deleting a selected word', async () => {300 await clickBlockAppender();301 await page.keyboard.type( 'alpha beta gamma' );302 await pressKeyTimes( 'ArrowLeft', ' gamma'.length );303 await page.keyboard.down( 'Shift' );304 await pressKeyTimes( 'ArrowLeft', 'beta'.length );305 await page.keyboard.up( 'Shift' );306 await page.keyboard.press( 'Backspace' );307 expect( await getEditedPostContent() ).toMatchSnapshot();308 await page.keyboard.type( 'beta' );309 expect( await getEditedPostContent() ).toMatchSnapshot();310 } );311 it( 'should create valid paragraph blocks when rapidly pressing Enter', async () => {312 await clickBlockAppender();313 await pressKeyTimes( 'Enter', 10 );314 // Check that none of the paragraph blocks have <br> in them.315 expect( await getEditedPostContent() ).toMatchSnapshot();316 } );317 it( 'should navigate empty paragraph', async () => {318 await clickBlockAppender();319 await page.keyboard.press( 'Enter' );320 await page.keyboard.press( 'ArrowLeft' );321 await page.keyboard.type( '1' );322 await page.keyboard.press( 'ArrowRight' );323 await page.keyboard.type( '2' );324 expect( await getEditedPostContent() ).toMatchSnapshot();325 } );326 it( 'should navigate contenteditable with padding', async () => {327 await clickBlockAppender();328 await page.keyboard.press( 'Enter' );329 await page.evaluate( () => {330 document.activeElement.style.paddingTop = '100px';331 } );332 await page.keyboard.press( 'ArrowUp' );333 await page.keyboard.type( '1' );334 await page.evaluate( () => {335 document.activeElement.style.paddingBottom = '100px';336 } );337 await page.keyboard.press( 'ArrowDown' );338 await page.keyboard.type( '2' );339 expect( await getEditedPostContent() ).toMatchSnapshot();340 } );341 it( 'should navigate contenteditable with normal line height', async () => {342 await clickBlockAppender();343 await page.keyboard.press( 'Enter' );344 await page.evaluate( () => {345 document.activeElement.style.lineHeight = 'normal';346 } );347 await page.keyboard.press( 'ArrowUp' );348 await page.keyboard.type( '1' );349 expect( await getEditedPostContent() ).toMatchSnapshot();350 } );351 it( 'should not prematurely multi-select', async () => {352 await clickBlockAppender();353 await page.keyboard.type( '1' );354 await page.keyboard.press( 'Enter' );355 await page.keyboard.type( '><<' );356 await pressKeyWithModifier( 'shift', 'Enter' );357 await page.keyboard.type( '<<<' );358 await page.keyboard.down( 'Shift' );359 await pressKeyTimes( 'ArrowLeft', '<<\n<<<'.length );360 await page.keyboard.up( 'Shift' );361 await page.keyboard.press( 'Backspace' );362 expect( await getEditedPostContent() ).toMatchSnapshot();363 } );364 it( 'should merge paragraphs', async () => {365 await page.keyboard.press( 'Enter' );366 await page.keyboard.type( '1' );367 await page.keyboard.press( 'Enter' );368 await page.keyboard.type( '2' );369 await page.keyboard.press( 'ArrowLeft' );370 await page.keyboard.press( 'Backspace' );371 expect( await getEditedPostContent() ).toMatchSnapshot();372 } );373 it( 'should merge forwards', async () => {374 await page.keyboard.press( 'Enter' );375 await page.keyboard.type( '1' );376 await page.keyboard.press( 'Enter' );377 await page.keyboard.type( '3' );378 await page.keyboard.press( 'ArrowUp' );379 await page.keyboard.press( 'Delete' );380 await page.keyboard.type( '2' );381 expect( await getEditedPostContent() ).toMatchSnapshot();382 } );383 it( 'should preserve horizontal position when navigating vertically between blocks', async () => {384 await page.keyboard.press( 'Enter' );385 await page.keyboard.type( 'abc' );386 await page.keyboard.press( 'Enter' );387 await page.keyboard.type( '23' );388 await page.keyboard.press( 'ArrowUp' );389 await page.keyboard.press( 'ArrowLeft' );390 await page.keyboard.press( 'ArrowLeft' );391 await page.keyboard.press( 'ArrowDown' );392 await page.keyboard.type( '1' );393 expect( await getEditedPostContent() ).toMatchSnapshot();394 } );395 it( 'should remember initial vertical position', async () => {396 await page.keyboard.press( 'Enter' );397 await page.keyboard.type( '1' );398 await page.keyboard.press( 'Enter' );399 await pressKeyWithModifier( 'shift', 'Enter' );400 await page.keyboard.type( '2' );401 await page.keyboard.press( 'ArrowUp' );402 await page.keyboard.press( 'ArrowUp' );403 await page.keyboard.type( 'x' ); // Should be right after "1".404 expect( await getEditedPostContent() ).toMatchSnapshot();405 } );406 it( 'should navigate contenteditable with side padding', async () => {407 await clickBlockAppender();408 await page.keyboard.press( 'Enter' );409 await page.evaluate( () => {410 document.activeElement.style.paddingLeft = '100px';411 } );412 await page.keyboard.press( 'Enter' );413 await page.keyboard.press( 'ArrowUp' );414 await page.keyboard.press( 'ArrowUp' );415 await page.keyboard.type( '1' );416 expect( await getEditedPostContent() ).toMatchSnapshot();417 } );418 it( 'should navigate empty paragraphs', async () => {419 await page.keyboard.press( 'Enter' );420 await page.keyboard.press( 'Enter' );421 await page.keyboard.press( 'Enter' );422 await page.keyboard.press( 'ArrowLeft' );423 await page.keyboard.press( 'ArrowLeft' );424 await page.keyboard.type( '1' );425 await page.keyboard.press( 'ArrowRight' );426 await page.keyboard.press( 'ArrowRight' );427 await page.keyboard.type( '3' );428 expect( await getEditedPostContent() ).toMatchSnapshot();429 } );430 it( 'should allow selecting entire list with longer last item', async () => {431 await page.keyboard.press( 'Enter' );432 await page.keyboard.type( 'a' );433 await page.keyboard.press( 'Enter' );434 await page.keyboard.type( '* b' );435 await page.keyboard.press( 'Enter' );436 await page.keyboard.type( 'cd' );437 await pressKeyWithModifier( 'shift', 'ArrowUp' );438 await pressKeyWithModifier( 'shift', 'ArrowUp' );439 // Ensure multi selection is not triggered and selection stays within440 // the list.441 await page.keyboard.press( 'Backspace' );442 expect( await getEditedPostContent() ).toMatchSnapshot();443 } );444 it( 'should not have a dead zone between blocks (lower)', async () => {445 await page.keyboard.press( 'Enter' );446 await page.keyboard.type( '1' );447 await page.keyboard.press( 'Enter' );448 await page.keyboard.type( '2' );449 await page.keyboard.press( 'ArrowUp' );450 // Find a point outside the paragraph between the blocks where it's451 // expected that the sibling inserter would be placed.452 const paragraph = await page.$( '[data-type="core/paragraph"]' );453 const paragraphRect = await paragraph.boundingBox();454 const x = paragraphRect.x + ( 2 * paragraphRect.width ) / 3;455 const y = paragraphRect.y + paragraphRect.height + 1;456 await page.mouse.move( x, y );457 await page.waitForSelector(458 '.block-editor-block-list__insertion-point'459 );460 const inserter = await page.$(461 '.block-editor-block-list__insertion-point'462 );463 const inserterRect = await inserter.boundingBox();464 const lowerInserterY = inserterRect.y + ( 2 * inserterRect.height ) / 3;465 await page.mouse.click( x, lowerInserterY );466 await page.keyboard.type( '3' );467 expect( await getEditedPostContent() ).toMatchSnapshot();468 } );469 it( 'should not have a dead zone above an aligned block', async () => {470 await page.keyboard.press( 'Enter' );471 await page.keyboard.type( '1' );472 await page.keyboard.press( 'Enter' );473 await page.keyboard.type( '/image' );474 await page.keyboard.press( 'Enter' );475 await clickBlockToolbarButton( 'Align' );476 const wideButton = await page.waitForXPath(477 `//button[contains(@class,'components-dropdown-menu__menu-item')]//span[contains(text(), 'Wide width')]`478 );479 await wideButton.click();480 // Select the previous block.481 await page.keyboard.press( 'ArrowUp' );482 // Confirm correct setup.483 expect( await getEditedPostContent() ).toMatchSnapshot();484 // Find a point outside the paragraph between the blocks where it's485 // expected that the sibling inserter would be placed.486 const paragraph = await page.$( '[data-type="core/paragraph"]' );487 const paragraphRect = await paragraph.boundingBox();488 const x = paragraphRect.x + ( 2 * paragraphRect.width ) / 3;489 const y = paragraphRect.y + paragraphRect.height + 1;490 await page.mouse.move( x, y );491 await page.waitForSelector(492 '.block-editor-block-list__insertion-point'493 );494 const inserter = await page.$(495 '.block-editor-block-list__insertion-point'496 );497 const inserterRect = await inserter.boundingBox();498 const lowerInserterY = inserterRect.y + ( 2 * inserterRect.height ) / 3;499 await page.mouse.click( x, lowerInserterY );500 const type = await page.evaluate( () =>501 document.activeElement.getAttribute( 'data-type' )502 );503 expect( type ).toBe( 'core/image' );504 } );505 it( 'should only consider the content as one tab stop', async () => {506 await page.keyboard.press( 'Enter' );507 await page.keyboard.type( '/table' );508 await page.keyboard.press( 'Enter' );509 // Move into the placeholder UI.510 await page.keyboard.press( 'ArrowDown' );511 // Tab to the "Create table" button.512 await page.keyboard.press( 'Tab' );513 await page.keyboard.press( 'Tab' );514 // Create the table.515 await page.keyboard.press( 'Space' );516 // Return focus after focus loss. This should be fixed.517 await page.keyboard.press( 'Tab' );518 // Navigate to the second cell.519 await page.keyboard.press( 'ArrowRight' );520 await page.keyboard.type( '2' );521 // Confirm correct setup.522 expect( await getEditedPostContent() ).toMatchSnapshot();523 // The content should only have one tab stop.524 await page.keyboard.press( 'Tab' );525 expect(526 await page.evaluate( () =>527 document.activeElement.getAttribute( 'aria-label' )528 )529 ).toBe( 'Post' );530 await pressKeyWithModifier( 'shift', 'Tab' );531 await pressKeyWithModifier( 'shift', 'Tab' );532 expect(533 await page.evaluate( () =>534 document.activeElement.getAttribute( 'aria-label' )535 )536 ).toBe( 'Table' );537 } );538 it( 'Should unselect all blocks when hitting double escape', async () => {539 // Add demo content.540 await page.keyboard.press( 'Enter' );541 await page.keyboard.type( 'Random Paragraph' );542 // Select a block.543 let activeBlockName = await getActiveBlockName();544 expect( activeBlockName ).toBe( 'core/paragraph' );545 // First escape enters navigaiton mode.546 await page.keyboard.press( 'Escape' );547 activeBlockName = await getActiveBlockName();548 expect( activeBlockName ).toBe( 'core/paragraph' );549 // Second escape unselects the blocks.550 await page.keyboard.press( 'Escape' );551 activeBlockName = await getActiveBlockName();552 expect( activeBlockName ).toBe( undefined );553 } );...

Full Screen

Full Screen

list.test.js

Source:list.test.js Github

copy

Full Screen

...20 // Create a block with some text that will trigger a list creation.21 await clickBlockAppender();22 await page.keyboard.type( '* A list item' );23 // Create a second list item.24 await page.keyboard.press( 'Enter' );25 await page.keyboard.type( 'Another list item' );26 expect( await getEditedPostContent() ).toMatchSnapshot();27 } );28 it( 'can be created by typing an asterisk in front of text of a paragraph block', async () => {29 // Create a list with the slash block shortcut.30 await clickBlockAppender();31 await page.keyboard.type( 'test' );32 await pressKeyTimes( 'ArrowLeft', 4 );33 await page.keyboard.type( '* ' );34 expect( await getEditedPostContent() ).toMatchSnapshot();35 } );36 it( 'can be created by using a number at the start of a paragraph block', async () => {37 // Create a block with some text that will trigger a list creation.38 await clickBlockAppender();39 await page.keyboard.type( '1) A list item' );40 expect( await getEditedPostContent() ).toMatchSnapshot();41 } );42 it( 'can undo asterisk transform', async () => {43 await clickBlockAppender();44 await page.keyboard.type( '1. ' );45 await pressKeyWithModifier( 'primary', 'z' );46 expect( await getEditedPostContent() ).toMatchSnapshot();47 } );48 it( 'should undo asterisk transform with backspace', async () => {49 await clickBlockAppender();50 await page.keyboard.type( '* ' );51 await page.keyboard.press( 'Backspace' );52 expect( await getEditedPostContent() ).toMatchSnapshot();53 } );54 it( 'should undo asterisk transform with backspace after selection changes', async () => {55 await clickBlockAppender();56 await page.keyboard.type( '* ' );57 await page.evaluate( () => new Promise( window.requestIdleCallback ) );58 await page.keyboard.press( 'Backspace' );59 expect( await getEditedPostContent() ).toMatchSnapshot();60 } );61 it( 'should undo asterisk transform with backspace setting isTyping state', async () => {62 await clickBlockAppender();63 await page.keyboard.type( '* ' );64 await showBlockToolbar();65 await page.keyboard.press( 'Backspace' );66 expect( await getEditedPostContent() ).toMatchSnapshot();67 } );68 it( 'should undo asterisk transform with backspace after selection changes without requestIdleCallback', async () => {69 await clickBlockAppender();70 await page.evaluate( () => delete window.requestIdleCallback );71 await page.keyboard.type( '* ' );72 await new Promise( ( resolve ) => setTimeout( resolve, 100 ) );73 await page.keyboard.press( 'Backspace' );74 expect( await getEditedPostContent() ).toMatchSnapshot();75 } );76 it( 'should undo asterisk transform with escape', async () => {77 await clickBlockAppender();78 await page.keyboard.type( '* ' );79 await page.keyboard.press( 'Escape' );80 expect( await getEditedPostContent() ).toMatchSnapshot();81 } );82 it( 'should not undo asterisk transform with backspace after typing', async () => {83 await clickBlockAppender();84 await page.keyboard.type( '* a' );85 await page.keyboard.press( 'Backspace' );86 await page.keyboard.press( 'Backspace' );87 expect( await getEditedPostContent() ).toMatchSnapshot();88 } );89 it( 'should not undo asterisk transform with backspace after selection change', async () => {90 await clickBlockAppender();91 await page.keyboard.press( 'Enter' );92 await page.keyboard.type( '* ' );93 await page.evaluate( () => new Promise( window.requestIdleCallback ) );94 await page.keyboard.press( 'ArrowUp' );95 await page.keyboard.press( 'ArrowDown' );96 await page.keyboard.press( 'Backspace' );97 // Expect list to be deleted98 expect( await getEditedPostContent() ).toMatchSnapshot();99 } );100 it( 'can be created by typing "/list"', async () => {101 // Create a list with the slash block shortcut.102 await clickBlockAppender();103 await page.keyboard.type( '/list' );104 await page.waitForXPath(105 `//*[contains(@class, "components-autocomplete__result") and contains(@class, "is-selected") and contains(text(), 'List')]`106 );107 await page.keyboard.press( 'Enter' );108 await page.keyboard.type( 'I’m a list' );109 expect( await getEditedPostContent() ).toMatchSnapshot();110 } );111 it( 'can be created by converting a paragraph', async () => {112 await clickBlockAppender();113 await page.keyboard.type( 'test' );114 await transformBlockTo( 'List' );115 expect( await getEditedPostContent() ).toMatchSnapshot();116 } );117 it( 'can be created by converting multiple paragraphs', async () => {118 await clickBlockAppender();119 await page.keyboard.type( 'one' );120 await page.keyboard.press( 'Enter' );121 await page.keyboard.type( 'two' );122 await page.keyboard.down( 'Shift' );123 await page.click( '[data-type="core/paragraph"]' );124 await page.keyboard.up( 'Shift' );125 await transformBlockTo( 'List' );126 expect( await getEditedPostContent() ).toMatchSnapshot();127 } );128 it( 'can be created by converting a paragraph with line breaks', async () => {129 await clickBlockAppender();130 await page.keyboard.type( 'one' );131 await pressKeyWithModifier( 'shift', 'Enter' );132 await page.keyboard.type( 'two' );133 await transformBlockTo( 'List' );134 expect( await getEditedPostContent() ).toMatchSnapshot();135 } );136 it( 'should not transform lines in block when transforming multiple blocks', async () => {137 await clickBlockAppender();138 await page.keyboard.type( 'one' );139 await pressKeyWithModifier( 'shift', 'Enter' );140 await page.keyboard.type( '...' );141 await page.keyboard.press( 'Enter' );142 await page.keyboard.type( 'two' );143 await page.keyboard.down( 'Shift' );144 await page.click( '[data-type="core/paragraph"]' );145 await page.keyboard.up( 'Shift' );146 await transformBlockTo( 'List' );147 expect( await getEditedPostContent() ).toMatchSnapshot();148 } );149 it( 'can be converted to paragraphs', async () => {150 await insertBlock( 'List' );151 await page.keyboard.type( 'one' );152 await page.keyboard.press( 'Enter' );153 await page.keyboard.type( 'two' );154 await transformBlockTo( 'Paragraph' );155 expect( await getEditedPostContent() ).toMatchSnapshot();156 } );157 it( 'can be converted when nested to paragraphs', async () => {158 await insertBlock( 'List' );159 await page.keyboard.type( 'one' );160 await page.keyboard.press( 'Enter' );161 await clickBlockToolbarButton( 'Indent' );162 await page.keyboard.type( 'two' );163 await transformBlockTo( 'Paragraph' );164 expect( await getEditedPostContent() ).toMatchSnapshot();165 } );166 it( 'can be created by converting a quote', async () => {167 await insertBlock( 'Quote' );168 await page.keyboard.type( 'one' );169 await page.keyboard.press( 'Enter' );170 await page.keyboard.type( 'two' );171 await transformBlockTo( 'List' );172 expect( await getEditedPostContent() ).toMatchSnapshot();173 } );174 it( 'can be converted to a quote', async () => {175 await insertBlock( 'List' );176 await page.keyboard.type( 'one' );177 await page.keyboard.press( 'Enter' );178 await page.keyboard.type( 'two' );179 await transformBlockTo( 'Quote' );180 expect( await getEditedPostContent() ).toMatchSnapshot();181 } );182 it( 'should create paragraph on split at end and merge back with content', async () => {183 await insertBlock( 'List' );184 await page.keyboard.type( 'one' );185 await page.keyboard.press( 'Enter' );186 await page.keyboard.press( 'Enter' );187 expect( await getEditedPostContent() ).toMatchSnapshot();188 await page.keyboard.type( 'two' );189 await pressKeyTimes( 'ArrowLeft', 'two'.length );190 await page.keyboard.press( 'Backspace' );191 expect( await getEditedPostContent() ).toMatchSnapshot();192 } );193 it( 'should split into two with paragraph and merge lists', async () => {194 await insertBlock( 'List' );195 await page.keyboard.type( 'one' );196 await page.keyboard.press( 'Enter' );197 await page.keyboard.type( 'two' );198 await page.keyboard.press( 'ArrowUp' );199 await page.keyboard.press( 'Enter' );200 expect( await getEditedPostContent() ).toMatchSnapshot();201 await page.keyboard.press( 'Enter' );202 expect( await getEditedPostContent() ).toMatchSnapshot();203 // Should remove paragraph without creating empty list item.204 await page.keyboard.press( 'Backspace' );205 // Should merge lists into one.206 await page.keyboard.press( 'ArrowDown' );207 await pressKeyTimes( 'ArrowLeft', 'two'.length );208 expect( await getEditedPostContent() ).toMatchSnapshot();209 } );210 it( 'should split into two ordered lists with paragraph', async () => {211 await clickBlockAppender();212 await page.keyboard.type( '1. one' );213 await page.keyboard.press( 'Enter' );214 await page.keyboard.type( 'two' );215 await page.keyboard.press( 'ArrowUp' );216 await page.keyboard.press( 'Enter' );217 await page.keyboard.press( 'Enter' );218 expect( await getEditedPostContent() ).toMatchSnapshot();219 } );220 it( 'should split indented list item', async () => {221 await insertBlock( 'List' );222 await page.keyboard.type( 'one' );223 await page.keyboard.press( 'Enter' );224 await clickBlockToolbarButton( 'Indent' );225 await page.keyboard.type( 'two' );226 await page.keyboard.press( 'Enter' );227 await page.keyboard.type( 'three' );228 expect( await getEditedPostContent() ).toMatchSnapshot();229 } );230 it( 'should be immeadiately saved on indentation', async () => {231 await insertBlock( 'List' );232 await page.keyboard.type( 'one' );233 await page.keyboard.press( 'Enter' );234 await pressKeyWithModifier( 'primary', 'm' );235 expect( await getEditedPostContent() ).toMatchSnapshot();236 } );237 it( 'should change the base list type', async () => {238 await insertBlock( 'List' );239 const button = await page.waitForSelector(240 'button[aria-label="Ordered"]'241 );242 await button.click();243 expect( await getEditedPostContent() ).toMatchSnapshot();244 } );245 it( 'should change the indented list type', async () => {246 await insertBlock( 'List' );247 await page.keyboard.type( 'a' );248 await page.keyboard.press( 'Enter' );249 await pressKeyWithModifier( 'primary', 'm' );250 await page.keyboard.type( '1' );251 await clickBlockToolbarButton( 'Ordered' );252 expect( await getEditedPostContent() ).toMatchSnapshot();253 } );254 it( 'should indent and outdent level 1', async () => {255 await insertBlock( 'List' );256 await page.keyboard.type( 'a' );257 await page.keyboard.press( 'Enter' );258 await pressKeyWithModifier( 'primary', 'm' );259 await page.keyboard.type( '1' );260 expect( await getEditedPostContent() ).toMatchSnapshot();261 await pressKeyWithModifier( 'primaryShift', 'm' );262 expect( await getEditedPostContent() ).toMatchSnapshot();263 } );264 it( 'should indent and outdent level 2', async () => {265 await insertBlock( 'List' );266 await page.keyboard.type( 'a' );267 await page.keyboard.press( 'Enter' );268 await pressKeyWithModifier( 'primary', 'm' );269 await page.keyboard.type( '1' );270 await page.keyboard.press( 'Enter' );271 await pressKeyWithModifier( 'primary', 'm' );272 await page.keyboard.type( 'i' );273 expect( await getEditedPostContent() ).toMatchSnapshot();274 await pressKeyWithModifier( 'primaryShift', 'm' );275 expect( await getEditedPostContent() ).toMatchSnapshot();276 await pressKeyWithModifier( 'primaryShift', 'm' );277 expect( await getEditedPostContent() ).toMatchSnapshot();278 } );279 it( 'should outdent with children', async () => {280 await insertBlock( 'List' );281 await page.keyboard.type( 'a' );282 await page.keyboard.press( 'Enter' );283 await pressKeyWithModifier( 'primary', 'm' );284 await page.keyboard.type( 'b' );285 await page.keyboard.press( 'Enter' );286 await pressKeyWithModifier( 'primary', 'm' );287 await page.keyboard.type( 'c' );288 expect( await getEditedPostContent() ).toMatchSnapshot();289 await page.keyboard.press( 'ArrowUp' );290 await pressKeyWithModifier( 'primaryShift', 'm' );291 expect( await getEditedPostContent() ).toMatchSnapshot();292 } );293 it( 'should insert a line break on shift+enter', async () => {294 await insertBlock( 'List' );295 await page.keyboard.type( 'a' );296 await pressKeyWithModifier( 'shift', 'Enter' );297 expect( await getEditedPostContent() ).toMatchSnapshot();298 } );299 it( 'should insert a line break on shift+enter in a non trailing list item', async () => {300 await insertBlock( 'List' );301 await page.keyboard.type( 'a' );302 await page.keyboard.press( 'Enter' );303 await page.keyboard.type( 'b' );304 await page.keyboard.press( 'Enter' );305 await page.keyboard.type( 'c' );306 await page.keyboard.press( 'ArrowUp' );307 await pressKeyWithModifier( 'shift', 'Enter' );308 expect( await getEditedPostContent() ).toMatchSnapshot();309 } );310 it( 'should create and remove indented list with keyboard only', async () => {311 await clickBlockAppender();312 await page.keyboard.type( '* 1' ); // Should be at level 0.313 await page.keyboard.press( 'Enter' );314 await page.keyboard.type( ' a' ); // Should be at level 1.315 await page.keyboard.press( 'Enter' );316 await page.keyboard.type( ' i' ); // Should be at level 2.317 expect( await getEditedPostContent() ).toMatchSnapshot();318 await page.keyboard.press( 'Backspace' );319 await page.keyboard.press( 'Backspace' ); // Should be at level 1.320 expect( await getEditedPostContent() ).toMatchSnapshot();321 await page.keyboard.press( 'Backspace' ); // Should be at level 0.322 expect( await getEditedPostContent() ).toMatchSnapshot();323 await page.keyboard.press( 'Backspace' ); // Should be at level 1.324 expect( await getEditedPostContent() ).toMatchSnapshot();325 await page.keyboard.press( 'Backspace' );326 await page.keyboard.press( 'Backspace' ); // Should be at level 0.327 expect( await getEditedPostContent() ).toMatchSnapshot();328 await page.keyboard.press( 'Backspace' ); // Should be at level 0.329 expect( await getEditedPostContent() ).toMatchSnapshot();330 await page.keyboard.press( 'Backspace' );331 await page.keyboard.press( 'Backspace' ); // Should remove list.332 expect( await getEditedPostContent() ).toMatchSnapshot();333 // That's 9 key presses to create the list, and 9 key presses to remove334 // the list. ;)335 } );336 it( 'should place the caret in the right place with nested list', async () => {337 await clickBlockAppender();338 await page.keyboard.type( '* 1' );339 await page.keyboard.press( 'Enter' );340 await page.keyboard.type( ' a' );341 await page.keyboard.press( 'ArrowUp' );342 await page.keyboard.press( 'Enter' );343 // The caret should land in the second item.344 await page.keyboard.type( '2' );345 expect( await getEditedPostContent() ).toMatchSnapshot();346 } );347 it( 'should not indent list on space with modifier', async () => {348 await clickBlockAppender();349 await page.keyboard.type( '* 1' );350 await page.keyboard.press( 'Enter' );351 await pressKeyWithModifier( 'shift', 'Space' );352 expect( await getEditedPostContent() ).toMatchSnapshot();353 } );354 it( 'should only convert to list when shortcut ends with space', async () => {355 await clickBlockAppender();356 // Tests the shortcut with a non breaking space.357 await page.keyboard.type( '* ' );358 expect( await getEditedPostContent() ).toMatchSnapshot();359 } );360 it( 'should preserve indentation after merging backward and forward', async () => {361 await clickBlockAppender();362 // Tests the shortcut with a non breaking space.363 await page.keyboard.type( '* 1' );364 await page.keyboard.press( 'Enter' );365 await page.keyboard.press( 'Space' );366 await page.keyboard.type( '2' );367 await page.keyboard.press( 'Enter' );368 await page.keyboard.type( '3' );369 // Create a new paragraph.370 await page.keyboard.press( 'Enter' );371 await page.keyboard.press( 'Enter' );372 // Merge the pragraph back. No list items should be joined.373 await page.keyboard.press( 'Backspace' );374 expect( await getEditedPostContent() ).toMatchSnapshot();375 // Again create a new paragraph.376 await page.keyboard.press( 'Enter' );377 // Move to the end of the list.378 await page.keyboard.press( 'ArrowLeft' );379 // Merge forward. No list items should be joined.380 await page.keyboard.press( 'Delete' );381 expect( await getEditedPostContent() ).toMatchSnapshot();382 } );383 it( 'first empty list item is graciously removed', async () => {384 await clickBlockAppender();385 await page.keyboard.type( '* 1' );386 await page.keyboard.press( 'Enter' );387 await page.keyboard.type( '2' );388 await page.keyboard.press( 'ArrowUp' );389 await page.keyboard.press( 'Backspace' );390 await page.keyboard.press( 'Backspace' );391 expect( await getEditedPostContent() ).toMatchSnapshot();392 } );393 it( 'should not change the contents when you change the list type to Ordered', async () => {394 await clickBlockAppender();395 await page.keyboard.type( '* 1' );396 await page.keyboard.press( 'Enter' );397 await page.keyboard.type( '2' );398 await page.keyboard.press( 'Enter' );399 await page.keyboard.type( '3' );400 await clickBlockToolbarButton( 'Ordered' );401 const content = await page.$eval(402 '.wp-block-list',403 ( el ) => el.innerHTML404 );405 expect( content ).toMatchSnapshot();406 } );407 it( 'should not change the contents when you change the list type to Unordered', async () => {408 await clickBlockAppender();409 await page.keyboard.type( '1. a' );410 await page.keyboard.press( 'Enter' );411 await page.keyboard.type( 'b' );412 await page.keyboard.press( 'Enter' );413 await page.keyboard.type( 'c' );414 await clickBlockToolbarButton( 'Unordered' );415 const content = await page.$eval(416 '.wp-block-list',417 ( el ) => el.innerHTML418 );419 expect( content ).toMatchSnapshot();420 } );...

Full Screen

Full Screen

epic.js

Source:epic.js Github

copy

Full Screen

...18 expect(title).toEqual('Full Editor - Quill Rich Text Editor');19 await page.type('.ql-editor', 'The Whale');20 let html = await page.$eval('.ql-editor', e => e.innerHTML);21 expect(html).toEqual('<p>The Whale</p>');22 await page.keyboard.press('Enter');23 html = await page.$eval('.ql-editor', e => e.innerHTML);24 expect(html).toEqual('<p>The Whale</p><p><br></p>');25 await page.keyboard.press('Enter');26 await page.keyboard.press('Tab');27 await page.type('.ql-editor', P1);28 await page.keyboard.press('Enter');29 await page.keyboard.press('Enter');30 await page.type('.ql-editor', P2);31 html = await page.$eval('.ql-editor', e => e.innerHTML);32 expect(html).toEqual(33 [34 '<p>The Whale</p>',35 '<p><br></p>',36 `<p>\t${P1}</p>`,37 '<p><br></p>',38 `<p>${P2}</p>`,39 ].join(''),40 );41 // More than enough to get to top42 await Promise.all(43 Array(20)44 .fill(0)45 .map(() => page.keyboard.press('ArrowUp')),46 );47 await page.keyboard.press('ArrowDown');48 await page.keyboard.press('Enter');49 await page.type('.ql-editor', CHAPTER);50 await page.keyboard.press('Enter');51 html = await page.$eval('.ql-editor', e => e.innerHTML);52 expect(html).toEqual(53 [54 '<p>The Whale</p>',55 '<p><br></p>',56 `<p>${CHAPTER}</p>`,57 '<p><br></p>',58 `<p>\t${P1}</p>`,59 '<p><br></p>',60 `<p>${P2}</p>`,61 ].join(''),62 );63 // More than enough to get to top64 await Promise.all(65 Array(20)66 .fill(0)67 .map(() => page.keyboard.press('ArrowUp')),68 );69 await page.keyboard.press('ArrowRight');70 await page.keyboard.press('ArrowRight');71 await page.keyboard.press('ArrowRight');72 await page.keyboard.press('ArrowRight');73 await page.keyboard.press('Backspace');74 await page.keyboard.press('Backspace');75 await page.keyboard.press('Backspace');76 await page.keyboard.press('Backspace');77 html = await page.$eval('.ql-editor', e => e.innerHTML);78 expect(html).toEqual(79 [80 '<p>Whale</p>',81 '<p><br></p>',82 `<p>${CHAPTER}</p>`,83 '<p><br></p>',84 `<p>\t${P1}</p>`,85 '<p><br></p>',86 `<p>${P2}</p>`,87 ].join(''),88 );89 await page.keyboard.press('Delete');90 await page.keyboard.press('Delete');91 await page.keyboard.press('Delete');92 await page.keyboard.press('Delete');93 await page.keyboard.press('Delete');94 html = await page.$eval('.ql-editor', e => e.innerHTML);95 expect(html).toEqual(96 [97 '<p><br></p>',98 '<p><br></p>',99 `<p>${CHAPTER}</p>`,100 '<p><br></p>',101 `<p>\t${P1}</p>`,102 '<p><br></p>',103 `<p>${P2}</p>`,104 ].join(''),105 );106 await page.keyboard.press('Delete');107 html = await page.$eval('.ql-editor', e => e.innerHTML);108 expect(html).toEqual(109 [110 '<p><br></p>',111 `<p>${CHAPTER}</p>`,112 '<p><br></p>',113 `<p>\t${P1}</p>`,114 '<p><br></p>',115 `<p>${P2}</p>`,116 ].join(''),117 );118 await page.click('.ql-toolbar .ql-bold');119 await page.click('.ql-toolbar .ql-italic');120 html = await page.$eval('.ql-editor', e => e.innerHTML);121 expect(html).toEqual(122 [123 '<p><strong><em><span class="ql-cursor">\uFEFF</span></em></strong></p>',124 `<p>${CHAPTER}</p>`,125 '<p><br></p>',126 `<p>\t${P1}</p>`,127 '<p><br></p>',128 `<p>${P2}</p>`,129 ].join(''),130 );131 let bold = await page.$('.ql-toolbar .ql-bold.ql-active');132 let italic = await page.$('.ql-toolbar .ql-italic.ql-active');133 expect(bold).not.toBe(null);134 expect(italic).not.toBe(null);135 await page.type('.ql-editor', 'Moby Dick');136 html = await page.$eval('.ql-editor', e => e.innerHTML);137 expect(html).toEqual(138 [139 '<p><strong><em>Moby Dick</em></strong></p>',140 `<p>${CHAPTER}</p>`,141 '<p><br></p>',142 `<p>\t${P1}</p>`,143 '<p><br></p>',144 `<p>${P2}</p>`,145 ].join(''),146 );147 bold = await page.$('.ql-toolbar .ql-bold.ql-active');148 italic = await page.$('.ql-toolbar .ql-italic.ql-active');149 expect(bold).not.toBe(null);150 expect(italic).not.toBe(null);151 await page.keyboard.press('ArrowRight');152 await page.keyboard.down('Shift');153 await Promise.all(154 Array(CHAPTER.length)155 .fill(0)156 .map(() => page.keyboard.press('ArrowRight')),157 );158 await page.keyboard.up('Shift');159 bold = await page.$('.ql-toolbar .ql-bold.ql-active');160 italic = await page.$('.ql-toolbar .ql-italic.ql-active');161 expect(bold).toBe(null);162 expect(italic).toBe(null);163 await page.keyboard.down(SHORTKEY);164 await page.keyboard.press('b');165 await page.keyboard.up(SHORTKEY);166 bold = await page.$('.ql-toolbar .ql-bold.ql-active');167 expect(bold).not.toBe(null);168 html = await page.$eval('.ql-editor', e => e.innerHTML);169 expect(html).toEqual(170 [171 '<p><strong><em>Moby Dick</em></strong></p>',172 `<p><strong>${CHAPTER}</strong></p>`,173 '<p><br></p>',174 `<p>\t${P1}</p>`,175 '<p><br></p>',176 `<p>${P2}</p>`,177 ].join(''),178 );179 await page.keyboard.press('ArrowLeft');180 await page.keyboard.press('ArrowUp');181 await page.click('.ql-toolbar .ql-header[value="1"]');182 html = await page.$eval('.ql-editor', e => e.innerHTML);183 expect(html).toEqual(184 [185 '<h1><strong><em>Moby Dick</em></strong></h1>',186 `<p><strong>${CHAPTER}</strong></p>`,187 '<p><br></p>',188 `<p>\t${P1}</p>`,189 '<p><br></p>',190 `<p>${P2}</p>`,191 ].join(''),192 );193 const header = await page.$('.ql-toolbar .ql-header.ql-active[value="1"]');194 expect(header).not.toBe(null);195 await page.keyboard.press('ArrowDown');196 await page.keyboard.press('ArrowDown');197 await page.keyboard.press('Enter');198 await page.keyboard.press('Enter');199 await page.keyboard.press('ArrowUp');200 await page.type('.ql-editor', 'AA');201 await page.keyboard.press('ArrowLeft');202 await page.keyboard.down(SHORTKEY);203 await page.keyboard.press('b');204 await page.keyboard.press('b');205 await page.keyboard.up(SHORTKEY);206 await page.type('.ql-editor', 'B');207 html = await page.$$eval('.ql-editor p', paras => paras[2].innerHTML);208 expect(html).toBe('ABA');209 await page.keyboard.down(SHORTKEY);210 await page.keyboard.press('b');211 await page.keyboard.up(SHORTKEY);212 await page.type('.ql-editor', 'C');213 await page.keyboard.down(SHORTKEY);214 await page.keyboard.press('b');215 await page.keyboard.up(SHORTKEY);216 await page.type('.ql-editor', 'D');217 html = await page.$$eval('.ql-editor p', paras => paras[2].innerHTML);218 expect(html).toBe('AB<strong>C</strong>DA');219 const selection = await page.evaluate(getSelectionInTextNode);220 expect(selection).toBe('["DA",1,"DA",1]');221 // await page.waitFor(1000000);222 await browser.close();223 });224});225function getSelectionInTextNode() {226 const {227 anchorNode,228 anchorOffset,...

Full Screen

Full Screen

rtl.test.js

Source:rtl.test.js Github

copy

Full Screen

...22 afterAll( async () => {23 await deactivatePlugin( 'gutenberg-test-plugin-activate-rtl' );24 } );25 it( 'should arrow navigate', async () => {26 await page.keyboard.press( 'Enter' );27 // We need at least three characters as arrow navigation *from* the28 // edges might be handled differently.29 await page.keyboard.type( ARABIC_ONE );30 await page.keyboard.type( ARABIC_TWO );31 await page.keyboard.press( 'ArrowRight' );32 // This is the important key press: arrow nav *from* the middle.33 await page.keyboard.press( 'ArrowRight' );34 await page.keyboard.type( ARABIC_ZERO );35 // Expect: ARABIC_ZERO + ARABIC_ONE + ARABIC_TWO (<p>٠١٢</p>).36 // N.b.: HTML is LTR, so direction will be reversed!37 expect( await getEditedPostContent() ).toMatchSnapshot();38 } );39 it( 'should split', async () => {40 await page.keyboard.press( 'Enter' );41 await page.keyboard.type( ARABIC_ZERO );42 await page.keyboard.type( ARABIC_ONE );43 await page.keyboard.press( 'ArrowRight' );44 await page.keyboard.press( 'Enter' );45 expect( await getEditedPostContent() ).toMatchSnapshot();46 } );47 it( 'should merge backward', async () => {48 await page.keyboard.press( 'Enter' );49 await page.keyboard.type( ARABIC_ZERO );50 await page.keyboard.press( 'Enter' );51 await page.keyboard.type( ARABIC_ONE );52 await page.keyboard.press( 'ArrowRight' );53 await page.keyboard.press( 'Backspace' );54 expect( await getEditedPostContent() ).toMatchSnapshot();55 } );56 it( 'should merge forward', async () => {57 await page.keyboard.press( 'Enter' );58 await page.keyboard.type( ARABIC_ZERO );59 await page.keyboard.press( 'Enter' );60 await page.keyboard.type( ARABIC_ONE );61 await page.keyboard.press( 'ArrowRight' );62 await page.keyboard.press( 'ArrowRight' );63 await page.keyboard.press( 'Delete' );64 expect( await getEditedPostContent() ).toMatchSnapshot();65 } );66 it( 'should arrow navigate between blocks', async () => {67 await page.keyboard.press( 'Enter' );68 await page.keyboard.type( ARABIC_ZERO );69 await page.keyboard.press( 'Enter' );70 await page.keyboard.type( ARABIC_ONE );71 await pressKeyWithModifier( 'shift', 'Enter' );72 await page.keyboard.type( ARABIC_TWO );73 await page.keyboard.press( 'ArrowRight' );74 await page.keyboard.press( 'ArrowRight' );75 await page.keyboard.press( 'ArrowRight' );76 // Move to the previous block with two lines in the current block.77 await page.keyboard.press( 'ArrowRight' );78 await pressKeyWithModifier( 'shift', 'Enter' );79 await page.keyboard.type( ARABIC_ONE );80 // Move to the next block with two lines in the current block.81 await page.keyboard.press( 'ArrowLeft' );82 await page.keyboard.type( ARABIC_ZERO );83 await pressKeyWithModifier( 'shift', 'Enter' );84 expect( await getEditedPostContent() ).toMatchSnapshot();85 } );86 it( 'should navigate inline boundaries', async () => {87 await page.keyboard.press( 'Enter' );88 // Wait for rich text editor to load.89 await page.waitForSelector( '.block-editor-rich-text__editable' );90 await pressKeyWithModifier( 'primary', 'b' );91 await page.keyboard.type( ARABIC_ONE );92 await pressKeyWithModifier( 'primary', 'b' );93 await page.keyboard.type( ARABIC_TWO );94 // Insert a character at each boundary position.95 for ( let i = 4; i > 0; i-- ) {96 await page.keyboard.press( 'ArrowRight' );97 await page.keyboard.type( ARABIC_ZERO );98 expect( await getEditedPostContent() ).toMatchSnapshot();99 await page.keyboard.press( 'Backspace' );100 }101 } );...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const qawolf = require("qawolf");2describe("test", () => {3 let browser;4 let page;5 beforeAll(async () => {6 browser = await qawolf.launch();7 page = await qawolf.createPage(browser);8 });9 afterAll(async () => {10 await qawolf.stopVideos();11 await browser.close();12 });13 it("test", async () => {14 await page.type("input[name=q]", "test");15 await page.keyboard.press("Enter");

Full Screen

Using AI Code Generation

copy

Full Screen

1const { launch } = require("qawolf");2const selectors = require("./selectors/test.json");3describe("test", () => {4 let browser;5 let page;6 beforeAll(async () => {7 page = await browser.newPage();8 });9 afterAll(async () => {10 await browser.close();11 });12 it("test", async () => {13 await page.click(selectors["#tsf > div:nth-child(2) > div > div.FPdoLc.VlcLAe > center > input.gNO89b"]);14 await page.keyboard.press("Enter");15 });16});

Full Screen

Using AI Code Generation

copy

Full Screen

1const qawolf = require("qawolf");2const selectors = require("./selectors/test.json");3const { chromium } = require("playwright");4(async () => {5 const browser = await chromium.launch();6 const context = await browser.newContext();7 const page = await context.newPage();8 await page.click(selectors[0].selector);9 await page.fill(selectors[0].selector, "

Full Screen

Using AI Code Generation

copy

Full Screen

1const qawolf = require('qawolf');2const { chromium } = require('playwright');3const { devices } = require('playwright');4(async () => {5 const browser = await chromium.launch();6 const context = await browser.newContext();7 const page = await context.newPage();8 await page.click('text=Sign in');9 await page.click('[placeholder="Email"]');10 await page.fill('[placeholder="Email"]', '

Full Screen

Using AI Code Generation

copy

Full Screen

1const { launch } = require("qawolf");2const selectors = require("../selectors/test");3describe("test", () => {4 let browser;5 let page;6 beforeAll(async () => {7 browser = await launch();8 page = await browser.newPage();9 });10 afterAll(async () => {11 await browser.close();12 });13 it("test", async () => {14 await page.click(selectors["text-field"]);15 await page.keyboard.press("hello");16 });17});18module.exports = {19};

Full Screen

Using AI Code Generation

copy

Full Screen

1const qawolf = require("qawolf");2const { type, click } = qawolf;3const browser = await qawolf.launch();4const context = await browser.newContext();5const page = await context.newPage();6await type(page, "input[name='name']", "Qawolf");7await click(page, "input[type='submit']");8await qawolf.stopVideos();9await browser.close();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { launch } = require('qawolf');2const selectors = require('./selectors.json');3const config = require('./config.json');4const { type } = require('qawolf');5describe('test', () => {6 let browser;7 let page;8 beforeAll(async () => {9 browser = await launch(config);10 });11 afterAll(async () => {12 await browser.close();13 });14 beforeEach(async () => {15 page = await browser.newPage();16 });17 afterEach(async () => {18 await page.close();19 });20 it('test', async () => {21 await page.waitForSelector(selectors['input']);22 await page.click(selectors['input']);23 await page.type(selectors['input'], "Hello World");24 });25});

Full Screen

Using AI Code Generation

copy

Full Screen

1const qawolf = require("qawolf");2const selectors = require("./selectors/test");3const searchQuery = "Hello World";4const browser = await qawolf.launch();5const context = await browser.newContext();6const page = await context.newPage();7await page.type(selectors[0], searchQuery);8await page.keyboard.press("Enter");9await page.waitForSelector(selectors[1]);10await qawolf.stopVideos();11await browser.close();

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run qawolf automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful