Skip to content

Commit cbf7a75

Browse files
authored
Merge pull request #1955 from bcgov/dev
Dev
2 parents fc2b30e + 0078b36 commit cbf7a75

55 files changed

Lines changed: 9873 additions & 111 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

applications/Unity.AutoUI/cypress/e2e/basicEmail.cy.ts

Lines changed: 93 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
1+
// cypress/e2e/basicEmail.cy.ts
2+
13
describe('Send an email', () => {
24
const TEST_EMAIL_TO = 'grantmanagementsupport@gov.bc.ca'
35
const TEST_EMAIL_CC = 'UnitySupport@gov.bc.ca'
46
const TEST_EMAIL_BCC = 'UNITYSUP@Victoria1.gov.bc.ca'
57
const TEMPLATE_NAME = 'Test Case 1'
68
const STANDARD_TIMEOUT = 20000
79

10+
// Only suppress the noisy ResizeObserver error that Unity throws in TEST.
11+
// Everything else should still fail the test.
12+
Cypress.on('uncaught:exception', (err) => {
13+
const msg = err && err.message ? err.message : ''
14+
if (msg.indexOf('ResizeObserver loop limit exceeded') >= 0) {
15+
return false
16+
}
17+
return true
18+
})
19+
820
const now = new Date()
921
const timestamp =
1022
now.getFullYear() +
@@ -23,8 +35,6 @@ describe('Send an email', () => {
2335

2436
function switchToDefaultGrantsProgramIfAvailable() {
2537
cy.get('body').then(($body) => {
26-
// If we are already on GrantPrograms (or can navigate there), try. Otherwise skip quietly.
27-
// Key point: never .should() an optional element.
2838
const hasUserInitials = $body.find('.unity-user-initials').length > 0
2939

3040
if (!hasUserInitials) {
@@ -41,7 +51,6 @@ describe('Send an email', () => {
4151

4252
if (switchLink.length === 0) {
4353
cy.log('Skipping tenant switch: "Switch Grant Programs" not present for this user/session')
44-
// Close dropdown so it does not block clicks later
4554
cy.get('body').click(0, 0)
4655
return
4756
}
@@ -74,6 +83,81 @@ describe('Send an email', () => {
7483
})
7584
}
7685

86+
function openSavedEmailFromHistoryBySubject(subject: string) {
87+
cy.get('body', { timeout: STANDARD_TIMEOUT }).then(($body) => {
88+
const historyTableById = $body.find('#EmailHistoryTable')
89+
if (historyTableById.length > 0) {
90+
cy.get('#EmailHistoryTable', { timeout: STANDARD_TIMEOUT })
91+
.should('be.visible')
92+
.within(() => {
93+
cy.contains('td', subject, { timeout: STANDARD_TIMEOUT })
94+
.should('exist')
95+
.click()
96+
})
97+
return
98+
}
99+
100+
// Fallback: find the subject anywhere in a TD (scoped to avoid brittle class names)
101+
cy.contains('td', subject, { timeout: STANDARD_TIMEOUT })
102+
.should('exist')
103+
.click()
104+
})
105+
}
106+
107+
function confirmSendDialogIfPresent() {
108+
// Wait until either a bootstrap modal is shown, or SweetAlert container appears, or confirm button exists.
109+
cy.get('body', { timeout: STANDARD_TIMEOUT }).should(($b) => {
110+
const hasBootstrapShownModal = $b.find('.modal.show').length > 0
111+
const hasSwal = $b.find('.swal2-container').length > 0
112+
const hasConfirmBtn = $b.find('#btn-confirm-send').length > 0
113+
expect(hasBootstrapShownModal || hasSwal || hasConfirmBtn).to.eq(true)
114+
})
115+
116+
cy.get('body', { timeout: STANDARD_TIMEOUT }).then(($b) => {
117+
const hasSwal = $b.find('.swal2-container').length > 0
118+
if (hasSwal) {
119+
// SweetAlert2 style
120+
cy.get('.swal2-container', { timeout: STANDARD_TIMEOUT }).should('be.visible')
121+
cy.contains('.swal2-container', 'Are you sure', { timeout: STANDARD_TIMEOUT }).should('exist')
122+
123+
// Typical confirm button class, with fallback to text match
124+
if ($b.find('.swal2-confirm').length > 0) {
125+
cy.get('.swal2-confirm', { timeout: STANDARD_TIMEOUT }).should('be.visible').click()
126+
} else {
127+
cy.contains('.swal2-container button', 'Yes', { timeout: STANDARD_TIMEOUT }).click()
128+
}
129+
return
130+
}
131+
132+
const hasBootstrapShownModal = $b.find('.modal.show').length > 0
133+
if (hasBootstrapShownModal) {
134+
// Bootstrap modal: assert the shown modal, not the inner content div
135+
cy.get('.modal.show', { timeout: STANDARD_TIMEOUT })
136+
.should('be.visible')
137+
.within(() => {
138+
cy.contains('Are you sure you want to send this email?', { timeout: STANDARD_TIMEOUT })
139+
.should('exist')
140+
141+
// Prefer the known id if present, otherwise click a button with expected intent text
142+
if (Cypress.$('#btn-confirm-send').length > 0) {
143+
cy.get('#btn-confirm-send', { timeout: STANDARD_TIMEOUT })
144+
.should('exist')
145+
.should('be.visible')
146+
.click()
147+
} else {
148+
cy.contains('button', 'Confirm', { timeout: STANDARD_TIMEOUT }).click()
149+
}
150+
})
151+
return
152+
}
153+
154+
// Last resort: confirm button exists but modal might not be "visible" by Cypress standards
155+
cy.get('#btn-confirm-send', { timeout: STANDARD_TIMEOUT })
156+
.should('exist')
157+
.click({ force: true })
158+
})
159+
}
160+
77161
it('Login', () => {
78162
cy.login()
79163
})
@@ -189,38 +273,27 @@ describe('Send an email', () => {
189273
})
190274

191275
it('Select saved email from Email History', () => {
192-
cy.contains('td.data-table-header', TEST_EMAIL_SUBJECT, { timeout: STANDARD_TIMEOUT })
193-
.should('exist')
194-
.click()
276+
openSavedEmailFromHistoryBySubject(TEST_EMAIL_SUBJECT)
195277

196278
cy.get('#EmailTo', { timeout: STANDARD_TIMEOUT }).should('be.visible')
197279
cy.get('#EmailCC').should('be.visible')
198280
cy.get('#EmailBCC').should('be.visible')
199281
cy.get('#EmailSubject').should('be.visible')
200282

201-
cy.get('#btn-send').should('be.visible')
202-
cy.get('#btn-save').should('be.visible')
283+
cy.get('#btn-send', { timeout: STANDARD_TIMEOUT }).should('exist')
284+
cy.get('#btn-save', { timeout: STANDARD_TIMEOUT }).should('exist')
203285
})
204286

205287
it('Send the email', () => {
206288
cy.get('#btn-send', { timeout: STANDARD_TIMEOUT })
207289
.should('exist')
208290
.should('be.visible')
291+
.should('not.be.disabled')
209292
.click()
210293
})
211294

212-
it('Confirm send email in modal', () => {
213-
cy.get('#modal-content', { timeout: STANDARD_TIMEOUT })
214-
.should('exist')
215-
.should('be.visible')
216-
217-
cy.contains('Are you sure you want to send this email?', { timeout: STANDARD_TIMEOUT })
218-
.should('exist')
219-
220-
cy.get('#btn-confirm-send', { timeout: STANDARD_TIMEOUT })
221-
.should('exist')
222-
.should('be.visible')
223-
.click()
295+
it('Confirm send email in dialog', () => {
296+
confirmSendDialogIfPresent()
224297
})
225298

226299
it('Verify Logout', () => {

applications/Unity.GrantManager/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@ src/Unity.GrantManager.DbMigrator/Logs/*
261261
src/Unity.GrantManager.Blazor.Server/Logs/*
262262
src/Unity.GrantManager.Blazor.Server.Tiered/Logs/*
263263

264+
# Development settings with sensitive information
265+
**/appsettings.Development.json
266+
264267
# Use abp install-libs to restore.
265268
**/wwwroot/libs/*
266269

applications/Unity.GrantManager/modules/Unity.Flex/src/Unity.Flex.Application/Unity.Flex.Application.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12+
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.5" />
1213
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.5" />
1314
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.5" />
1415
<PackageReference Include="System.Text.Json" Version="9.0.5" />

applications/Unity.GrantManager/modules/Unity.Flex/test/Unity.Flex.Application.Tests/Unity.Flex.Application.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<ItemGroup>
1212
<ProjectReference Include="..\..\src\Unity.Flex.Application\Unity.Flex.Application.csproj" />
1313
<ProjectReference Include="..\Unity.Flex.TestBase\Unity.Flex.TestBase.csproj" />
14+
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.5" />
1415
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.5" />
1516
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.5" />
1617
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />

applications/Unity.GrantManager/modules/Unity.Flex/test/Unity.Flex.TestBase/Security/FakeCurrentPrincipalAccessor.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.Collections.Generic;
2-
using System.Security.Claims;
1+
using System.Security.Claims;
32
using Volo.Abp.DependencyInjection;
43
using Volo.Abp.Security.Claims;
54

@@ -13,14 +12,14 @@ protected override ClaimsPrincipal GetClaimsPrincipal()
1312
return GetPrincipal();
1413
}
1514

16-
private ClaimsPrincipal GetPrincipal()
15+
private static ClaimsPrincipal GetPrincipal()
1716
{
18-
return new ClaimsPrincipal(new ClaimsIdentity(new List<Claim>
19-
{
17+
return new ClaimsPrincipal(new ClaimsIdentity(
18+
[
2019
new Claim(AbpClaimTypes.UserId, "2e701e62-0953-4dd3-910b-dc6cc93ccb0d"),
2120
new Claim(AbpClaimTypes.UserName, "admin"),
2221
new Claim(AbpClaimTypes.Email, "admin@abp.io")
23-
}
22+
]
2423
)
2524
);
2625
}

applications/Unity.GrantManager/modules/Unity.Identity.Web/src/Unity.Identity.Web.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
</ItemGroup>
3232

3333
<ItemGroup>
34+
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.5" />
3435
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.5" />
3536
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.5" />
3637
<PackageReference Include="System.Text.Json" Version="9.0.5" />

applications/Unity.GrantManager/modules/Unity.Notifications/src/Unity.Notifications.EntityFrameworkCore/Unity.Notifications.EntityFrameworkCore.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12+
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.5" />
1213
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.5" />
1314
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.5" />
1415
<PackageReference Include="System.Text.Json" Version="9.0.5" />

applications/Unity.GrantManager/modules/Unity.Notifications/test/Unity.Notifications.Application.Tests/Unity.Notifications.Application.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<ItemGroup>
1212
<ProjectReference Include="..\..\src\Unity.Notifications.Application\Unity.Notifications.Application.csproj" />
1313
<ProjectReference Include="..\Unity.Notifications.Domain.Tests\Unity.Notifications.Domain.Tests.csproj" />
14+
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.5" />
1415
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.5" />
1516
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
1617
<PackageReference Include="System.Text.Json" Version="9.0.5" />

applications/Unity.GrantManager/modules/Unity.Notifications/test/Unity.Notifications.Domain.Tests/Unity.Notifications.Domain.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12+
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.5" />
1213
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.5" />
1314
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.5" />
1415
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />

applications/Unity.GrantManager/modules/Unity.Notifications/test/Unity.Notifications.EntityFrameworkCore.Tests/Unity.Notifications.EntityFrameworkCore.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12+
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.5" />
1213
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.5" />
1314
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.5" />
1415
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />

0 commit comments

Comments
 (0)