@@ -44,6 +44,7 @@ import {
4444} from '@dailydotdev/shared/src/graphql/squads' ;
4545import {
4646 type SourceMember ,
47+ SourceType ,
4748 type Squad ,
4849 SourceMemberRole ,
4950 SourcePermissions ,
@@ -57,8 +58,9 @@ import {
5758 CONTENT_PREFERENCE_STATUS_QUERY ,
5859 ContentPreferenceType ,
5960} from '@dailydotdev/shared/src/graphql/contentPreference' ;
61+ import { gqlClient } from '@dailydotdev/shared/src/graphql/common' ;
6062import { useSquad } from '@dailydotdev/shared/src/hooks/squads/useSquad' ;
61- import SquadPage from '../pages/squads/[handle]' ;
63+ import SquadPage , { getServerSideProps } from '../pages/squads/[handle]' ;
6264
6365const defaultSquad : Squad = {
6466 ...generateTestSquad ( ) ,
@@ -259,6 +261,35 @@ const renderComponent = (
259261} ;
260262
261263describe ( 'squad page' , ( ) => {
264+ it ( 'should redirect machine sources to the canonical sources route' , async ( ) => {
265+ jest . spyOn ( gqlClient , 'request' ) . mockResolvedValueOnce ( {
266+ source : {
267+ id : 'daily' ,
268+ name : 'daily.dev' ,
269+ image : 'https://daily.dev/daily.png' ,
270+ handle : 'daily' ,
271+ permalink : 'https://app.daily.dev/sources/daily' ,
272+ type : SourceType . Machine ,
273+ public : true ,
274+ } ,
275+ } as Awaited < ReturnType < typeof gqlClient . request > > ) ;
276+
277+ const setHeader = jest . fn ( ) ;
278+ const result = await getServerSideProps ( {
279+ params : { handle : 'daily' } ,
280+ query : { } ,
281+ res : { setHeader } ,
282+ } as never ) ;
283+
284+ expect ( setHeader ) . toHaveBeenCalled ( ) ;
285+ expect ( result ) . toEqual ( {
286+ redirect : {
287+ destination : '/sources/daily' ,
288+ permanent : false ,
289+ } ,
290+ } ) ;
291+ } ) ;
292+
262293 it ( 'should request source feed' , async ( ) => {
263294 renderComponent ( ) ;
264295 await waitForNock ( ) ;
0 commit comments