@@ -12,8 +12,21 @@ import {
1212 renderTeamsPortal ,
1313 TeamsPortalStore ,
1414 type TeamsPortalGateway ,
15+ type TeamsPortalSnapshot ,
1516} from "./teams-portal.ts" ;
1617
18+ type TeamsPortalGatewayMock = TeamsPortalGateway & {
19+ request : ReturnType < typeof vi . fn > ;
20+ stop : ReturnType < typeof vi . fn > ;
21+ } ;
22+
23+ type TeamsPortalPresenceParticipant = NonNullable < TeamsPortalSnapshot [ "presence" ] > [ number ] ;
24+
25+ const portalPresence : TeamsPortalPresenceParticipant [ ] = [
26+ { id : "ada" , kind : "human" , self : true } ,
27+ { id : "review-agent" , kind : "agent" , self : false } ,
28+ ] ;
29+
1730function authenticatedSession ( expiresAt = Date . now ( ) + 60_000 ) {
1831 return {
1932 authenticated : true as const ,
@@ -28,10 +41,7 @@ function tabResult(mode: "read" | "request" | "write" = "read") {
2841 workspaceId : "workspace-1" ,
2942 workspaceVersion : 8 ,
3043 capabilityMode : mode ,
31- presence : [
32- { id : "ada" , kind : "human" , self : true } ,
33- { id : "review-agent" , kind : "agent" , self : false } ,
34- ] ,
44+ presence : portalPresence ,
3545 tab : {
3646 id : "tab-1" ,
3747 revision : 4 ,
@@ -43,10 +53,7 @@ function tabResult(mode: "read" | "request" | "write" = "read") {
4353 } ;
4454}
4555
46- function createGateway ( response = tabResult ( ) ) : TeamsPortalGateway & {
47- request : ReturnType < typeof vi . fn > ;
48- stop : ReturnType < typeof vi . fn > ;
49- } {
56+ function createGateway ( response = tabResult ( ) ) : TeamsPortalGatewayMock {
5057 return {
5158 request : vi . fn ( async ( ) => response ) ,
5259 stop : vi . fn ( ) ,
@@ -247,8 +254,8 @@ describe("Teams portal store", () => {
247254 const pendingPresence = new Promise < ReturnType < typeof tabResult > > ( ( resolve ) => {
248255 resolvePresence = resolve ;
249256 } ) ;
250- const gateway = {
251- request : vi . fn ( ( method : string ) => {
257+ const gateway : TeamsPortalGatewayMock = {
258+ request : vi . fn ( ( method ? : string ) => {
252259 if ( method === "workspaces.tab.get" ) {
253260 tabReads += 1 ;
254261 return tabReads === 1 ? Promise . resolve ( tabResult ( ) ) : pendingPresence ;
0 commit comments