Skip to content

Commit b4c8e2d

Browse files
committed
better organization of test
1 parent a7ad769 commit b4c8e2d

File tree

1 file changed

+30
-28
lines changed

1 file changed

+30
-28
lines changed

cypress/e2e/browse.cy.js

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ describe('Browsing', () => {
6969
// filtering by query is handled in the api and not the webstore
7070
// since we are stubbing that response, our tests will not return actual filtered wares based on on test query.
7171
// the purpose of these tests is just to show that the correct components appear in the UI in each case.
72-
context('a search is completed successfully from the browse page', () => {
72+
context('a search is completed successfully and', () => {
7373
before(() => {
7474
wares = true
7575
error = false
7676
})
77-
it('completes a search with a blank query', () => {
77+
it('has a blank query', () => {
7878
// Find the search button and perform an empty search, which should lead to the browse page
7979
cy.get('button.search-button').click()
8080
// The new url should include "/browse"
@@ -87,7 +87,7 @@ describe('Browsing', () => {
8787
cy.get(".card[data-cy='item-card']").should('be.visible')
8888
})
8989

90-
it('completes a search with a query term', () => {
90+
it('has a query term', () => {
9191
// Type an example search into the searchbar
9292
cy.get('input.search-bar').type('test')
9393
// Press the search button
@@ -103,7 +103,7 @@ describe('Browsing', () => {
103103
before(() => {
104104
wares = false
105105
})
106-
it('completes a search with a query term, but has no results', () => {
106+
it('has a query term, but that term has no results', () => {
107107
// type an example search into the searchbar
108108
cy.get('input.search-bar').type('asdfghjk')
109109
// Press the search button
@@ -134,30 +134,32 @@ describe('Browsing', () => {
134134
cy.visit('/')
135135
})
136136

137-
it('completes a search from the home page and navigates to "/browse" with a blank query', () => {
138-
// Find the search button and perform an empty search, which should lead to the browse page
139-
cy.get('button.search-button').click()
140-
// The new url should include "/browse"
141-
cy.url().should('include', '/browse')
142-
// The new url should not contain a query
143-
cy.url().should('not.include', '?')
144-
// The search bar on the browse page should remain blank
145-
cy.get('input.search-bar').should('have.value', '')
146-
// The service card component should be visible
147-
cy.get(".card[data-cy='item-card']").should('be.visible')
148-
})
149-
150-
it('completes a search from the home page and navigates to "/browse" with a query term', () => {
151-
// type an example search into the searchbar
152-
cy.get('input.search-bar').type('test')
153-
// Press the search button
154-
cy.get('button.search-button').click()
155-
// The new url should include "/browse"
156-
cy.url().should('include', '/browse?q=test')
157-
// The search bar on the browse page should have the text that was searched for
158-
cy.get('input.search-bar').should('have.value', 'test')
159-
// The service card component should be visible
160-
cy.get(".card[data-cy='item-card']").should('be.visible')
137+
context('a search is completed successfully and', () => {
138+
it('navigates to "/browse" with a blank query', () => {
139+
// Find the search button and perform an empty search, which should lead to the browse page
140+
cy.get('button.search-button').click()
141+
// The new url should include "/browse"
142+
cy.url().should('include', '/browse')
143+
// The new url should not contain a query
144+
cy.url().should('not.include', '?')
145+
// The search bar on the browse page should remain blank
146+
cy.get('input.search-bar').should('have.value', '')
147+
// The service card component should be visible
148+
cy.get(".card[data-cy='item-card']").should('be.visible')
149+
})
150+
151+
it('navigates to "/browse" with a query term', () => {
152+
// type an example search into the searchbar
153+
cy.get('input.search-bar').type('test')
154+
// Press the search button
155+
cy.get('button.search-button').click()
156+
// The new url should include "/browse"
157+
cy.url().should('include', '/browse?q=test')
158+
// The search bar on the browse page should have the text that was searched for
159+
cy.get('input.search-bar').should('have.value', 'test')
160+
// The service card component should be visible
161+
cy.get(".card[data-cy='item-card']").should('be.visible')
162+
})
161163
})
162164
})
163165
})

0 commit comments

Comments
 (0)