diff --git a/api/src/prescription/campaign/application/campaign-administration-route.js b/api/src/prescription/campaign/application/campaign-administration-route.js index 05d89be59bc..4a8c87c9bfc 100644 --- a/api/src/prescription/campaign/application/campaign-administration-route.js +++ b/api/src/prescription/campaign/application/campaign-administration-route.js @@ -27,7 +27,7 @@ const register = async function (server) { }, { method: 'PATCH', - path: '/api/campaigns/{id}', + path: '/api/campaigns/{campaignId}', config: { pre: [ { @@ -37,7 +37,7 @@ const register = async function (server) { ], validate: { params: Joi.object({ - id: identifiersType.campaignId, + campaignId: identifiersType.campaignId, }), payload: Joi.object({ data: { @@ -65,12 +65,12 @@ const register = async function (server) { }, { method: 'PUT', - path: '/api/campaigns/{id}/archive', + path: '/api/campaigns/{campaignId}/archive', config: { pre: [{ method: securityPreHandlers.checkAuthorizationToManageCampaign }], validate: { params: Joi.object({ - id: identifiersType.campaignId, + campaignId: identifiersType.campaignId, }), }, handler: campaignAdministrationController.archiveCampaign, @@ -82,12 +82,12 @@ const register = async function (server) { }, { method: 'DELETE', - path: '/api/campaigns/{id}/archive', + path: '/api/campaigns/{campaignId}/archive', config: { pre: [{ method: securityPreHandlers.checkAuthorizationToManageCampaign }], validate: { params: Joi.object({ - id: identifiersType.campaignId, + campaignId: identifiersType.campaignId, }), }, handler: campaignAdministrationController.unarchiveCampaign, @@ -132,7 +132,7 @@ const register = async function (server) { }, { method: 'PATCH', - path: '/api/admin/campaigns/{id}', + path: '/api/admin/campaigns/{campaignId}', config: { pre: [ { @@ -147,7 +147,7 @@ const register = async function (server) { ], validate: { params: Joi.object({ - id: identifiersType.campaignId, + campaignId: identifiersType.campaignId, }), payload: Joi.object({ data: { diff --git a/api/src/prescription/campaign/application/campaign-adminstration-controller.js b/api/src/prescription/campaign/application/campaign-adminstration-controller.js index 87bfd94cc1d..3b1864c8654 100644 --- a/api/src/prescription/campaign/application/campaign-adminstration-controller.js +++ b/api/src/prescription/campaign/application/campaign-adminstration-controller.js @@ -51,7 +51,7 @@ const save = async function (request, h, dependencies = { requestResponseUtils, }; const update = async function (request, _, dependencies = { campaignReportSerializer }) { - const campaignId = request.params.id; + const { campaignId } = request.params; const result = await usecases.updateCampaign({ campaignId, ...request.deserializedPayload }); @@ -67,7 +67,7 @@ const swapCampaignCodes = async function (request, h) { }; const updateCampaignDetails = async function (request, h) { - const campaignId = request.params.id; + const { campaignId } = request.params; const authenticatedUserId = request.auth.credentials.userId; const campaignDetails = request.deserializedPayload; @@ -92,14 +92,14 @@ const updateCampaignCode = async function (request, h) { const archiveCampaign = function (request, h, dependencies = { campaignReportSerializer }) { const { userId } = request.auth.credentials; - const campaignId = request.params.id; + const { campaignId } = request.params; return usecases.archiveCampaign({ userId, campaignId }).then(dependencies.campaignReportSerializer.serialize); }; const unarchiveCampaign = function (request, h, dependencies = { campaignReportSerializer }) { const { userId } = request.auth.credentials; - const campaignId = request.params.id; + const { campaignId } = request.params; return usecases.unarchiveCampaign({ userId, campaignId }).then(dependencies.campaignReportSerializer.serialize); }; diff --git a/api/src/prescription/campaign/application/campaign-controller.js b/api/src/prescription/campaign/application/campaign-controller.js index f3eeeeadccb..62c5eae96ba 100644 --- a/api/src/prescription/campaign/application/campaign-controller.js +++ b/api/src/prescription/campaign/application/campaign-controller.js @@ -23,7 +23,7 @@ const getGroups = async function (request) { const getAnalysis = async function (request, h, dependencies = { campaignAnalysisSerializer }) { const { userId } = request.auth.credentials; - const campaignId = request.params.id; + const { campaignId } = request.params; const locale = extractLocaleFromRequest(request); const campaignAnalysis = await usecases.computeCampaignAnalysis({ userId, campaignId, locale }); return dependencies.campaignAnalysisSerializer.serialize(campaignAnalysis); diff --git a/api/src/prescription/campaign/application/campaign-detail-controller.js b/api/src/prescription/campaign/application/campaign-detail-controller.js index ca3985bbfac..47de4cdbf39 100644 --- a/api/src/prescription/campaign/application/campaign-detail-controller.js +++ b/api/src/prescription/campaign/application/campaign-detail-controller.js @@ -32,7 +32,7 @@ const getById = async function ( }, ) { const { userId } = request.auth.credentials; - const campaignId = request.params.id; + const { campaignId } = request.params; const tokenForCampaignResults = dependencies.tokenService.createTokenForCampaignResults({ userId, campaignId }); @@ -41,13 +41,13 @@ const getById = async function ( }; const getCampaignDetails = async function (request) { - const campaignId = request.params.id; + const { campaignId } = request.params; const campaign = await usecases.getCampaignManagement({ campaignId }); return campaignDetailsManagementSerializer.serialize(campaign); }; const findPaginatedFilteredCampaigns = async function (request, _, dependencies = { campaignReportSerializer }) { - const organizationId = request.params.id; + const { organizationId } = request.params; const options = request.query; const userId = request.auth.credentials.userId; @@ -65,7 +65,7 @@ const findPaginatedFilteredCampaigns = async function (request, _, dependencies }; const getCsvAssessmentResults = async function (request, h) { - const campaignId = request.params.id; + const { campaignId } = request.params; const writableStream = new PassThrough(); @@ -88,7 +88,7 @@ const getCsvAssessmentResults = async function (request, h) { }; const getCsvProfilesCollectionResults = async function (request, h) { - const campaignId = request.params.id; + const { campaignId } = request.params; const writableStream = new PassThrough(); @@ -114,7 +114,7 @@ const findParticipantsActivity = async function ( h, dependencies = { campaignParticipantsActivitySerializer }, ) { - const campaignId = request.params.id; + const { campaignId } = request.params; const { page, filter: filters } = request.query; if (filters.divisions && !Array.isArray(filters.divisions)) { diff --git a/api/src/prescription/campaign/application/campaign-detail-route.js b/api/src/prescription/campaign/application/campaign-detail-route.js index f891c5cd732..a1c145aaf51 100644 --- a/api/src/prescription/campaign/application/campaign-detail-route.js +++ b/api/src/prescription/campaign/application/campaign-detail-route.js @@ -30,12 +30,12 @@ const register = async function (server) { }, { method: 'GET', - path: '/api/campaigns/{id}', + path: '/api/campaigns/{campaignId}', config: { pre: [{ method: securityPreHandlers.checkAuthorizationToAccessCampaign }], validate: { params: Joi.object({ - id: identifiersType.campaignId, + campaignId: identifiersType.campaignId, }), }, handler: campaignDetailController.getById, @@ -45,7 +45,7 @@ const register = async function (server) { }, { method: 'GET', - path: '/api/admin/campaigns/{id}', + path: '/api/admin/campaigns/{campaignId}', config: { pre: [ { @@ -61,7 +61,7 @@ const register = async function (server) { ], validate: { params: Joi.object({ - id: identifiersType.campaignId, + campaignId: identifiersType.campaignId, }), }, handler: campaignDetailController.getCampaignDetails, @@ -74,12 +74,12 @@ const register = async function (server) { }, { method: 'GET', - path: '/api/organizations/{id}/campaigns', + path: '/api/organizations/{organizationId}/campaigns', config: { pre: [{ method: securityPreHandlers.checkUserBelongsToOrganization }], validate: { params: Joi.object({ - id: identifiersType.organizationId, + organizationId: identifiersType.organizationId, }), query: Joi.object({ page: { @@ -104,12 +104,12 @@ const register = async function (server) { }, { method: 'GET', - path: '/api/campaigns/{id}/csv-profiles-collection-results', + path: '/api/campaigns/{campaignId}/csv-profiles-collection-results', config: { pre: [{ method: securityPreHandlers.checkAuthorizationToAccessCampaign }], validate: { params: Joi.object({ - id: identifiersType.campaignId, + campaignId: identifiersType.campaignId, }), }, handler: campaignDetailController.getCsvProfilesCollectionResults, @@ -123,12 +123,12 @@ const register = async function (server) { }, { method: 'GET', - path: '/api/campaigns/{id}/csv-assessment-results', + path: '/api/campaigns/{campaignId}/csv-assessment-results', config: { pre: [{ method: securityPreHandlers.checkAuthorizationToAccessCampaign }], validate: { params: Joi.object({ - id: identifiersType.campaignId, + campaignId: identifiersType.campaignId, }), }, handler: campaignDetailController.getCsvAssessmentResults, @@ -142,11 +142,11 @@ const register = async function (server) { }, { method: 'GET', - path: '/api/campaigns/{id}/participants-activity', + path: '/api/campaigns/{campaignId}/participants-activity', config: { validate: { params: Joi.object({ - id: identifiersType.campaignId, + campaignId: identifiersType.campaignId, }), query: Joi.object({ page: { diff --git a/api/src/prescription/campaign/application/campaign-results-controller.js b/api/src/prescription/campaign/application/campaign-results-controller.js index 04d1032bc75..c73aeeb4f56 100644 --- a/api/src/prescription/campaign/application/campaign-results-controller.js +++ b/api/src/prescription/campaign/application/campaign-results-controller.js @@ -6,7 +6,7 @@ import * as campaignCollectiveResultSerializer from '../infrastructure/serialize import * as campaignProfilesCollectionParticipationSummarySerializer from '../infrastructure/serializers/jsonapi/campaign-profiles-collection-participation-summary-serializer.js'; const findAssessmentParticipationResults = async function (request) { - const campaignId = request.params.id; + const { campaignId } = request.params; const { page, filter: filters } = request.query; if (filters.divisions && !Array.isArray(filters.divisions)) { filters.divisions = [filters.divisions]; @@ -29,7 +29,7 @@ const findAssessmentParticipationResults = async function (request) { }; const findProfilesCollectionParticipations = async function (request) { - const campaignId = request.params.id; + const { campaignId } = request.params; const { page, filter: filters } = request.query; if (filters.divisions && !Array.isArray(filters.divisions)) { filters.divisions = [filters.divisions]; @@ -50,7 +50,7 @@ const findProfilesCollectionParticipations = async function (request) { const getCollectiveResult = async function (request, h, dependencies = { campaignCollectiveResultSerializer }) { const { userId } = request.auth.credentials; - const campaignId = request.params.id; + const { campaignId } = request.params; const locale = extractLocaleFromRequest(request); const campaignCollectiveResult = await usecases.computeCampaignCollectiveResult({ userId, campaignId, locale }); diff --git a/api/src/prescription/campaign/application/campaign-results-route.js b/api/src/prescription/campaign/application/campaign-results-route.js index 296d97a45fb..f6049dbd6ff 100644 --- a/api/src/prescription/campaign/application/campaign-results-route.js +++ b/api/src/prescription/campaign/application/campaign-results-route.js @@ -8,12 +8,12 @@ const register = async function (server) { server.route([ { method: 'GET', - path: '/api/campaigns/{id}/assessment-results', + path: '/api/campaigns/{campaignId}/assessment-results', config: { pre: [{ method: securityPreHandlers.checkAuthorizationToAccessCampaign }], validate: { params: Joi.object({ - id: identifiersType.campaignId, + campaignId: identifiersType.campaignId, }), query: Joi.object({ filter: Joi.object({ @@ -39,12 +39,12 @@ const register = async function (server) { }, { method: 'GET', - path: '/api/campaigns/{id}/profiles-collection-participations', + path: '/api/campaigns/{campaignId}/profiles-collection-participations', config: { pre: [{ method: securityPreHandlers.checkAuthorizationToAccessCampaign }], validate: { params: Joi.object({ - id: identifiersType.campaignId, + campaignId: identifiersType.campaignId, }), query: Joi.object({ filter: Joi.object({ @@ -69,11 +69,11 @@ const register = async function (server) { }, { method: 'GET', - path: '/api/campaigns/{id}/collective-results', + path: '/api/campaigns/{campaignId}/collective-results', config: { validate: { params: Joi.object({ - id: identifiersType.campaignId, + campaignId: identifiersType.campaignId, }), }, handler: campaignResultsController.getCollectiveResult, diff --git a/api/src/prescription/campaign/application/campaign-route.js b/api/src/prescription/campaign/application/campaign-route.js index 2e72d600119..97d62a5c9f8 100644 --- a/api/src/prescription/campaign/application/campaign-route.js +++ b/api/src/prescription/campaign/application/campaign-route.js @@ -42,11 +42,11 @@ const register = async function (server) { }, { method: 'GET', - path: '/api/campaigns/{id}/analyses', + path: '/api/campaigns/{campaignId}/analyses', config: { validate: { params: Joi.object({ - id: identifiersType.campaignId, + campaignId: identifiersType.campaignId, }), }, handler: campaignController.getAnalysis, diff --git a/api/src/prescription/campaign/application/campaign-stats-controller.js b/api/src/prescription/campaign/application/campaign-stats-controller.js index 5467ad86506..2e8ac01b9be 100644 --- a/api/src/prescription/campaign/application/campaign-stats-controller.js +++ b/api/src/prescription/campaign/application/campaign-stats-controller.js @@ -6,7 +6,7 @@ import * as participationsCountByMasteryRateSerializer from '../infrastructure/s const getParticipationsByStage = async function (request) { const { userId } = request.auth.credentials; - const campaignId = request.params.id; + const { campaignId } = request.params; const participationsByStage = await usecases.getCampaignParticipationsCountByStage({ userId, campaignId }); @@ -18,7 +18,7 @@ const getParticipationsByStage = async function (request) { const getParticipationsByStatus = async function (request) { const { userId } = request.auth.credentials; - const campaignId = request.params.id; + const { campaignId } = request.params; const participantsCounts = await usecases.getCampaignParticipationsCountsByStatus({ userId, campaignId }); @@ -29,7 +29,7 @@ const getParticipationsByStatus = async function (request) { }; const getParticipationsByDay = async function (request) { const { userId } = request.auth.credentials; - const campaignId = request.params.id; + const { campaignId } = request.params; const participantsCounts = await usecases.getCampaignParticipationsActivityByDay({ userId, campaignId }); @@ -41,7 +41,7 @@ const getParticipationsByDay = async function (request) { const getParticipationsCountByMasteryRate = async function (request) { const { userId } = request.auth.credentials; - const campaignId = request.params.id; + const { campaignId } = request.params; const resultDistribution = await usecases.getParticipationsCountByMasteryRate({ userId, campaignId }); diff --git a/api/src/prescription/campaign/application/campaign-stats-route.js b/api/src/prescription/campaign/application/campaign-stats-route.js index db10a9aa1ab..3f731f72b75 100644 --- a/api/src/prescription/campaign/application/campaign-stats-route.js +++ b/api/src/prescription/campaign/application/campaign-stats-route.js @@ -7,10 +7,10 @@ const register = async function (server) { server.route([ { method: 'GET', - path: '/api/campaigns/{id}/stats/participations-by-stage', + path: '/api/campaigns/{campaignId}/stats/participations-by-stage', config: { validate: { - params: Joi.object({ id: identifiersType.campaignId }), + params: Joi.object({ campaignId: identifiersType.campaignId }), }, handler: campaignStatsController.getParticipationsByStage, notes: [ @@ -22,10 +22,10 @@ const register = async function (server) { }, { method: 'GET', - path: '/api/campaigns/{id}/stats/participations-by-status', + path: '/api/campaigns/{campaignId}/stats/participations-by-status', config: { validate: { - params: Joi.object({ id: identifiersType.campaignId }), + params: Joi.object({ campaignId: identifiersType.campaignId }), }, handler: campaignStatsController.getParticipationsByStatus, notes: [ @@ -37,10 +37,10 @@ const register = async function (server) { }, { method: 'GET', - path: '/api/campaigns/{id}/stats/participations-by-day', + path: '/api/campaigns/{campaignId}/stats/participations-by-day', config: { validate: { - params: Joi.object({ id: identifiersType.campaignId }), + params: Joi.object({ campaignId: identifiersType.campaignId }), }, handler: campaignStatsController.getParticipationsByDay, notes: [ @@ -52,10 +52,10 @@ const register = async function (server) { }, { method: 'GET', - path: '/api/campaigns/{id}/stats/participations-by-mastery-rate', + path: '/api/campaigns/{campaignId}/stats/participations-by-mastery-rate', config: { validate: { - params: Joi.object({ id: identifiersType.campaignId }), + params: Joi.object({ campaignId: identifiersType.campaignId }), }, handler: campaignStatsController.getParticipationsCountByMasteryRate, notes: [ diff --git a/api/src/shared/application/security-pre-handlers.js b/api/src/shared/application/security-pre-handlers.js index 35feb8b9a4a..6d6f8cf1b53 100644 --- a/api/src/shared/application/security-pre-handlers.js +++ b/api/src/shared/application/security-pre-handlers.js @@ -629,7 +629,7 @@ async function checkAuthorizationToManageCampaign( dependencies = { checkAuthorizationToManageCampaignUsecase }, ) { const userId = request.auth.credentials.userId; - const campaignId = request.params.id; + const campaignId = request.params.campaignId || request.params.id; const isAdminOrOwnerOfTheCampaign = await dependencies.checkAuthorizationToManageCampaignUsecase.execute({ userId, campaignId, diff --git a/api/tests/acceptance/application/campaigns/campaign-controller_test.js b/api/tests/acceptance/application/campaigns/campaign-controller_test.js index 8d2a0b95011..9c436b77238 100644 --- a/api/tests/acceptance/application/campaigns/campaign-controller_test.js +++ b/api/tests/acceptance/application/campaigns/campaign-controller_test.js @@ -12,7 +12,7 @@ describe('Acceptance | API | Campaign Controller', function () { server = await createServer(); }); - describe('PATCH /api/campaigns/{id}', function () { + describe('PATCH /api/campaigns/{campaignId}', function () { it('should return 200 when user is admin but not owner of the campaign', async function () { // given const organization = databaseBuilder.factory.buildOrganization(); diff --git a/api/tests/prescription/campaign/acceptance/application/campaign-administration-route_test.js b/api/tests/prescription/campaign/acceptance/application/campaign-administration-route_test.js index d21f87fee14..167b23c7747 100644 --- a/api/tests/prescription/campaign/acceptance/application/campaign-administration-route_test.js +++ b/api/tests/prescription/campaign/acceptance/application/campaign-administration-route_test.js @@ -305,7 +305,7 @@ describe('Acceptance | API | campaign-administration-route', function () { }); }); - describe('PATCH /api/admin/campaigns/{id}', function () { + describe('PATCH /api/admin/campaigns/{campaignId}', function () { it('should return the updated campaign', async function () { // given const campaign = databaseBuilder.factory.buildCampaign({ name: 'odlName', multipleSendings: false }); @@ -361,7 +361,7 @@ describe('Acceptance | API | campaign-administration-route', function () { }); }); - describe('PUT /api/campaigns/{id}/archive', function () { + describe('PUT /api/campaigns/{campaignId}/archive', function () { it('should return 200 when user is admin in organization', async function () { // given const organization = databaseBuilder.factory.buildOrganization(); @@ -405,7 +405,7 @@ describe('Acceptance | API | campaign-administration-route', function () { }); }); - describe('DELETE /api/campaigns/{id}/archive', function () { + describe('DELETE /api/campaigns/{campaignId}/archive', function () { it('should return 200 when user is admin in organization', async function () { // given const organization = databaseBuilder.factory.buildOrganization(); diff --git a/api/tests/prescription/campaign/acceptance/application/campaign-detail-route_test.js b/api/tests/prescription/campaign/acceptance/application/campaign-detail-route_test.js index 4cc86abd2da..907b452a81c 100644 --- a/api/tests/prescription/campaign/acceptance/application/campaign-detail-route_test.js +++ b/api/tests/prescription/campaign/acceptance/application/campaign-detail-route_test.js @@ -54,7 +54,7 @@ describe('Acceptance | API | campaign-detail-route', function () { }); }); - describe('GET /api/campaigns/{id}', function () { + describe('GET /api/campaigns/{campaignId}', function () { const options = { headers: { authorization: null }, method: 'GET', @@ -109,7 +109,7 @@ describe('Acceptance | API | campaign-detail-route', function () { }); }); - describe('GET /api/campaigns/{id}/csv-profiles-collection-results', function () { + describe('GET /api/campaigns/{campaignId}/csv-profiles-collection-results', function () { const options = { headers: { authorization: null }, method: 'GET', @@ -191,7 +191,7 @@ describe('Acceptance | API | campaign-detail-route', function () { }); }); - describe('GET /api/campaigns/{id}/csv-assessment-results', function () { + describe('GET /api/campaigns/{campaignId}/csv-assessment-results', function () { let campaign; let organization; @@ -277,7 +277,7 @@ describe('Acceptance | API | campaign-detail-route', function () { }); }); - describe('GET /api/campaigns/{id}/participants-activity', function () { + describe('GET /api/campaigns/{campaignId}/participants-activity', function () { const participant1 = { firstName: 'John', lastName: 'McClane', division: '5eme' }; const participant2 = { firstName: 'Holly', lastName: 'McClane', division: '4eme' }; const participant3 = { firstName: 'Mary', lastName: 'McClane', group: 'L1' }; diff --git a/api/tests/prescription/campaign/acceptance/application/campaign-results-route_test.js b/api/tests/prescription/campaign/acceptance/application/campaign-results-route_test.js index 009d8dc78f8..b07423a83b5 100644 --- a/api/tests/prescription/campaign/acceptance/application/campaign-results-route_test.js +++ b/api/tests/prescription/campaign/acceptance/application/campaign-results-route_test.js @@ -17,7 +17,7 @@ describe('Acceptance | API | campaign-results-route', function () { server = await createServer(); }); - describe('GET /api/campaigns/{id}/assessment-results', function () { + describe('GET /api/campaigns/{campaignId}/assessment-results', function () { const participant1 = { firstName: 'John', lastName: 'McClane', id: 12, email: 'john.mclane@die.hard' }; const participant2 = { firstName: 'Holly', lastName: 'McClane', id: 13, email: 'holly.mclane@die.hard' }; @@ -114,7 +114,7 @@ describe('Acceptance | API | campaign-results-route', function () { }); }); - describe('GET /api/campaigns/{id}/profiles-collection-participations', function () { + describe('GET /api/campaigns/{campaignId}/profiles-collection-participations', function () { beforeEach(async function () { const learningContent = [ { @@ -523,7 +523,7 @@ describe('Acceptance | API | campaign-results-route', function () { }); }); - describe('GET /api/campaigns/{id}/collective-result', function () { + describe('GET /api/campaigns/{campaignId}/collective-result', function () { const assessmentStartDate = '2018-01-02'; const participationStartDate = '2018-01-01'; diff --git a/api/tests/prescription/campaign/acceptance/application/campaign-route_test.js b/api/tests/prescription/campaign/acceptance/application/campaign-route_test.js index 63d85c76196..f5693bec6e6 100644 --- a/api/tests/prescription/campaign/acceptance/application/campaign-route_test.js +++ b/api/tests/prescription/campaign/acceptance/application/campaign-route_test.js @@ -64,7 +64,7 @@ describe('Acceptance | API | Campaign Route', function () { }); }); - describe('GET /api/campaigns/{id}/analyses', function () { + describe('GET /api/campaigns/{campaignId}/analyses', function () { let userId, organization, campaign; describe('skill Ids provide by the campaign', function () { diff --git a/api/tests/prescription/campaign/acceptance/application/campaign-stats-route_test.js b/api/tests/prescription/campaign/acceptance/application/campaign-stats-route_test.js index d226af09fcd..919c79c55b1 100644 --- a/api/tests/prescription/campaign/acceptance/application/campaign-stats-route_test.js +++ b/api/tests/prescription/campaign/acceptance/application/campaign-stats-route_test.js @@ -14,7 +14,7 @@ describe('Acceptance | API | Campaign Stats Route', function () { server = await createServer(); }); - describe('GET /api/campaigns/{id}/stats/participations-by-stage', function () { + describe('GET /api/campaigns/{campaignId}/stats/participations-by-stage', function () { it('should return the campaign by id', async function () { // given const learningContentObjects = learningContentBuilder.fromAreas([ @@ -101,7 +101,7 @@ describe('Acceptance | API | Campaign Stats Route', function () { }); }); - describe('GET /api/campaigns/{id}/stats/participations-by-status', function () { + describe('GET /api/campaigns/{campaignId}/stats/participations-by-status', function () { it('should return participations counts by status for the campaign', async function () { // given const campaign = databaseBuilder.factory.buildCampaign(); @@ -140,7 +140,7 @@ describe('Acceptance | API | Campaign Stats Route', function () { }); }); - describe('GET /api/campaigns/{id}/stats/participations-by-day', function () { + describe('GET /api/campaigns/{campaignId}/stats/participations-by-day', function () { it('should return the activity by day', async function () { // given const campaign = databaseBuilder.factory.buildCampaign(); @@ -168,7 +168,7 @@ describe('Acceptance | API | Campaign Stats Route', function () { }); }); - describe('GET /api/campaigns/{id}/stats/participations-by-mastery-rate', function () { + describe('GET /api/campaigns/{campaignId}/stats/participations-by-mastery-rate', function () { it('should return the mastery rate distribution', async function () { const { id: userId } = databaseBuilder.factory.buildUser(); const { id: organizationId } = databaseBuilder.factory.buildOrganization(); diff --git a/api/tests/prescription/campaign/integration/application/campaign-detail-route_test.js b/api/tests/prescription/campaign/integration/application/campaign-detail-route_test.js index 8d2417a5b41..26e934e16d5 100644 --- a/api/tests/prescription/campaign/integration/application/campaign-detail-route_test.js +++ b/api/tests/prescription/campaign/integration/application/campaign-detail-route_test.js @@ -6,7 +6,7 @@ import { expect, HttpTestServer, sinon } from '../../../../test-helper.js'; describe('Integration | Application | Route | campaign detail router', function () { let httpTestServer; - describe('GET /api/campaigns/{id}/csv-profiles-collection-results', function () { + describe('GET /api/campaigns/{campaignId}/csv-profiles-collection-results', function () { it('should exist', async function () { // given sinon.stub(securityPreHandlers, 'checkAuthorizationToAccessCampaign').callsFake((request, h) => h.response(true)); @@ -28,7 +28,7 @@ describe('Integration | Application | Route | campaign detail router', function }); }); - describe('GET /api/campaigns/{id}/csv-assessment-results', function () { + describe('GET /api/campaigns/{campaignId}/csv-assessment-results', function () { it('should exist', async function () { // given sinon.stub(securityPreHandlers, 'checkAuthorizationToAccessCampaign').callsFake((request, h) => h.response(true)); @@ -48,7 +48,7 @@ describe('Integration | Application | Route | campaign detail router', function }); }); - describe('GET /api/organizations/:id/campaigns', function () { + describe('GET /api/organizations/{organizationId}/campaigns', function () { it('should call the organization controller to get the campaigns', async function () { sinon.stub(campaignDetailController, 'findPaginatedFilteredCampaigns').returns('ok'); sinon.stub(securityPreHandlers, 'checkUserBelongsToOrganization').callsFake((request, h) => h.response(true)); diff --git a/api/tests/prescription/campaign/integration/application/campaign-results-route_test.js b/api/tests/prescription/campaign/integration/application/campaign-results-route_test.js index 3dbaf2d13b1..aa7e2d0e10d 100644 --- a/api/tests/prescription/campaign/integration/application/campaign-results-route_test.js +++ b/api/tests/prescription/campaign/integration/application/campaign-results-route_test.js @@ -9,7 +9,7 @@ import { } from '../../../../test-helper.js'; describe('Integration | Application | campaign-results-route', function () { - describe('GET /api/campaigns/{id}/assessment-results', function () { + describe('GET /api/campaigns/{campaignId}/assessment-results', function () { const method = 'GET'; let headers, httpTestServer, organizationId, campaignId, url; @@ -72,7 +72,7 @@ describe('Integration | Application | campaign-results-route', function () { }); }); - describe('GET /api/campaigns/{id}/profiles-collection-participations', function () { + describe('GET /api/campaigns/{campaignId}/profiles-collection-participations', function () { const method = 'GET'; let headers, httpTestServer, organizationId, campaignId, url; diff --git a/api/tests/prescription/campaign/unit/application/campaign-administration-controller_test.js b/api/tests/prescription/campaign/unit/application/campaign-administration-controller_test.js index 76c4b31da0c..2ca5da5b184 100644 --- a/api/tests/prescription/campaign/unit/application/campaign-administration-controller_test.js +++ b/api/tests/prescription/campaign/unit/application/campaign-administration-controller_test.js @@ -160,7 +160,7 @@ describe('Unit | Application | Controller | Campaign administration', function ( // given const request = { auth: { credentials: { userId: 1 } }, - params: { id: 1 }, + params: { campaignId: 1 }, deserializedPayload: { name: 'New name', title: 'New title', @@ -253,7 +253,7 @@ describe('Unit | Application | Controller | Campaign administration', function ( // when const response = await campaignAdministrationController.archiveCampaign( { - params: { id: campaignId }, + params: { campaignId }, auth: { credentials: { userId }, }, @@ -294,7 +294,7 @@ describe('Unit | Application | Controller | Campaign administration', function ( // when const response = await campaignAdministrationController.unarchiveCampaign( { - params: { id: campaignId }, + params: { campaignId }, auth: { credentials: { userId }, }, diff --git a/api/tests/prescription/campaign/unit/application/campaign-administration-route_test.js b/api/tests/prescription/campaign/unit/application/campaign-administration-route_test.js index 3adc5e0f624..f0f35c4b929 100644 --- a/api/tests/prescription/campaign/unit/application/campaign-administration-route_test.js +++ b/api/tests/prescription/campaign/unit/application/campaign-administration-route_test.js @@ -25,7 +25,7 @@ describe('Unit | Application | Router | campaign-administration-router ', functi }); }); - describe('PATCH /api/campaigns/{id}', function () { + describe('PATCH /api/campaigns/{campaignId}', function () { it('should return 400 with an invalid campaign id', async function () { // given const httpTestServer = new HttpTestServer(); @@ -118,7 +118,7 @@ describe('Unit | Application | Router | campaign-administration-router ', functi }); }); - describe('PATCH /api/admin/campaigns/{id}', function () { + describe('PATCH /api/admin/campaigns/{campaignId}', function () { it('should return 204', async function () { // given sinon @@ -365,7 +365,7 @@ describe('Unit | Application | Router | campaign-administration-router ', functi }); }); - describe('PUT /api/campaigns/{id}/archive', function () { + describe('PUT /api/campaigns/{campaignId}/archive', function () { it('should return 400 with an invalid campaign id', async function () { // given const httpTestServer = new HttpTestServer(); @@ -379,7 +379,7 @@ describe('Unit | Application | Router | campaign-administration-router ', functi }); }); - describe('DELETE /api/campaigns/{id}/archive', function () { + describe('DELETE /api/campaigns/{campaignId}/archive', function () { it('should return 400 with an invalid campaign id', async function () { // given const httpTestServer = new HttpTestServer(); diff --git a/api/tests/prescription/campaign/unit/application/campaign-controller_test.js b/api/tests/prescription/campaign/unit/application/campaign-controller_test.js index a9e84832df3..685d2138265 100644 --- a/api/tests/prescription/campaign/unit/application/campaign-controller_test.js +++ b/api/tests/prescription/campaign/unit/application/campaign-controller_test.js @@ -29,7 +29,7 @@ describe('Unit | Application | Controller | Campaign', function () { const request = { auth: { credentials: { userId } }, - params: { id: campaignId }, + params: { campaignId }, headers: { 'accept-language': locale }, }; @@ -46,7 +46,7 @@ describe('Unit | Application | Controller | Campaign', function () { // given const error = new UserNotAuthorizedToAccessEntityError('User does not have access to this campaign'); const request = { - params: { id: campaignId }, + params: { campaignId }, auth: { credentials: { userId }, }, diff --git a/api/tests/prescription/campaign/unit/application/campaign-detail-controller_test.js b/api/tests/prescription/campaign/unit/application/campaign-detail-controller_test.js index 9ae2990e032..591bcddb6a1 100644 --- a/api/tests/prescription/campaign/unit/application/campaign-detail-controller_test.js +++ b/api/tests/prescription/campaign/unit/application/campaign-detail-controller_test.js @@ -43,7 +43,7 @@ describe('Unit | Application | Controller | Campaign detail', function () { }; request = { params: { - id: campaign.id, + campaignId: campaign.id, }, auth: { credentials: { @@ -93,7 +93,7 @@ describe('Unit | Application | Controller | Campaign detail', function () { beforeEach(function () { organizationId = 1; request = { - params: { id: organizationId }, + params: { organizationId }, auth: { credentials: { userId: 1, @@ -314,7 +314,7 @@ describe('Unit | Application | Controller | Campaign detail', function () { // when const response = await campaignDetailController.findParticipantsActivity( { - params: { id: campaignId }, + params: { campaignId }, auth: { credentials: { userId }, }, @@ -344,7 +344,7 @@ function _getRequestForCampaignId(campaignId) { accessToken: 'token', }, params: { - id: campaignId, + campaignId, }, i18n: { __: sinon.stub(), diff --git a/api/tests/prescription/campaign/unit/application/campaign-detail-route_test.js b/api/tests/prescription/campaign/unit/application/campaign-detail-route_test.js index 236587a3252..fa6f8bfa15f 100644 Binary files a/api/tests/prescription/campaign/unit/application/campaign-detail-route_test.js and b/api/tests/prescription/campaign/unit/application/campaign-detail-route_test.js differ diff --git a/api/tests/prescription/campaign/unit/application/campaign-results-controller_test.js b/api/tests/prescription/campaign/unit/application/campaign-results-controller_test.js index 3b3e49e32dc..21ab85ebd0a 100644 --- a/api/tests/prescription/campaign/unit/application/campaign-results-controller_test.js +++ b/api/tests/prescription/campaign/unit/application/campaign-results-controller_test.js @@ -31,7 +31,7 @@ describe('Unit | Application | Controller | Campaign Results', function () { const request = { auth: { credentials: { userId } }, - params: { id: campaignId }, + params: { campaignId }, headers: { 'accept-language': locale }, }; @@ -50,7 +50,7 @@ describe('Unit | Application | Controller | Campaign Results', function () { 'User does not have access to this campaign participation', ); const request = { - params: { id: campaignId }, + params: { campaignId }, auth: { credentials: { userId }, }, diff --git a/api/tests/prescription/campaign/unit/application/campaign-results-route_test.js b/api/tests/prescription/campaign/unit/application/campaign-results-route_test.js index b97b2d8a7ea..d3b809fadb5 100644 --- a/api/tests/prescription/campaign/unit/application/campaign-results-route_test.js +++ b/api/tests/prescription/campaign/unit/application/campaign-results-route_test.js @@ -4,7 +4,7 @@ import { securityPreHandlers } from '../../../../../src/shared/application/secur import { expect, HttpTestServer, sinon } from '../../../../test-helper.js'; describe('Unit | Application | campaign-results-router ', function () { - describe('GET /api/campaigns/{id}/profiles-collection-participations', function () { + describe('GET /api/campaigns/{campaignId}/profiles-collection-participations', function () { beforeEach(function () { sinon.stub(securityPreHandlers, 'checkAuthorizationToAccessCampaign').returns((_, h) => h.response(true)); sinon @@ -202,7 +202,7 @@ describe('Unit | Application | campaign-results-router ', function () { }); }); - describe('GET /api/campaigns/{id}/collective-results', function () { + describe('GET /api/campaigns/{campaignId}/collective-results', function () { it('should return 200', async function () { // given sinon diff --git a/api/tests/prescription/campaign/unit/application/campaign-route_test.js b/api/tests/prescription/campaign/unit/application/campaign-route_test.js index 235521d7e14..00af63752c1 100644 --- a/api/tests/prescription/campaign/unit/application/campaign-route_test.js +++ b/api/tests/prescription/campaign/unit/application/campaign-route_test.js @@ -57,7 +57,7 @@ describe('Unit | Application | Router | campaign-router ', function () { }); }); - describe('GET /api/campaigns/{id}/analyses', function () { + describe('GET /api/campaigns/{campaignId}/analyses', function () { it('should return 200', async function () { // given sinon.stub(campaignController, 'getAnalysis').callsFake((request, h) => h.response('ok').code(200)); diff --git a/api/tests/prescription/campaign/unit/application/campaign-stats-route_test.js b/api/tests/prescription/campaign/unit/application/campaign-stats-route_test.js index 169273fe970..5d1854befae 100644 --- a/api/tests/prescription/campaign/unit/application/campaign-stats-route_test.js +++ b/api/tests/prescription/campaign/unit/application/campaign-stats-route_test.js @@ -3,7 +3,7 @@ import * as moduleUnderTest from '../../../../../src/prescription/campaign/appli import { expect, HttpTestServer, sinon } from '../../../../test-helper.js'; describe('Unit | Application | Router | campaign-router ', function () { - describe('GET /api/campaigns/{id}/stats/participations-by-stage', function () { + describe('GET /api/campaigns/{campaignId}/stats/participations-by-stage', function () { it('should return 200', async function () { // given sinon @@ -32,7 +32,7 @@ describe('Unit | Application | Router | campaign-router ', function () { }); }); - describe('GET /api/campaigns/{id}/stats/participations-by-status', function () { + describe('GET /api/campaigns/{campaignId}/stats/participations-by-status', function () { it('should return 200', async function () { sinon .stub(campaignStatsController, 'getParticipationsByStatus') @@ -58,7 +58,7 @@ describe('Unit | Application | Router | campaign-router ', function () { }); }); - describe('GET /api/campaigns/{id}/stats/participations-by-mastery-rate', function () { + describe('GET /api/campaigns/{campaignId}/stats/participations-by-mastery-rate', function () { beforeEach(function () { sinon .stub(campaignStatsController, 'getParticipationsCountByMasteryRate')