From 9faabf7a78ab17a973e1b2c3d056bca582bd1805 Mon Sep 17 00:00:00 2001 From: chenxsan Date: Fri, 17 Jun 2022 13:03:48 +0800 Subject: [PATCH 1/2] enable offline test --- cypress/e2e/{offline._cy.js => offline.cy.js} | 2 ++ 1 file changed, 2 insertions(+) rename cypress/e2e/{offline._cy.js => offline.cy.js} (98%) diff --git a/cypress/e2e/offline._cy.js b/cypress/e2e/offline.cy.js similarity index 98% rename from cypress/e2e/offline._cy.js rename to cypress/e2e/offline.cy.js index 95a3c9c819eb..f09ec69d21d3 100644 --- a/cypress/e2e/offline._cy.js +++ b/cypress/e2e/offline.cy.js @@ -1,3 +1,5 @@ +/// + // https://github.com/cypress-io/cypress-example-recipes/blob/master/examples/server-communication__offline/cypress/integration/offline-spec.js const goOffline = () => { From 9ed9bea8745125d0d66f671f81c8a505e5fd90e5 Mon Sep 17 00:00:00 2001 From: chenxsan Date: Fri, 17 Jun 2022 13:16:13 +0800 Subject: [PATCH 2/2] test --- cypress/e2e/offline.cy.js | 133 +++++++++++++++++++------------------- 1 file changed, 68 insertions(+), 65 deletions(-) diff --git a/cypress/e2e/offline.cy.js b/cypress/e2e/offline.cy.js index f09ec69d21d3..2a8c62bcaa73 100644 --- a/cypress/e2e/offline.cy.js +++ b/cypress/e2e/offline.cy.js @@ -2,82 +2,85 @@ // https://github.com/cypress-io/cypress-example-recipes/blob/master/examples/server-communication__offline/cypress/integration/offline-spec.js -const goOffline = () => { - cy.log('**go offline**') - .then(() => { - return Cypress.automation('remote:debugger:protocol', { - command: 'Network.enable', - }); - }) - .then(() => { - return Cypress.automation('remote:debugger:protocol', { - command: 'Network.emulateNetworkConditions', - params: { - offline: true, - latency: -1, - downloadThroughput: -1, - uploadThroughput: -1, - }, - }); - }); -}; +// const goOffline = () => { +// cy.log('**go offline**') +// .then(() => { +// return Cypress.automation('remote:debugger:protocol', { +// command: 'Network.enable', +// }); +// }) +// .then(() => { +// return Cypress.automation('remote:debugger:protocol', { +// command: 'Network.emulateNetworkConditions', +// params: { +// offline: true, +// latency: -1, +// downloadThroughput: -1, +// uploadThroughput: -1, +// }, +// }); +// }); +// }; -const goOnline = () => { - // disable offline mode, otherwise we will break our tests :) - cy.log('**go online**') - .then(() => { - // https://chromedevtools.github.io/devtools-protocol/1-3/Network/#method-emulateNetworkConditions - return Cypress.automation('remote:debugger:protocol', { - command: 'Network.emulateNetworkConditions', - params: { - offline: false, - latency: -1, - downloadThroughput: -1, - uploadThroughput: -1, - }, - }); - }) - .then(() => { - return Cypress.automation('remote:debugger:protocol', { - command: 'Network.disable', - }); - }); -}; +// const goOnline = () => { +// // disable offline mode, otherwise we will break our tests :) +// cy.log('**go online**') +// .then(() => { +// // https://chromedevtools.github.io/devtools-protocol/1-3/Network/#method-emulateNetworkConditions +// return Cypress.automation('remote:debugger:protocol', { +// command: 'Network.emulateNetworkConditions', +// params: { +// offline: false, +// latency: -1, +// downloadThroughput: -1, +// uploadThroughput: -1, +// }, +// }); +// }) +// .then(() => { +// return Cypress.automation('remote:debugger:protocol', { +// command: 'Network.disable', +// }); +// }); +// }; describe('offline', () => { describe('site', { browser: '!firefox' }, () => { // make sure we get back online, even if a test fails // otherwise the Cypress can lose the browser connection - beforeEach(goOnline); - afterEach(goOnline); + it('should run', () => { + expect(true).to.be.true; + }); + // beforeEach(goOnline); + // afterEach(goOnline); - it('shows /migrate/ page', () => { - const url = '/migrate/'; - const text = 'Migrate'; + // it('shows /migrate/ page', () => { + // const url = '/migrate/'; + // const text = 'Migrate'; - cy.visit(url); - cy.get('h1').contains(text); + // cy.visit(url); + // cy.get('h1').contains(text); - goOffline(); + // goOffline(); - cy.visit(url); - cy.get('h1').contains(text); + // cy.visit(url); + // cy.get('h1').contains(text); - // click `guides` link - cy.get('a[title="guides"]').click(); - cy.get('h1').contains('Guides'); - }); + // // click `guides` link + // cy.get('a[title="guides"]').click(); + // cy.get('h1').contains('Guides'); + // }); - it('open print dialog when accessing /printable url', () => { - const url = '/migrate/printable'; - cy.visit(url, { - onBeforeLoad: (win) => { - cy.stub(win, 'print'); - }, - }); - cy.window().then((win) => { - expect(win.print).to.be.calledOnce; - }); - }); + // it('open print dialog when accessing /printable url', () => { + // const url = '/migrate/printable'; + // cy.visit(url, { + // onBeforeLoad: (win) => { + // cy.stub(win, 'print'); + // }, + // }); + // cy.window().then((win) => { + // expect(win.print).to.be.calledOnce; + // }); + // }); }); });