|
| 1 | +/** |
| 2 | + * Mock service responses for opportunity-related external services. |
| 3 | + * Only the actual service calls are mocked - all other flow logic remains unchanged. |
| 4 | + */ |
| 5 | + |
| 6 | +import { |
| 7 | + EmploymentType, |
| 8 | + OpportunityType, |
| 9 | + SalaryPeriod, |
| 10 | + SeniorityLevel, |
| 11 | +} from '@dailydotdev/schema'; |
| 12 | + |
| 13 | +/** |
| 14 | + * Check if external services should be mocked |
| 15 | + */ |
| 16 | +export const isMockEnabled = (): boolean => |
| 17 | + process.env.MOCK_EXTERNAL_SERVICES === 'true'; |
| 18 | + |
| 19 | +/** |
| 20 | + * Mock response for Brokkr parseOpportunity service call |
| 21 | + * Returns plain objects that match the expected protobuf message shape |
| 22 | + */ |
| 23 | +export const mockBrokkrParseOpportunityResponse = () => ({ |
| 24 | + opportunity: { |
| 25 | + type: OpportunityType.JOB, |
| 26 | + title: 'Senior Full Stack Developer', |
| 27 | + tldr: 'Join our team to build cutting-edge developer tools and shape the future of how developers discover content.', |
| 28 | + content: { |
| 29 | + overview: { |
| 30 | + content: |
| 31 | + 'We are looking for a Senior Full Stack Developer to join our growing engineering team. You will work on building and scaling our platform that serves millions of developers worldwide.', |
| 32 | + }, |
| 33 | + responsibilities: { |
| 34 | + content: |
| 35 | + '- Design and implement new features across the full stack\n- Collaborate with product and design teams\n- Mentor junior developers\n- Participate in code reviews and architectural decisions', |
| 36 | + }, |
| 37 | + requirements: { |
| 38 | + content: |
| 39 | + '- 5+ years of experience with modern web technologies\n- Strong proficiency in TypeScript and React\n- Experience with Node.js and PostgreSQL\n- Excellent communication skills', |
| 40 | + }, |
| 41 | + }, |
| 42 | + meta: { |
| 43 | + roleType: 0.0, |
| 44 | + teamSize: 15, |
| 45 | + seniorityLevel: SeniorityLevel.SENIOR, |
| 46 | + employmentType: EmploymentType.FULL_TIME, |
| 47 | + salary: { |
| 48 | + min: BigInt(120000), |
| 49 | + max: BigInt(130000), |
| 50 | + currency: 'USD', |
| 51 | + period: SalaryPeriod.ANNUAL, |
| 52 | + }, |
| 53 | + equity: true, |
| 54 | + }, |
| 55 | + keywords: ['typescript', 'react', 'nodejs', 'postgresql', 'graphql'], |
| 56 | + }, |
| 57 | +}); |
| 58 | + |
| 59 | +/** |
| 60 | + * Mock response for Gondul screeningQuestions service call |
| 61 | + */ |
| 62 | +export const mockGondulScreeningQuestionsResponse = () => ({ |
| 63 | + screening: [ |
| 64 | + 'What experience do you have building and scaling applications for millions of users?', |
| 65 | + 'How do you approach mentoring junior developers while maintaining your own productivity?', |
| 66 | + 'Describe your experience with TypeScript and React in production.', |
| 67 | + ], |
| 68 | +}); |
| 69 | + |
| 70 | +/** |
| 71 | + * Mock user IDs for opportunityPreview (simulates Gondul preview response) |
| 72 | + * These should be valid user IDs from your local database (from seed data) |
| 73 | + * Using testuser1-10 which have SourceMember entries for publicsquad |
| 74 | + */ |
| 75 | +export const mockPreviewUserIds = [ |
| 76 | + 'testuser', |
| 77 | + 'testuser1', |
| 78 | + 'testuser2', |
| 79 | + 'testuser3', |
| 80 | + 'testuser4', |
| 81 | + 'testuser5', |
| 82 | + 'testuser6', |
| 83 | + 'testuser7', |
| 84 | + 'testuser8', |
| 85 | + 'testuser9', |
| 86 | +]; |
| 87 | +export const mockPreviewTotalCount = 4827; |
| 88 | + |
| 89 | +/** |
| 90 | + * Mock tags for opportunityPreview result |
| 91 | + * These are used when computing the aggregated tags from user data |
| 92 | + */ |
| 93 | +export const mockPreviewTags = [ |
| 94 | + 'react', |
| 95 | + 'typescript', |
| 96 | + 'javascript', |
| 97 | + 'nodejs', |
| 98 | + 'python', |
| 99 | + 'graphql', |
| 100 | + 'nextjs', |
| 101 | + 'aws', |
| 102 | +]; |
| 103 | + |
| 104 | +/** |
| 105 | + * Mock squads for opportunityPreview result |
| 106 | + * These should match squad IDs from the seed data |
| 107 | + */ |
| 108 | +export const mockPreviewSquadIds = ['publicsquad']; |
| 109 | + |
| 110 | +/** |
| 111 | + * Mock PDF buffer for scraper service (minimal valid PDF) |
| 112 | + */ |
| 113 | +export const mockScraperPdfBuffer = (): Buffer => { |
| 114 | + // Minimal PDF structure |
| 115 | + return Buffer.from('%PDF-1.4\n1 0 obj\n<<>>\nendobj\ntrailer\n<<>>\n%%EOF'); |
| 116 | +}; |
| 117 | + |
| 118 | +/** |
| 119 | + * Mock engagement profile returned from Snotra getProfile |
| 120 | + */ |
| 121 | +export const mockSnotraEngagementProfile = { |
| 122 | + profile_text: |
| 123 | + 'Active developer with strong engagement in React and TypeScript communities. Regular contributor to open source projects and frequent reader of frontend development content. Shows consistent interest in modern web technologies and best practices.', |
| 124 | + update_at: new Date().toISOString(), |
| 125 | +}; |
0 commit comments