Skip to content

Commit 44418a4

Browse files
authored
Merge pull request #267 from scientist-softserv/255-e2e-pages-home
255-e2e-pages-home
2 parents ef45bf8 + cfe0304 commit 44418a4

File tree

2 files changed

+68
-1
lines changed

2 files changed

+68
-1
lines changed

cypress/e2e/home.cy.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
describe('Viewing Home page', () => {
2+
// declare variables that can be used to change how the response is intercepted.
3+
let loading
4+
let error
5+
let featuredServices
6+
7+
beforeEach(() => {
8+
// Intercept the response from the endpoint to view all requests
9+
cy.customApiIntercept({
10+
action: 'GET',
11+
alias: 'useAllWares',
12+
requestURL: `/providers/${Cypress.env('NEXT_PUBLIC_PROVIDER_ID')}/wares.json`,
13+
data: featuredServices,
14+
defaultFixture: 'services/wares.json',
15+
emptyFixture: 'services/no-wares.json',
16+
loading,
17+
error
18+
})
19+
cy.visit('/')
20+
})
21+
22+
23+
context('featured services list is loading', () => {
24+
before(() => {
25+
loading = true
26+
})
27+
it('should show 3 placeholder cards loading', () => {
28+
cy.get('p.placeholder-glow').should('be.visible').then(() => {
29+
cy.log('Loading text displays correctly.')
30+
})
31+
})
32+
})
33+
34+
context('error while making a request to the api', () => {
35+
before(() => {
36+
loading = false
37+
error = true
38+
})
39+
it('should show an error message.', () => {
40+
cy.get("div[role='alert']").should('be.visible').then(() => {
41+
cy.log('Successfully hits an error.')
42+
})
43+
})
44+
})
45+
46+
context('home page components are loading successfully, &', () => {
47+
before(() => {
48+
featuredServices = true
49+
error = false
50+
})
51+
it('should show the search bar.', () => {
52+
cy.get("form[data-cy='search-bar']").should('exist').then(() => {
53+
cy.log('Search bar renders successfully.')
54+
})
55+
})
56+
it('should show the about text.', () => {
57+
cy.get("section[data-cy='about-us-section']").should('exist').then(() => {
58+
cy.log('Abouttext renders successfully.')
59+
})
60+
})
61+
it('should show the featured services cards.', () => {
62+
cy.get("div[data-cy='item-group']").should('exist').then(() => {
63+
cy.log('Status bar renders successfully.')
64+
})
65+
})
66+
})
67+
})

pages/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const Home = () => {
4444
/>
4545
<div className='container'>
4646
<SearchBar onSubmit={handleOnSubmit} />
47-
<TitledTextBox title={ABOUT_US_TITLE} text={ABOUT_US_TEXT} />
47+
<TitledTextBox title={ABOUT_US_TITLE} text={ABOUT_US_TEXT} dataCy='about-us-section'/>
4848
{isError ? (
4949
<Notice
5050
alert={configureErrors([isError])}

0 commit comments

Comments
 (0)