@@ -7,158 +7,194 @@ const REMOTE = "ed".repeat(32);
77const GENERAL = "9a1657ac-f7aa-5db0-b632-d8bbeb6dfb50" ;
88const LABEL = "Not managed on this device" ;
99
10- test ( "existing owned member uses one cloud across picker, members, author, chip, hover, profile and DM" , async ( {
11- page,
12- } , testInfo ) => {
13- await installMockBridge ( page , {
14- managedAgents : [ ] ,
15- searchProfiles : [
16- {
17- pubkey : REMOTE ,
18- displayName : "Remote Scout" ,
19- ownerPubkey : OWNER ,
20- isAgent : true ,
21- } ,
22- ] ,
23- relayAgents : [
24- {
25- pubkey : REMOTE ,
26- name : "Remote Scout" ,
27- ownerPubkey : OWNER ,
28- respondTo : "owner-only" ,
29- channelNames : [ "general" ] ,
30- status : "offline" ,
31- } ,
32- ] ,
33- } ) ;
34- await page . goto ( "/" ) ;
35- await page . getByTestId ( "channel-general" ) . click ( ) ;
36- await expect ( page . getByTestId ( "chat-title" ) ) . toHaveText ( "general" ) ;
37- // Fixture setup only: the UI workflow starts with membership and a DM already present.
38- const dm = await page . evaluate (
39- async ( { pubkey, channelId } ) => {
40- await window . __BUZZ_E2E_INVOKE_MOCK_COMMAND__ ?.( "add_channel_members" , {
41- channelId,
42- pubkeys : [ pubkey ] ,
43- role : "bot" ,
44- } ) ;
45- const dm = ( await window . __BUZZ_E2E_INVOKE_MOCK_COMMAND__ ?.( "open_dm" , {
46- pubkeys : [ pubkey ] ,
47- } ) ) as { id : string } ;
48- await window . __BUZZ_E2E_QUERY_CLIENT__ ?. invalidateQueries ( {
49- queryKey : [ "channels" ] ,
10+ // The delayed fixture exceeds the marker assertion's 5s deadline, proving that
11+ // source readiness is awaited independently of whether a cloud ever renders.
12+ for ( const agentListDelayMs of [ 0 , 6_000 ] ) {
13+ test ( `existing owned member uses one cloud across picker, members, author, chip, hover, profile and DM (directory delay ${ agentListDelayMs } ms)` , async ( {
14+ page,
15+ } , testInfo ) => {
16+ await installMockBridge ( page , {
17+ agentListDelayMs,
18+ managedAgents : [ ] ,
19+ searchProfiles : [
20+ {
21+ pubkey : REMOTE ,
22+ displayName : "Remote Scout" ,
23+ ownerPubkey : OWNER ,
24+ isAgent : true ,
25+ } ,
26+ ] ,
27+ relayAgents : [
28+ {
29+ pubkey : REMOTE ,
30+ name : "Remote Scout" ,
31+ ownerPubkey : OWNER ,
32+ respondTo : "owner-only" ,
33+ channelNames : [ "general" ] ,
34+ status : "offline" ,
35+ } ,
36+ ] ,
37+ } ) ;
38+ await page . goto ( "/" ) ;
39+ await page . getByTestId ( "channel-general" ) . click ( ) ;
40+ await expect ( page . getByTestId ( "chat-title" ) ) . toHaveText ( "general" ) ;
41+ // The channel shell can mount before the provider's directory queries settle.
42+ // Wait for successful source reads, not a delay or a larger marker timeout:
43+ // the assertions below must still fail if ready data renders no cloud.
44+ await expect
45+ . poll (
46+ ( ) =>
47+ page . evaluate ( ( ) => {
48+ const client = window . __BUZZ_E2E_QUERY_CLIENT__ ;
49+ return Object . fromEntries (
50+ [ "identity" , "managed-agents" , "relay-agents" ] . map ( ( key ) => {
51+ const state = client ?. getQueryState ( [ key ] ) ;
52+ return [
53+ key ,
54+ { status : state ?. status , fetchStatus : state ?. fetchStatus } ,
55+ ] ;
56+ } ) ,
57+ ) ;
58+ } ) ,
59+ {
60+ message :
61+ "Cloud provenance requires successful identity and agent directory reads" ,
62+ timeout : 10_000 ,
63+ } ,
64+ )
65+ . toMatchObject ( {
66+ identity : { status : "success" } ,
67+ "managed-agents" : { status : "success" } ,
68+ "relay-agents" : { status : "success" } ,
5069 } ) ;
51- return dm ;
52- } ,
53- { pubkey : REMOTE , channelId : GENERAL } ,
54- ) ;
55- await page . getByTestId ( "channel-general" ) . click ( ) ;
56- const input = page . getByTestId ( "message-input" ) ;
57- await input . fill ( "@Remote" ) ;
58- const suggestion = page . getByTestId ( `mention-suggestion-${ REMOTE } ` ) ;
59- await expect (
60- suggestion . getByRole ( "img" , { name : LABEL } ) . locator ( "svg.lucide-cloud" ) ,
61- ) . toBeVisible ( ) ;
62- await waitForAnimations ( page ) ;
63- await page
64- . getByTestId ( "mention-autocomplete" )
65- . screenshot ( { path : testInfo . outputPath ( "cloud-picker.png" ) } ) ;
66- await input . press ( "Escape" ) ;
67- await input . fill ( "" ) ;
70+ // Fixture setup only: the UI workflow starts with membership and a DM already present.
71+ const dm = await page . evaluate (
72+ async ( { pubkey, channelId } ) => {
73+ await window . __BUZZ_E2E_INVOKE_MOCK_COMMAND__ ?.( "add_channel_members" , {
74+ channelId,
75+ pubkeys : [ pubkey ] ,
76+ role : "bot" ,
77+ } ) ;
78+ const dm = ( await window . __BUZZ_E2E_INVOKE_MOCK_COMMAND__ ?.( "open_dm" , {
79+ pubkeys : [ pubkey ] ,
80+ } ) ) as { id : string } ;
81+ await window . __BUZZ_E2E_QUERY_CLIENT__ ?. invalidateQueries ( {
82+ queryKey : [ "channels" ] ,
83+ } ) ;
84+ return dm ;
85+ } ,
86+ { pubkey : REMOTE , channelId : GENERAL } ,
87+ ) ;
88+ await page . getByTestId ( "channel-general" ) . click ( ) ;
89+ const input = page . getByTestId ( "message-input" ) ;
90+ await input . fill ( "@Remote" ) ;
91+ const suggestion = page . getByTestId ( `mention-suggestion-${ REMOTE } ` ) ;
92+ await expect (
93+ suggestion . getByRole ( "img" , { name : LABEL } ) . locator ( "svg.lucide-cloud" ) ,
94+ ) . toBeVisible ( ) ;
95+ await waitForAnimations ( page ) ;
96+ await page
97+ . getByTestId ( "mention-autocomplete" )
98+ . screenshot ( { path : testInfo . outputPath ( "cloud-picker.png" ) } ) ;
99+ await input . press ( "Escape" ) ;
100+ await input . fill ( "" ) ;
68101
69- await page . getByTestId ( "channel-members-trigger" ) . click ( ) ;
70- const members = page . getByTestId ( "members-sidebar" ) ;
71- const memberMarker = page . getByTestId (
72- `sidebar-member-agent-provenance-${ REMOTE } ` ,
73- ) ;
74- await expect ( memberMarker ) . toHaveAttribute ( "aria-label" , LABEL ) ;
75- await expect ( memberMarker . locator ( "svg.lucide-cloud" ) ) . toBeVisible ( ) ;
76- await waitForAnimations ( page ) ;
77- await members . screenshot ( { path : testInfo . outputPath ( "cloud-members.png" ) } ) ;
78- await members . getByRole ( "button" , { name : "Close" , exact : true } ) . click ( ) ;
102+ await page . getByTestId ( "channel-members-trigger" ) . click ( ) ;
103+ const members = page . getByTestId ( "members-sidebar" ) ;
104+ const memberMarker = page . getByTestId (
105+ `sidebar-member-agent-provenance-${ REMOTE } ` ,
106+ ) ;
107+ await expect ( memberMarker ) . toHaveAttribute ( "aria-label" , LABEL ) ;
108+ await expect ( memberMarker . locator ( "svg.lucide-cloud" ) ) . toBeVisible ( ) ;
109+ await waitForAnimations ( page ) ;
110+ await members . screenshot ( {
111+ path : testInfo . outputPath ( "cloud-members.png" ) ,
112+ } ) ;
113+ await members . getByRole ( "button" , { name : "Close" , exact : true } ) . click ( ) ;
79114
80- await expect
81- . poll ( ( ) =>
82- page . evaluate ( ( ) =>
83- window . __BUZZ_E2E_HAS_MOCK_LIVE_SUBSCRIPTION__ ?.( {
84- channelName : "general" ,
85- } ) ,
86- ) ,
87- )
88- . toBe ( true ) ;
89- await page . evaluate ( ( pubkey ) => {
90- window . __BUZZ_E2E_EMIT_MOCK_MESSAGE__ ?.( {
91- channelName : "general" ,
92- content : "Cloud provenance example: @Remote Scout" ,
93- pubkey,
94- // A self-reference is non-notifying, but still resolves a mention chip.
95- extraTags : [ [ "mention" , pubkey ] ] ,
96- kind : 40002 ,
115+ await expect
116+ . poll ( ( ) =>
117+ page . evaluate ( ( ) =>
118+ window . __BUZZ_E2E_HAS_MOCK_LIVE_SUBSCRIPTION__ ?.( {
119+ channelName : "general" ,
120+ } ) ,
121+ ) ,
122+ )
123+ . toBe ( true ) ;
124+ await page . evaluate ( ( pubkey ) => {
125+ window . __BUZZ_E2E_EMIT_MOCK_MESSAGE__ ?.( {
126+ channelName : "general" ,
127+ content : "Cloud provenance example: @Remote Scout" ,
128+ pubkey,
129+ // A self-reference is non-notifying, but still resolves a mention chip.
130+ extraTags : [ [ "mention" , pubkey ] ] ,
131+ kind : 40002 ,
132+ } ) ;
133+ } , REMOTE ) ;
134+ const article = page
135+ . getByTestId ( "message-row" )
136+ . filter ( { hasText : "Cloud provenance example:" } ) ;
137+ await expect (
138+ article . getByTestId ( "message-header" ) . getByRole ( "img" , { name : LABEL } ) ,
139+ ) . toBeVisible ( ) ;
140+ const chip = article . locator ( "[data-mention]" ) ;
141+ await expect ( chip . locator ( "svg.lucide-cloud" ) ) . toBeVisible ( ) ;
142+ await waitForAnimations ( page ) ;
143+ await article . screenshot ( {
144+ path : testInfo . outputPath ( "cloud-author-chip.png" ) ,
97145 } ) ;
98- } , REMOTE ) ;
99- const article = page
100- . getByTestId ( "message-row" )
101- . filter ( { hasText : "Cloud provenance example:" } ) ;
102- await expect (
103- article . getByTestId ( "message-header" ) . getByRole ( "img" , { name : LABEL } ) ,
104- ) . toBeVisible ( ) ;
105- const chip = article . locator ( "[data-mention]" ) ;
106- await expect ( chip . locator ( "svg.lucide-cloud" ) ) . toBeVisible ( ) ;
107- await waitForAnimations ( page ) ;
108- await article . screenshot ( {
109- path : testInfo . outputPath ( "cloud-author-chip.png" ) ,
110- } ) ;
111- await chip . hover ( ) ;
112- const hover = page . getByTestId ( "user-profile-popover" ) ;
113- await expect (
114- hover . getByTestId ( "user-profile-popover-agent-provenance" ) ,
115- ) . toHaveAttribute ( "title" , LABEL ) ;
116- await waitForAnimations ( page ) ;
117- await hover . screenshot ( { path : testInfo . outputPath ( "cloud-hover.png" ) } ) ;
118- await chip . click ( ) ;
119- const panel = page . getByTestId ( "user-profile-panel" ) ;
120- await expect (
121- panel . getByRole ( "img" , { name : LABEL } ) . locator ( "svg.lucide-cloud" ) ,
122- ) . toBeVisible ( ) ;
123- await waitForAnimations ( page ) ;
124- await panel . screenshot ( { path : testInfo . outputPath ( "cloud-profile.png" ) } ) ;
125- await page . getByTestId ( "auxiliary-panel-close" ) . click ( ) ;
126- await expect (
127- page
128- . getByTestId ( `channel-agent-provenance-${ dm . id } ` )
129- . locator ( "svg.lucide-cloud" ) ,
130- ) . toBeVisible ( ) ;
131- await page . locator ( `[data-channel-id="${ dm . id } "]` ) . click ( ) ;
132- await expect (
133- page
134- . getByTestId ( "chat-header-agent-provenance" )
135- . locator ( "svg.lucide-cloud" ) ,
136- ) . toBeVisible ( ) ;
137- await waitForAnimations ( page ) ;
138- await page . screenshot ( { path : testInfo . outputPath ( "cloud-dm.png" ) } ) ;
139- await openNewMessagePage ( page ) ;
140- await page . getByTestId ( "new-dm-search" ) . fill ( "Remote Scout" ) ;
141- const recipient = page . getByTestId ( `new-dm-result-${ REMOTE } ` ) ;
142- await expect (
143- recipient . getByRole ( "img" , { name : LABEL } ) . locator ( "svg.lucide-cloud" ) ,
144- ) . toBeVisible ( ) ;
145- await waitForAnimations ( page ) ;
146- await recipient . screenshot ( {
147- path : testInfo . outputPath ( "cloud-recipient.png" ) ,
148- } ) ;
149- await page . getByTestId ( "channel-random" ) . click ( ) ;
150- await page . getByTestId ( "channel-members-trigger" ) . click ( ) ;
151- await page . getByPlaceholder ( "Add people and agents" ) . fill ( "Remote Scout" ) ;
152- const addResult = page . getByTestId ( `channel-user-search-result-${ REMOTE } ` ) ;
153- await expect (
154- addResult . getByRole ( "img" , { name : LABEL } ) . locator ( "svg.lucide-cloud" ) ,
155- ) . toBeVisible ( ) ;
156- await waitForAnimations ( page ) ;
157- await addResult . screenshot ( {
158- path : testInfo . outputPath ( "cloud-add-member-picker.png" ) ,
146+ await chip . hover ( ) ;
147+ const hover = page . getByTestId ( "user-profile-popover" ) ;
148+ await expect (
149+ hover . getByTestId ( "user-profile-popover-agent-provenance" ) ,
150+ ) . toHaveAttribute ( "title" , LABEL ) ;
151+ await waitForAnimations ( page ) ;
152+ await hover . screenshot ( { path : testInfo . outputPath ( "cloud-hover.png" ) } ) ;
153+ await chip . click ( ) ;
154+ const panel = page . getByTestId ( "user-profile-panel" ) ;
155+ await expect (
156+ panel . getByRole ( "img" , { name : LABEL } ) . locator ( "svg.lucide-cloud" ) ,
157+ ) . toBeVisible ( ) ;
158+ await waitForAnimations ( page ) ;
159+ await panel . screenshot ( { path : testInfo . outputPath ( "cloud-profile.png" ) } ) ;
160+ await page . getByTestId ( "auxiliary-panel-close" ) . click ( ) ;
161+ await expect (
162+ page
163+ . getByTestId ( `channel-agent-provenance-${ dm . id } ` )
164+ . locator ( "svg.lucide-cloud" ) ,
165+ ) . toBeVisible ( ) ;
166+ await page . locator ( `[data-channel-id="${ dm . id } "]` ) . click ( ) ;
167+ await expect (
168+ page
169+ . getByTestId ( "chat-header-agent-provenance" )
170+ . locator ( "svg.lucide-cloud" ) ,
171+ ) . toBeVisible ( ) ;
172+ await waitForAnimations ( page ) ;
173+ await page . screenshot ( { path : testInfo . outputPath ( "cloud-dm.png" ) } ) ;
174+ await openNewMessagePage ( page ) ;
175+ await page . getByTestId ( "new-dm-search" ) . fill ( "Remote Scout" ) ;
176+ const recipient = page . getByTestId ( `new-dm-result-${ REMOTE } ` ) ;
177+ await expect (
178+ recipient . getByRole ( "img" , { name : LABEL } ) . locator ( "svg.lucide-cloud" ) ,
179+ ) . toBeVisible ( ) ;
180+ await waitForAnimations ( page ) ;
181+ await recipient . screenshot ( {
182+ path : testInfo . outputPath ( "cloud-recipient.png" ) ,
183+ } ) ;
184+ await page . getByTestId ( "channel-random" ) . click ( ) ;
185+ await page . getByTestId ( "channel-members-trigger" ) . click ( ) ;
186+ await page . getByPlaceholder ( "Add people and agents" ) . fill ( "Remote Scout" ) ;
187+ const addResult = page . getByTestId ( `channel-user-search-result-${ REMOTE } ` ) ;
188+ await expect (
189+ addResult . getByRole ( "img" , { name : LABEL } ) . locator ( "svg.lucide-cloud" ) ,
190+ ) . toBeVisible ( ) ;
191+ await waitForAnimations ( page ) ;
192+ await addResult . screenshot ( {
193+ path : testInfo . outputPath ( "cloud-add-member-picker.png" ) ,
194+ } ) ;
195+ // No invitation or local lifecycle action is exercised by this presentation test.
196+ await expect (
197+ page . getByRole ( "button" , { name : "Invite" , exact : true } ) ,
198+ ) . toHaveCount ( 0 ) ;
159199 } ) ;
160- // No invitation or local lifecycle action is exercised by this presentation test.
161- await expect (
162- page . getByRole ( "button" , { name : "Invite" , exact : true } ) ,
163- ) . toHaveCount ( 0 ) ;
164- } ) ;
200+ }
0 commit comments