diff --git a/cypress/e2e/requests.cy.js b/cypress/e2e/requests.cy.js
index 1e7d730..003ef6a 100644
--- a/cypress/e2e/requests.cy.js
+++ b/cypress/e2e/requests.cy.js
@@ -2,50 +2,103 @@ describe('Viewing all requests', () => {
describe('as a logged out user', () => {
it('should show an error message.', () => {
// Visit a protected route in order to allow cypress to set the cookie and mock the login
- cy.visit("/requests")
+ cy.visit('/requests')
cy.get('div.alert-heading').contains('Unauthorized').then(() => {
- cy.log("A logged out user is not able to view requests.")
+ cy.log('A logged out user is not able to view requests.')
})
})
})
describe('as a logged in user', () => {
let scientistApiBaseURL = `https://${Cypress.env('NEXT_PUBLIC_PROVIDER_NAME')}.scientist.com/api/v2`
+ // declare variables that can be used to change how the response is intercepted.
let requestList
+ let loading
+ let error
beforeEach(() => {
// Call the custom cypress command to log in
cy.login(Cypress.env('TEST_SCIENTIST_USER'), Cypress.env('TEST_SCIENTIST_PW'))
-
// Intercept the response from the endpoint to view all requests
+ // TODO(summer-cook): extract out this base url into the config to use as an environment variable. it was not cooperating before
cy.intercept('GET', `${scientistApiBaseURL}/quote_groups/mine.json`, (req) => {
- if (requestList === true) {
- req.reply({fixture: 'all-requests/requests.json'})
- } else {
- req.reply({fixture: 'all-requests/no-requests.json'})
+ if ((requestList === undefined) && (loading === true)) {
+ // reply with an empty response: both data and error will be undefined.
+ req.reply()
+ } else if ((requestList === undefined) && (loading === false) && (error === true)) {
+ // error will be defined
+ req.reply({ statusCode: 500 })
+ } else if (requestList === true) {
+ // reply with a request body- default status code is 200
+ req.reply({ fixture: 'all-requests/requests.json' })
+ } else if (requestList === false) {
+ req.reply({ fixture: 'all-requests/no-requests.json' })
}
- }).as('useAllRequests')
- cy.visit("/requests")
+ })
+ // Intercept the response from the endpoint that gets the default ware ID
+ cy.intercept('GET', `${scientistApiBaseURL}/wares.json?q=make-a-request`, { fixture: 'all-requests/make-a-request.json' })
+ cy.visit('/requests')
})
- context('has requests', () => {
+
+ context('request list is loading', () => {
before(() => {
- requestList = true
+ loading = true
})
- it("shows the user's request list.", () => {
- cy.get('article.request-item').should('exist').then(() => {
- cy.log('Successfully viewing request list.')
+ it('should show a loading spinner.', () => {
+ cy.get("[aria-label='tail-spin-loading']").should('be.visible').then(() => {
+ cy.log('Loading spinner displays correctly.')
})
})
})
- context('has 0 requests', () => {
- before(() => {
- requestList = false
+ // TODO: uncomment this and try to make the page it not get an undefined error
+ // context('error while making a request to the api', () => {
+ // before(() => {
+ // requestList = undefined
+ // loading = false
+ // error = true
+ // })
+ // it('should show an error message.', () => {
+ // cy.get("div[role='alert']").should('be.visible').then(() => {
+ // cy.log('Successfully hits an error.')
+ // })
+ // })
+ // })
+
+ describe('request components are loading successfully, &', () => {
+ context('the user has requests', () => {
+ before(() => {
+ requestList = true
+ })
+ it("should show the user's request list.", () => {
+ cy.get('article.request-item').should('exist').then(() => {
+ cy.log('Successfully viewing request list.')
+ })
+ })
+ })
+
+ context('the user has 0 requests', () => {
+ before(() => {
+ requestList = []
+ })
+ it("should show a message notifying the user they don't have any requests.", () => {
+ cy.get('p.no-requests').contains('You do not have any requests yet.').then(() => {
+ cy.log('Successfully viewing request page with no requests.')
+ })
+ })
})
- it("shows a message notifying the user they don't have any requests.", () => {
- cy.get('p.no-requests').contains('You do not have any requests yet.').then(() => {
- cy.log('Successfully viewing request page with no requests.')
+
+ context('the user can see the
Here is a 3rd request
", - "status": "Compliance Required", + "status": "SOW Submitted", "billing_same_as_shipping": false, "proposed_deadline": null, "updated_at": "2023-02-23T07:12:44.086Z",