Skip to content

Commit 6f971ef

Browse files
authored
Merge pull request #250 from scientist-softserv/individual-request-test
indiv request test
2 parents 17d4904 + 49d3c99 commit 6f971ef

File tree

6 files changed

+375
-0
lines changed

6 files changed

+375
-0
lines changed

cypress/e2e/request.cy.js

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
import useOneRequestResponseBody from '../fixtures/one-request/request.json'
2+
3+
describe.skip('Viewing one request', () => {
4+
// TODO: currently this uses a real request uuid, which would allow it to visit a route that actually existed.
5+
// since the routes are generated dynamically, we will need to mock the next router in order to generate a route for a fake request w/ mock uuid within the test
6+
// this test should remain skipped until the above is done since it runs as a regular e2e vs e2e with mocked data
7+
// Existing ticket to complete this test: https://github.com/scientist-softserv/webstore/issues/218
8+
let uuid = useOneRequestResponseBody.uuid
9+
10+
describe('as a logged out user', () => {
11+
it('should show an error message.', () => {
12+
cy.visit(`/requests/${uuid}`)
13+
cy.get('div.alert-heading').contains('Unauthorized').then(() => {
14+
cy.log('A logged out user is not able to view a single request.')
15+
})
16+
})
17+
})
18+
19+
describe('as a logged in user', () => {
20+
// declare variables that can be used to change how the response is intercepted.
21+
let request
22+
let proposals
23+
let messages
24+
let files
25+
let loading
26+
let error
27+
28+
beforeEach(() => {
29+
// Call the custom cypress command to log in
30+
cy.login(Cypress.env('TEST_SCIENTIST_USER'), Cypress.env('TEST_SCIENTIST_PW'))
31+
32+
// Intercept the response from the endpoint to view one request
33+
cy.customApiIntercept({
34+
action: 'GET',
35+
alias: 'useOneRequest',
36+
requestURL: `/quote_groups/${uuid}.json`,
37+
data: request,
38+
dataFixture: 'one-request/request.json',
39+
emptyDataFixture: 'empty.json',
40+
loading,
41+
error
42+
})
43+
44+
cy.customApiIntercept({
45+
action: 'GET',
46+
alias: 'useAllSOWs',
47+
requestURL: `/quote_groups/${uuid}/proposals.json`,
48+
data: proposals,
49+
dataFixture: 'one-request/proposals.json',
50+
emptyDataFixture: 'empty.json',
51+
loading,
52+
error
53+
})
54+
55+
cy.customApiIntercept({
56+
action: 'GET',
57+
alias: 'useAllMessages',
58+
requestURL: `/quote_groups/${uuid}/messages.json`,
59+
data: messages,
60+
dataFixture: 'one-request/messages.json',
61+
emptyDataFixture: 'empty.json',
62+
loading,
63+
error
64+
})
65+
66+
cy.customApiIntercept({
67+
action: 'GET',
68+
alias: 'useAllFiles',
69+
requestURL: `/quote_groups/${uuid}/notes.json`,
70+
data: files,
71+
dataFixture: 'one-request/notes.json',
72+
emptyDataFixture: 'empty.json',
73+
loading,
74+
error
75+
})
76+
cy.visit(`/requests/${uuid}`)
77+
})
78+
79+
context('request is loading', () => {
80+
before(() => {
81+
loading = true
82+
})
83+
it('should show a loading spinner.', () => {
84+
cy.get("[aria-label='tail-spin-loading']").should('be.visible').then(() => {
85+
cy.log('Loading spinner displays correctly.')
86+
})
87+
})
88+
})
89+
90+
describe('request page components are loading successfully, &', () => {
91+
context('the request page', () => {
92+
before(() => {
93+
loading =
94+
request = true
95+
proposals = true
96+
messages = true
97+
files = true
98+
})
99+
100+
it("should show the request stats section.", () => {
101+
cy.get('div.request-stats-card').should('exist').then(() => {
102+
cy.log('Request stats section renders successfully.')
103+
})
104+
})
105+
106+
it("should show the status bar.", () => {
107+
cy.get("div[data-cy='status-bar']").should('exist').then(() => {
108+
cy.log('Status bar renders successfully.')
109+
})
110+
})
111+
// TODO: add tests to confirm that messages, files, additional info, document sections all show correctly.
112+
})
113+
})
114+
})
115+
})

cypress/fixtures/empty.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"notes": [
3+
{
4+
"id": 674804,
5+
"title": null,
6+
"status": null,
7+
"body": "hi",
8+
"created_by": "Summer Cook",
9+
"created_at": "2023-03-01T22:16:46.167Z",
10+
"updated_at": "2023-03-01T22:16:46.167Z",
11+
"attachments": [],
12+
"user_ref": {
13+
"first_name": "Summer",
14+
"last_name": "Cook",
15+
"organization_name": "Acme",
16+
"email": "[email protected]",
17+
"title": "Frontend Dev",
18+
"company": "",
19+
"site": "{\"name\"=>\"Cell Based Assays\", \"billing_same_as_shipping\"=>true}",
20+
"image": "https://avatars.scientist.com/avatars/0d93b3808f701fc3dbde5002a80c2475/S C/xs?time=1677774999"
21+
}
22+
}
23+
]
24+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"messages": [
3+
{
4+
"id": 674334,
5+
"title": "SOW Submitted to Customer",
6+
"status": "SOW Submitted",
7+
"body": null,
8+
"created_by": "Sherman Tang",
9+
"created_at": "2023-02-23T07:16:25.153Z",
10+
"updated_at": "2023-02-23T07:16:25.153Z",
11+
"attachments": [],
12+
"user_ref": {
13+
"first_name": "Sherman",
14+
"last_name": "Tang",
15+
"organization_name": "Biogen",
16+
"email": "[email protected]",
17+
"title": "Master tester",
18+
"company": "",
19+
"site": "Asia",
20+
"image": "https://avatars.scientist.com/avatars/20c7e703deca8fcabb2df42096142740/S T/xs?time=1677774999"
21+
},
22+
"proposal_ref": {
23+
"id": 4594,
24+
"type": "SOW",
25+
"identifier": "092985",
26+
"retail_total_price": "6.0",
27+
"retail_subtotal_price": "3.0",
28+
"wholesale_total_price": "5.7",
29+
"wholesale_subtotal_price": "2.7",
30+
"tax_cost": "0.0",
31+
"shipping_cost": "3.0",
32+
"retail_total_price_currency": "$6.00",
33+
"retail_subtotal_price_currency": "$3.00",
34+
"wholesale_total_price_currency": "$5.70",
35+
"wholesale_subtotal_price_currency": "$2.70",
36+
"tax_cost_currency": "$0.00",
37+
"shipping_cost_currency": "$3.00",
38+
"currency": "USD",
39+
"currency_unit": "$",
40+
"provider_name": "Dragon Pharmacology",
41+
"status": "Approval Required",
42+
"status_description": "You must submit this SOW for internal approval before proceeding",
43+
"created_at": "2023-02-23T07:15:57.950Z",
44+
"updated_at": "2023-02-23T07:16:25.081Z",
45+
"turn_around_time": {
46+
"id": 908312,
47+
"min": 3024000,
48+
"max": 3628800,
49+
"display_units": "weeks",
50+
"human": "5 - 6 weeks"
51+
}
52+
}
53+
},
54+
{
55+
"id": 674804,
56+
"title": null,
57+
"status": null,
58+
"body": "hi",
59+
"created_by": "Summer Cook",
60+
"created_at": "2023-03-01T22:16:46.167Z",
61+
"updated_at": "2023-03-01T22:16:46.167Z",
62+
"attachments": [],
63+
"user_ref": {
64+
"first_name": "Summer",
65+
"last_name": "Cook",
66+
"organization_name": "Acme",
67+
"email": "[email protected]",
68+
"title": "Frontend Dev",
69+
"company": "",
70+
"site": "{\"name\"=>\"Cell Based Assays\", \"billing_same_as_shipping\"=>true}",
71+
"image": "https://avatars.scientist.com/avatars/0d93b3808f701fc3dbde5002a80c2475/S C/xs?time=1677774999"
72+
}
73+
}
74+
]
75+
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
[
2+
{
3+
"id": 4594,
4+
"type": "SOW",
5+
"identifier": "092985",
6+
"retail_total_price": "6.0",
7+
"retail_subtotal_price": "3.0",
8+
"wholesale_total_price": "5.7",
9+
"wholesale_subtotal_price": "2.7",
10+
"tax_cost": "0.0",
11+
"shipping_cost": "3.0",
12+
"retail_total_price_currency": "$6.00",
13+
"retail_subtotal_price_currency": "$3.00",
14+
"wholesale_total_price_currency": "$5.70",
15+
"wholesale_subtotal_price_currency": "$2.70",
16+
"tax_cost_currency": "$0.00",
17+
"shipping_cost_currency": "$3.00",
18+
"currency": "USD",
19+
"currency_unit": "$",
20+
"provider_name": "Dragon Pharmacology",
21+
"status": "Approval Required",
22+
"status_description": "You must submit this SOW for internal approval before proceeding",
23+
"created_at": "2023-02-22T23:15:57.950-08:00",
24+
"updated_at": "2023-02-22T23:16:25.081-08:00",
25+
"uuid": "1327b754-b750-4ab6-b9f6-5f11d942412c",
26+
"compliance_status": {
27+
"status": "Approval Required",
28+
"description": "You must submit this SOW for internal approval before proceeding"
29+
},
30+
"line_items": [
31+
{
32+
"id": 21189,
33+
"retail_unit_price_currency": "$1.00",
34+
"retail_unit_price": "1.0",
35+
"retail_subtotal_price_currency": "$1.00",
36+
"retail_subtotal_price": "1.0",
37+
"quantity": "1.0",
38+
"currency": "USD",
39+
"currency_unit": "$",
40+
"name": "Test Item A - Study Design",
41+
"subtotal": "$1.00",
42+
"unit_price": "$1.00"
43+
},
44+
{
45+
"id": 21190,
46+
"retail_unit_price_currency": "$2.00",
47+
"retail_unit_price": "2.0",
48+
"retail_subtotal_price_currency": "$2.00",
49+
"retail_subtotal_price": "2.0",
50+
"quantity": "1.0",
51+
"currency": "USD",
52+
"currency_unit": "$",
53+
"name": "Test Item B - Analysis",
54+
"subtotal": "$2.00",
55+
"unit_price": "$2.00"
56+
}
57+
],
58+
"payment_terms": "NET 60",
59+
"ship_to": {
60+
"id": 454297,
61+
"organization_name": "acme-staging",
62+
"street": "9833 45th Avenue SW",
63+
"street2": "",
64+
"city": "Seattle",
65+
"state": "WA",
66+
"zipcode": "98136",
67+
"country": "Mexico",
68+
"latitude": null,
69+
"longitude": null,
70+
"name": null,
71+
"attention": "",
72+
"person_name": "Summer Cook",
73+
"care_of": null,
74+
"text": "9833 45th Avenue SW\nSeattle, WA, 98136"
75+
},
76+
"ship_from": {
77+
"id": 454299,
78+
"organization_name": "San Diego Beach Warehouse",
79+
"street": "404 San Diego Lane",
80+
"street2": "",
81+
"city": "San Diego",
82+
"state": "california",
83+
"zipcode": "92075",
84+
"country": "US",
85+
"latitude": null,
86+
"longitude": null,
87+
"name": null,
88+
"attention": null,
89+
"person_name": null,
90+
"care_of": null,
91+
"text": "404 San Diego Lane\nSan Diego, california, 92075\nUnited States"
92+
},
93+
"quote_group_name": "Cell Based Assays",
94+
"quote_group_identifier": "8AE755",
95+
"download_pdf": "/quote_groups/596127b7-2356-45aa-aec4-a4f8608ae755/proposals/1327b754-b750-4ab6-b9f6-5f11d942412c.pdf",
96+
"organization_provider_ref": {
97+
"id": 1065239,
98+
"uuid": "5599e8b0-0192-4473-a25d-3c23536b1ec4",
99+
"provider_id": 609,
100+
"slug": "dragon-pharmacology",
101+
"name": "Dragon Pharmacology",
102+
"website": "http://www.dragonpharmacology.com",
103+
"snippet_plain": "Dragon Pharmacology provides research models for various diseases. Dragon Pharmacology is a trusted TEST vendor for pharmacological animal models.",
104+
"snippet": "Dragon Pharmacology provides research models for various diseases. Dragon Pharmacology is a trusted *TEST* vendor for pharmacological animal models.",
105+
"html_snippet": "<p>Dragon Pharmacology provides research models for various diseases. Dragon Pharmacology is a trusted <strong>TEST</strong> vendor for pharmacological animal models.</p>",
106+
"description": "Dragon Pharmacology provides research models for various diseases. Dragon Pharmacology is a trusted TEST vendor for pharmacological animal models.",
107+
"html_description": "<p>Dragon Pharmacology provides research models for various diseases. Dragon Pharmacology is a trusted TEST vendor for pharmacological animal models.</p>",
108+
"created_at": "2011-07-11T15:43:27.000-07:00",
109+
"updated_at": "2022-08-15T22:37:49.568-07:00",
110+
"urls": {
111+
"storefront": "https://acme-staging.scientist.com/wares/make-a-request/quote_groups/new?provider=Dragon+Pharmacology&name=Dragon+Pharmacology",
112+
"backoffice": "https://backoffice-staging.scientist.com/providers/dragon-pharmacology/edit",
113+
"provider_rfis": "https://acme-staging.scientist.com/providers/5599e8b0-0192-4473-a25d-3c23536b1ec4#rfis609"
114+
}
115+
},
116+
"assigned_legal_document_pdf": "/quote_groups/596127b7-2356-45aa-aec4-a4f8608ae755/quoted_wares/bec88afc-8e3f-4ae5-80d1-6a7f0761f199/legal_documents/13.pdf",
117+
"attachments": []
118+
}
119+
]
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"id": 80688,
3+
"identifier": "8AE755",
4+
"uuid": "596127b7-2356-45aa-aec4-a4f8608ae755",
5+
"name": "Example Request",
6+
"description": "<p>this is an example request</p>",
7+
"status": "Compliance Required",
8+
"billing_same_as_shipping": false,
9+
"proposed_deadline": null,
10+
"updated_at": "2023-02-23T07:12:44.086Z",
11+
"created_at": "2023-02-16T21:51:59.343Z",
12+
"shipping_address": {
13+
"id": 453994,
14+
"organization_name": "acme-staging",
15+
"street": "123 Pineapple Way",
16+
"street2": "",
17+
"city": "Bikini Bottom",
18+
"state": "CA",
19+
"zipcode": "92107",
20+
"country": "Mexico",
21+
"person_name": "Summer Cook",
22+
"text": "123 Pineapple Way\nBikini Bottom, CA, 92107"
23+
},
24+
"billing_address": {
25+
"id": 453995,
26+
"organization_name": "acme-staging",
27+
"street": "123 Pineapple Way",
28+
"street2": "",
29+
"city": "Bikini Bottom",
30+
"state": "CA",
31+
"zipcode": "92107",
32+
"country": "Mexico",
33+
"name": null,
34+
"text": "123 Pineapple Way\nBikini Bottom, CA, 92107"
35+
},
36+
"quoted_ware_refs": [
37+
{
38+
"id": 728152
39+
}
40+
]
41+
}

0 commit comments

Comments
 (0)