@@ -2375,4 +2375,146 @@ describe('mutation upsertUserGeneralExperience with repository', () => {
23752375 'ZOD_VALIDATION_ERROR' ,
23762376 ) ;
23772377 } ) ;
2378+
2379+ it ( 'should create an opensource experience with custom repository (null id)' , async ( ) => {
2380+ loggedUser = '1' ;
2381+
2382+ const res = await client . mutate ( UPSERT_OPENSOURCE_MUTATION , {
2383+ variables : {
2384+ input : {
2385+ type : 'opensource' ,
2386+ title : 'GitLab Contributor' ,
2387+ description : 'Contributing to a GitLab project' ,
2388+ startedAt : new Date ( '2023-01-01' ) ,
2389+ repository : {
2390+ id : null ,
2391+ owner : 'myorg' ,
2392+ name : 'myproject' ,
2393+ url : 'https://gitlab.com/myorg/myproject' ,
2394+ image : null ,
2395+ } ,
2396+ } ,
2397+ } ,
2398+ } ) ;
2399+
2400+ expect ( res . errors ) . toBeFalsy ( ) ;
2401+ expect ( res . data . upsertUserGeneralExperience ) . toMatchObject ( {
2402+ id : expect . any ( String ) ,
2403+ type : 'opensource' ,
2404+ title : 'GitLab Contributor' ,
2405+ company : null ,
2406+ customCompanyName : null ,
2407+ repository : {
2408+ id : null ,
2409+ owner : 'myorg' ,
2410+ name : 'myproject' ,
2411+ url : 'https://gitlab.com/myorg/myproject' ,
2412+ image : null ,
2413+ } ,
2414+ } ) ;
2415+
2416+ // Verify the repository is stored in flags
2417+ const saved = await con . getRepository ( UserExperience ) . findOne ( {
2418+ where : { id : res . data . upsertUserGeneralExperience . id } ,
2419+ } ) ;
2420+ expect ( saved ?. flags ) . toMatchObject ( {
2421+ repository : {
2422+ id : null ,
2423+ owner : 'myorg' ,
2424+ name : 'myproject' ,
2425+ url : 'https://gitlab.com/myorg/myproject' ,
2426+ image : null ,
2427+ } ,
2428+ } ) ;
2429+ } ) ;
2430+
2431+ it ( 'should create an opensource experience with custom repository without owner' , async ( ) => {
2432+ loggedUser = '1' ;
2433+
2434+ const res = await client . mutate ( UPSERT_OPENSOURCE_MUTATION , {
2435+ variables : {
2436+ input : {
2437+ type : 'opensource' ,
2438+ title : 'Custom Repo Contributor' ,
2439+ startedAt : new Date ( '2023-01-01' ) ,
2440+ repository : {
2441+ id : null ,
2442+ owner : null ,
2443+ name : 'standalone-project' ,
2444+ url : 'https://example.com/standalone-project' ,
2445+ image : null ,
2446+ } ,
2447+ } ,
2448+ } ,
2449+ } ) ;
2450+
2451+ expect ( res . errors ) . toBeFalsy ( ) ;
2452+ expect ( res . data . upsertUserGeneralExperience ) . toMatchObject ( {
2453+ type : 'opensource' ,
2454+ repository : {
2455+ id : null ,
2456+ owner : null ,
2457+ name : 'standalone-project' ,
2458+ url : 'https://example.com/standalone-project' ,
2459+ image : null ,
2460+ } ,
2461+ } ) ;
2462+ } ) ;
2463+
2464+ it ( 'should update from GitHub repository to custom repository' , async ( ) => {
2465+ loggedUser = '1' ;
2466+
2467+ // First create with GitHub repository
2468+ const created = await client . mutate ( UPSERT_OPENSOURCE_MUTATION , {
2469+ variables : {
2470+ input : {
2471+ type : 'opensource' ,
2472+ title : 'Initial Contribution' ,
2473+ startedAt : new Date ( '2023-01-01' ) ,
2474+ repository : {
2475+ id : '10270250' ,
2476+ owner : 'facebook' ,
2477+ name : 'react' ,
2478+ url : 'https://github.com/facebook/react' ,
2479+ image : 'https://avatars.githubusercontent.com/u/69631?v=4' ,
2480+ } ,
2481+ } ,
2482+ } ,
2483+ } ) ;
2484+
2485+ expect ( created . errors ) . toBeFalsy ( ) ;
2486+ const experienceId = created . data . upsertUserGeneralExperience . id ;
2487+
2488+ // Update to custom repository
2489+ const updated = await client . mutate ( UPSERT_OPENSOURCE_MUTATION , {
2490+ variables : {
2491+ id : experienceId ,
2492+ input : {
2493+ type : 'opensource' ,
2494+ title : 'Moved to GitLab' ,
2495+ startedAt : new Date ( '2023-01-01' ) ,
2496+ repository : {
2497+ id : null ,
2498+ owner : 'myorg' ,
2499+ name : 'forked-project' ,
2500+ url : 'https://gitlab.com/myorg/forked-project' ,
2501+ image : null ,
2502+ } ,
2503+ } ,
2504+ } ,
2505+ } ) ;
2506+
2507+ expect ( updated . errors ) . toBeFalsy ( ) ;
2508+ expect ( updated . data . upsertUserGeneralExperience ) . toMatchObject ( {
2509+ id : experienceId ,
2510+ title : 'Moved to GitLab' ,
2511+ repository : {
2512+ id : null ,
2513+ owner : 'myorg' ,
2514+ name : 'forked-project' ,
2515+ url : 'https://gitlab.com/myorg/forked-project' ,
2516+ image : null ,
2517+ } ,
2518+ } ) ;
2519+ } ) ;
23782520} ) ;
0 commit comments