@@ -893,21 +893,22 @@ describe('authorized fork and sync against PostgreSQL', () => {
893893
894894 await db . update ( workspace ) . set ( { archivedAt : new Date ( ) } ) . where ( eq ( workspace . id , childId ) )
895895 const fromGrandchild = await setDefault ( grandchildId , false )
896- expect ( await policyOf ( sourceWorkspaceId ) ) . toBe ( false )
897- expect ( await policyOf ( grandchildId ) ) . toBe ( false )
898- expect ( await policyOf ( childId ) ) . toBe ( true )
899- // The archived member was neither written nor audited.
900- const expectedFromGrandchild = fromGrandchild . changedWorkspaces . map ( ( member ) => member . id )
901- expect ( expectedFromGrandchild ) . toEqual (
902- expect . arrayContaining ( [ sourceWorkspaceId , grandchildId ] )
896+ // Every live member flips back - the ones the first change covered and the two forks
897+ // created since - while the archived child is neither written nor audited.
898+ const expectedFromGrandchild = [
899+ ...[ ...changed . keys ( ) ] . filter ( ( id ) => id !== childId ) ,
900+ newForkId ,
901+ grandchildId ,
902+ ] . sort ( )
903+ expect ( fromGrandchild . changedWorkspaces . map ( ( member ) => member . id ) . sort ( ) ) . toEqual (
904+ expectedFromGrandchild
903905 )
904- expect ( expectedFromGrandchild ) . not . toContain ( childId )
906+ for ( const id of expectedFromGrandchild ) expect ( await policyOf ( id ) ) . toBe ( false )
907+ expect ( await policyOf ( childId ) ) . toBe ( true )
905908 await vi . waitFor (
906909 async ( ) => {
907910 const entries = await auditedFrom ( grandchildId )
908- expect ( entries . map ( ( entry ) => entry . resourceId ) . sort ( ) ) . toEqual (
909- [ ...expectedFromGrandchild ] . sort ( )
910- )
911+ expect ( entries . map ( ( entry ) => entry . resourceId ) . sort ( ) ) . toEqual ( expectedFromGrandchild )
911912 } ,
912913 { timeout : 5000 }
913914 )
0 commit comments