|
| 1 | +/// <reference types="cypress" /> |
| 2 | +/* eslint-env browser */ |
| 3 | +describe('window size', () => { |
| 4 | + it('shows the page clearly', () => { |
| 5 | + // let's get the total opened browser dimensions |
| 6 | + const windowWidth = window.top.innerWidth |
| 7 | + const windowHeight = window.top.innerHeight |
| 8 | + |
| 9 | + cy.log(`browser window is: **${windowWidth} x ${windowHeight}**`) |
| 10 | + cy.task('log', { message: 'browser window', o: { windowWidth, windowHeight } }, { log: false }) |
| 11 | + |
| 12 | + // part of the browser window is taken up the command log |
| 13 | + const commandLog = window.top.document.querySelector('.reporter-wrap') |
| 14 | + const commandLogWidth = commandLog.offsetWidth |
| 15 | + const commandLogHeight = commandLog.offsetHeight |
| 16 | + |
| 17 | + cy.log(`command log is: **${commandLogWidth} x ${commandLogHeight}**`) |
| 18 | + cy.task('log', { message: 'command log', o: { commandLogWidth, commandLogHeight } }, { log: false }) |
| 19 | + |
| 20 | + // the app thinks it has the following dimensions |
| 21 | + cy.window({ log: false }).then((win) => { |
| 22 | + // the application is scaled to fit into its iframe |
| 23 | + // and the iframe's dimensions are |
| 24 | + const iframe = cy.state('$autIframe') |
| 25 | + const iframeWidth = Math.round(iframe.width()) |
| 26 | + const iframeHeight = Math.round(iframe.height()) |
| 27 | + |
| 28 | + cy.log(`app iframe real size is: **${iframeWidth} x ${iframeHeight}**`) |
| 29 | + cy.task('log', { message: 'app iframe real size', o: { iframeWidth, iframeHeight } }, { log: false }) |
| 30 | + |
| 31 | + // the application thinks it has the window of the follow size |
| 32 | + // which is the "viewport" numbers |
| 33 | + const viewportWidth = win.innerWidth |
| 34 | + const viewportHeight = win.innerHeight |
| 35 | + |
| 36 | + cy.log(`app viewport is: **${viewportWidth} x ${viewportHeight}**`) |
| 37 | + cy.task('log', { message: 'app viewport', o: { viewportWidth, viewportHeight } }, { log: false }) |
| 38 | + }) |
| 39 | + |
| 40 | + cy.visit('index.html') |
| 41 | + cy.screenshot('page', { capture: 'runner' }) |
| 42 | + }) |
| 43 | +}) |
0 commit comments