AAE-30882 - Fixed unit test for js-api

This commit is contained in:
VitoAlbano
2025-08-22 12:48:30 +01:00
committed by Vito Albano
parent e400bc1068
commit c17c8232af
43 changed files with 575 additions and 460 deletions

View File

@@ -15,7 +15,6 @@
* limitations under the License.
*/
import nock from 'nock';
import { BaseMock } from '../base.mock';
const fakeReportList = [
@@ -154,58 +153,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.createNockWithCors().post('/activiti-app/app/rest/reporting/default-reports').reply(200);
}
get200ResponseTasksByProcessDefinitionId(reportId: string, processDefinitionId: string): void {
nock(this.host, { encodedQueryParams: true })
this.createNockWithCors()
.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.createNockWithCors().get('/activiti-app/app/rest/reporting/reports').reply(200, fakeReportList);
}
get200ResponseReportParams(reportId: string): void {
nock(this.host, { encodedQueryParams: true })
this.createNockWithCors()
.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.createNockWithCors()
.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.createNockWithCors().get('/activiti-app/app/rest/reporting/process-definitions').reply(200, fakeProcessDefinitionsNoApp);
}
get200ResponseUpdateReport(reportId: string): void {
nock(this.host, { encodedQueryParams: true })
this.createNockWithCors()
.put('/activiti-app/app/rest/reporting/reports/' + reportId)
.reply(200);
}
get200ResponseExportReport(reportId: string): void {
nock(this.host, { encodedQueryParams: true })
this.createNockWithCors()
.post('/activiti-app/app/rest/reporting/reports/' + reportId + '/export-to-csv')
.reply(200, 'CSV');
}
get200ResponseSaveReport(reportId: string): void {
nock(this.host, { encodedQueryParams: true })
this.createNockWithCors()
.post('/activiti-app/app/rest/reporting/reports/' + reportId)
.reply(200);
}
get200ResponseDeleteReport(reportId: string): void {
nock(this.host, { encodedQueryParams: true })
this.createNockWithCors()
.delete('/activiti-app/app/rest/reporting/reports/' + reportId)
.reply(200);
}