Skip to content

feat: add mock functionality for opportunity-related services#3380

Merged
idoshamun merged 6 commits intomainfrom
recruiter-mocks
Dec 31, 2025
Merged

feat: add mock functionality for opportunity-related services#3380
idoshamun merged 6 commits intomainfrom
recruiter-mocks

Conversation

@idoshamun
Copy link
Copy Markdown
Member

  • 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.
@pulumi
Copy link
Copy Markdown

pulumi Bot commented Dec 29, 2025

🍹 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

Copy link
Copy Markdown
Contributor

@rebelchris rebelchris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can make them even more inline by just returning mocked objects but letting the rest happen?

Comment thread src/schema/opportunity.ts
Parse an opportunity from a URL or file upload
"""
parseOpportunity(payload: ParseOpportunityInput!): Opportunity!
@rateLimit(limit: 5, duration: 3600)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test only

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Fixed

Comment thread src/schema/opportunity.ts Outdated
// Mock path: skip Brokkr/Scraper and create opportunity directly
if (isMockEnabled()) {
ctx.log.info('Using mock parseOpportunity - skipping Brokkr/Scraper');
return mockParseOpportunity({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldnt it be nicer of this just returned the proto object so rest of function keeps evaluating?

Comment thread src/schema/opportunity.ts Outdated
ctx.log.info(
'Using mock recommendOpportunityScreeningQuestions - skipping Gondul',
);
return mockRecommendScreeningQuestions({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, if we wrap dynamic around screen response we can make sure the saving etc doesnt break?

@idoshamun idoshamun requested a review from rebelchris December 29, 2025 19:06
@idoshamun
Copy link
Copy Markdown
Member Author

@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

Copy link
Copy Markdown
Contributor

@rebelchris rebelchris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! actually also made it a lot leaner this way 👀

* Returns plain objects that match the expected protobuf message shape
*/
export const mockBrokkrParseOpportunityResponse = () => ({
opportunity: {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: doesn't this expect proto type response?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@idoshamun idoshamun merged commit 65ce8aa into main Dec 31, 2025
10 checks passed
@idoshamun idoshamun deleted the recruiter-mocks branch December 31, 2025 12:53
Comment thread src/schema/opportunity.ts
* Generates a unique organization name with format "CompanyXX"
* Tries random numbers first, falls back to UUID suffix for guaranteed uniqueness
*/
async function generateUniqueOrganizationName(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we simply do something like org-uuidv4?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's user facing, I wanted to have something that will not scare recruiters a way. So I copied the username generation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants