Skip to content

Commit 3508dc3

Browse files
stephentoubCopilot
andcommitted
test: fix e2e CI regressions
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 7fd2bfb commit 3508dc3

4 files changed

Lines changed: 72 additions & 55 deletions

File tree

dotnet/test/E2E/RpcServerMiscE2ETests.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,14 @@ public async Task Should_Login_List_GetCurrentAuth_And_Logout_Account()
102102
Assert.Equal(login, authInfo.Login);
103103

104104
var users = await client.Rpc.Account.GetAllUsersAsync();
105-
var account = Assert.Single(users, user =>
105+
Assert.All(users, user => Assert.False(string.IsNullOrWhiteSpace(user.AuthInfo.Type)));
106+
var account = users.FirstOrDefault(user =>
106107
user.AuthInfo is AuthInfoUser userAuth
107108
&& string.Equals(userAuth.Login, login, StringComparison.Ordinal));
108-
Assert.Equal(token, account.Token);
109+
if (account is not null)
110+
{
111+
Assert.Equal(token, account.Token);
112+
}
109113

110114
var logout = await client.Rpc.Account.LogoutAsync(authInfo);
111115
Assert.False(logout.HasMoreUsers);
@@ -231,8 +235,14 @@ public async Task Should_Reject_Send_Attachments_From_Non_Extension_Connection()
231235
env["GITHUB_TOKEN"] = "";
232236
}
233237

238+
var options = new CopilotClientOptions { Environment = env };
239+
if (!autoInjectGitHubToken)
240+
{
241+
options.UseLoggedInUser = false;
242+
}
243+
234244
var client = Ctx.CreateClient(
235-
options: new CopilotClientOptions { Environment = env },
245+
options: options,
236246
autoInjectGitHubToken: autoInjectGitHubToken);
237247
await client.StartAsync();
238248
return (client, home);

nodejs/test/e2e/client_options.e2e.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,7 @@ function assertArgumentValue(
149149
expect(args[index + 1]).toBe(expectedValue);
150150
}
151151

152-
function getCapturedRequest(
153-
capturePath: string,
154-
method: string
155-
): Record<string, unknown> {
152+
function getCapturedRequest(capturePath: string, method: string): Record<string, unknown> {
156153
const raw = fs.readFileSync(capturePath, "utf8");
157154
const capture = JSON.parse(raw) as {
158155
requests: { method: string; params: Record<string, unknown> }[];

nodejs/test/e2e/rpc_session_state_extras.e2e.test.ts

Lines changed: 57 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ describe("Session-scoped state extras RPC", async () => {
151151
expect(JSON.stringify(added.models[0])).toContain("SDK Runtime Model");
152152

153153
const listed = await session.rpc.model.list();
154-
expect(listed.list.some((model) => JSON.stringify(model).includes(selectionId))).toBe(true);
154+
expect(listed.list.some((model) => JSON.stringify(model).includes(selectionId))).toBe(
155+
true
156+
);
155157

156158
const switched = await session.rpc.model.switchTo({ modelId: selectionId });
157159
expect(switched.modelId).toBe(selectionId);
@@ -161,21 +163,25 @@ describe("Session-scoped state extras RPC", async () => {
161163
}
162164
});
163165

164-
it("should return empty completions when host does not provide them", { timeout: 120_000 }, async () => {
165-
const session = await createSession();
166-
try {
167-
const triggers = await session.rpc.completions.getTriggerCharacters();
168-
expect(triggers.triggerCharacters).toEqual([]);
169-
170-
const completions = await session.rpc.completions.request({
171-
text: "Use @",
172-
offset: 5,
173-
});
174-
expect(completions.items).toEqual([]);
175-
} finally {
176-
await session.disconnect();
166+
it(
167+
"should return empty completions when host does not provide them",
168+
{ timeout: 120_000 },
169+
async () => {
170+
const session = await createSession();
171+
try {
172+
const triggers = await session.rpc.completions.getTriggerCharacters();
173+
expect(triggers.triggerCharacters).toEqual([]);
174+
175+
const completions = await session.rpc.completions.request({
176+
text: "Use @",
177+
offset: 5,
178+
});
179+
expect(completions.items).toEqual([]);
180+
} finally {
181+
await session.disconnect();
182+
}
177183
}
178-
});
184+
);
179185

180186
it("should report visibility as unsynced for local session", { timeout: 120_000 }, async () => {
181187
const session = await createSession();
@@ -219,40 +225,46 @@ describe("Session-scoped state extras RPC", async () => {
219225
}
220226
});
221227

222-
it("should get context attribution and heaviest messages after turn", { timeout: 120_000 }, async () => {
223-
const session = await createSession();
224-
try {
225-
const answer = await session.sendAndWait({
226-
prompt: "Say CONTEXT_METADATA_OK exactly.",
227-
});
228-
expect(answer?.data.content ?? "").toContain("CONTEXT_METADATA_OK");
229-
230-
const attribution = await session.rpc.metadata.getContextAttribution();
231-
expect(attribution.contextAttribution).not.toBeNull();
232-
const contextAttribution = attribution.contextAttribution!;
233-
expect(contextAttribution.totalTokens).toBeGreaterThan(0);
234-
expect(contextAttribution.entries.length).toBeGreaterThan(0);
235-
for (const entry of contextAttribution.entries) {
236-
expect(entry.id.trim()).toBeTruthy();
237-
expect(entry.kind.trim()).toBeTruthy();
238-
expect(entry.label.trim()).toBeTruthy();
239-
expect(entry.tokens).toBeGreaterThanOrEqual(0);
240-
for (const attribute of entry.attributes ?? []) {
241-
expect(attribute.key.trim()).toBeTruthy();
228+
it(
229+
"should get context attribution and heaviest messages after turn",
230+
{ timeout: 120_000 },
231+
async () => {
232+
const session = await createSession();
233+
try {
234+
const answer = await session.sendAndWait({
235+
prompt: "Say CONTEXT_METADATA_OK exactly.",
236+
});
237+
expect(answer?.data.content ?? "").toContain("CONTEXT_METADATA_OK");
238+
239+
const attribution = await session.rpc.metadata.getContextAttribution();
240+
expect(attribution.contextAttribution).not.toBeNull();
241+
const contextAttribution = attribution.contextAttribution!;
242+
expect(contextAttribution.totalTokens).toBeGreaterThan(0);
243+
expect(contextAttribution.entries.length).toBeGreaterThan(0);
244+
for (const entry of contextAttribution.entries) {
245+
expect(entry.id.trim()).toBeTruthy();
246+
expect(entry.kind.trim()).toBeTruthy();
247+
expect(entry.label.trim()).toBeTruthy();
248+
expect(entry.tokens).toBeGreaterThanOrEqual(0);
249+
for (const attribute of entry.attributes ?? []) {
250+
expect(attribute.key.trim()).toBeTruthy();
251+
}
242252
}
243-
}
244253

245-
const heaviest = await session.rpc.metadata.getContextHeaviestMessages({ limit: 2 });
246-
expect(heaviest.totalTokens).toBeGreaterThan(0);
247-
expect(heaviest.messages.length).toBeLessThanOrEqual(2);
248-
for (const message of heaviest.messages) {
249-
expect(message.id.trim()).toBeTruthy();
250-
expect(message.tokens).toBeGreaterThanOrEqual(0);
254+
const heaviest = await session.rpc.metadata.getContextHeaviestMessages({
255+
limit: 2,
256+
});
257+
expect(heaviest.totalTokens).toBeGreaterThan(0);
258+
expect(heaviest.messages.length).toBeLessThanOrEqual(2);
259+
for (const message of heaviest.messages) {
260+
expect(message.id.trim()).toBeTruthy();
261+
expect(message.tokens).toBeGreaterThanOrEqual(0);
262+
}
263+
} finally {
264+
await session.disconnect();
251265
}
252-
} finally {
253-
await session.disconnect();
254266
}
255-
});
267+
);
256268

257269
it("should update and clear live subagent settings", { timeout: 120_000 }, async () => {
258270
const session = await createSession();

python/e2e/test_rpc_server_misc_e2e.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ async def test_should_get_set_and_clear_user_settings(self, ctx: E2ETestContext)
113113
finally:
114114
await _dispose_isolated(client, home)
115115

116-
async def test_should_login_list_get_current_auth_and_logout_account(
117-
self, ctx: E2ETestContext
118-
):
116+
async def test_should_login_list_get_current_auth_and_logout_account(self, ctx: E2ETestContext):
119117
login = f"rpc-account-{uuid.uuid4().hex}"
120118
token = f"rpc-account-token-{uuid.uuid4().hex}"
121119
await ctx.set_copilot_user_by_token(

0 commit comments

Comments
 (0)