From 9c261febaac0c5fd823a7029ae5d7b9af5b02a62 Mon Sep 17 00:00:00 2001 From: alicegoarnisson Date: Wed, 15 Jan 2025 10:50:57 +0100 Subject: [PATCH 1/5] chore(orga): turned functions into getters --- ...end-completed-participation-results-to-pole-emploi.js | 2 +- .../prod/insert-missing-pole-emploi-sending-from-date.js | 2 +- .../send-started-participation-results-to-pole-emploi.js | 2 +- api/src/prescription/campaign/domain/models/Campaign.js | 9 ++++++--- ...tart-writing-campaign-assessment-results-to-stream.js | 2 +- .../repositories/campaign-administration-repository.js | 2 +- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/api/lib/domain/usecases/send-completed-participation-results-to-pole-emploi.js b/api/lib/domain/usecases/send-completed-participation-results-to-pole-emploi.js index 37a766b0b09..d452ffdbd4f 100644 --- a/api/lib/domain/usecases/send-completed-participation-results-to-pole-emploi.js +++ b/api/lib/domain/usecases/send-completed-participation-results-to-pole-emploi.js @@ -27,7 +27,7 @@ const sendCompletedParticipationResultsToPoleEmploi = async ({ const campaign = await campaignRepository.get(participation.campaignId); const organization = await organizationRepository.get(campaign.organizationId); - if (campaign.isAssessment() && organization.isPoleEmploi) { + if (campaign.isAssessment && organization.isPoleEmploi) { const user = await userRepository.get(participation.userId); const targetProfile = await targetProfileRepository.get(campaign.targetProfileId); const assessment = await assessmentRepository.get(participation.lastAssessment.id); diff --git a/api/scripts/prod/insert-missing-pole-emploi-sending-from-date.js b/api/scripts/prod/insert-missing-pole-emploi-sending-from-date.js index 8a195b75650..7fe22cd63fa 100644 --- a/api/scripts/prod/insert-missing-pole-emploi-sending-from-date.js +++ b/api/scripts/prod/insert-missing-pole-emploi-sending-from-date.js @@ -44,7 +44,7 @@ async function insertMissingPoleEmploiSendingFromDate(startDate, endDate = new D const campaign = await campaignRepository.get(campaignByCode.id); const organization = await organizationRepository.get(campaign.organizationId); - if (!campaign.isAssessment() || !organization.isPoleEmploi) { + if (!campaign.isAssessment || !organization.isPoleEmploi) { throw new Error('La campagne ne respecte pas les conditions pour générer les événements'); } diff --git a/api/src/prescription/campaign-participation/domain/usecases/send-started-participation-results-to-pole-emploi.js b/api/src/prescription/campaign-participation/domain/usecases/send-started-participation-results-to-pole-emploi.js index 9b4c2a96d9a..4bce8e36b62 100644 --- a/api/src/prescription/campaign-participation/domain/usecases/send-started-participation-results-to-pole-emploi.js +++ b/api/src/prescription/campaign-participation/domain/usecases/send-started-participation-results-to-pole-emploi.js @@ -24,7 +24,7 @@ const sendStartedParticipationResultsToPoleEmploi = async ({ const campaign = await campaignRepository.get(participation.campaignId); const organization = await organizationRepository.get(campaign.organizationId); - if (campaign.isAssessment() && organization.isPoleEmploi) { + if (campaign.isAssessment && organization.isPoleEmploi) { const user = await userRepository.get(participation.userId); const targetProfile = await targetProfileRepository.get(campaign.targetProfileId); const payload = PoleEmploiPayload.buildForParticipationStarted({ diff --git a/api/src/prescription/campaign/domain/models/Campaign.js b/api/src/prescription/campaign/domain/models/Campaign.js index 39fd2e67253..37015491dbb 100644 --- a/api/src/prescription/campaign/domain/models/Campaign.js +++ b/api/src/prescription/campaign/domain/models/Campaign.js @@ -66,21 +66,24 @@ class Campaign { this.hasParticipation = participationCount > 0; } - isAssessment() { + get isAssessment() { return this.type === CampaignTypes.ASSESSMENT; } - isProfilesCollection() { + get isProfilesCollection() { return this.type === CampaignTypes.PROFILES_COLLECTION; } - isArchived() { + get isArchived() { return Boolean(this.archivedAt); } get isDeleted() { return Boolean(this.deletedAt); } + get isAccessible() { + return !this.archivedAt && !this.deletedAt; + } delete(userId) { if (this.deletedAt) { diff --git a/api/src/prescription/campaign/domain/usecases/start-writing-campaign-assessment-results-to-stream.js b/api/src/prescription/campaign/domain/usecases/start-writing-campaign-assessment-results-to-stream.js index 3ede39d5d7b..2b949bfd785 100644 --- a/api/src/prescription/campaign/domain/usecases/start-writing-campaign-assessment-results-to-stream.js +++ b/api/src/prescription/campaign/domain/usecases/start-writing-campaign-assessment-results-to-stream.js @@ -57,7 +57,7 @@ const startWritingCampaignAssessmentResultsToStream = async function ({ const campaign = await campaignRepository.get(campaignId); const translate = i18n.__; - if (!campaign.isAssessment()) { + if (!campaign.isAssessment) { throw new CampaignTypeError(); } diff --git a/api/src/prescription/campaign/infrastructure/repositories/campaign-administration-repository.js b/api/src/prescription/campaign/infrastructure/repositories/campaign-administration-repository.js index 18a80200ebe..93fd4a601da 100644 --- a/api/src/prescription/campaign/infrastructure/repositories/campaign-administration-repository.js +++ b/api/src/prescription/campaign/infrastructure/repositories/campaign-administration-repository.js @@ -101,7 +101,7 @@ const save = async function (campaigns, dependencies = { skillRepository }) { latestCreatedCampaign.idPixType = params.type; } - if (latestCreatedCampaign.isAssessment()) { + if (latestCreatedCampaign.isAssessment) { const cappedTubes = await trx('target-profile_tubes') .select('tubeId', 'level') .where('targetProfileId', campaignAttributes.targetProfileId); From 1443e8fe75e17e97da5dbbc14b22d7e31422a5e0 Mon Sep 17 00:00:00 2001 From: alicegoarnisson Date: Wed, 15 Jan 2025 10:53:25 +0100 Subject: [PATCH 2/5] chore(orga): make campaignToJoin a child of Campaign model --- .../domain/read-models/CampaignToJoin.js | 72 +++---------------- 1 file changed, 9 insertions(+), 63 deletions(-) diff --git a/api/src/prescription/campaign/domain/read-models/CampaignToJoin.js b/api/src/prescription/campaign/domain/read-models/CampaignToJoin.js index 317e2908696..ea7684912f4 100644 --- a/api/src/prescription/campaign/domain/read-models/CampaignToJoin.js +++ b/api/src/prescription/campaign/domain/read-models/CampaignToJoin.js @@ -1,21 +1,8 @@ import { Assessment } from '../../../../shared/domain/models/Assessment.js'; -import { CampaignTypes } from '../../../shared/domain/constants.js'; +import { Campaign } from '../models/Campaign.js'; -class CampaignToJoin { +class CampaignToJoin extends Campaign { constructor({ - id, - code, - title, - idPixLabel, - idPixType, - customLandingPageText, - externalIdHelpImageUrl, - alternativeTextToExternalIdHelpImage, - archivedAt, - deletedAt, - type, - isForAbsoluteNovice, - organizationId, organizationName, organizationType, organizationLogoUrl, @@ -27,48 +14,22 @@ class CampaignToJoin { targetProfileName, targetProfileImageUrl, targetProfileIsSimplifiedAccess, - customResultPageText, - customResultPageButtonText, - customResultPageButtonUrl, - multipleSendings, - assessmentMethod, + ...campaignAttributes } = {}) { - this.id = id; - this.code = code; - this.title = title; - this.type = type; - - this.targetProfileName = targetProfileName; - this.targetProfileImageUrl = targetProfileImageUrl; - - this.customLandingPageText = customLandingPageText; - this.customResultPageButtonText = customResultPageButtonText; - this.customResultPageButtonUrl = customResultPageButtonUrl; - this.customResultPageText = customResultPageText; - - this.externalIdHelpImageUrl = externalIdHelpImageUrl; - this.idPixLabel = idPixLabel; - this.idPixType = idPixType; - this.alternativeTextToExternalIdHelpImage = alternativeTextToExternalIdHelpImage; - this.isSimplifiedAccess = targetProfileIsSimplifiedAccess; - this.isForAbsoluteNovice = isForAbsoluteNovice; - - this.identityProvider = identityProvider; - - this.organizationId = organizationId; + super(campaignAttributes); this.organizationName = organizationName; this.organizationType = organizationType; this.organizationLogoUrl = organizationLogoUrl; this.organizationShowNPS = organizationShowNPS; this.organizationFormNPSUrl = organizationFormNPSUrl; - this.multipleSendings = multipleSendings; - this.assessmentMethod = assessmentMethod; + this.targetProfileName = targetProfileName; + this.targetProfileImageUrl = targetProfileImageUrl; + this.isSimplifiedAccess = targetProfileIsSimplifiedAccess; - this.isRestricted = organizationIsManagingStudents || hasLearnersImportFeature; - this.archivedAt = archivedAt; - this.deletedAt = deletedAt; + this.identityProvider = identityProvider; + this.isRestricted = organizationIsManagingStudents || hasLearnersImportFeature; this.reconciliationFields = null; } @@ -76,21 +37,6 @@ class CampaignToJoin { return this.isRestricted && Array.isArray(this.reconciliationFields); } - get isAssessment() { - return this.type === CampaignTypes.ASSESSMENT; - } - - get isProfilesCollection() { - return this.type === CampaignTypes.PROFILES_COLLECTION; - } - - get isAccessible() { - if (Boolean(this.archivedAt) || Boolean(this.deletedAt)) { - return false; - } - return true; - } - get isFlash() { return this.assessmentMethod === Assessment.methods.FLASH; } From dd1c522f7ea4e938611dc38065276b7ec988607d Mon Sep 17 00:00:00 2001 From: alicegoarnisson Date: Wed, 15 Jan 2025 10:54:17 +0100 Subject: [PATCH 3/5] chore(orga): makes campaignManagement a child of Campaign.js --- .../domain/models/CampaignManagement.js | 54 +++---------------- .../domain/models/CampaignManagement_test.js | 47 ++++++++++------ 2 files changed, 37 insertions(+), 64 deletions(-) diff --git a/api/src/prescription/campaign/domain/models/CampaignManagement.js b/api/src/prescription/campaign/domain/models/CampaignManagement.js index 269948cefc1..27d2a68669a 100644 --- a/api/src/prescription/campaign/domain/models/CampaignManagement.js +++ b/api/src/prescription/campaign/domain/models/CampaignManagement.js @@ -1,72 +1,30 @@ -import { CampaignTypes } from '../../../shared/domain/constants.js'; -class CampaignManagement { +import { Campaign } from './Campaign.js'; + +class CampaignManagement extends Campaign { constructor({ - id, - code, - name, - idPixLabel, - idPixType, - createdAt, - archivedAt, - deletedAt, - type, creatorLastName, creatorFirstName, - creatorId, - organizationId, organizationName, - targetProfileId, targetProfileName, - title, - customLandingPageText, - customResultPageText, - customResultPageButtonText, - customResultPageButtonUrl, - isForAbsoluteNovice, ownerLastName, ownerFirstName, ownerId, shared, started, completed, - multipleSendings, + ...campaignAttributes } = {}) { - this.id = id; - this.code = code; - this.name = name; - this.type = type; - this.idPixLabel = idPixLabel; - this.idPixType = idPixType; - this.createdAt = createdAt; - this.archivedAt = archivedAt; - this.deletedAt = deletedAt; + super(campaignAttributes); this.creatorLastName = creatorLastName; this.creatorFirstName = creatorFirstName; - this.creatorId = creatorId; - this.organizationId = organizationId; this.organizationName = organizationName; - this.targetProfileId = targetProfileId; this.targetProfileName = targetProfileName; - this.isForAbsoluteNovice = isForAbsoluteNovice; - this.title = title; - this.customLandingPageText = customLandingPageText; - this.customResultPageText = customResultPageText; - this.customResultPageButtonText = customResultPageButtonText; - this.customResultPageButtonUrl = customResultPageButtonUrl; this.ownerLastName = ownerLastName; this.ownerFirstName = ownerFirstName; this.ownerId = ownerId; this.sharedParticipationsCount = shared; this.totalParticipationsCount = this.#computeTotalParticipation(this.sharedParticipationsCount, started, completed); - this.multipleSendings = multipleSendings; - } - - get isTypeProfilesCollection() { - return this.type === CampaignTypes.PROFILES_COLLECTION; - } - - get isTypeAssessment() { - return this.type === CampaignTypes.ASSESSMENT; + this.hasParticipation = this.totalParticipationsCount > 0; } #computeTotalParticipation(sharedParticipationsCount, started, completed) { diff --git a/api/tests/prescription/campaign/unit/domain/models/CampaignManagement_test.js b/api/tests/prescription/campaign/unit/domain/models/CampaignManagement_test.js index f253f140efd..0ae8abe7abf 100644 --- a/api/tests/prescription/campaign/unit/domain/models/CampaignManagement_test.js +++ b/api/tests/prescription/campaign/unit/domain/models/CampaignManagement_test.js @@ -3,7 +3,7 @@ import { CampaignTypes } from '../../../../../../src/prescription/shared/domain/ import { expect } from '../../../../../test-helper.js'; describe('CampaignManagement', function () { - it('returns correct object', function () { + it('returns correct object including inherited properties', function () { const input = { id: 1, code: 'code', @@ -12,32 +12,37 @@ describe('CampaignManagement', function () { idPixLabel: 'idPixLabel', idPixType: 'idPixType', createdAt: new Date(2020, 10, 23), + alternativeTextToExternalIdHelpImage: null, archivedAt: new Date(2021, 10, 23), + archivedBy: null, + assessmentMethod: null, deletedAt: null, - creatorLastName: 'creatorLastName', - creatorFirstName: 'creatorFirstName', + deletedBy: null, + externalIdHelpImageUrl: null, + hasParticipation: true, creatorId: 123, organizationId: 456, - organizationName: 'organizationName', targetProfileId: 678, - targetProfileName: 'targetProfileName', - isForAbsoluteNovice: false, title: 'title', customLandingPageText: 'customLandingPageText', customResultPageText: 'customResultPageText', customResultPageButtonText: 'customResultPageButtonText', customResultPageButtonUrl: 'customResultPageButtonUrl', + multipleSendings: 'multipleSendings', + isForAbsoluteNovice: false, + creatorLastName: 'creatorLastName', + creatorFirstName: 'creatorFirstName', + organizationName: 'organizationName', + targetProfileName: 'targetProfileName', ownerLastName: 'ownerLastName', ownerFirstName: 'ownerFirstName', ownerId: 234, - multipleSendings: 'multipleSendings', shared: 5, started: 3, completed: 2, }; - const campaignManagement = new CampaignManagement(input); - expect(campaignManagement).to.deep.equal({ + const expected = { id: 1, code: 'code', name: 'name', @@ -45,28 +50,38 @@ describe('CampaignManagement', function () { idPixLabel: 'idPixLabel', idPixType: 'idPixType', createdAt: new Date(2020, 10, 23), + alternativeTextToExternalIdHelpImage: null, archivedAt: new Date(2021, 10, 23), + archivedBy: null, + assessmentMethod: null, deletedAt: null, - creatorLastName: 'creatorLastName', - creatorFirstName: 'creatorFirstName', + deletedBy: null, + externalIdHelpImageUrl: null, + hasParticipation: true, creatorId: 123, organizationId: 456, - organizationName: 'organizationName', targetProfileId: 678, - targetProfileName: 'targetProfileName', - isForAbsoluteNovice: false, title: 'title', customLandingPageText: 'customLandingPageText', customResultPageText: 'customResultPageText', customResultPageButtonText: 'customResultPageButtonText', customResultPageButtonUrl: 'customResultPageButtonUrl', + multipleSendings: 'multipleSendings', + isForAbsoluteNovice: false, + creatorLastName: 'creatorLastName', + creatorFirstName: 'creatorFirstName', + organizationName: 'organizationName', + targetProfileName: 'targetProfileName', ownerLastName: 'ownerLastName', ownerFirstName: 'ownerFirstName', ownerId: 234, - multipleSendings: 'multipleSendings', sharedParticipationsCount: 5, totalParticipationsCount: 10, - }); + }; + + const campaignManagement = new CampaignManagement(input); + + expect(campaignManagement).to.deep.equal(expected); }); describe('#totalParticipationsCount', function () { From bd735cd5444f5471baba42df4a56f0bbb5faf427 Mon Sep 17 00:00:00 2001 From: alicegoarnisson Date: Wed, 15 Jan 2025 10:55:30 +0100 Subject: [PATCH 4/5] chore(orga): renamed isTypeProfilesCollection into isProfilesCollection --- .../jsonapi/campaign-details-management-serializer.js | 2 +- .../jsonapi/campaign-details-management-serializer_test.js | 4 ++-- orga/app/components/campaign/header/title.gjs | 2 +- orga/app/models/campaign.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/src/prescription/campaign/infrastructure/serializers/jsonapi/campaign-details-management-serializer.js b/api/src/prescription/campaign/infrastructure/serializers/jsonapi/campaign-details-management-serializer.js index ff2e3443cb8..89d76b37880 100644 --- a/api/src/prescription/campaign/infrastructure/serializers/jsonapi/campaign-details-management-serializer.js +++ b/api/src/prescription/campaign/infrastructure/serializers/jsonapi/campaign-details-management-serializer.js @@ -25,7 +25,7 @@ const serialize = function (campaignManagement, meta) { 'customResultPageButtonUrl', 'sharedParticipationsCount', 'totalParticipationsCount', - 'isTypeProfilesCollection', + 'isProfilesCollection', 'isTypeAssessment', 'multipleSendings', 'isForAbsoluteNovice', diff --git a/api/tests/prescription/campaign/unit/infrastructure/serializers/jsonapi/campaign-details-management-serializer_test.js b/api/tests/prescription/campaign/unit/infrastructure/serializers/jsonapi/campaign-details-management-serializer_test.js index f6124b67d80..c8731d23d8d 100644 --- a/api/tests/prescription/campaign/unit/infrastructure/serializers/jsonapi/campaign-details-management-serializer_test.js +++ b/api/tests/prescription/campaign/unit/infrastructure/serializers/jsonapi/campaign-details-management-serializer_test.js @@ -26,7 +26,7 @@ describe('Unit | Serializer | JSONAPI | campaign-details-management-serializer', customResultPageButtonUrl: 'www.pix.fr', sharedParticipationsCount: 5, totalParticipationsCount: 10, - isTypeProfilesCollection: false, + isProfilesCollection: false, isTypeAssessment: true, multipleSendings: false, isForAbsoluteNovice: true, @@ -60,7 +60,7 @@ describe('Unit | Serializer | JSONAPI | campaign-details-management-serializer', 'custom-result-page-button-url': campaignManagement.customResultPageButtonUrl, 'shared-participations-count': campaignManagement.sharedParticipationsCount, 'total-participations-count': campaignManagement.totalParticipationsCount, - 'is-type-profiles-collection': false, + 'is-profiles-collection': false, 'is-type-assessment': true, 'multiple-sendings': campaignManagement.multipleSendings, 'is-for-absolute-novice': true, diff --git a/orga/app/components/campaign/header/title.gjs b/orga/app/components/campaign/header/title.gjs index 468abb63249..e4ed0e6edf8 100644 --- a/orga/app/components/campaign/header/title.gjs +++ b/orga/app/components/campaign/header/title.gjs @@ -34,7 +34,7 @@ export default class Header extends Component { } get shouldShowMultipleSending() { - return this.args.campaign.isTypeProfilesCollection || this.isMultipleSendingsForAssessmentEnabled; + return this.args.campaign.isProfilesCollection || this.isMultipleSendingsForAssessmentEnabled; } get isMultipleSendingsForAssessmentEnabled() { diff --git a/orga/app/models/campaign.js b/orga/app/models/campaign.js index 67221c670a3..f93d2fa58ef 100644 --- a/orga/app/models/campaign.js +++ b/orga/app/models/campaign.js @@ -58,7 +58,7 @@ export default class Campaign extends Model { return `${this.ownerFirstName} ${this.ownerLastName}`; } - get isTypeProfilesCollection() { + get isProfilesCollection() { return this.type === 'PROFILES_COLLECTION'; } From 858e115180778bcdbd6a20813b63d44264e46b47 Mon Sep 17 00:00:00 2001 From: alicegoarnisson Date: Wed, 15 Jan 2025 10:58:12 +0100 Subject: [PATCH 5/5] chore(orga): attributes to fix when we have the correct Campaign.js in domainBuilder, for now tests need to pass --- .../domain/models/CampaignParticipation.js | 6 ++++-- .../campaign-participation/domain/usecases/index.js | 2 +- .../send-shared-participation-results-to-pole-emploi.js | 3 ++- ...riting-campaign-profiles-collection-results-to-stream.js | 1 + api/tests/unit/domain/models/Campaign_test.js | 2 ++ 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/api/src/prescription/campaign-participation/domain/models/CampaignParticipation.js b/api/src/prescription/campaign-participation/domain/models/CampaignParticipation.js index ab9e4c82556..49934747f60 100644 --- a/api/src/prescription/campaign-participation/domain/models/CampaignParticipation.js +++ b/api/src/prescription/campaign-participation/domain/models/CampaignParticipation.js @@ -96,7 +96,8 @@ class CampaignParticipation { throw new CampaignParticiationInvalidStatus(this.id, CampaignParticipationStatuses.TO_SHARE); } - if (this.campaign.isProfilesCollection()) { + //TODO: rewrite when we have only one model for Campaign, for now now tests are based on Campaign.js from api context + if (this.campaign.type === 'PROFILES_COLLECTION') { throw new CantImproveCampaignParticipationError(); } } @@ -115,7 +116,8 @@ class CampaignParticipation { if (this.isDeleted) { throw new CampaignParticipationDeletedError('Cannot share results on a deleted participation.'); } - if (this.campaign.isAssessment() && lastAssessmentNotCompleted(this)) { + //TODO: rewrite when we have only one model for Campaign, for now tests are based on Campaign.js from api context + if (this.campaign.type === 'ASSESSMENT' && lastAssessmentNotCompleted(this)) { throw new AssessmentNotCompletedError(); } } diff --git a/api/src/prescription/campaign-participation/domain/usecases/index.js b/api/src/prescription/campaign-participation/domain/usecases/index.js index 9ef315124af..ea2214db9f3 100644 --- a/api/src/prescription/campaign-participation/domain/usecases/index.js +++ b/api/src/prescription/campaign-participation/domain/usecases/index.js @@ -91,6 +91,7 @@ const dependencies = { badgeAcquisitionRepository, badgeForCalculationRepository, badgeRepository, + campaignRepository, campaignAnalysisRepository, campaignAssessmentParticipationRepository, campaignAssessmentParticipationResultRepository, @@ -99,7 +100,6 @@ const dependencies = { campaignParticipationRepository, campaignParticipationResultRepository, campaignProfileRepository, - campaignRepository, targetProfileRepository, compareStagesAndAcquiredStages, competenceEvaluationRepository, diff --git a/api/src/prescription/campaign-participation/domain/usecases/send-shared-participation-results-to-pole-emploi.js b/api/src/prescription/campaign-participation/domain/usecases/send-shared-participation-results-to-pole-emploi.js index 0e2f4bc2acb..5f9a096f48c 100644 --- a/api/src/prescription/campaign-participation/domain/usecases/send-shared-participation-results-to-pole-emploi.js +++ b/api/src/prescription/campaign-participation/domain/usecases/send-shared-participation-results-to-pole-emploi.js @@ -27,7 +27,8 @@ const sendSharedParticipationResultsToPoleEmploi = async ({ const campaign = await campaignRepository.get(participation.campaignId); const organization = await organizationRepository.get(campaign.organizationId); - if (campaign.isAssessment() && organization.isPoleEmploi) { + //TODO: rewrite when we have only one model for Campaign, for now tests are based on Campaign.js from api context + if (campaign.type === 'ASSESSMENT' && organization.isPoleEmploi) { const badges = await badgeRepository.findByCampaignId(participation.campaignId); const badgeAcquiredIds = await badgeAcquisitionRepository.getAcquiredBadgeIds({ badgeIds: badges.map((badge) => badge.id), diff --git a/api/src/prescription/campaign/domain/usecases/start-writing-campaign-profiles-collection-results-to-stream.js b/api/src/prescription/campaign/domain/usecases/start-writing-campaign-profiles-collection-results-to-stream.js index aa22497deb8..d7923df3a45 100644 --- a/api/src/prescription/campaign/domain/usecases/start-writing-campaign-profiles-collection-results-to-stream.js +++ b/api/src/prescription/campaign/domain/usecases/start-writing-campaign-profiles-collection-results-to-stream.js @@ -23,6 +23,7 @@ const startWritingCampaignProfilesCollectionResultsToStream = async function ({ const translate = i18n.__; let additionalHeaders = []; + //TODO: rewrite when we have only one model for Campaign, for now tests are based on Campaign.js from api context if (!campaign.isProfilesCollection()) { throw new CampaignTypeError(); } diff --git a/api/tests/unit/domain/models/Campaign_test.js b/api/tests/unit/domain/models/Campaign_test.js index 0f6ce470154..ea77e8ba897 100644 --- a/api/tests/unit/domain/models/Campaign_test.js +++ b/api/tests/unit/domain/models/Campaign_test.js @@ -73,6 +73,7 @@ describe('Unit | Domain | Models | Campaign', function () { const campaign = domainBuilder.buildCampaign.ofTypeProfilesCollection(); // when / then + //TODO: rewrite when we have only one Campaign model on domainBuilder expect(campaign.isProfilesCollection()).to.be.true; }); @@ -81,6 +82,7 @@ describe('Unit | Domain | Models | Campaign', function () { const campaign = domainBuilder.buildCampaign.ofTypeAssessment(); // when / then + //TODO: rewrite when we have only one Campaign model on domainBuilder expect(campaign.isProfilesCollection()).to.be.false; }); });