Skip to content

Commit fa97504

Browse files
committed
PUB-2365 - Fixed merge conflicts
2 parents 3d81509 + a16c1ad commit fa97504

File tree

4 files changed

+122
-16
lines changed

4 files changed

+122
-16
lines changed

src/test/end-to-end/tests/custom-steps.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export = function () {
8080
this.usePlaywrightTo('Go to media login', async ({ page }) => {
8181
page.goto(testConfig.TEST_URL + '/sign-in');
8282
});
83+
this.waitForText('With a Court and tribunal hearings account');
8384
this.click('With a Court and tribunal hearings account');
8485
this.click('Continue');
8586
this.waitForText('Sign in with your email address');
@@ -93,6 +94,7 @@ export = function () {
9394
this.usePlaywrightTo('Go to media login', async ({ page }) => {
9495
page.goto(testConfig.TEST_URL + '/sign-in');
9596
});
97+
this.waitForText('With a Court and tribunal hearings account');
9698
this.click('With a Court and tribunal hearings account');
9799
this.click('Continue');
98100
this.waitForText('Sign in with your email address');
@@ -105,6 +107,7 @@ export = function () {
105107
this.usePlaywrightTo('Go to cft login', async ({ page }) => {
106108
page.goto(testConfig.TEST_URL + '/sign-in');
107109
});
110+
this.waitForText('With a MyHMCTS account');
108111
this.click('With a MyHMCTS account');
109112
this.click('Continue');
110113
this.waitForText('Sign in');
@@ -118,6 +121,7 @@ export = function () {
118121
this.usePlaywrightTo('Go to cft login', async ({ page }) => {
119122
page.goto(testConfig.TEST_URL + '/sign-in');
120123
});
124+
this.waitForText('With a MyHMCTS account');
121125
this.click('With a MyHMCTS account');
122126
this.click('Continue');
123127
this.waitForText('Sign in');
@@ -130,6 +134,7 @@ export = function () {
130134
this.usePlaywrightTo('Go to cft Welsh login', async ({ page }) => {
131135
page.goto(testConfig.TEST_URL + '/sign-in');
132136
});
137+
this.waitForText('With a MyHMCTS account');
133138
this.click('Cymraeg');
134139
this.click('Gyda chyfrif MyHMCTS');
135140
this.click('Parhau');

src/test/end-to-end/tests/login-test.ts

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,20 @@ Scenario(
3434
}
3535
).tag('@Nightly');
3636

37-
Scenario.skip(
38-
'I as a media user should be able to see the beta tag and feedback link when logging in',
39-
async ({ I }) => {
40-
I.usePlaywrightTo('Go to home page', async ({ page }) => {
41-
page.goto(testConfig.TEST_URL + '/sign-in');
42-
});
43-
I.click('With a Court and tribunal hearings account');
44-
I.click('Continue');
45-
I.waitForText('Sign in with your email address');
46-
I.seeBetaFeedbackOnPage('b2c/login');
47-
I.executeScript('window.history.back();');
48-
I.click('Forgot your password?');
49-
I.waitForText('Please provide the following details.');
50-
I.seeBetaFeedbackOnPage('b2c/reset-pw');
51-
}
52-
);
37+
Scenario('I as a media user should be able to see the beta tag and feedback link when logging in', async ({ I }) => {
38+
I.usePlaywrightTo('Go to home page', async ({ page }) => {
39+
page.goto(testConfig.TEST_URL + '/sign-in');
40+
});
41+
I.waitForText('With a Court and tribunal hearings account');
42+
I.click('With a Court and tribunal hearings account');
43+
I.click('Continue');
44+
I.waitForText('Sign in with your email address');
45+
I.seeBetaFeedbackOnPage('b2c/login');
46+
I.executeScript('window.history.back();');
47+
I.click('Forgot your password?');
48+
I.waitForText('Please provide the following details.');
49+
I.seeBetaFeedbackOnPage('b2c/reset-pw');
50+
});
5351

5452
Scenario('I as a CFT user should be able to sign-in with the valid credentials in English', async ({ I }) => {
5553
I.loginAsCftUser();
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
const mockTrackTrace = jest.fn();
2+
const mockSetSendLiveMetrics = jest.fn().mockReturnThis();
3+
const mockStart = jest.fn().mockReturnThis();
4+
5+
jest.mock('applicationinsights', () => {
6+
return {
7+
setup: jest.fn(() => ({
8+
setSendLiveMetrics: mockSetSendLiveMetrics,
9+
start: mockStart,
10+
})),
11+
defaultClient: {
12+
context: {
13+
tags: {},
14+
keys: {
15+
cloudRole: 'undefined-frontend',
16+
},
17+
},
18+
trackTrace: mockTrackTrace,
19+
},
20+
};
21+
});
22+
23+
import * as appInsights from 'applicationinsights';
24+
import { AppInsights } from '../../../../main/modules/appinsights';
25+
26+
jest.mock('config', () => ({
27+
get: jest.fn(() => {
28+
return 'CONFIG_CONNECTION_STRING';
29+
}),
30+
}));
31+
32+
describe('App Insights', () => {
33+
beforeEach(() => {
34+
jest.clearAllMocks();
35+
delete process.env.APP_INSIGHTS_CONNECTION_STRING;
36+
appInsights.defaultClient.context.tags = {};
37+
});
38+
39+
it('Uses environment variable for connection string', () => {
40+
process.env.APP_INSIGHTS_CONNECTION_STRING = 'ENV_CONNECTION_STRING';
41+
const appInsightsLibrary = new AppInsights();
42+
appInsightsLibrary.enable();
43+
44+
expect(appInsights.setup).toHaveBeenCalledWith('ENV_CONNECTION_STRING');
45+
expect(mockSetSendLiveMetrics).toHaveBeenCalledWith(true);
46+
expect(mockStart).toHaveBeenCalled();
47+
expect(appInsights.defaultClient.context.tags[appInsights.defaultClient.context.keys.cloudRole]).toBe(
48+
'pip-frontend'
49+
);
50+
expect(mockTrackTrace).toHaveBeenCalledWith({ message: 'App insights activated' });
51+
});
52+
53+
it('Uses config for connection string if env not set', () => {
54+
const appInsightsLibrary = new AppInsights();
55+
appInsightsLibrary.enable();
56+
57+
expect(appInsights.setup).toHaveBeenCalledWith('CONFIG_CONNECTION_STRING');
58+
expect(mockSetSendLiveMetrics).toHaveBeenCalledWith(true);
59+
expect(mockStart).toHaveBeenCalled();
60+
expect(appInsights.defaultClient.context.tags[appInsights.defaultClient.context.keys.cloudRole]).toBe(
61+
'pip-frontend'
62+
);
63+
expect(mockTrackTrace).toHaveBeenCalledWith({ message: 'App insights activated' });
64+
});
65+
66+
it('Does nothing if no connection string is available', async () => {
67+
jest.resetModules();
68+
jest.doMock('config', () => ({
69+
get: jest.fn(() => undefined),
70+
}));
71+
delete process.env.APP_INSIGHTS_CONNECTION_STRING;
72+
73+
const { AppInsights: AppInsightsNoConfig } = await import('../../../../main/modules/appinsights');
74+
const appInsightsLibrary = new AppInsightsNoConfig();
75+
appInsightsLibrary.enable();
76+
77+
expect(appInsights.setup).not.toHaveBeenCalled();
78+
expect(mockSetSendLiveMetrics).not.toHaveBeenCalled();
79+
expect(mockStart).not.toHaveBeenCalled();
80+
expect(mockTrackTrace).not.toHaveBeenCalled();
81+
});
82+
});

src/test/unit/requests/dataManagementRequests.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ const errorMessage = {
1313
message: 'test',
1414
};
1515

16+
const errorResponseWithStatusButNoText = {
17+
response: {
18+
status: 400,
19+
},
20+
};
21+
1622
const errorResponseWithUiErrorText = {
1723
response: {
1824
status: 400,
@@ -285,5 +291,20 @@ describe('Data Management requests', () => {
285291
});
286292
expect(await fileUploadAPI.uploadLocationFile({ file: '', fileName: 'baz' })).toBeFalsy();
287293
});
294+
295+
it('should return false when error response text is not present', async () => {
296+
sinon.stub(superagent, 'post').callsFake(() => {
297+
return {
298+
set(): any {
299+
return {
300+
set(): any {
301+
return { attach: sinon.stub().rejects(errorResponseWithStatusButNoText) };
302+
},
303+
};
304+
},
305+
};
306+
});
307+
expect(await fileUploadAPI.uploadLocationFile({ file: '', fileName: 'baz' })).toBeFalsy();
308+
});
288309
});
289310
});

0 commit comments

Comments
 (0)