|
| 1 | +/// <reference types="cypress" /> |
| 2 | + |
| 3 | +describe('Example 27 - GraphQL Basic API without Pagination', () => { |
| 4 | + const GRID_ROW_HEIGHT = 35; |
| 5 | + const fullPreTitles = ['Country', 'Language', 'Continent']; |
| 6 | + const fullTitles = ['Code', 'Name', 'Native', 'Phone Area Code', 'Currency', 'Emoji', 'Names', 'Native', 'Codes', 'Name', 'Code']; |
| 7 | + |
| 8 | + it('should display Example title', () => { |
| 9 | + cy.visit(`${Cypress.config('baseExampleUrl')}/graphql-nopage`); |
| 10 | + cy.get('h2').should('contain', 'Example 27: GraphQL Basic API without Pagination'); |
| 11 | + }); |
| 12 | + |
| 13 | + it('should display a processing alert which will change to done', () => { |
| 14 | + cy.get('[data-test=status]').should('contain', 'processing'); |
| 15 | + cy.get('[data-test=status]').should('contain', 'done'); |
| 16 | + }); |
| 17 | + |
| 18 | + it('should have exact Column Pre-Header & Column Header Titles in the grid', () => { |
| 19 | + cy.get('#grid27') |
| 20 | + .find('.slick-header-columns:nth(0)') |
| 21 | + .children() |
| 22 | + .each(($child, index) => expect($child.text()).to.eq(fullPreTitles[index])); |
| 23 | + |
| 24 | + cy.get('#grid27') |
| 25 | + .find('.slick-header-columns:nth(1)') |
| 26 | + .children() |
| 27 | + .each(($child, index) => expect($child.text()).to.eq(fullTitles[index])); |
| 28 | + }); |
| 29 | + |
| 30 | + it('should expect first 3 rows to be an exact match of data provided by the external GraphQL API', () => { |
| 31 | + cy.get('.right-footer.metrics') |
| 32 | + .contains('250 of 250 items'); |
| 33 | + |
| 34 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(0)`).should('contain', 'AD'); |
| 35 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(1)`).should('contain', 'Andorra'); |
| 36 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(2)`).should('contain', 'Andorra'); |
| 37 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(3)`).should('contain', '376'); |
| 38 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(4)`).should('contain', 'EUR'); |
| 39 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(6)`).should('contain', 'Catalan'); |
| 40 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(7)`).should('contain', 'Català'); |
| 41 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(8)`).should('contain', 'ca'); |
| 42 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(9)`).should('contain', 'Europe'); |
| 43 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(10)`).should('contain', 'EU'); |
| 44 | + |
| 45 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(0)`).should('contain', 'AE'); |
| 46 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(1)`).should('contain', 'United Arab Emirates'); |
| 47 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(2)`).should('contain', 'دولة الإمارات العربية المتحدة'); |
| 48 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(3)`).should('contain', '971'); |
| 49 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(4)`).should('contain', 'AED'); |
| 50 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(6)`).should('contain', 'Arabic'); |
| 51 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(7)`).should('contain', 'العربية'); |
| 52 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(8)`).should('contain', 'ar'); |
| 53 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(9)`).should('contain', 'Asia'); |
| 54 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(10)`).should('contain', 'AS'); |
| 55 | + |
| 56 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 2}px"] > .slick-cell:nth(0)`).should('contain', 'AF'); |
| 57 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 2}px"] > .slick-cell:nth(1)`).should('contain', 'Afghanistan'); |
| 58 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 2}px"] > .slick-cell:nth(2)`).should('contain', 'افغانستان'); |
| 59 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 2}px"] > .slick-cell:nth(3)`).should('contain', '93'); |
| 60 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 2}px"] > .slick-cell:nth(4)`).should('contain', 'AFN'); |
| 61 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 2}px"] > .slick-cell:nth(6)`).should('contain', 'Pashto, Uzbek, Turkmen'); |
| 62 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 2}px"] > .slick-cell:nth(7)`).should('contain', 'پښتو, Ўзбек, Туркмен / تركمن'); |
| 63 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 2}px"] > .slick-cell:nth(8)`).should('contain', 'ps, uz, tk'); |
| 64 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 2}px"] > .slick-cell:nth(9)`).should('contain', 'Asia'); |
| 65 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 2}px"] > .slick-cell:nth(10)`).should('contain', 'AS'); |
| 66 | + }); |
| 67 | + |
| 68 | + it('should sort by country name and expect first 2 rows as Afghanistan and Albania', () => { |
| 69 | + cy.get(`.slick-header-columns:nth(1) .slick-header-column:nth-child(2)`).contains('Name').click(); |
| 70 | + |
| 71 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(0)`).should('contain', 'AF'); |
| 72 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(1)`).should('contain', 'Afghanistan'); |
| 73 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(2)`).should('contain', 'افغانستان'); |
| 74 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(3)`).should('contain', '93'); |
| 75 | + |
| 76 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(0)`).should('contain', 'AL'); |
| 77 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(1)`).should('contain', 'Albania'); |
| 78 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(2)`).should('contain', 'Shqipëria'); |
| 79 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(3)`).should('contain', '355'); |
| 80 | + }); |
| 81 | + |
| 82 | + it('should filter by Language Codes "fr, de" and expect 2 rows of data in the grid', () => { |
| 83 | + cy.get('.search-filter.filter-languageCode') |
| 84 | + .type('fr, de'); |
| 85 | + |
| 86 | + cy.get('.right-footer.metrics') |
| 87 | + .contains('2 of 250 items'); |
| 88 | + |
| 89 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(0)`).should('contain', 'BE'); |
| 90 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(1)`).should('contain', 'Belgium'); |
| 91 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(2)`).should('contain', 'België'); |
| 92 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(3)`).should('contain', '32'); |
| 93 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(4)`).should('contain', 'EUR'); |
| 94 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(6)`).should('contain', 'Dutch, French, German'); |
| 95 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(7)`).should('contain', 'Nederlands, Français, Deutsch'); |
| 96 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(8)`).should('contain', 'nl, fr, de'); |
| 97 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(9)`).should('contain', 'Europe'); |
| 98 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(10)`).should('contain', 'EU'); |
| 99 | + |
| 100 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(0)`).should('contain', 'LU'); |
| 101 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(1)`).should('contain', 'Luxembourg'); |
| 102 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(2)`).should('contain', 'Luxembourg'); |
| 103 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(3)`).should('contain', '352'); |
| 104 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(4)`).should('contain', 'EUR'); |
| 105 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(6)`).should('contain', 'French, German, Luxembourgish'); |
| 106 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(7)`).should('contain', 'Français, Deutsch, Lëtzebuergesch'); |
| 107 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(8)`).should('contain', 'fr, de, lb'); |
| 108 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(9)`).should('contain', 'Europe'); |
| 109 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(10)`).should('contain', 'EU'); |
| 110 | + }); |
| 111 | + |
| 112 | + it('should Clear all Filters and expect all rows to be back', () => { |
| 113 | + cy.get('#grid27') |
| 114 | + .find('button.slick-gridmenu-button') |
| 115 | + .trigger('click') |
| 116 | + .click(); |
| 117 | + |
| 118 | + cy.get(`.slick-gridmenu:visible`) |
| 119 | + .find('.slick-gridmenu-item') |
| 120 | + .first() |
| 121 | + .find('span') |
| 122 | + .contains('Clear all Filters') |
| 123 | + .click(); |
| 124 | + |
| 125 | + cy.get('.right-footer.metrics') |
| 126 | + .contains('250 of 250 items'); |
| 127 | + }); |
| 128 | + |
| 129 | + it('should filter Language Native with "Aymar" and expect only 1 row in the grid', () => { |
| 130 | + cy.get('div.ms-filter.filter-languageNative') |
| 131 | + .trigger('click'); |
| 132 | + |
| 133 | + cy.get('.ms-search:visible') |
| 134 | + .type('Aymar'); |
| 135 | + |
| 136 | + cy.get('.ms-drop:visible') |
| 137 | + .contains('Aymar') |
| 138 | + .click(); |
| 139 | + |
| 140 | + cy.get('.ms-ok-button:visible') |
| 141 | + .click(); |
| 142 | + |
| 143 | + cy.get('.right-footer.metrics') |
| 144 | + .contains('1 of 250 items'); |
| 145 | + |
| 146 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(0)`).should('contain', 'BO'); |
| 147 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(1)`).should('contain', 'Bolivia'); |
| 148 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(2)`).should('contain', 'Bolivia'); |
| 149 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(3)`).should('contain', '591'); |
| 150 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(4)`).should('contain', 'BOB,BOV'); |
| 151 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(6)`).should('contain', 'Spanish, Aymara, Quechua'); |
| 152 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(7)`).should('contain', 'Español, Aymar, Runa Simi'); |
| 153 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(8)`).should('contain', 'es, ay, qu'); |
| 154 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(9)`).should('contain', 'South America'); |
| 155 | + cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(10)`).should('contain', 'SA'); |
| 156 | + }); |
| 157 | +}); |
0 commit comments