Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions python/e2e/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from copilot import CopilotClient
from copilot.types import Tool

from .testharness import E2ETestContext, get_final_assistant_message, get_next_event_of_type
from .testharness import E2E_FAKE_GITHUB_TOKEN, E2ETestContext, get_final_assistant_message, get_next_event_of_type

pytestmark = pytest.mark.asyncio(loop_scope="module")

Expand Down Expand Up @@ -160,13 +160,12 @@ async def test_should_resume_a_session_using_a_new_client(self, ctx: E2ETestCont
assert "2" in answer.data.content

# Resume using a new client
github_token = "fake-token-for-e2e-tests" if os.environ.get("CI") == "true" else None
new_client = CopilotClient(
{
"cli_path": ctx.cli_path,
"cwd": ctx.work_dir,
"env": ctx.get_env(),
"github_token": github_token,
"github_token": E2E_FAKE_GITHUB_TOKEN,
}
)

Expand Down
3 changes: 2 additions & 1 deletion python/e2e/testharness/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"""Test harness for E2E tests."""

from .context import CLI_PATH, E2ETestContext
from .context import CLI_PATH, E2E_FAKE_GITHUB_TOKEN, E2ETestContext
from .helper import get_final_assistant_message, get_next_event_of_type
from .proxy import CapiProxy

__all__ = [
"CLI_PATH",
"E2E_FAKE_GITHUB_TOKEN",
"E2ETestContext",
"CapiProxy",
"get_final_assistant_message",
Expand Down
10 changes: 7 additions & 3 deletions python/e2e/testharness/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ def get_cli_path_for_tests() -> str:
CLI_PATH = get_cli_path_for_tests()
SNAPSHOTS_DIR = Path(__file__).parents[3] / "test" / "snapshots"

# E2E tests use a replaying proxy with canned responses, so real auth is
# never needed. Without a token the CLI looks for credentials under
# XDG_CONFIG_HOME, which points to an isolated temp dir and is therefore
# empty, causing a silent auth failure that makes tests hang.
E2E_FAKE_GITHUB_TOKEN = "fake-token-for-e2e-tests"


class E2ETestContext:
"""Holds shared resources for E2E tests."""
Expand All @@ -53,14 +59,12 @@ async def setup(self):
self.proxy_url = await self._proxy.start()

# Create the shared client (like Node.js/Go do)
# Use fake token in CI to allow cached responses without real auth
github_token = "fake-token-for-e2e-tests" if os.environ.get("CI") == "true" else None
self._client = CopilotClient(
{
"cli_path": self.cli_path,
"cwd": self.work_dir,
"env": self.get_env(),
"github_token": github_token,
"github_token": E2E_FAKE_GITHUB_TOKEN,
}
)

Expand Down
Loading