|
| 1 | +describe('Cypress In Cypress - run mode', { viewportWidth: 1200 }, () => { |
| 2 | + it('e2e run mode spec runner header is correct', () => { |
| 3 | + cy.scaffoldProject('cypress-in-cypress') |
| 4 | + cy.findBrowsers() |
| 5 | + cy.openProject('cypress-in-cypress') |
| 6 | + cy.startAppServer() |
| 7 | + cy.visitApp() |
| 8 | + |
| 9 | + simulateRunModeInUI() |
| 10 | + |
| 11 | + cy.contains('dom-content.spec').click() |
| 12 | + cy.location().should((location) => { |
| 13 | + expect(location.hash).to.contain('dom-content.spec') |
| 14 | + }) |
| 15 | + |
| 16 | + cy.findByTestId('aut-url').should('be.visible') |
| 17 | + cy.findByTestId('playground-activator').should('not.exist') |
| 18 | + |
| 19 | + // confirm expected content is rendered |
| 20 | + cy.contains('1000x660').should('be.visible') |
| 21 | + cy.contains('84%').should('be.visible') |
| 22 | + cy.contains('Chrome 1').should('be.visible') |
| 23 | + cy.contains('http://localhost:4455/cypress/e2e/dom-content.html').should('be.visible') |
| 24 | + |
| 25 | + cy.percySnapshot() |
| 26 | + |
| 27 | + // confirm no interactions are implemented |
| 28 | + cy.findByTestId('viewport').click() |
| 29 | + cy.contains('The viewport determines').should('not.exist') |
| 30 | + cy.contains('Chrome 1').click() |
| 31 | + cy.contains('Firefox').should('not.exist') |
| 32 | + }) |
| 33 | + |
| 34 | + it('component testing run mode spec runner header is correct', () => { |
| 35 | + cy.scaffoldProject('cypress-in-cypress') |
| 36 | + cy.findBrowsers() |
| 37 | + cy.openProject('cypress-in-cypress') |
| 38 | + cy.startAppServer('component') |
| 39 | + cy.visitApp() |
| 40 | + simulateRunModeInUI() |
| 41 | + cy.contains('TestComponent.spec').click() |
| 42 | + cy.location().should((location) => { |
| 43 | + expect(location.hash).to.contain('TestComponent.spec') |
| 44 | + }) |
| 45 | + |
| 46 | + cy.findByTestId('aut-url').should('not.exist') |
| 47 | + cy.findByTestId('playground-activator').should('not.exist') |
| 48 | + |
| 49 | + // confirm expected content is rendered |
| 50 | + cy.contains('500x500').should('be.visible') |
| 51 | + cy.contains('Chrome 1').should('be.visible') |
| 52 | + |
| 53 | + cy.percySnapshot() |
| 54 | + |
| 55 | + // confirm no interactions are implemented |
| 56 | + cy.findByTestId('viewport').click() |
| 57 | + cy.contains('The viewport determines').should('not.exist') |
| 58 | + cy.contains('Chrome 1').click() |
| 59 | + cy.contains('Firefox').should('not.exist') |
| 60 | + }) |
| 61 | +}) |
| 62 | + |
| 63 | +function simulateRunModeInUI () { |
| 64 | + // this simulates run mode enough for this test |
| 65 | + cy.window().then((win) => { |
| 66 | + win.__CYPRESS_MODE__ = 'run' |
| 67 | + cy.get('body').then(($el) => { |
| 68 | + $el.find('[data-cy="sidebar"]')?.remove() |
| 69 | + }) |
| 70 | + }) |
| 71 | +} |
0 commit comments