@@ -43,9 +43,9 @@ const setup = async (props?: SetupProps): Promise<{ id: string }> => {
4343 const { id } = await setupUtil ( {
4444 moduleDir : import . meta. dir ,
4545 moduleVariables : {
46- install_sourcegraph_amp : props ?. skipAmpMock ? "true" : "false" ,
46+ workdir : "/home/coder" ,
47+ install_amp : props ?. skipAmpMock ? "true" : "false" ,
4748 install_agentapi : props ?. skipAgentAPIMock ? "true" : "false" ,
48- sourcegraph_amp_model : "test-model" ,
4949 ...props ?. moduleVariables ,
5050 } ,
5151 registerCleanup,
@@ -68,45 +68,94 @@ const setup = async (props?: SetupProps): Promise<{ id: string }> => {
6868
6969setDefaultTimeout ( 60 * 1000 ) ;
7070
71- describe ( "sourcegraph- amp" , async ( ) => {
71+ describe ( "amp" , async ( ) => {
7272 beforeAll ( async ( ) => {
7373 await runTerraformInit ( import . meta. dir ) ;
7474 } ) ;
7575
76- test ( "happy-path" , async ( ) => {
77- const { id } = await setup ( ) ;
76+ // test("happy-path", async () => {
77+ // const { id } = await setup();
78+ // await execModuleScript(id);
79+ // await expectAgentAPIStarted(id);
80+ // });
81+ //
82+ // test("api-key", async () => {
83+ // const apiKey = "test-api-key-123";
84+ // const { id } = await setup({
85+ // moduleVariables: {
86+ // amp_api_key: apiKey,
87+ // },
88+ // });
89+ // await execModuleScript(id);
90+ // const resp = await readFileContainer(
91+ // id,
92+ // "/home/coder/.amp-module/agentapi-start.log",
93+ // );
94+ // expect(resp).toContain("amp_api_key provided !");
95+ // });
96+ //
97+ test ( "install-latest-version" , async ( ) => {
98+ const { id } = await setup ( {
99+ skipAmpMock : true ,
100+ skipAgentAPIMock : true ,
101+ moduleVariables : {
102+ amp_version : "" ,
103+ } ,
104+ } ) ;
78105 await execModuleScript ( id ) ;
79106 await expectAgentAPIStarted ( id ) ;
80107 } ) ;
81108
82- test ( "api-key" , async ( ) => {
83- const apiKey = "test-api-key-123" ;
109+ test ( "install-specific-version" , async ( ) => {
84110 const { id } = await setup ( {
111+ skipAmpMock : true ,
85112 moduleVariables : {
86- sourcegraph_amp_api_key : apiKey ,
113+ amp_version : "0.0.1755964909-g31e083" ,
87114 } ,
88115 } ) ;
89116 await execModuleScript ( id ) ;
90117 const resp = await readFileContainer (
91118 id ,
92- "/home/coder/.sourcegraph-amp-module/agentapi-start.log" ,
119+ "/home/coder/.amp-module/agentapi-start.log" ,
120+ ) ;
121+ expect ( resp ) . toContain ( "0.0.1755964909-g31e08" ) ;
122+ } ) ;
123+
124+ test ( "install-via-npm" , async ( ) => {
125+ const { id } = await setup ( {
126+ skipAmpMock : true ,
127+ moduleVariables : {
128+ install_via_npm : "true" ,
129+ } ,
130+ } ) ;
131+ await execModuleScript ( id ) ;
132+
133+ const installLog = await readFileContainer (
134+ id ,
135+ "/home/coder/.amp-module/install.log" ,
93136 ) ;
94- expect ( resp ) . toContain ( "sourcegraph_amp_api_key provided !" ) ;
137+ expect ( installLog ) . toContain ( "Installing Amp via npm" ) ;
138+
139+ const startLog = await readFileContainer (
140+ id ,
141+ "/home/coder/.amp-module/agentapi-start.log" ,
142+ ) ;
143+ expect ( startLog ) . toContain ( "AMP version:" ) ;
95144 } ) ;
96145
97- test ( "custom-folder " , async ( ) => {
98- const folder = "/tmp/sourcegraph- amp-test" ;
146+ test ( "custom-workdir " , async ( ) => {
147+ const workdir = "/tmp/amp-test" ;
99148 const { id } = await setup ( {
100149 moduleVariables : {
101- folder ,
150+ workdir ,
102151 } ,
103152 } ) ;
104153 await execModuleScript ( id ) ;
105154 const resp = await readFileContainer (
106155 id ,
107- "/home/coder/.sourcegraph- amp-module/install .log" ,
156+ "/home/coder/.amp-module/agentapi-start .log" ,
108157 ) ;
109- expect ( resp ) . toContain ( folder ) ;
158+ expect ( resp ) . toContain ( workdir ) ;
110159 } ) ;
111160
112161 test ( "pre-post-install-scripts" , async ( ) => {
@@ -119,39 +168,104 @@ describe("sourcegraph-amp", async () => {
119168 await execModuleScript ( id ) ;
120169 const preLog = await readFileContainer (
121170 id ,
122- "/home/coder/.sourcegraph- amp-module/pre_install.log" ,
171+ "/home/coder/.amp-module/pre_install.log" ,
123172 ) ;
124173 expect ( preLog ) . toContain ( "pre-install-script" ) ;
125174 const postLog = await readFileContainer (
126175 id ,
127- "/home/coder/.sourcegraph- amp-module/post_install.log" ,
176+ "/home/coder/.amp-module/post_install.log" ,
128177 ) ;
129178 expect ( postLog ) . toContain ( "post-install-script" ) ;
130179 } ) ;
131180
132- test ( "system-prompt" , async ( ) => {
133- const prompt = "this is a system prompt for AMP" ;
134- const { id } = await setup ( ) ;
135- await execModuleScript ( id , {
136- SOURCEGRAPH_AMP_SYSTEM_PROMPT : prompt ,
181+ test ( "instruction-prompt" , async ( ) => {
182+ const prompt = "this is a instruction prompt for AMP" ;
183+ const { id } = await setup ( {
184+ moduleVariables : {
185+ instruction_prompt : prompt ,
186+ } ,
187+ } ) ;
188+ await execModuleScript ( id ) ;
189+ const resp = await readFileContainer ( id , "/home/coder/.config/AGENTS.md" ) ;
190+ expect ( resp ) . toContain ( prompt ) ;
191+ } ) ;
192+
193+ test ( "ai-prompt" , async ( ) => {
194+ const prompt = "this is a task prompt for AMP" ;
195+ const { id } = await setup ( {
196+ moduleVariables : {
197+ ai_prompt : prompt ,
198+ } ,
137199 } ) ;
200+ await execModuleScript ( id ) ;
138201 const resp = await readFileContainer (
139202 id ,
140- "/home/coder/.sourcegraph- amp-module/SYSTEM_PROMPT.md " ,
203+ "/home/coder/.amp-module/agentapi-start.log " ,
141204 ) ;
142- expect ( resp ) . toContain ( prompt ) ;
205+ expect ( resp ) . toContain ( `amp task prompt provided : ${ prompt } ` ) ;
143206 } ) ;
144207
145- test ( "task-prompt" , async ( ) => {
146- const prompt = "this is a task prompt for AMP" ;
208+ test ( "custom-base-config" , async ( ) => {
209+ const customConfig = JSON . stringify ( {
210+ "amp.anthropic.thinking.enabled" : false ,
211+ "amp.todos.enabled" : false ,
212+ "amp.tools.stopTimeout" : 900 ,
213+ "amp.git.commit.ampThread.enabled" : true ,
214+ } ) ;
215+ const customMcp = JSON . stringify ( {
216+ "test-server" : {
217+ command : "/usr/bin/test-mcp" ,
218+ args : [ "--test-arg" ] ,
219+ type : "stdio" ,
220+ } ,
221+ } ) ;
222+ const { id } = await setup ( {
223+ moduleVariables : {
224+ base_amp_config : customConfig ,
225+ mcp : customMcp ,
226+ } ,
227+ } ) ;
228+ await execModuleScript ( id , {
229+ CODER_AGENT_TOKEN : "test-token" ,
230+ CODER_AGENT_URL : "http://test-url:3000" ,
231+ } ) ;
232+ const settingsContent = await readFileContainer (
233+ id ,
234+ "/home/coder/.config/amp/settings.json" ,
235+ ) ;
236+ const settings = JSON . parse ( settingsContent ) ;
237+
238+ expect ( settings [ "amp.anthropic.thinking.enabled" ] ) . toBe ( false ) ;
239+ expect ( settings [ "amp.todos.enabled" ] ) . toBe ( false ) ;
240+ expect ( settings [ "amp.tools.stopTimeout" ] ) . toBe ( 900 ) ;
241+ expect ( settings [ "amp.git.commit.ampThread.enabled" ] ) . toBe ( true ) ;
242+ expect ( settings [ "amp.mcpServers" ] ) . toBeDefined ( ) ;
243+ expect ( settings [ "amp.mcpServers" ] . coder ) . toBeDefined ( ) ;
244+ expect ( settings [ "amp.mcpServers" ] [ "test-server" ] ) . toBeDefined ( ) ;
245+ expect ( settings [ "amp.mcpServers" ] [ "test-server" ] . command ) . toBe (
246+ "/usr/bin/test-mcp" ,
247+ ) ;
248+ expect ( settings [ "amp.mcpServers" ] [ "test-server" ] . args ) . toEqual ( [
249+ "--test-arg" ,
250+ ] ) ;
251+ } ) ;
252+
253+ test ( "default-base-config" , async ( ) => {
147254 const { id } = await setup ( ) ;
148255 await execModuleScript ( id , {
149- SOURCEGRAPH_AMP_TASK_PROMPT : prompt ,
256+ CODER_AGENT_TOKEN : "test-token" ,
257+ CODER_AGENT_URL : "http://test-url:3000" ,
150258 } ) ;
151- const resp = await readFileContainer (
259+ const settingsContent = await readFileContainer (
152260 id ,
153- "/home/coder/.sourcegraph- amp-module/agentapi-start.log " ,
261+ "/home/coder/.config/ amp/settings.json " ,
154262 ) ;
155- expect ( resp ) . toContain ( `sourcegraph amp task prompt provided : ${ prompt } ` ) ;
263+ const settings = JSON . parse ( settingsContent ) ;
264+
265+ expect ( settings [ "amp.anthropic.thinking.enabled" ] ) . toBe ( true ) ;
266+ expect ( settings [ "amp.todos.enabled" ] ) . toBe ( true ) ;
267+ expect ( settings [ "amp.mcpServers" ] ) . toBeDefined ( ) ;
268+ expect ( settings [ "amp.mcpServers" ] . coder ) . toBeDefined ( ) ;
269+ expect ( settings [ "amp.mcpServers" ] . coder . command ) . toBe ( "coder" ) ;
156270 } ) ;
157271} ) ;
0 commit comments