Skip to content

Conversation

@aseemxs
Copy link
Contributor

@aseemxs aseemxs commented Dec 17, 2025

Problem

Two unit tests were flaky, timing out after 30 seconds in CI but passing locally:

  • recommendationHandler - "should call telemetry function that records a CodeWhisperer service invocation"
  • editorContext - "Should return expected fields for optOut, nextToken and reference config"

Root cause: buildListRecommendationRequest() calls getWorkspaceId() which executes vscode.commands.executeCommand('aws.amazonq.getWorkspaceId'). This
command may not be registered in the test environment, causing an indefinite hang.

Solution

Mock vscode.commands.executeCommand to return { workspaces: [] } in the affected tests, preventing the hang while still testing the actual logic.

Also extracted duplicate mockServerResult to a helper function to satisfy the duplicate code checker.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  • Treat all work as PUBLIC. Private feature/x branches will not be squash-merged at release time.
  • Your code changes must meet the guidelines in CONTRIBUTING.md.
  • License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

Adding console.log timestamps to identify where tests hang in CI.
Tests: recommendationHandler and editorContext

This is a temporary debug commit - DO NOT MERGE
@aseemxs aseemxs requested a review from a team as a code owner December 17, 2025 23:57
@aseemxs aseemxs closed this Dec 18, 2025
@aseemxs aseemxs reopened this Dec 18, 2025
@aseemxs aseemxs changed the title debug: add logging to investigate flaky tests test(amazonq): add logging to investigate flaky tests Dec 18, 2025
@aseemxs aseemxs closed this Dec 18, 2025
@aseemxs aseemxs reopened this Dec 18, 2025
@aseemxs aseemxs closed this Dec 18, 2025
@aseemxs aseemxs reopened this Dec 18, 2025
The tests were hanging because buildListRecommendationRequest() calls
getWorkspaceId() which executes 'aws.amazonq.getWorkspaceId' command.
This command may not be registered in the test environment, causing
an indefinite hang.

Fix: Mock vscode.commands.executeCommand to return empty workspaces,
preventing the hang while still testing the actual logic.

Root cause identified via debug logging in CI.
@aseemxs aseemxs changed the title test(amazonq): add logging to investigate flaky tests fix(amazonq): mock vscode.commands.executeCommand to fix flaky tests Dec 23, 2025
@github-actions
Copy link

  • This pull request implements a feat or fix, so it must include a changelog entry (unless the fix is for an unreleased feature). Review the changelog guidelines.
    • Note: beta or "experiment" features that have active users should announce fixes in the changelog.
    • If this is not a feature or fix, use an appropriate type from the title guidelines. For example, telemetry-only changes should use the telemetry type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant