Skip to content

Commit 92fab47

Browse files
committed
indiv request test draft
1 parent 979f51f commit 92fab47

File tree

6 files changed

+404
-0
lines changed

6 files changed

+404
-0
lines changed

cypress/e2e/request.cy.js

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
import useOneRequestResponseBody from '../fixtures/one-request/request.json'
2+
3+
describe('Viewing one request', () => {
4+
// currently this is using a real request ID, since the routes are generated dynamically, so far i haven't found a way to generate a route for a fake request within the test
5+
let uuid = useOneRequestResponseBody.uuid
6+
7+
describe('as a logged out user', () => {
8+
it('should show an error message.', () => {
9+
cy.visit(`/requests/${uuid}`)
10+
cy.get('div.alert-heading').contains('Unauthorized').then(() => {
11+
cy.log('A logged out user is not able to view a single request.')
12+
})
13+
})
14+
})
15+
16+
describe('as a logged in user', () => {
17+
// declare variables that can be used to change how the response is intercepted.
18+
let request
19+
let proposals
20+
let messages
21+
let files
22+
let loading
23+
let error
24+
25+
beforeEach(() => {
26+
// Call the custom cypress command to log in
27+
cy.login(Cypress.env('TEST_SCIENTIST_USER'), Cypress.env('TEST_SCIENTIST_PW'))
28+
29+
// Intercept the response from the endpoint to view one request
30+
cy.customApiIntercept({
31+
action: 'GET',
32+
alias: 'useOneRequest',
33+
requestURL: `/quote_groups/${uuid}.json`,
34+
data: request,
35+
dataFixture: 'one-request/request.json',
36+
emptyDataFixture: 'empty.json',
37+
loading,
38+
error
39+
})
40+
41+
cy.customApiIntercept({
42+
action: 'GET',
43+
alias: 'useAllSOWs',
44+
requestURL: `/quote_groups/${uuid}/proposals.json`,
45+
data: proposals,
46+
dataFixture: 'one-request/proposals.json',
47+
emptyDataFixture: 'empty.json',
48+
loading,
49+
error
50+
})
51+
52+
cy.customApiIntercept({
53+
action: 'GET',
54+
alias: 'useAllMessages',
55+
requestURL: `/quote_groups/${uuid}/messages.json`,
56+
data: messages,
57+
dataFixture: 'one-request/messages.json',
58+
emptyDataFixture: 'empty.json',
59+
loading,
60+
error
61+
})
62+
63+
cy.customApiIntercept({
64+
action: 'GET',
65+
alias: 'useAllFiles',
66+
requestURL: `/quote_groups/${uuid}/notes.json`,
67+
data: files,
68+
dataFixture: 'one-request/notes.json',
69+
emptyDataFixture: 'empty.json',
70+
loading,
71+
error
72+
})
73+
cy.visit(`/requests/${uuid}`)
74+
})
75+
76+
context('request is loading', () => {
77+
before(() => {
78+
loading = true
79+
})
80+
it('should show a loading spinner.', () => {
81+
cy.get("[aria-label='tail-spin-loading']").should('be.visible').then(() => {
82+
cy.log('Loading spinner displays correctly.')
83+
})
84+
})
85+
})
86+
87+
describe('request page components are loading successfully, &', () => {
88+
context('the request page', () => {
89+
before(() => {
90+
loading = false
91+
request = true
92+
proposals = true
93+
messages = true
94+
files = true
95+
})
96+
it("should show the request stats section.", () => {
97+
console.log({loading, request, proposals, messages, files, error})
98+
// cy.get('div.request-stats-card').should('exist').then(() => {
99+
// cy.log('Request stats section renders successfully.')
100+
// })
101+
})
102+
// it("should show the status bar.", () => {
103+
// cy.get("div[data-cy='status-bar']").should('exist').then(() => {
104+
// cy.log('Status bar renders successfully.')
105+
// })
106+
// })
107+
})
108+
109+
// context('the user has 0 requests', () => {
110+
// before(() => {
111+
// requestList = false
112+
// })
113+
// it("should show a message notifying the user they don't have any requests.", () => {
114+
// cy.get('p.no-requests').contains('You do not have any requests yet.').then(() => {
115+
// cy.log('Successfully viewing request page with no requests.')
116+
// })
117+
// })
118+
// })
119+
120+
// context('the user can see the <LinkedButton /> component', () => {
121+
// [true, false].forEach((value) => {
122+
// before(() => {
123+
// requestList = value
124+
// })
125+
// it(`should show a button that links to the initialize request page for the default ware ${value ? 'with a request list' : 'with 0 requests'}.`, () => {
126+
// cy.get("a[data-cy='linked-button']").should('have.attr', 'href', `/requests/new/make-a-request?id=123`).then(() => {
127+
// cy.log('The <LinkedButton /> component displays correctly')
128+
// })
129+
// })
130+
// })
131+
// })
132+
})
133+
})
134+
})
135+
136+
137+
// it('renders the request page with the appropriate components', () => {
138+
// let requestPath = useOneRequestResponseBody.request.href.pathname
139+
// //let scientistApiBaseURL = `https://${Cypress.env('NEXT_PUBLIC_PROVIDER_NAME')}.scientist.com/api/${Cypress.env('NEXT_PUBLIC_SCIENTIST_API_VERSION')}`
140+
// cy.intercept('GET', `${scientistApiBaseURL}/quote_groups/*`, { fixture: 'one-request/request.json' }).as('useOneRequest')
141+
// //cy.wait(['@useOneRequest'])
142+
// cy.visit(requestPath)
143+
// cy.get('h1').should('contains.text', useOneRequestResponseBody.request.title)
144+
// })

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+
]

0 commit comments

Comments
 (0)