Skip to content

E2E Selenium Suite #82

@PhilipWoulfe

Description

@PhilipWoulfe

User Story #82: E2E Selenium Suite (The Safety Net)
The Goal

Provide the agent with a "Physical" verification layer. While API tests verify data, Selenium ensures the UI actually works for the end-user. For the agent, this suite acts as a pre-deployment gate: if the bot can’t successfully navigate the UI to submit a selection, the code is considered "broken" and won't reach production.
Acceptance Criteria

[ ] Environment Parity: The suite runs against the :test environment (after #80 CF Service Token is applied).

[ ] Atomic Test Cases: Individual C# test methods cover "Login," "Pick Driver," and "Submit Selection".

[ ] Integration Check: The suite uses the GET endpoint from #86 to verify the selection was recorded server-side after the UI click.

[ ] Agent-Ready Reporting: Test results are output in a standard .xml or .json format that the GC Agent (#81) can parse to decide on PR approval.

Implementation Details (C# Selenium)

  1. Page Object Model (POM)

For an agent, stability is key. Using the Page Object Model ensures that if you change a CSS class in the UI, you only update it in one place in the test code.
C#

public class SelectionPage {
private readonly IWebDriver _driver;
public SelectionPage(IWebDriver driver) => _driver = driver;

// Locators
private IWebElement DriverDropdown => _driver.FindElement(By.Id("driver-select"));
private IWebElement SubmitButton => _driver.FindElement(By.Id("submit-selection"));

public void SelectDriver(string driverId) {
    new SelectElement(DriverDropdown).SelectByValue(driverId);
}

public void ClickSubmit() => SubmitButton.Click();

}

  1. The Verification Loop

The agent shouldn't just trust the "Success" toast message. It should perform a "Double Check".

Step A: Use Selenium to click "Submit".

Step B: Wait 500ms for DB persistence.

Step C: Use HttpClient within the C# test to call GET /api/selections/current and assert the new selection exists in the returned JSON.

Why this is critical for the Agent

Visual Regression: Since the agent is autonomous, it won't "see" if a CSS update accidentally hides the submit button behind a footer. Selenium catches this.

End-to-End Proof: It proves the entire stack—Cloudflare Tunnel, UI, API, and Cosmos DB—are all talking to each other correctly.

Technical Risks

Flakiness (Timing): UI tests are notoriously "brittle." Use WebDriverWait (Explicit Waits) instead of Thread.Sleep to ensure the agent doesn't fail tests due to network lag.

Data Cleanup: The agent needs a way to "reset" its test user's selections so it can run the suite multiple times without hitting "Selection already exists" errors. We might need a "Delete" endpoint for the test user.

Shall we move to #83 (System Date Mocking), so the agent can actually test the "Lockout" logic within this Selenium suite?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions