Skip to content

Commit f9d4eae

Browse files
committed
fix the first home spec
made the cypress config file more dynamic. it also will allow us to correctly intercept api calls in our `customApiIntercept` command. update the "featured services list is loading" test check that we in fact have 3 placeholder items, as the description states.
1 parent 7c7ea59 commit f9d4eae

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

cypress.config.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,17 @@ module.exports = defineConfig({
2323
env: {
2424
TEST_SCIENTIST_USER: '[email protected]',
2525
TEST_SCIENTIST_PW: '!test1234',
26-
NEXT_PUBLIC_PROVIDER_NAME: 'acme',
27-
NEXT_PUBLIC_PROVIDER_ID: '572'
26+
NEXT_PUBLIC_PROVIDER_NAME: process.env.NEXT_PUBLIC_PROVIDER_NAME,
27+
NEXT_PUBLIC_PROVIDER_ID: process.env.NEXT_PUBLIC_PROVIDER_ID,
28+
NEXT_PUBLIC_TOKEN: process.env.NEXT_PUBLIC_TOKEN,
29+
// importing the `API_PER_PAGE` variable from the constants file throws
30+
// errors since this file doesn't follow ES6 syntax. if the value is
31+
// changed in constants, it needs to be updated here too
32+
API_PER_PAGE: 2000,
2833
},
2934
reporter: 'junit',
3035
reporterOptions: {
3136
mochaFile: 'cypress/results/results-[hash].xml',
3237
toConsole: true,
3338
},
34-
});
39+
})

cypress/e2e/home.cy.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ describe('Viewing Home page', () => {
55
let featuredServices
66

77
beforeEach(() => {
8-
// Intercept the response from the endpoint to view all requests
98
cy.customApiIntercept({
109
action: 'GET',
1110
alias: 'useAllWares',
12-
requestURL: `/providers/${Cypress.env('NEXT_PUBLIC_PROVIDER_ID')}/wares.json`,
11+
requestURL: `/wares.json?per_page=${Cypress.env('API_PER_PAGE')}`,
1312
data: featuredServices,
1413
defaultFixture: 'services/wares.json',
1514
emptyFixture: 'services/no-wares.json',
@@ -19,13 +18,11 @@ describe('Viewing Home page', () => {
1918
cy.visit('/')
2019
})
2120

22-
2321
context('featured services list is loading', () => {
24-
before(() => {
25-
loading = true
26-
})
22+
before(() => loading = true)
23+
2724
it('should show 3 placeholder cards loading', () => {
28-
cy.get('p.placeholder-glow').should('be.visible').then(() => {
25+
cy.get('p.placeholder-glow').should('have.length', 3).then(() => {
2926
cy.log('Loading text displays correctly.')
3027
})
3128
})

0 commit comments

Comments
 (0)