feat: add mock functionality for opportunity-related services#3380
feat: add mock functionality for opportunity-related services#3380
Conversation
idoshamun
commented
Dec 29, 2025
- Introduced mock implementations for opportunity parsing, preview, and screening questions to facilitate local development without external service dependencies.
- Updated SnotraClient to utilize mock engagement profiles when enabled.
- Added configuration options in Pulumi for enabling mock external services.
- Introduced mock implementations for opportunity parsing, preview, and screening questions to facilitate local development without external service dependencies. - Updated SnotraClient to utilize mock engagement profiles when enabled. - Added configuration options in Pulumi for enabling mock external services.
|
🍹 The Update (preview) for dailydotdev/api/prod (at 8142f26) was successful. Resource Changes Name Type Operation
~ vpc-native-personalized-digest-cron kubernetes:batch/v1:CronJob update
~ vpc-native-clean-stale-user-transactions-cron kubernetes:batch/v1:CronJob update
~ vpc-native-clean-gifted-plus-cron kubernetes:batch/v1:CronJob update
~ vpc-native-update-highlighted-views-cron kubernetes:batch/v1:CronJob update
+ vpc-native-api-db-migration-2095c61b kubernetes:batch/v1:Job create
~ vpc-native-update-tag-recommendations-cron kubernetes:batch/v1:CronJob update
~ vpc-native-check-analytics-report-cron kubernetes:batch/v1:CronJob update
~ vpc-native-update-source-tag-view-cron kubernetes:batch/v1:CronJob update
~ vpc-native-bg-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-update-source-public-threshold-cron kubernetes:batch/v1:CronJob update
~ vpc-native-daily-digest-cron kubernetes:batch/v1:CronJob update
~ vpc-native-sync-subscription-with-cio-cron kubernetes:batch/v1:CronJob update
~ vpc-native-validate-active-users-cron kubernetes:batch/v1:CronJob update
+ vpc-native-api-clickhouse-migration-2095c61b kubernetes:batch/v1:Job create
~ vpc-native-private-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-update-tags-str-cron kubernetes:batch/v1:CronJob update
~ vpc-native-generic-referral-reminder-cron kubernetes:batch/v1:CronJob update
~ vpc-native-update-views-cron kubernetes:batch/v1:CronJob update
~ vpc-native-clean-zombie-images-cron kubernetes:batch/v1:CronJob update
~ vpc-native-ws-deployment kubernetes:apps/v1:Deployment update
- api-sub-api.recruiter-opportunity-live-notification gcp:pubsub/subscription:Subscription delete
~ vpc-native-calculate-top-readers-cron kubernetes:batch/v1:CronJob update
~ vpc-native-clean-zombie-opportunities-cron kubernetes:batch/v1:CronJob update
- vpc-native-api-clickhouse-migration-fd7ae65b kubernetes:batch/v1:Job delete
~ vpc-native-personalized-digest-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-update-current-streak-cron kubernetes:batch/v1:CronJob update
~ vpc-native-clean-zombie-users-cron kubernetes:batch/v1:CronJob update
~ vpc-native-hourly-notification-cron kubernetes:batch/v1:CronJob update
~ vpc-native-clean-zombie-user-companies-cron kubernetes:batch/v1:CronJob update
~ vpc-native-post-analytics-clickhouse-cron kubernetes:batch/v1:CronJob update
~ vpc-native-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-user-profile-updated-sync-cron kubernetes:batch/v1:CronJob update
- api-sub-api.recruiter-new-candidate-notification gcp:pubsub/subscription:Subscription delete
- vpc-native-api-db-migration-fd7ae65b kubernetes:batch/v1:Job delete
~ vpc-native-update-trending-cron kubernetes:batch/v1:CronJob update
~ vpc-native-temporal-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-generate-search-invites-cron kubernetes:batch/v1:CronJob update
~ vpc-native-post-analytics-history-day-clickhouse-cron kubernetes:batch/v1:CronJob update
|
rebelchris
left a comment
There was a problem hiding this comment.
I think we can make them even more inline by just returning mocked objects but letting the rest happen?
| Parse an opportunity from a URL or file upload | ||
| """ | ||
| parseOpportunity(payload: ParseOpportunityInput!): Opportunity! | ||
| @rateLimit(limit: 5, duration: 3600) |
| // Mock path: skip Brokkr/Scraper and create opportunity directly | ||
| if (isMockEnabled()) { | ||
| ctx.log.info('Using mock parseOpportunity - skipping Brokkr/Scraper'); | ||
| return mockParseOpportunity({ |
There was a problem hiding this comment.
Wouldnt it be nicer of this just returned the proto object so rest of function keeps evaluating?
| ctx.log.info( | ||
| 'Using mock recommendOpportunityScreeningQuestions - skipping Gondul', | ||
| ); | ||
| return mockRecommendScreeningQuestions({ |
There was a problem hiding this comment.
Same here, if we wrap dynamic around screen response we can make sure the saving etc doesnt break?
|
@rebelchris i tried now to make it as close as possible, but the opportunity preview was more challenging due to its async nature. i had to hack it a bit |
rebelchris
left a comment
There was a problem hiding this comment.
Nice! actually also made it a lot leaner this way 👀
| * Returns plain objects that match the expected protobuf message shape | ||
| */ | ||
| export const mockBrokkrParseOpportunityResponse = () => ({ | ||
| opportunity: { |
There was a problem hiding this comment.
nit: doesn't this expect proto type response?
There was a problem hiding this comment.
It introduced some parsing issues, so reverted to this
- Updated mock user IDs to include test users for better simulation. - Added mock tags and squad IDs to facilitate opportunity preview testing in mock mode. - Integrated mock tags and squads into the opportunity resolver logic for fallback when no real data is available.
- Added a function to generate unique organization names when not provided, using a combination of random numbers and UUIDs for guaranteed uniqueness. - Updated the opportunity mutation to utilize this new functionality, ensuring that organizations are created with unique names in the database.
| * Generates a unique organization name with format "CompanyXX" | ||
| * Tries random numbers first, falls back to UUID suffix for guaranteed uniqueness | ||
| */ | ||
| async function generateUniqueOrganizationName( |
There was a problem hiding this comment.
Can't we simply do something like org-uuidv4?
There was a problem hiding this comment.
Since it's user facing, I wanted to have something that will not scare recruiters a way. So I copied the username generation