|
| 1 | +describe('Example - Spreadsheet and Cell Selection', { retries: 0 }, () => { |
| 2 | + const GRID_ROW_HEIGHT = 25; |
| 3 | + const titles = [ |
| 4 | + '', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', |
| 5 | + 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', |
| 6 | + 'Z', 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK' |
| 7 | + ]; |
| 8 | + |
| 9 | + it('should load Example', () => { |
| 10 | + cy.visit(`${Cypress.config('baseUrl')}/examples/example-frozen-columns-and-rows-spreadsheet.html`); |
| 11 | + }); |
| 12 | + |
| 13 | + it('should have exact column titles on grid', () => { |
| 14 | + cy.get('#myGrid') |
| 15 | + .find('.slick-header-columns') |
| 16 | + .children() |
| 17 | + .each(($child, index) => { |
| 18 | + if (index < titles.length) { |
| 19 | + expect($child.text()).to.eq(titles[index]); |
| 20 | + } |
| 21 | + }); |
| 22 | + }); |
| 23 | + |
| 24 | + it('should click on cell B5 (top left canvas) and ArrowUp 1 times and ArrowDown 3 time and expect cell selection B5-B8 (from top left canvas to bottom left canvas', () => { |
| 25 | + cy.get(`.grid-canvas-top.grid-canvas-left .slick-row[style="top: ${GRID_ROW_HEIGHT * 5}px;"] > .slick-cell.l2.r2`) |
| 26 | + .as('cell_B5') |
| 27 | + .click(); |
| 28 | + |
| 29 | + cy.get('@cell_B5') |
| 30 | + .type('{shift}{uparrow}{downarrow}{downarrow}{downarrow}{downarrow}', { release: false }); |
| 31 | + |
| 32 | + cy.get('.slick-cell.l2.r2.selected') |
| 33 | + .should('have.length', 4); |
| 34 | + |
| 35 | + cy.get('#selectionRange') |
| 36 | + .should('have.text', '{"fromRow":5,"fromCell":2,"toCell":2,"toRow":8}'); |
| 37 | + }); |
| 38 | + |
| 39 | + it('should click on cell E5 (top right canvas) then PageDown 2 times w/selection E5-F41 (bottom right canvas', () => { |
| 40 | + cy.get(`.grid-canvas-top.grid-canvas-right .slick-row[style="top: ${GRID_ROW_HEIGHT * 5}px;"] > .slick-cell.l5.r5`) |
| 41 | + .as('cell_E5') |
| 42 | + .click(); |
| 43 | + |
| 44 | + cy.get('@cell_E5') |
| 45 | + .type('{shift}{rightarrow}{pagedown}{pagedown}', { release: false }); |
| 46 | + |
| 47 | + cy.get('#selectionRange') |
| 48 | + .should('have.text', '{"fromRow":5,"fromCell":5,"toCell":6,"toRow":41}'); |
| 49 | + }); |
| 50 | + |
| 51 | + it('should click on cell F40 then Shift+Ctrl+Home and expect selection A0-F40', () => { |
| 52 | + cy.get(`.grid-canvas-bottom.grid-canvas-right .slick-row[style="top: ${GRID_ROW_HEIGHT * 33}px;"] > .slick-cell.l6.r6`) |
| 53 | + .as('cell_F40') |
| 54 | + .click(); |
| 55 | + |
| 56 | + cy.get('@cell_F40') |
| 57 | + .type('{shift}{ctrl}{home}', { release: false }); |
| 58 | + |
| 59 | + cy.get('#selectionRange') |
| 60 | + .should('have.text', '{"fromRow":0,"fromCell":0,"toCell":6,"toRow":40}'); |
| 61 | + }); |
| 62 | + |
| 63 | + it('should click on cell F40 then Shift+Ctrl+End and expect selection of F40-CV98', () => { |
| 64 | + cy.get(`.grid-canvas-bottom.grid-canvas-right .slick-row[style="top: ${GRID_ROW_HEIGHT * 33}px;"] > .slick-cell.l5.r5`) |
| 65 | + .as('cell_F40') |
| 66 | + .click(); |
| 67 | + |
| 68 | + cy.get('@cell_F40') |
| 69 | + .type('{shift}{ctrl}{end}', { release: false }); |
| 70 | + |
| 71 | + cy.get('#selectionRange') |
| 72 | + .should('have.text', '{"fromRow":40,"fromCell":5,"toCell":100,"toRow":99}'); |
| 73 | + }); |
| 74 | + |
| 75 | + it('should click on cell CS95 then Ctrl+A and expect selection of A0-CV98', () => { |
| 76 | + cy.get(`.grid-canvas-bottom.grid-canvas-right .slick-row[style="top: ${GRID_ROW_HEIGHT * 89}px;"] > .slick-cell.l95.r95`) |
| 77 | + .as('cell_CS95') |
| 78 | + .click(); |
| 79 | + |
| 80 | + cy.get('@cell_CS95') |
| 81 | + .type('{ctrl}{A}', { release: false }); |
| 82 | + |
| 83 | + cy.get('#selectionRange') |
| 84 | + .should('have.text', '{"fromRow":0,"fromCell":0,"toCell":100,"toRow":99}'); |
| 85 | + }); |
| 86 | +}); |
0 commit comments