11import { expect } from '@playwright/test'
22
3- import * as mockServer from '../fixtures/mock-server'
43import {
54 chatInputMentions ,
65 clickEditorTab ,
76 createEmptyChatPanel ,
8- getChatInputs ,
9- getChatSidebarPanel ,
107 mentionMenu ,
118 mentionMenuItems ,
129 openFileInEditorTab ,
1310 selectLineRangeInEditorTab ,
1411 sidebarSignin ,
1512} from './common'
16- import {
17- type DotcomUrlOverride ,
18- type WorkspaceDirectory ,
19- mockEnterpriseRepoMapping ,
20- test ,
21- testWithGitRemote ,
22- } from './helpers'
23-
24- testWithGitRemote ( 'initial context - self-serve repo' , async ( { page, sidebar } ) => {
25- await sidebarSignin ( page , sidebar )
26- const chatFrame = getChatSidebarPanel ( page )
27- const lastChatInput = getChatInputs ( chatFrame ) . last ( )
28-
29- // The current repository should be initially present in the chat input.
30- await expect ( chatInputMentions ( lastChatInput ) ) . toHaveText ( [ 'myrepo' ] )
31- } )
13+ import { type WorkspaceDirectory , mockEnterpriseRepoMapping , test , testWithGitRemote } from './helpers'
3214
3315testWithGitRemote ( 'initial context - enterprise repo' , async ( { page, sidebar, server } ) => {
3416 mockEnterpriseRepoMapping ( server , 'codehost.example/user/myrepo' )
@@ -71,25 +53,21 @@ testWithGitRemote('initial context - file', async ({ page, sidebar, server }) =>
7153} )
7254
7355// Test with multi-root workspace to verify initial context switches between workspace folders
74- const testWithMultiRoot = test
75- . extend < DotcomUrlOverride > ( {
76- dotcomUrl : mockServer . SERVER_URL ,
77- } )
78- . extend < WorkspaceDirectory > ( {
79- // biome-ignore lint/correctness/noEmptyPattern: Playwright needs empty pattern to specify "no dependencies".
80- workspaceDirectory : async ( { } , use ) => {
81- const path = require ( 'node:path' )
82- const vscodeRoot = path . resolve ( __dirname , '..' , '..' )
83- // Use the multi-root.code-workspace file to load both workspace and workspace2 folders
84- const multiRootWorkspaceFile = path . join (
85- vscodeRoot ,
86- 'test' ,
87- 'fixtures' ,
88- 'multi-root.code-workspace'
89- )
90- await use ( multiRootWorkspaceFile )
91- } ,
92- } )
56+ const testWithMultiRoot = test . extend < WorkspaceDirectory > ( {
57+ // biome-ignore lint/correctness/noEmptyPattern: Playwright needs empty pattern to specify "no dependencies".
58+ workspaceDirectory : async ( { } , use ) => {
59+ const path = require ( 'node:path' )
60+ const vscodeRoot = path . resolve ( __dirname , '..' , '..' )
61+ // Use the multi-root.code-workspace file to load both workspace and workspace2 folders
62+ const multiRootWorkspaceFile = path . join (
63+ vscodeRoot ,
64+ 'test' ,
65+ 'fixtures' ,
66+ 'multi-root.code-workspace'
67+ )
68+ await use ( multiRootWorkspaceFile )
69+ } ,
70+ } )
9371
9472testWithMultiRoot (
9573 'initial context - switches between multi-root workspace folders' ,
@@ -104,6 +82,25 @@ testWithMultiRoot(
10482 } ,
10583 } )
10684
85+ // Mock additional endpoints needed for enterprise context (from mockEnterpriseRepoMapping)
86+ server . onGraphQl ( 'Repositories' ) . replyJson ( {
87+ data : {
88+ repositories : {
89+ nodes : [
90+ { id : 'workspace-id' , name : 'github.com/sourcegraph/workspace' } ,
91+ { id : 'workspace2-id' , name : 'github.com/sourcegraph/workspace2' } ,
92+ ] ,
93+ pageInfo : { endCursor : 'workspace2-id' } ,
94+ } ,
95+ } ,
96+ } )
97+ server . onGraphQl ( 'Repository' ) . replyJson ( {
98+ data : { repository : { id : 'workspace-id' } } ,
99+ } )
100+ server . onGraphQl ( 'ResolveRepoName' ) . replyJson ( {
101+ data : { repository : { name : 'github.com/sourcegraph/workspace' } } ,
102+ } )
103+
107104 await sidebarSignin ( page , sidebar )
108105 await openFileInEditorTab ( page , 'buzz.ts' )
109106 const [ chatFrame , lastChatInput ] = await createEmptyChatPanel ( page )
0 commit comments