From fb6d845cec5bb664367354148b08e02bca62a01c Mon Sep 17 00:00:00 2001 From: Gleb Bahmutov Date: Thu, 4 May 2023 09:10:04 -0400 Subject: [PATCH] bonus 39 --- cypress.config.js | 6 ++++++ cypress/e2e/cart/add-to-cart.cy.ts | 5 ++++- cypress/e2e/inventory/product-ids.cy.ts | 5 ++++- cypress/e2e/login/direct-attempt.cy.ts | 5 ++++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/cypress.config.js b/cypress.config.js index ea58fd4..1a197da 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -42,6 +42,12 @@ module.exports = defineConfig({ setupNodeEvents(cypressOn, config) { // implement node event listeners here // and load any plugins that require the Node environment + console.log('the base url', config.baseUrl) + if (!config.baseUrl.includes('localhost')) { + console.log('disabled the code coverage plugin') + config.env.coverage = false + } + // fix https://github.com/cypress-io/cypress/issues/22428 const on = cypressOnFix(cypressOn) cypressSplit(on, config) diff --git a/cypress/e2e/cart/add-to-cart.cy.ts b/cypress/e2e/cart/add-to-cart.cy.ts index b1ad6fb..09b3e8b 100644 --- a/cypress/e2e/cart/add-to-cart.cy.ts +++ b/cypress/e2e/cart/add-to-cart.cy.ts @@ -2,6 +2,8 @@ import { LoginPage } from '@support/pages/login.page' import { InventoryPage } from '@support/pages/inventory.page' import { LoginInfo } from '..' +const isLocal = Cypress.config('baseUrl')?.includes('local') + describe('Cart', () => { // create a small type on the fly using jsdoc comment // just to help type check help us @@ -15,7 +17,8 @@ describe('Cart', () => { // or restore the previous user session beforeEach(() => { LoginPage.login(user.username, user.password) - cy.visit('/inventory.html') + const pageUrl = isLocal ? '/inventory.html' : '/?/inventory.html' + cy.visit(pageUrl) cy.location('pathname').should('equal', '/inventory.html') }) diff --git a/cypress/e2e/inventory/product-ids.cy.ts b/cypress/e2e/inventory/product-ids.cy.ts index 2cc5987..0d6963d 100644 --- a/cypress/e2e/inventory/product-ids.cy.ts +++ b/cypress/e2e/inventory/product-ids.cy.ts @@ -1,5 +1,7 @@ import { LoginPage } from '@support/pages/login.page' +const isLocal = Cypress.config('baseUrl')?.includes('local') + describe('Products', () => { // create a small type on the fly using jsdoc comment // just to help type check help us @@ -14,7 +16,8 @@ describe('Products', () => { // or restore the previous user session beforeEach(() => { LoginPage.login(user.username, user.password) - cy.visit('/inventory.html') + const pageUrl = isLocal ? '/inventory.html' : '/?/inventory.html' + cy.visit(pageUrl) cy.location('pathname').should('equal', '/inventory.html') }) diff --git a/cypress/e2e/login/direct-attempt.cy.ts b/cypress/e2e/login/direct-attempt.cy.ts index bb9ee28..82dddd6 100644 --- a/cypress/e2e/login/direct-attempt.cy.ts +++ b/cypress/e2e/login/direct-attempt.cy.ts @@ -1,8 +1,11 @@ import { LoginPage } from '@support/pages/login.page' +const isLocal = Cypress.config('baseUrl')?.includes('local') + describe('anonymous user', () => { it('gets an error trying to visit the inventory page', () => { - cy.visit('/inventory.html') + const pageUrl = isLocal ? '/inventory.html' : '/?/inventory.html' + cy.visit(pageUrl) // confirm we are on root page // https://on.cypress.io/location cy.location('pathname').should('equal', '/')