@@ -16,9 +16,24 @@ import { remoteConfig } from '../../src/remoteConfig';
1616
1717let con : DataSource ;
1818
19- const testOrgPrefix = 'esat-' ; // expire-super-agent-trial prefix
20- // UUID base for test opportunity IDs (valid UUID format)
21- const testOpBase = 'e5a70000-0000-0000-0000-00000000000' ;
19+ // Valid UUIDs for test organizations
20+ const testOrgIds = {
21+ expiredWithPlan : 'e5a70001-0000-0000-0000-000000000001' ,
22+ expiredNoPlan : 'e5a70002-0000-0000-0000-000000000002' ,
23+ activeTrial : 'e5a70003-0000-0000-0000-000000000003' ,
24+ noTrial : 'e5a70004-0000-0000-0000-000000000004' ,
25+ } ;
26+
27+ // Valid UUIDs for test opportunities
28+ const testOpIds = {
29+ trialLive : 'e5a70100-0000-0000-0000-000000000001' ,
30+ trialReview : 'e5a70100-0000-0000-0000-000000000002' ,
31+ trialClosed : 'e5a70100-0000-0000-0000-000000000003' ,
32+ trialDraft : 'e5a70100-0000-0000-0000-000000000004' ,
33+ paidLive : 'e5a70100-0000-0000-0000-000000000005' ,
34+ activeTrial : 'e5a70100-0000-0000-0000-000000000006' ,
35+ noTrialOrg : 'e5a70100-0000-0000-0000-000000000007' ,
36+ } ;
2237
2338beforeAll ( async ( ) => {
2439 con = await createOrGetConnection ( ) ;
@@ -32,7 +47,7 @@ beforeEach(async () => {
3247
3348 await saveFixtures ( con , Organization , [
3449 {
35- id : ` ${ testOrgPrefix } expired-with-plan` ,
50+ id : testOrgIds . expiredWithPlan ,
3651 name : 'Expired With Plan Org ESAT' ,
3752 recruiterSubscriptionFlags : {
3853 isTrialActive : true ,
@@ -43,7 +58,7 @@ beforeEach(async () => {
4358 } ,
4459 } ,
4560 {
46- id : ` ${ testOrgPrefix } expired-no-plan` ,
61+ id : testOrgIds . expiredNoPlan ,
4762 name : 'Expired No Plan Org ESAT' ,
4863 recruiterSubscriptionFlags : {
4964 isTrialActive : true ,
@@ -53,7 +68,7 @@ beforeEach(async () => {
5368 } ,
5469 } ,
5570 {
56- id : ` ${ testOrgPrefix } active-trial` ,
71+ id : testOrgIds . activeTrial ,
5772 name : 'Active Trial Org ESAT' ,
5873 recruiterSubscriptionFlags : {
5974 isTrialActive : true ,
@@ -63,7 +78,7 @@ beforeEach(async () => {
6378 } ,
6479 } ,
6580 {
66- id : ` ${ testOrgPrefix } no-trial` ,
81+ id : testOrgIds . noTrial ,
6782 name : 'No Trial Org ESAT' ,
6883 recruiterSubscriptionFlags : {
6984 status : SubscriptionStatus . Active ,
@@ -76,12 +91,12 @@ beforeEach(async () => {
7691 await saveFixtures ( con , OpportunityJob , [
7792 // Trial opportunity for expired org - should have trial features removed
7893 {
79- id : ` ${ testOpBase } 1` ,
94+ id : testOpIds . trialLive ,
8095 type : OpportunityType . JOB ,
8196 state : OpportunityState . LIVE ,
8297 title : 'Trial Live Op ESAT' ,
8398 tldr : 'Trial live opportunity' ,
84- organizationId : ` ${ testOrgPrefix } expired-no-plan` ,
99+ organizationId : testOrgIds . expiredNoPlan ,
85100 flags : {
86101 plan : 'pri_seat_123' ,
87102 isTrial : true ,
@@ -93,12 +108,12 @@ beforeEach(async () => {
93108 } ,
94109 // Trial opportunity in review for expired org - should have trial features removed
95110 {
96- id : ` ${ testOpBase } 2` ,
111+ id : testOpIds . trialReview ,
97112 type : OpportunityType . JOB ,
98113 state : OpportunityState . IN_REVIEW ,
99114 title : 'Trial Review Op ESAT' ,
100115 tldr : 'Trial in review opportunity' ,
101- organizationId : ` ${ testOrgPrefix } expired-no-plan` ,
116+ organizationId : testOrgIds . expiredNoPlan ,
102117 flags : {
103118 plan : 'pri_seat_456' ,
104119 isTrial : true ,
@@ -110,59 +125,58 @@ beforeEach(async () => {
110125 } ,
111126 // Trial opportunity already closed - should not be affected
112127 {
113- id : ` ${ testOpBase } 3` ,
128+ id : testOpIds . trialClosed ,
114129 type : OpportunityType . JOB ,
115130 state : OpportunityState . CLOSED ,
116131 title : 'Trial Closed Op ESAT' ,
117132 tldr : 'Trial closed opportunity' ,
118- organizationId : ` ${ testOrgPrefix } expired-no-plan` ,
133+ organizationId : testOrgIds . expiredNoPlan ,
119134 flags : { plan : 'pri_seat_789' , isTrial : true , batchSize : 150 } ,
120135 } ,
121136 // Trial opportunity draft - should not be affected
122137 {
123- id : ` ${ testOpBase } 4` ,
138+ id : testOpIds . trialDraft ,
124139 type : OpportunityType . JOB ,
125140 state : OpportunityState . DRAFT ,
126141 title : 'Trial Draft Op ESAT' ,
127142 tldr : 'Trial draft opportunity' ,
128- organizationId : ` ${ testOrgPrefix } expired-no-plan` ,
143+ organizationId : testOrgIds . expiredNoPlan ,
129144 flags : { plan : 'pri_seat_abc' , isTrial : true , batchSize : 150 } ,
130145 } ,
131146 // Paid opportunity without trial for expired org - should not be affected
132147 {
133- id : ` ${ testOpBase } 5` ,
148+ id : testOpIds . paidLive ,
134149 type : OpportunityType . JOB ,
135150 state : OpportunityState . LIVE ,
136151 title : 'Paid Live Op ESAT' ,
137152 tldr : 'Paid live opportunity' ,
138- organizationId : ` ${ testOrgPrefix } expired-with-plan` ,
153+ organizationId : testOrgIds . expiredWithPlan ,
139154 flags : { plan : 'pri_original_123' , batchSize : 200 } ,
140155 } ,
141156 // Trial opportunity for active trial org - should not be affected
142157 {
143- id : ` ${ testOpBase } 6` ,
158+ id : testOpIds . activeTrial ,
144159 type : OpportunityType . JOB ,
145160 state : OpportunityState . LIVE ,
146161 title : 'Active Trial Op ESAT' ,
147162 tldr : 'Active trial opportunity' ,
148- organizationId : ` ${ testOrgPrefix } active-trial` ,
163+ organizationId : testOrgIds . activeTrial ,
149164 flags : { plan : 'pri_seat_xyz' , isTrial : true , batchSize : 150 } ,
150165 } ,
151166 // Opportunity for non-trial org - should not be affected
152167 {
153- id : ` ${ testOpBase } 7` ,
168+ id : testOpIds . noTrialOrg ,
154169 type : OpportunityType . JOB ,
155170 state : OpportunityState . LIVE ,
156171 title : 'No Trial Org Op ESAT' ,
157172 tldr : 'No trial org opportunity' ,
158- organizationId : ` ${ testOrgPrefix } no-trial` ,
173+ organizationId : testOrgIds . noTrial ,
159174 flags : { plan : 'pri_regular_123' , batchSize : 100 } ,
160175 } ,
161176 ] ) ;
162177} ) ;
163178
164179afterEach ( ( ) => {
165- // @ts -expect-error - resetting to undefined for tests
166180 remoteConfig . vars . superAgentTrial = undefined ;
167181} ) ;
168182
@@ -178,7 +192,7 @@ describe('expireSuperAgentTrial cron', () => {
178192 // Verify expired trial with original plan - keeps active status
179193 const expiredWithPlan = await con
180194 . getRepository ( Organization )
181- . findOneBy ( { id : ` ${ testOrgPrefix } expired-with-plan` } ) ;
195+ . findOneBy ( { id : testOrgIds . expiredWithPlan } ) ;
182196 expect ( expiredWithPlan ?. recruiterSubscriptionFlags ) . toMatchObject ( {
183197 isTrialActive : false ,
184198 status : SubscriptionStatus . Active ,
@@ -191,7 +205,7 @@ describe('expireSuperAgentTrial cron', () => {
191205 // Verify expired trial without original plan - downgrades to none
192206 const expiredNoPlan = await con
193207 . getRepository ( Organization )
194- . findOneBy ( { id : ` ${ testOrgPrefix } expired-no-plan` } ) ;
208+ . findOneBy ( { id : testOrgIds . expiredNoPlan } ) ;
195209 expect ( expiredNoPlan ?. recruiterSubscriptionFlags ) . toMatchObject ( {
196210 isTrialActive : false ,
197211 status : SubscriptionStatus . None ,
@@ -200,7 +214,7 @@ describe('expireSuperAgentTrial cron', () => {
200214 // Verify active trial was not affected
201215 const activeTrial = await con
202216 . getRepository ( Organization )
203- . findOneBy ( { id : ` ${ testOrgPrefix } active-trial` } ) ;
217+ . findOneBy ( { id : testOrgIds . activeTrial } ) ;
204218 expect ( activeTrial ?. recruiterSubscriptionFlags ) . toMatchObject ( {
205219 isTrialActive : true ,
206220 status : SubscriptionStatus . Active ,
@@ -212,7 +226,7 @@ describe('expireSuperAgentTrial cron', () => {
212226 // Verify org without trial was not affected
213227 const noTrial = await con
214228 . getRepository ( Organization )
215- . findOneBy ( { id : ` ${ testOrgPrefix } no-trial` } ) ;
229+ . findOneBy ( { id : testOrgIds . noTrial } ) ;
216230 expect ( noTrial ?. recruiterSubscriptionFlags ) . toMatchObject ( {
217231 status : SubscriptionStatus . Active ,
218232 } ) ;
@@ -227,7 +241,7 @@ describe('expireSuperAgentTrial cron', () => {
227241 // Trial LIVE opportunity for expired org - should remain LIVE but have trial features removed
228242 // and batchSize reset to default (50)
229243 const trialLive = await opportunityRepo . findOneBy ( {
230- id : ` ${ testOpBase } 1` ,
244+ id : testOpIds . trialLive ,
231245 } ) ;
232246 expect ( trialLive ?. state ) . toBe ( OpportunityState . LIVE ) ;
233247 expect ( trialLive ?. flags ?. plan ) . toBe ( 'pri_seat_123' ) ; // plan preserved
@@ -239,7 +253,7 @@ describe('expireSuperAgentTrial cron', () => {
239253
240254 // Trial IN_REVIEW opportunity for expired org - should remain IN_REVIEW but have trial features removed
241255 const trialReview = await opportunityRepo . findOneBy ( {
242- id : ` ${ testOpBase } 2` ,
256+ id : testOpIds . trialReview ,
243257 } ) ;
244258 expect ( trialReview ?. state ) . toBe ( OpportunityState . IN_REVIEW ) ;
245259 expect ( trialReview ?. flags ?. plan ) . toBe ( 'pri_seat_456' ) ; // plan preserved
@@ -248,36 +262,36 @@ describe('expireSuperAgentTrial cron', () => {
248262
249263 // Trial CLOSED opportunity - should remain closed and have trial features intact (not affected)
250264 const trialClosed = await opportunityRepo . findOneBy ( {
251- id : ` ${ testOpBase } 3` ,
265+ id : testOpIds . trialClosed ,
252266 } ) ;
253267 expect ( trialClosed ?. state ) . toBe ( OpportunityState . CLOSED ) ;
254268 expect ( trialClosed ?. flags ?. isTrial ) . toBe ( true ) ; // not affected since already closed
255269
256270 // Trial DRAFT opportunity - should remain draft and have trial features intact (not affected)
257271 const trialDraft = await opportunityRepo . findOneBy ( {
258- id : ` ${ testOpBase } 4` ,
272+ id : testOpIds . trialDraft ,
259273 } ) ;
260274 expect ( trialDraft ?. state ) . toBe ( OpportunityState . DRAFT ) ;
261275 expect ( trialDraft ?. flags ?. isTrial ) . toBe ( true ) ; // not affected since draft
262276
263277 // Paid opportunity without trial for expired org - should remain unchanged
264278 const paidLive = await opportunityRepo . findOneBy ( {
265- id : ` ${ testOpBase } 5` ,
279+ id : testOpIds . paidLive ,
266280 } ) ;
267281 expect ( paidLive ?. state ) . toBe ( OpportunityState . LIVE ) ;
268282 expect ( paidLive ?. flags ?. plan ) . toBe ( 'pri_original_123' ) ;
269283 expect ( paidLive ?. flags ?. batchSize ) . toBe ( 200 ) ; // batchSize preserved (not a trial feature here)
270284
271285 // Trial opportunity for active trial org - should remain unchanged
272286 const activeTrial = await opportunityRepo . findOneBy ( {
273- id : ` ${ testOpBase } 6` ,
287+ id : testOpIds . activeTrial ,
274288 } ) ;
275289 expect ( activeTrial ?. state ) . toBe ( OpportunityState . LIVE ) ;
276290 expect ( activeTrial ?. flags ?. isTrial ) . toBe ( true ) ; // trial still active
277291
278292 // Opportunity for non-trial org - should remain unchanged
279293 const noTrialOp = await opportunityRepo . findOneBy ( {
280- id : ` ${ testOpBase } 7` ,
294+ id : testOpIds . noTrialOrg ,
281295 } ) ;
282296 expect ( noTrialOp ?. state ) . toBe ( OpportunityState . LIVE ) ;
283297 expect ( noTrialOp ?. flags ?. batchSize ) . toBe ( 100 ) ;
@@ -299,19 +313,19 @@ describe('expireSuperAgentTrial cron', () => {
299313 await saveFixtures ( con , OpportunityUserRecruiter , [
300314 // User 1 is recruiter on trial opportunity for expired org
301315 {
302- opportunityId : ` ${ testOpBase } 1` ,
316+ opportunityId : testOpIds . trialLive ,
303317 userId : '1' ,
304318 type : OpportunityUserType . Recruiter ,
305319 } ,
306320 // User 2 is recruiter on trial opportunity for active trial org (not affected)
307321 {
308- opportunityId : ` ${ testOpBase } 6` ,
322+ opportunityId : testOpIds . activeTrial ,
309323 userId : '2' ,
310324 type : OpportunityUserType . Recruiter ,
311325 } ,
312326 // User 3 is recruiter on paid opportunity (not affected)
313327 {
314- opportunityId : ` ${ testOpBase } 5` ,
328+ opportunityId : testOpIds . paidLive ,
315329 userId : '3' ,
316330 type : OpportunityUserType . Recruiter ,
317331 } ,
0 commit comments