11import type { ZodError } from 'zod' ;
22import { DataSource , IsNull } from 'typeorm' ;
33import request from 'supertest' ;
4- import { Alerts , Feed , Keyword , User } from '../../src/entity' ;
4+ import { Alerts , Keyword , User } from '../../src/entity' ;
55import { Opportunity } from '../../src/entity/opportunities/Opportunity' ;
66import { OpportunityMatch } from '../../src/entity/OpportunityMatch' ;
77import { Organization } from '../../src/entity/Organization' ;
8- import {
9- ContentPreferenceOrganization ,
10- ContentPreferenceOrganizationStatus ,
11- } from '../../src/entity/contentPreference/ContentPreferenceOrganization' ;
8+
129import { OpportunityKeyword } from '../../src/entity/OpportunityKeyword' ;
1310import { DatasetLocation } from '../../src/entity/dataset/DatasetLocation' ;
1411import { OpportunityLocation } from '../../src/entity/opportunities/OpportunityLocation' ;
@@ -5737,12 +5734,12 @@ describe('mutation parseOpportunity', () => {
57375734describe ( 'mutation createSharedSlackChannel' , ( ) => {
57385735 const MUTATION = /* GraphQL */ `
57395736 mutation CreateSharedSlackChannel(
5740- $organizationId : ID!
5737+ $opportunityId : ID!
57415738 $email: String!
57425739 $channelName: String!
57435740 ) {
57445741 createSharedSlackChannel(
5745- organizationId : $organizationId
5742+ opportunityId : $opportunityId
57465743 email: $email
57475744 channelName: $channelName
57485745 ) {
@@ -5755,22 +5752,6 @@ describe('mutation createSharedSlackChannel', () => {
57555752 // Reset all mocks before each test
57565753 mockConversationsCreate . mockReset ( ) ;
57575754 mockConversationsInviteShared . mockReset ( ) ;
5758-
5759- // Add organization membership for user 1
5760- await con . getRepository ( Feed ) . save ( {
5761- id : '1' ,
5762- name : 'My Feed' ,
5763- userId : '1' ,
5764- } ) ;
5765- await saveFixtures ( con , ContentPreferenceOrganization , [
5766- {
5767- userId : '1' ,
5768- organizationId : '550e8400-e29b-41d4-a716-446655440000' ,
5769- referenceId : '550e8400-e29b-41d4-a716-446655440000' ,
5770- status : ContentPreferenceOrganizationStatus . Free ,
5771- feedId : '1' ,
5772- } ,
5773- ] ) ;
57745755 } ) ;
57755756
57765757 it ( 'should require authentication' , async ( ) => {
@@ -5779,7 +5760,7 @@ describe('mutation createSharedSlackChannel', () => {
57795760 {
57805761 mutation : MUTATION ,
57815762 variables : {
5782- organizationId : '550e8400-e29b-41d4-a716-446655440000 ' ,
5763+ opportunityId : '550e8400-e29b-41d4-a716-446655440001 ' ,
57835764 email : 'user@example.com' ,
57845765 channelName : 'test-channel' ,
57855766 } ,
@@ -5796,7 +5777,7 @@ describe('mutation createSharedSlackChannel', () => {
57965777 {
57975778 mutation : MUTATION ,
57985779 variables : {
5799- organizationId : '550e8400-e29b-41d4-a716-446655440000 ' ,
5780+ opportunityId : '550e8400-e29b-41d4-a716-446655440001 ' ,
58005781 email : 'user@example.com' ,
58015782 channelName : 'test-channel' ,
58025783 } ,
@@ -5830,7 +5811,7 @@ describe('mutation createSharedSlackChannel', () => {
58305811
58315812 const res = await client . mutate ( MUTATION , {
58325813 variables : {
5833- organizationId : '550e8400-e29b-41d4-a716-446655440000 ' ,
5814+ opportunityId : '550e8400-e29b-41d4-a716-446655440001 ' ,
58345815 email : 'user@example.com' ,
58355816 channelName : 'test-channel' ,
58365817 } ,
@@ -5878,7 +5859,7 @@ describe('mutation createSharedSlackChannel', () => {
58785859
58795860 const res = await client . mutate ( MUTATION , {
58805861 variables : {
5881- organizationId : '550e8400-e29b-41d4-a716-446655440000 ' ,
5862+ opportunityId : '550e8400-e29b-41d4-a716-446655440001 ' ,
58825863 email : 'user@example.com' ,
58835864 channelName : 'existing-channel' ,
58845865 } ,
@@ -5915,7 +5896,7 @@ describe('mutation createSharedSlackChannel', () => {
59155896
59165897 const res = await client . mutate ( MUTATION , {
59175898 variables : {
5918- organizationId : '550e8400-e29b-41d4-a716-446655440000 ' ,
5899+ opportunityId : '550e8400-e29b-41d4-a716-446655440001 ' ,
59195900 email : 'user@example.com' ,
59205901 channelName : 'test-channel' ,
59215902 } ,
@@ -5925,14 +5906,14 @@ describe('mutation createSharedSlackChannel', () => {
59255906 } ) ;
59265907
59275908 it ( 'should forbid non-members from creating slack channels' , async ( ) => {
5928- loggedUser = '2' ; // User 2 is not a member of organization 550e8400
5909+ loggedUser = '2' ; // User 2 is not a recrioter of opporunity/org 550e8400
59295910
59305911 await testMutationErrorCode (
59315912 client ,
59325913 {
59335914 mutation : MUTATION ,
59345915 variables : {
5935- organizationId : '550e8400-e29b-41d4-a716-446655440000 ' ,
5916+ opportunityId : '550e8400-e29b-41d4-a716-446655440001 ' ,
59365917 email : 'user@example.com' ,
59375918 channelName : 'test-channel' ,
59385919 } ,
@@ -5942,24 +5923,22 @@ describe('mutation createSharedSlackChannel', () => {
59425923 } ) ;
59435924
59445925 it ( 'should require active subscription' , async ( ) => {
5945- loggedUser = '2 ' ;
5926+ loggedUser = '1 ' ;
59465927
5947- // Create organization membership for user 2
5948- await con . getRepository ( ContentPreferenceOrganization ) . save ( {
5949- userId : '2' ,
5950- organizationId : 'ed487a47-6f4d-480f-9712-f48ab29db27c' ,
5951- referenceId : 'ed487a47-6f4d-480f-9712-f48ab29db27c' ,
5952- status : ContentPreferenceOrganizationStatus . Free ,
5953- feedId : '1' ,
5928+ // Create a recruiter record for the logged-in user
5929+ await con . getRepository ( OpportunityUserRecruiter ) . save ( {
5930+ opportunityId : '550e8400-e29b-41d4-a716-446655440001' ,
5931+ userId : '1' ,
5932+ type : OpportunityUserType . Recruiter ,
59545933 } ) ;
59555934
59565935 // Update organization to have inactive subscription
59575936 await con . getRepository ( Organization ) . update (
5958- { id : 'ed487a47-6f4d-480f-9712-f48ab29db27c ' } ,
5937+ { id : '550e8400-e29b-41d4-a716-446655440000 ' } ,
59595938 {
59605939 recruiterSubscriptionFlags : updateRecruiterSubscriptionFlags ( {
59615940 subscriptionId : 'sub_456' ,
5962- status : SubscriptionStatus . Pending ,
5941+ status : SubscriptionStatus . Cancelled ,
59635942 provider : 'paddle' ,
59645943 items : [ { priceId : 'pri_456' , quantity : 3 } ] ,
59655944 } ) ,
@@ -5971,7 +5950,7 @@ describe('mutation createSharedSlackChannel', () => {
59715950 {
59725951 mutation : MUTATION ,
59735952 variables : {
5974- organizationId : 'ed487a47-6f4d-480f-9712-f48ab29db27c ' ,
5953+ opportunityId : '550e8400-e29b-41d4-a716-446655440001 ' ,
59755954 email : 'user@example.com' ,
59765955 channelName : 'test-channel' ,
59775956 } ,
@@ -6009,7 +5988,7 @@ describe('mutation createSharedSlackChannel', () => {
60095988 {
60105989 mutation : MUTATION ,
60115990 variables : {
6012- organizationId : '550e8400-e29b-41d4-a716-446655440000 ' ,
5991+ opportunityId : '550e8400-e29b-41d4-a716-446655440001 ' ,
60135992 email : 'user@example.com' ,
60145993 channelName : 'new-channel' ,
60155994 } ,
0 commit comments