-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathchefsdata.cy.ts
More file actions
233 lines (195 loc) · 12.2 KB
/
chefsdata.cy.ts
File metadata and controls
233 lines (195 loc) · 12.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/// <reference types="cypress" />
// cypress/e2e/chefsdata.cy.ts
describe('Unity Login and check data from CHEFS', () => {
const STANDARD_TIMEOUT = 20000
// TEST renders the Submission tab inside an open shadow root (Form.io).
// Enabling this makes cy.get / cy.contains pierce shadow DOM consistently across envs.
before(() => {
Cypress.config('includeShadowDom', true)
})
it('Verify Login', () => {
// 1.) Always start from the base URL
cy.visit(Cypress.env('webapp.url'))
// 2.) Decide auth path based on visible UI
cy.get('body', { timeout: STANDARD_TIMEOUT }).then(($body) => {
// Already authenticated
if ($body.find('button:contains("VIEW APPLICATIONS")').length > 0) {
cy.contains('VIEW APPLICATIONS', { timeout: STANDARD_TIMEOUT }).click({ force: true })
return
}
// Not authenticated
if ($body.find('button:contains("LOGIN")').length > 0) {
cy.contains('LOGIN', { timeout: STANDARD_TIMEOUT }).should('exist').click({ force: true })
cy.contains('IDIR', { timeout: STANDARD_TIMEOUT }).should('exist').click({ force: true })
cy.get('body', { timeout: STANDARD_TIMEOUT }).then(($loginBody) => {
// Perform IDIR login only if prompted
if ($loginBody.find('#user').length > 0) {
cy.get('#user', { timeout: STANDARD_TIMEOUT }).type(Cypress.env('test1username'))
cy.get('#password', { timeout: STANDARD_TIMEOUT }).type(Cypress.env('test1password'))
cy.contains('Continue', { timeout: STANDARD_TIMEOUT }).should('exist').click({ force: true })
} else {
cy.log('Already logged in')
}
})
return
}
// Fail loudly if neither state is detectable
throw new Error('Unable to determine authentication state')
})
// 3.) Post-condition check
cy.url({ timeout: STANDARD_TIMEOUT }).should('include', '/GrantApplications')
})
// Verify that the details panel populates with mapped data
it('Verify the UI is populated with valid data from CHEFS', () => {
cy.getSubmissionDetail('confirmationID').then((id) => {
cy.log(`Confirmation ID: ${id}`)
})
// Ensure the search field exists
cy.get('#search', { timeout: STANDARD_TIMEOUT }).should('exist')
// Select "All time" from quick date range to widen the search
cy.get('body', { timeout: STANDARD_TIMEOUT }).then(($body) => {
if ($body.find('select#quickDateRange').length > 0) {
cy.get('select#quickDateRange', { timeout: STANDARD_TIMEOUT })
.should('be.visible')
.select('alltime')
}
})
// Clear and focus search
cy.get('#search', { timeout: STANDARD_TIMEOUT }).clear()
cy.get('#search', { timeout: STANDARD_TIMEOUT }).click({ force: true })
// Type confirmation ID
cy.getSubmissionDetail('confirmationID').then((id) => {
cy.get('#search', { timeout: STANDARD_TIMEOUT }).type(id)
})
// Select matching row if table rendering exists
cy.getSubmissionDetail('confirmationID').then((id) => {
cy.get('body', { timeout: STANDARD_TIMEOUT }).then(($body) => {
if ($body.find(`tr:contains("${id}")`).length > 0) {
cy.contains('tr', id, { timeout: STANDARD_TIMEOUT })
.find('.checkbox-select')
.click({ force: true })
}
})
})
// Open the info panel if available
cy.get('body', { timeout: STANDARD_TIMEOUT }).then(($body) => {
if ($body.find('#applicationLink').length > 0) {
cy.get('#applicationLink', { timeout: STANDARD_TIMEOUT }).click({ force: true })
}
})
// Summary panel assertions
cy.get('label[for="Category"]', { timeout: STANDARD_TIMEOUT }).next('.display-input').should('include.text', 'AutoUI')
cy.get('label.display-input-label[for="OrganizationName"]', { timeout: STANDARD_TIMEOUT }).next('div.display-input').should('contain.text', 'DOLPHIN ASPHALT')
cy.get('label.display-input-label[for="OrganizationNumber"]', { timeout: STANDARD_TIMEOUT }).next('div.display-input').should('contain.text', 'FM0162628')
cy.get('label[for="EconomicRegion"]', { timeout: STANDARD_TIMEOUT }).next('.display-input').should('include.text', 'Kootenay')
cy.get('label[for="RegionalDistrict"]', { timeout: STANDARD_TIMEOUT }).next('.display-input').should('include.text', 'East Kootenay')
cy.get('label[for="Community"]', { timeout: STANDARD_TIMEOUT }).next('.display-input').should('include.text', 'East Kootenay B')
cy.get('label[for="RequestedAmount"]', { timeout: STANDARD_TIMEOUT }).next('.display-input').should('include.text', '$89,000.00')
cy.get('label[for="ProjectBudget"]', { timeout: STANDARD_TIMEOUT }).next('.display-input').should('include.text', '$125,000.00')
cy.get('label[for="Sector"]', { timeout: STANDARD_TIMEOUT }).next('.display-input').should('include.text', 'Other services (except public administration)')
cy.get('#closeSummaryCanvas', { timeout: STANDARD_TIMEOUT }).click({ force: true })
// Open the application details
cy.get('#externalLink', { timeout: STANDARD_TIMEOUT }).should('exist').click({ force: true })
// Review & Assessment tab
cy.get('#nav-review-and-assessment-tab', { timeout: STANDARD_TIMEOUT }).should('exist').click({ force: true })
cy.get('#RequestedAmountInputAR', { timeout: STANDARD_TIMEOUT }).should('have.value', '89,000.00')
cy.get('#TotalBudgetInputAR', { timeout: STANDARD_TIMEOUT }).should('have.value', '125,000.00')
// Project Info tab
cy.get('#nav-project-info-tab', { timeout: STANDARD_TIMEOUT }).should('exist').click({ force: true })
cy.get('#ProjectInfo_ProjectName', { timeout: STANDARD_TIMEOUT }).should('have.value', 'Hanbury Development Initiative - Phase 2')
cy.get('#startDate', { timeout: STANDARD_TIMEOUT }).should('have.value', '2026-01-05')
cy.get('#ProjectInfo_ProjectEndDate', { timeout: STANDARD_TIMEOUT }).should('have.value', '2027-03-11')
cy.get('#RequestedAmountInputPI', { timeout: STANDARD_TIMEOUT }).should('have.value', '89,000.00')
cy.get('#TotalBudgetInputPI', { timeout: STANDARD_TIMEOUT }).should('have.value', '125,000.00')
cy.get('#ProjectInfo_Acquisition', { timeout: STANDARD_TIMEOUT }).should('have.value', 'NO')
cy.get('#ProjectInfo_Forestry', { timeout: STANDARD_TIMEOUT }).should('have.value', 'FORESTRY')
cy.get('#ProjectInfo_ForestryFocus', { timeout: STANDARD_TIMEOUT }).should('have.value', 'SECONDARY')
cy.get('#economicRegions', { timeout: STANDARD_TIMEOUT }).should('have.value', 'Kootenay')
cy.get('#regionalDistricts', { timeout: STANDARD_TIMEOUT }).should('have.value', 'East Kootenay')
cy.get('#communities', { timeout: STANDARD_TIMEOUT }).should('have.value', 'East Kootenay B')
cy.get('#ProjectInfo_CommunityPopulation', { timeout: STANDARD_TIMEOUT }).should('have.value', '38')
cy.get('#ProjectInfo_ElectoralDistrict', { timeout: STANDARD_TIMEOUT }).should('have.value', 'Kootenay-Rockies')
cy.get('#ProjectInfo_Place', { timeout: STANDARD_TIMEOUT }).should('have.value', 'Hanbury')
// Applicant Info tab
cy.contains('a.nav-link', 'Applicant Info', { timeout: STANDARD_TIMEOUT }).should('exist').click({ force: true })
// Applicant Summary fieldset
cy.get('fieldset[name="Unity_GrantManager_ApplicationManagement_Applicant_Summary"]', { timeout: STANDARD_TIMEOUT })
.should('exist')
.as('appSummary')
cy.get('@appSummary').find('#ApplicantSummary_ApplicantName', { timeout: STANDARD_TIMEOUT }).should('have.value', 'Dolphin Asphalt')
cy.get('@appSummary').find('#ApplicantSummary_Sector', { timeout: STANDARD_TIMEOUT }).should('exist')
cy.get('@appSummary').find('#ApplicantSummary_SubSector', { timeout: STANDARD_TIMEOUT }).should('exist')
cy.get('@appSummary')
.find('#ApplicantSummary_SectorSubSectorIndustryDesc', { timeout: STANDARD_TIMEOUT })
.should('exist')
.invoke('val')
.should('equal', 'Stone Aggregate Recycling')
// Contact Info fieldset (TEST uses ContactInfo_* ids) :contentReference[oaicite:2]{index=2}
cy.get('fieldset[name="Unity_GrantManager_ApplicationManagement_Applicant_Contact"]', { timeout: STANDARD_TIMEOUT })
.should('exist')
.as('contactInfo')
cy.get('@contactInfo').find('#ContactInfo_Name', { timeout: STANDARD_TIMEOUT }).should('have.value', 'Jeff Gordon')
cy.get('@contactInfo').find('#ContactInfo_Title', { timeout: STANDARD_TIMEOUT }).should('have.value', 'Sr. Analyst')
cy.get('@contactInfo').find('#ContactInfo_Email', { timeout: STANDARD_TIMEOUT }).should('have.value', 'Jeff.Gordon@Dolphin.ca')
cy.get('@contactInfo').find('#ContactInfo_Phone', { timeout: STANDARD_TIMEOUT }).should('have.value', '(250) 621-3217')
cy.get('@contactInfo').find('#ContactInfo_Phone2', { timeout: STANDARD_TIMEOUT }).should('have.value', '(887) 362-1459')
// Sector/Sub-sector dropdown behavior
cy.get('@appSummary').find('#ApplicantSummary_Sector', { timeout: STANDARD_TIMEOUT }).select('Manufacturing')
const subs = [
'Apparel manufacturing',
'Beverage and tobacco product manufacturing',
'Chemical manufacturing',
'Computer and electronic product manufacturing',
'Electrical equipment, appliance, and component manufacturing',
'Fabricated metal product manufacturing',
'Food manufacturing',
'Furniture and related product manufacturing',
'Leather and allied product manufacturing',
'Machinery manufacturing',
'Miscellaneous manufacturing',
'Non-metallic mineral product manufacturing',
'Other',
'Paper manufacturing',
'Petroleum and coal product manufacturing',
'Plastics and rubber products manufacturing',
'Primary metal manufacturing',
'Printing and related support activities',
'Textile mills',
'Textile product mills',
'Transportation equipment manufacturing',
'Wood product manufacturing'
]
subs.forEach((text) => {
cy.get('@appSummary')
.find('#ApplicantSummary_SubSector', { timeout: STANDARD_TIMEOUT })
.select(text)
.should('have.value', text)
})
// Payment Info tab
cy.get('#nav-payment-info-tab', { timeout: STANDARD_TIMEOUT }).should('exist').click({ force: true })
cy.get('#RequestedAmount', { timeout: STANDARD_TIMEOUT }).should('have.value', '89,000.00')
// Submission tab
cy.get('#nav-summery-tab', { timeout: STANDARD_TIMEOUT }).should('exist').click({ force: true })
// In TEST, the section headers are inside shadow DOM and include the numeric prefix (e.g., "2. ELIGIBILITY").
// Anchor to the actual tag and allow the number to vary.
const sectionRegexes: RegExp[] = [
/^\s*\d+\.\s*INTRODUCTION\s*$/i,
/^\s*\d+\.\s*ELIGIBILITY\s*$/i,
/^\s*\d+\.\s*APPLICANT INFORMATION\s*$/i,
/^\s*\d+\.\s*PROJECT INFORMATION\s*$/i,
/^\s*\d+\.\s*PROJECT TIMELINES\s*$/i,
/^\s*\d+\.\s*PROJECT BUDGET\s*$/i,
/^\s*\d+\.\s*ATTESTATION\s*$/i
]
// Wait for one known header to render
cy.contains('h4', /^\s*\d+\.\s*INTRODUCTION\s*$/i, { timeout: STANDARD_TIMEOUT }).should('exist')
sectionRegexes.forEach((rx) => {
cy.contains('h4', rx, { timeout: STANDARD_TIMEOUT })
.should('exist')
.click({ force: true })
})
})
it('Verify Logout', () => {
cy.logout()
})
})