AAE-30882 Remove superagent for fetch (#11856)

* [AAE-30882] - Remove superagent for fetch

* [AAE-30882] - Fixing comments

* [AAE-30882] - fixde failing unit tests

* [AAE-30882] - fixde failing unit tests

* [AAE-30882] - fixd sonarcloud comment
This commit is contained in:
Vito Albano
2026-05-07 09:12:07 +01:00
committed by GitHub
parent 9cdacf3ebf
commit 57bf066164
54 changed files with 2127 additions and 922 deletions
@@ -15,7 +15,6 @@
* limitations under the License.
*/
import nock from 'nock';
import { BaseMock } from '../base.mock';
export class BpmAuthMock extends BaseMock {
@@ -29,7 +28,7 @@ export class BpmAuthMock extends BaseMock {
}
get200Response(): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.post(
'/activiti-app/app/authentication',
'j_username=' + this.username + '&j_password=' + this.password + '&_spring_security_remember_me=true&submit=Login'
@@ -38,11 +37,11 @@ export class BpmAuthMock extends BaseMock {
}
get200ResponseLogout(): void {
nock(this.host, { encodedQueryParams: true }).get('/activiti-app/app/logout', {}).reply(200);
this.mock().get('/activiti-app/app/logout').reply(200);
}
get401Response(): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.post('/activiti-app/app/authentication', 'j_username=wrong&j_password=name&_spring_security_remember_me=true&submit=Login')
.reply(401, {
error: {
@@ -52,8 +51,19 @@ export class BpmAuthMock extends BaseMock {
});
}
get401ResponseAdminCredentials(): void {
this.mock()
.post('/activiti-app/app/authentication', 'j_username=admin&j_password=admin&_spring_security_remember_me=true&submit=Login')
.reply(401, {
error: {
message: 'This request requires HTTP authentication.',
statusCode: 401
}
});
}
get403Response(): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.post('/activiti-app/app/authentication', 'j_username=wrong&j_password=name&_spring_security_remember_me=true&submit=Login')
.reply(403, {
error: {
@@ -15,12 +15,11 @@
* limitations under the License.
*/
import nock from 'nock';
import { BaseMock } from '../base.mock';
import { BaseMock, mockHost } from '../base.mock';
export class ModelJsonBpmMock extends BaseMock {
get200EditorDisplayJsonClient(): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.get('/activiti-app/app/rest/models/1/model-json')
.reply(200, {
elements: [
@@ -87,7 +86,7 @@ export class ModelJsonBpmMock extends BaseMock {
}
get200HistoricEditorDisplayJsonClient(): void {
nock('https://127.0.0.1:9999', { encodedQueryParams: true })
mockHost('https://127.0.0.1:9999')
.get('/activiti-app/app/rest/models/1/history/1/model-json')
.reply(200, {
elements: [
@@ -15,12 +15,11 @@
* limitations under the License.
*/
import nock from 'nock';
import { BaseMock } from '../base.mock';
export class ModelsMock extends BaseMock {
get200getModels(): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.get('/activiti-app/api/enterprise/models')
.query({ filter: 'myReusableForms', modelType: '2' })
.reply(200, {
@@ -15,7 +15,6 @@
* limitations under the License.
*/
import nock from 'nock';
import { BaseMock } from '../base.mock';
const fakeVariable1 = {
@@ -34,13 +33,13 @@ const fakeVariablesList = [fakeVariable1, fakeVariable2];
export class ProcessInstanceVariablesMock extends BaseMock {
addListProcessInstanceVariables200Response(processInstanceId: string): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.get('/activiti-app/api/enterprise/process-instances/' + processInstanceId + '/variables')
.reply(200, fakeVariablesList);
}
addListProcessInstanceVariables500Response(processInstanceId: string): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.get('/activiti-app/api/enterprise/process-instances/' + processInstanceId + '/variables')
.reply(500, {
messageKey: 'UNKNOWN',
@@ -49,13 +48,13 @@ export class ProcessInstanceVariablesMock extends BaseMock {
}
addPutProcessInstanceVariables200Response(processInstanceId: string): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.put('/activiti-app/api/enterprise/process-instances/' + processInstanceId + '/variables')
.reply(200, fakeVariablesList);
}
addPutProcessInstanceVariables500Response(processInstanceId: string): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.put('/activiti-app/api/enterprise/process-instances/' + processInstanceId + '/variables')
.reply(500, {
messageKey: 'UNKNOWN',
@@ -64,13 +63,13 @@ export class ProcessInstanceVariablesMock extends BaseMock {
}
addGetProcessInstanceVariable200Response(processInstanceId: string, variableName: string): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.get('/activiti-app/api/enterprise/process-instances/' + processInstanceId + '/variables/' + variableName)
.reply(200, fakeVariable1);
}
addGetProcessInstanceVariable500Response(processInstanceId: string, variableName: string): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.get('/activiti-app/api/enterprise/process-instances/' + processInstanceId + '/variables/' + variableName)
.reply(500, {
messageKey: 'UNKNOWN',
@@ -79,13 +78,13 @@ export class ProcessInstanceVariablesMock extends BaseMock {
}
addUpdateProcessInstanceVariable200Response(processInstanceId: string, variableName: string): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.put('/activiti-app/api/enterprise/process-instances/' + processInstanceId + '/variables/' + variableName)
.reply(200, fakeVariable1);
}
addUpdateProcessInstanceVariable500Response(processInstanceId: string, variableName: string): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.put('/activiti-app/api/enterprise/process-instances/' + processInstanceId + '/variables/' + variableName)
.reply(500, {
messageKey: 'UNKNOWN',
@@ -94,13 +93,13 @@ export class ProcessInstanceVariablesMock extends BaseMock {
}
addDeleteProcessInstanceVariable200Response(processInstanceId: string, variableName: string): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.delete('/activiti-app/api/enterprise/process-instances/' + processInstanceId + '/variables/' + variableName)
.reply(200);
}
addDeleteProcessInstanceVariable500Response(processInstanceId: string, variableName: string): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.delete('/activiti-app/api/enterprise/process-instances/' + processInstanceId + '/variables/' + variableName)
.reply(500, {
messageKey: 'UNKNOWN',
@@ -15,12 +15,11 @@
* limitations under the License.
*/
import nock from 'nock';
import { BaseMock } from '../base.mock';
export class ProcessMock extends BaseMock {
get200Response(): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.post('/activiti-app/api/enterprise/process-instances/query')
.reply(200, {
size: 2,
@@ -82,7 +81,7 @@ export class ProcessMock extends BaseMock {
}
get200getProcessDefinitionStartForm(): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.get('/activiti-app/api/enterprise/process-definitions/testProcess%3A1%3A7504/start-form')
.reply(200, {
id: 2002,
@@ -15,12 +15,11 @@
* limitations under the License.
*/
import nock from 'nock';
import { BaseMock } from '../base.mock';
export class ProfileMock extends BaseMock {
get200getProfile(): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.get('/activiti-app/api/enterprise/profile')
.reply(200, {
id: 1,
@@ -94,10 +93,10 @@ export class ProfileMock extends BaseMock {
}
get401getProfile(): void {
nock(this.host, { encodedQueryParams: true }).get('/activiti-app/api/enterprise/profile').reply(401);
this.mock().get('/activiti-app/api/enterprise/profile').reply(401);
}
get200getProfilePicture(): void {
nock(this.host, { encodedQueryParams: true }).get('/activiti-app/api/enterprise/profile-picture').reply(200, 'BUFFERSIZE');
this.mock().get('/activiti-app/api/enterprise/profile-picture').reply(200, 'BUFFERSIZE');
}
}
@@ -15,7 +15,8 @@
* limitations under the License.
*/
import nock from 'nock';
// cspell:ignore collapseable
import { BaseMock } from '../base.mock';
const fakeReportList = [
@@ -154,58 +155,56 @@ const fakeProcessDefinitionsNoApp: any[] = [
export class ReportsMock extends BaseMock {
get200ResponseCreateDefaultReport(): void {
nock(this.host, { encodedQueryParams: true }).post('/activiti-app/app/rest/reporting/default-reports').reply(200);
this.mock().post('/activiti-app/app/rest/reporting/default-reports').reply(200);
}
get200ResponseTasksByProcessDefinitionId(reportId: string, processDefinitionId: string): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.get('/activiti-app/app/rest/reporting/report-params/' + reportId + '/tasks')
.query({ processDefinitionId })
.reply(200, ['Fake Task 1', 'Fake Task 2', 'Fake Task 3']);
}
get200ResponseReportList(): void {
nock(this.host, { encodedQueryParams: true }).get('/activiti-app/app/rest/reporting/reports').reply(200, fakeReportList);
this.mock().get('/activiti-app/app/rest/reporting/reports').reply(200, fakeReportList);
}
get200ResponseReportParams(reportId: string): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.get('/activiti-app/app/rest/reporting/report-params/' + reportId)
.reply(200, fakeReportParams);
}
get200ResponseReportsByParams(reportId: string, paramsQuery: { status: string }): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.post('/activiti-app/app/rest/reporting/report-params/' + reportId, paramsQuery)
.reply(200, fakeChartReports);
}
get200ResponseProcessDefinitions(): void {
nock(this.host, { encodedQueryParams: true })
.get('/activiti-app/app/rest/reporting/process-definitions')
.reply(200, fakeProcessDefinitionsNoApp);
this.mock().get('/activiti-app/app/rest/reporting/process-definitions').reply(200, fakeProcessDefinitionsNoApp);
}
get200ResponseUpdateReport(reportId: string): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.put('/activiti-app/app/rest/reporting/reports/' + reportId)
.reply(200);
}
get200ResponseExportReport(reportId: string): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.post('/activiti-app/app/rest/reporting/reports/' + reportId + '/export-to-csv')
.reply(200, 'CSV');
}
get200ResponseSaveReport(reportId: string): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.post('/activiti-app/app/rest/reporting/reports/' + reportId)
.reply(200);
}
get200ResponseDeleteReport(reportId: string): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.delete('/activiti-app/app/rest/reporting/reports/' + reportId)
.reply(200);
}
@@ -15,42 +15,14 @@
* limitations under the License.
*/
import nock from 'nock';
import { BaseMock } from '../base.mock';
export class TaskFormMock extends BaseMock {
get200getTaskFormVariables(): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.get('/activiti-app/api/enterprise/task-forms/5028/variables')
.reply(
200,
[{ id: 'initiator', type: 'string', value: '1001' }],
[
'Server',
'Apache-Coyote/1.1',
'set-cookie',
'ACTIVITI_REMEMBER_ME=NjdOdGwvcUtFTkVEczQyMGh4WFp5QT09OmpUL1UwdFVBTC94QTJMTFFUVFgvdFE9PQ',
'X-Content-Type-Options',
'nosniff',
'X-XSS-Protection',
'1; mode=block',
'Cache-Control',
'no-cache, no-store, max-age=0, must-revalidate',
'Pragma',
'no-cache',
'Expires',
'0',
'X-Frame-Options',
'SAMEORIGIN',
'Content-Type',
'application/json',
'Transfer-Encoding',
'chunked',
'Date',
'Tue, 01 Nov 2016 19:43:36 GMT',
'Connection',
'close'
]
);
.reply(200, [{ id: 'initiator', type: 'string', value: '1001' }], {
'set-cookie': 'ACTIVITI_REMEMBER_ME=NjdOdGwvcUtFTkVEczQyMGh4WFp5QT09OmpUL1UwdFVBTC94QTJMTFFUVFgvdFE9PQ'
});
}
}
@@ -15,7 +15,6 @@
* limitations under the License.
*/
import nock from 'nock';
import { BaseMock } from '../base.mock';
const formValues = [
@@ -42,7 +41,7 @@ const formValues = [
export class TasksMock extends BaseMock {
get200Response(): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.post('/activiti-app/api/enterprise/tasks/query', {})
.reply(200, {
size: 2,
@@ -128,7 +127,7 @@ export class TasksMock extends BaseMock {
}
get200ResponseGetTask(taskId: string): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.get('/activiti-app/api/enterprise/tasks/' + taskId)
.reply(200, {
id: '10',
@@ -166,14 +165,14 @@ export class TasksMock extends BaseMock {
}
get400TaskFilter(): void {
nock(this.host, { encodedQueryParams: true }).post('/activiti-app/api/enterprise/tasks/filter', {}).reply(400, {
this.mock().post('/activiti-app/api/enterprise/tasks/filter', {}).reply(400, {
message: 'A valid filterId or filter params must be provided',
messageKey: 'GENERAL.ERROR.BAD-REQUEST'
});
}
get200TaskFilter(): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.post('/activiti-app/api/enterprise/tasks/filter', { appDefinitionId: 1 })
.reply(200, {
size: 2,
@@ -249,7 +248,7 @@ export class TasksMock extends BaseMock {
}
get404CompleteTask(taskId: string): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.put('/activiti-app/api/enterprise/tasks/' + taskId + '/action/complete')
.reply(404, {
message: 'Task with id: ' + taskId + ' does not exist',
@@ -258,7 +257,7 @@ export class TasksMock extends BaseMock {
}
get200CreateTask(name: string): void {
nock(this.host, { encodedQueryParams: true }).post('/activiti-app/api/enterprise/tasks', { name }).reply(200, {
this.mock().post('/activiti-app/api/enterprise/tasks', { name }).reply(200, {
id: '10001',
name: 'test-name',
description: null,
@@ -293,7 +292,7 @@ export class TasksMock extends BaseMock {
}
get200getTaskForm(): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.get('/activiti-app/api/enterprise/task-forms/2518')
.reply(200, {
id: 1,
@@ -1033,10 +1032,10 @@ export class TasksMock extends BaseMock {
}
get200getRestFieldValuesColumn(): void {
nock(this.host, { encodedQueryParams: true }).get('/activiti-app/api/enterprise/task-forms/1/form-values/label/user').reply(200, formValues);
this.mock().get('/activiti-app/api/enterprise/task-forms/1/form-values/label/user').reply(200, formValues);
}
get200getRestFieldValues(): void {
nock(this.host, { encodedQueryParams: true }).get('/activiti-app/api/enterprise/task-forms/2/form-values/label').reply(200, formValues);
this.mock().get('/activiti-app/api/enterprise/task-forms/2/form-values/label').reply(200, formValues);
}
}
@@ -15,12 +15,11 @@
* limitations under the License.
*/
import nock from 'nock';
import { BaseMock } from '../base.mock';
export class UserFiltersMock extends BaseMock {
get200getUserTaskFilters(): void {
nock(this.host, { encodedQueryParams: true })
this.mock()
.get('/activiti-app/api/enterprise/filters/tasks')
.query({ appId: '1' })
.reply(200, {