Skip to content

Commit 6db01a3

Browse files
authored
Merge branch 'develop' into dependabot/npm_and_yarn/apps/frontend/multi-c22e25d29b
2 parents 75f3898 + d861746 commit 6db01a3

5 files changed

Lines changed: 170 additions & 42 deletions

File tree

.github/workflows/rebase-prs-with-develop.yml renamed to .github/workflows/update-prs-with-develop.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Rebase PRs with develop
1+
name: Update PRs with develop
22

33
on:
44
push:
@@ -7,6 +7,8 @@ on:
77

88
jobs:
99
sync-prs:
10+
# Disabled until we can push with a PAT that has workflow scope; otherwise CI stays in "Waiting".
11+
if: ${{ false }}
1012
runs-on: ubuntu-latest
1113

1214
steps:
@@ -20,7 +22,9 @@ jobs:
2022
git config --global user.name "github-actions[bot]"
2123
git config --global user.email "github-actions[bot]@users.noreply.github.com"
2224
23-
- name: Rebase all open non-Dependabots PRs with develop branch as base
25+
- name: Merge develop into all open non-Dependabot PRs
26+
# TODO: Re-enable once we replace the default GITHUB_TOKEN with a PAT that has repo+workflow scopes
27+
# so that downstream PR checks trigger automatically after the bot pushes merge commits.
2428
env:
2529
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2630
run: |
@@ -32,14 +36,14 @@ jobs:
3236
gh pr checkout $pr
3337
git fetch origin develop
3438
35-
# Attempt rebase
36-
if git rebase origin/develop; then
37-
echo "PR #$pr rebased successfully. Pushing changes..."
38-
git push --force-with-lease
39+
# Attempt merge
40+
if git merge --no-edit origin/develop; then
41+
echo "PR #$pr merged successfully. Pushing changes..."
42+
git push
3943
else
40-
echo "Conflict in PR #$pr. Rebase aborted."
41-
git rebase --abort
44+
echo "Conflict in PR #$pr. Merge aborted."
45+
git merge --abort
4246
# Optional: Notify author
43-
gh pr comment $pr --body "⚠️ Automatic rebase failed due to conflicts. Please rebase manually."
47+
gh pr comment $pr --body "⚠️ Automatic merge of \`develop\` into this PR failed due to conflicts. Please resolve the conflicts and update your branch."
4448
fi
4549
done
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
import 'reflect-metadata';
2+
import { faker } from '@faker-js/faker';
3+
import * as Logger from '@user-office-software/duo-logger';
4+
import { container } from 'tsyringe';
5+
6+
import { Tokens } from '../../config/Tokens';
7+
import { ApplicationEvent } from '../../events/applicationEvents';
8+
import { Event } from '../../events/event.enum';
9+
import { stfcEmailHandler } from './stfcEmailHandler';
10+
11+
const ORIGINAL_ENV = process.env;
12+
const spyLogError = jest
13+
.spyOn(Logger.logger, 'logError')
14+
.mockImplementation(() => {});
15+
const spyLogInfo = jest
16+
.spyOn(Logger.logger, 'logInfo')
17+
.mockImplementation(() => {});
18+
// Mock MailService
19+
const mockMailService = {
20+
sendMail: jest.fn(),
21+
};
22+
describe('stfcEmailHandler', () => {
23+
beforeAll(() => {
24+
container.registerInstance(Tokens.MailService, mockMailService);
25+
});
26+
afterEach(() => {
27+
process.env = ORIGINAL_ENV;
28+
jest.clearAllMocks();
29+
jest.resetModules();
30+
});
31+
32+
describe('These are the test for the handler function stfcEmailhandler', () => {
33+
it('When running Node process does not have env.FBS_EMAIL value', () => {
34+
process.env.FBS_EMAIL = '';
35+
const mockEvent = {
36+
type: Event.CALL_CREATED,
37+
call: {},
38+
isRejection: false,
39+
} as ApplicationEvent;
40+
41+
stfcEmailHandler(mockEvent);
42+
43+
expect(process.env.FBS_EMAIL).toBe('');
44+
expect(spyLogError).toHaveBeenCalledTimes(1);
45+
expect(spyLogError).toHaveBeenCalledWith(
46+
'Could not send email(s) on call creation, environmental variable (FBS_EMAIL) not found',
47+
{}
48+
);
49+
});
50+
51+
it('mailService.sendMail is sucessful', async () => {
52+
// When all required settings are valid
53+
const inviteEmail = faker.internet.email();
54+
process.env.FBS_EMAIL = inviteEmail;
55+
const mockEvent = {
56+
type: Event.CALL_CREATED,
57+
call: {
58+
shortCode: 'string',
59+
startCall: new Date(2000, 1, 1),
60+
endCall: new Date(2000, 1, 2),
61+
},
62+
isRejection: false,
63+
} as ApplicationEvent;
64+
65+
//create mock instances
66+
mockMailService.sendMail.mockResolvedValue({ success: true });
67+
68+
await stfcEmailHandler(mockEvent);
69+
70+
expect(process.env.FBS_EMAIL).toBe(inviteEmail);
71+
expect(mockMailService.sendMail).toHaveBeenCalledWith({
72+
content: { template_id: 'call-created-email' },
73+
substitution_data: {
74+
shortCode: 'string',
75+
startCall: new Date(2000, 1, 1),
76+
endCall: new Date(2000, 1, 2),
77+
},
78+
recipients: [{ address: inviteEmail }],
79+
});
80+
expect(spyLogInfo).toHaveBeenCalledTimes(1);
81+
// this result is derived from the SkipSendMailService.ts, as that is what is mapped in the test environment
82+
expect(spyLogInfo).toHaveBeenCalledWith('Emails sent on call creation:', {
83+
result: {
84+
success: true,
85+
},
86+
event: mockEvent,
87+
});
88+
});
89+
90+
it('mailService.sendMail is not sucessful', async () => {
91+
// Then mailService.catch is evoked, logError(x) will be present
92+
const inviteEmail = faker.internet.email();
93+
process.env.FBS_EMAIL = inviteEmail;
94+
const mockEvent = {
95+
type: Event.CALL_CREATED,
96+
call: {
97+
shortCode: 'error',
98+
},
99+
isRejection: false,
100+
} as ApplicationEvent;
101+
const forcedError = new Error('SMTP down');
102+
103+
mockMailService.sendMail.mockRejectedValueOnce(forcedError);
104+
container.registerInstance(Tokens.MailService, mockMailService);
105+
106+
await stfcEmailHandler(mockEvent);
107+
// have added this line as the class.method in the handler function is not asynced
108+
// and the asserts/expects will check before .then or .catch gets process
109+
await new Promise(setImmediate);
110+
111+
expect(mockMailService.sendMail).toHaveBeenCalledWith({
112+
content: { template_id: 'call-created-email' },
113+
substitution_data: {
114+
shortCode: 'error',
115+
},
116+
recipients: [{ address: inviteEmail }],
117+
});
118+
expect(mockMailService.sendMail).toHaveBeenCalled();
119+
expect(spyLogError).toHaveBeenCalledTimes(1);
120+
expect(spyLogError).toHaveBeenCalledWith(
121+
'Could not send email(s) on call creation:',
122+
{
123+
error: forcedError,
124+
event: mockEvent,
125+
}
126+
);
127+
});
128+
});
129+
});

apps/e2e/cypress/e2e/peopleTable.cy.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -433,21 +433,18 @@ context('PageTable component tests', () => {
433433
});
434434

435435
cy.intercept('POST', '/graphql', (req) => {
436-
return new Promise((resolve) => {
437-
setTimeout(() => resolve(req.continue()), 1000); // delay by 1 second to see the loader
438-
});
439-
}).as('delayedRequest');
436+
if (req.body?.operationName === 'getUsers') {
437+
req.alias = 'getUsers';
438+
}
439+
});
440440

441441
cy.get('[data-cy="people-table"] thead')
442442
.contains('Firstname')
443443
.parent()
444444
.find('[data-testid="mtableheader-sortlabel"]')
445445
.click();
446446

447-
cy.get('[data-cy="people-table"] [role="progressbar"]').should('exist');
448-
449-
cy.wait('@delayedRequest');
450-
447+
cy.wait('@getUsers');
451448
cy.finishedLoading();
452449

453450
cy.get('[data-cy="people-table"] tbody tr')
@@ -465,10 +462,7 @@ context('PageTable component tests', () => {
465462
.find('[data-testid="mtableheader-sortlabel"]')
466463
.click();
467464

468-
cy.get('[data-cy="people-table"] [role="progressbar"]').should('exist');
469-
470-
cy.wait('@delayedRequest');
471-
465+
cy.wait('@getUsers');
472466
cy.finishedLoading();
473467

474468
cy.get('[data-cy="people-table"] tbody tr')

apps/e2e/package-lock.json

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)