Skip to content

Commit 0df8ebc

Browse files
committed
8 working request specs!
1 parent 252cf4e commit 0df8ebc

File tree

9 files changed

+356
-108
lines changed

9 files changed

+356
-108
lines changed

cypress/e2e/request.cy.js

Lines changed: 50 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import {
22
requestUuid as uuid,
3-
requestPageApiCalls as apiCalls,
3+
requestPageApiCalls,
44
} from '../support/e2e'
55

66
describe('Viewing one request', () => {
7-
// Existing ticket to complete this test: https://github.com/scientist-softserv/webstore/issues/218
8-
97
describe('as a logged out user', () => {
108
it('should show an error message.', () => {
119
cy.visit(`/requests/${uuid}`)
@@ -16,17 +14,22 @@ describe('Viewing one request', () => {
1614
})
1715

1816
describe('as a logged in user', () => {
17+
let apiCalls = Object.assign({}, requestPageApiCalls)
18+
1919
beforeEach(() => {
2020
cy.login(Cypress.env('TEST_SCIENTIST_USER'), Cypress.env('TEST_SCIENTIST_PW'))
2121

22-
apiCalls.forEach((item) => {
23-
const key = Object.keys(item)[0]
24-
cy.customApiIntercept(item[key])
22+
Object.entries(apiCalls).forEach((item) => {
23+
cy.customApiIntercept(item[1])
2524
})
26-
2725
cy.visit(`/requests/${uuid}`)
2826
})
2927

28+
afterEach(() => {
29+
// in order for the tests to not be order dependent, we need to reset the apiCalls object to the original state
30+
apiCalls = Object.assign({}, requestPageApiCalls)
31+
})
32+
3033
describe('makes a call to the api', () => {
3134
context('which when given an invalid uuid', () => {
3235
before(() => {
@@ -52,11 +55,12 @@ describe('Viewing one request', () => {
5255

5356
context('which when returns undefined error and data values', () => {
5457
before(() => {
55-
apiCalls.forEach((item) => {
56-
const key = Object.keys(item)[0]
57-
58-
item[key].data = undefined
59-
item[key].error = undefined
58+
Object.entries(apiCalls).forEach(([key, value]) => {
59+
apiCalls[key] = {
60+
...value,
61+
data: undefined,
62+
error: undefined,
63+
}
6064
})
6165
})
6266

@@ -82,53 +86,54 @@ describe('Viewing one request', () => {
8286

8387
context('with messages', () => {
8488
before(() => {
85-
cy.customApiIntercept({
86-
action: 'GET',
87-
alias: 'useAllMessages',
88-
requestURL: `/quote_groups/${uuid}/messages.json`,
89-
data: messages,
90-
dataFixture: 'one-request/messages.json',
91-
emptyDataFixture: 'empty.json',
92-
loading,
93-
error
94-
})
89+
apiCalls['useMessages'] = {
90+
...apiCalls['useMessages'],
91+
data: 'one-request/messages/index.json',
92+
}
9593
})
9694

97-
it('displays the messages', () => {})
95+
it('displays the messages', () => {
96+
cy.get('div.card-body p.card-text')
97+
.contains('this is a message from the customer')
98+
.should('be.visible')
99+
})
98100
})
99101

100102
context('with documents', () => {
101103
before(() => {
102-
cy.customApiIntercept({
103-
action: 'GET',
104-
alias: 'useAllSOWs',
105-
requestURL: `/quote_groups/${uuid}/proposals.json`,
106-
data: proposals,
107-
dataFixture: 'one-request/proposals.json',
108-
emptyDataFixture: 'empty.json',
109-
loading,
110-
error
111-
})
104+
apiCalls['useAllSOWs'] = {
105+
...apiCalls['useAllSOWs'],
106+
data: 'one-request/sows/index.json',
107+
}
108+
apiCalls['getAllPOs'] = {
109+
...apiCalls['getAllPOs'],
110+
data: 'one-request/pos/index.json',
111+
}
112112
})
113113

114-
it('displays the documents', () => {})
114+
it('displays the documents', () => {
115+
cy.get('div.document').should('have.length', 2)
116+
cy.get('div.badge').contains('SOW').should('be.visible')
117+
cy.get('div.badge').contains('PO').should('be.visible')
118+
})
115119
})
116120

117121
context('with files', () => {
118122
before(() => {
119-
cy.customApiIntercept({
120-
action: 'GET',
121-
alias: 'useAllFiles',
122-
requestURL: `/quote_groups/${uuid}/notes.json`,
123-
data: files,
124-
dataFixture: 'one-request/notes.json',
125-
emptyDataFixture: 'empty.json',
126-
loading,
127-
error
128-
})
123+
apiCalls['useFiles'] = {
124+
...apiCalls['useFiles'],
125+
data: 'one-request/files/index.json',
126+
}
129127
})
130128

131-
it('displays the files', () => {})
129+
it('displays the files', () => {
130+
cy.get('div.actions-group')
131+
.contains('View Files')
132+
.click()
133+
cy.get('div#document-tabs-tabpane-files')
134+
.contains('downtown.jpg')
135+
.should('be.visible')
136+
})
132137
})
133138
})
134139
})

cypress/fixtures/one-request/files.json

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"notes": [
3+
{
4+
"id": 5019371,
5+
"title": "New Attachment",
6+
"status": "Other File",
7+
"body": null,
8+
"created_by": "Alisha Evans",
9+
"created_at": "2024-02-14T19:40:47.759Z",
10+
"updated_at": "2024-02-14T19:40:47.759Z",
11+
"attachments": [
12+
{
13+
"uuid": "fa70a15b-3230-41d5-9913-93ee0bcf2e3e",
14+
"filename": "downtown.jpg",
15+
"content_type": "image/jpeg",
16+
"content_length": 326048,
17+
"created_at": "2024-02-14T19:40:47.769Z",
18+
"download": "/quote_groups/596127b7-2356-45aa-aec4-a4f8608ae755/attachments/downtown.jpg"
19+
}
20+
],
21+
"user_ref": {
22+
"first_name": "Alisha",
23+
"last_name": "Evans",
24+
"organization_name": "Acme",
25+
"email": "[email protected]",
26+
"title": "software engineer",
27+
"company": "Triage Pharmaceuticals [DEMO], Scientist.com",
28+
"image": "https://avatars.scientist.com/avatars/alpha/user/xs?time=1707939658"
29+
}
30+
}
31+
]
32+
}

cypress/fixtures/one-request/messages.json renamed to cypress/fixtures/one-request/messages/index.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"id": 674804,
5555
"title": null,
5656
"status": null,
57-
"body": "hi",
57+
"body": "this is a message from the customer",
5858
"created_by": "Summer Cook",
5959
"created_at": "2023-03-01T22:16:46.167Z",
6060
"updated_at": "2023-03-01T22:16:46.167Z",
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"total": 1,
3+
"purchase_orders": [
4+
{
5+
"id": 168795,
6+
"po_number": "PO595363",
7+
"retail_total_price": "1625.0",
8+
"retail_subtotal_price": "1425.0",
9+
"wholesale_total_price": "1553.75",
10+
"wholesale_subtotal_price": "1353.75",
11+
"tax_cost": "0.0",
12+
"shipping_cost": "200.0",
13+
"retail_total_price_currency": "$1,625.00",
14+
"retail_subtotal_price_currency": "$1,425.00",
15+
"wholesale_total_price_currency": "$1,553.75",
16+
"wholesale_subtotal_price_currency": "$1,353.75",
17+
"tax_cost_currency": "$0.00",
18+
"shipping_cost_currency": "$200.00",
19+
"currency": "USD",
20+
"currency_unit": "$",
21+
"provider_name": "Beachside Biotechnology Services [Demo]",
22+
"status": "Work in Progress",
23+
"status_description": "(SOW 595363)",
24+
"created_at": "2023-12-15T19:45:33.745Z",
25+
"updated_at": "2023-12-15T19:45:35.408Z",
26+
"type": "PO",
27+
"identifier": null,
28+
"turn_around_time": {
29+
"id": 890642,
30+
"min": 604800,
31+
"max": 1814400,
32+
"display_units": "weeks",
33+
"human": "1 - 3 weeks"
34+
}
35+
}
36+
]
37+
}

0 commit comments

Comments
 (0)