|
| 1 | +it('renders Testing Playground Header', () => { |
| 2 | + cy.visit('/'); |
| 3 | + |
| 4 | + cy.findByRole('heading', { |
| 5 | + level: 1, |
| 6 | + name: 'Testing Playground mascot Froggy ️ Testing Playground', |
| 7 | + }).should('exist'); |
| 8 | + |
| 9 | + cy.findByRole('link', { |
| 10 | + name: 'Testing Playground mascot Froggy ️ Testing Playground', |
| 11 | + }) |
| 12 | + .should('exist') |
| 13 | + .and('have.attr', 'href', '/'); |
| 14 | + |
| 15 | + cy.findByRole('button', { name: /playground/i }).should('exist'); |
| 16 | + cy.findByRole('button', { name: /run/i }).should('exist'); |
| 17 | + cy.findByRole('button', { name: /settings/i }).should('exist'); |
| 18 | + cy.findByRole('button', { name: /more info/i }).should('exist'); |
| 19 | + |
| 20 | + cy.findByRole('button', { name: /playground/i }).click(); |
| 21 | + // playground menu shows |
| 22 | + cy.findByRole('menuitem', { name: /new/i }).should('exist'); |
| 23 | + cy.findByRole('menuitem', { name: /save/i }).should('exist'); |
| 24 | + cy.findByRole('menuitem', { name: /fork/i }).should('exist'); |
| 25 | + cy.findByRole('menuitem', { name: /share/i }).should('exist'); |
| 26 | + cy.findByRole('menuitem', { name: /embed/i }).should('exist'); |
| 27 | + |
| 28 | + cy.findByRole('button', { name: /settings/i }).click(); |
| 29 | + // previous menu disappear |
| 30 | + cy.findByRole('menuitem', { name: /new/i }).should('not.exist'); |
| 31 | + cy.findByRole('menuitem', { name: /save/i }).should('not.exist'); |
| 32 | + cy.findByRole('menuitem', { name: /fork/i }).should('not.exist'); |
| 33 | + cy.findByRole('menuitem', { name: /share/i }).should('not.exist'); |
| 34 | + cy.findByRole('menuitem', { name: /embed/i }).should('not.exist'); |
| 35 | + |
| 36 | + // settings menu shows |
| 37 | + cy.findByLabelText(/auto-run code/i).should('exist'); |
| 38 | + cy.findByLabelText(/test-id attribute:/i).should('exist'); |
| 39 | + |
| 40 | + cy.findByRole('button', { name: /more info/i }).click(); |
| 41 | + // previous menu disappear |
| 42 | + cy.findByLabelText(/auto-run code/i).should('not.be.visible'); |
| 43 | + cy.findByLabelText(/test-id attribute:/i).should('not.be.visible'); |
| 44 | + |
| 45 | + // more info menu shows |
| 46 | + cy.findByRole('menuitem', { name: /roadmap/i }).should('exist').and('have.attr', 'href', 'https://github.com/testing-library/testing-playground/projects/1'); |
| 47 | + cy.findByRole('menuitem', { name: /github/i }).should('exist').and('have.attr', 'href', 'https://github.com/testing-library/testing-playground/issues'); |
| 48 | + cy.findByRole('menuitem', { name: /support us/i }).should('exist').and('have.attr', 'href', 'https://github.com/sponsors/smeijer'); |
| 49 | + cy.findByRole('menuitem', { name: /twitter/i }).should('exist').and('have.attr', 'href', 'https://twitter.com/meijer_s'); |
| 50 | + cy.findByRole('menuitem', { name: /chrome extension/i }).should('exist').and('have.attr', 'href', 'https://chrome.google.com/webstore/detail/testing-playground/hejbmebodbijjdhflfknehhcgaklhano'); |
| 51 | + cy.findByRole('menuitem', { name: /introduction/i }).should('exist').and('have.attr', 'href', 'https://testing-library.com/docs/dom-testing-library/intro'); |
| 52 | + cy.findByRole('menuitem', { name: /query priority/i }).should('exist').and('have.attr', 'href', 'https://testing-library.com/docs/guide-which-query'); |
| 53 | + cy.findByRole('menuitem', { name: /common mistakes/i }).should('exist').and('have.attr', 'href', 'https://kentcdodds.com/blog/common-mistakes-with-react-testing-library'); |
| 54 | + |
| 55 | + // click outside |
| 56 | + cy.findByRole('button', { name: /more info/i }).parent().click(); |
| 57 | + // previous menu disappear |
| 58 | + cy.findByRole('menuitem', { name: /roadmap/i }).should('not.exist'); |
| 59 | + cy.findByRole('menuitem', { name: /github/i }).should('not.exist'); |
| 60 | + cy.findByRole('menuitem', { name: /support us/i }).should('not.exist'); |
| 61 | + cy.findByRole('menuitem', { name: /twitter/i }).should('not.exist'); |
| 62 | + cy.findByRole('menuitem', { name: /chrome extension/i }).should('not.exist'); |
| 63 | + cy.findByRole('menuitem', { name: /introduction/i }).should('not.exist'); |
| 64 | + cy.findByRole('menuitem', { name: /query priority/i }).should('not.exist'); |
| 65 | + cy.findByRole('menuitem', { name: /common mistakes/i }).should('not.exist'); |
| 66 | +}); |
0 commit comments