Skip to content

Commit 4637c60

Browse files
cameronhotchkiesGoose
andauthored
fix(desktop): stabilize flaky DM expansion E2E ordering assertions (#2004)
## Summary Fixes 4 flaky DM expansion E2E tests in Desktop Smoke shard 1 that were failing non-deterministically on CI (also reproducing on `main` at run `29526844596`). **Failing tests:** - `channels.spec.ts:652` — creates the DM before preparing a persona mention - `channels.spec.ts:760` — routes an agent mention from an existing DM to the expanded conversation - `channels.spec.ts:815` — routes a relay-agent mention from an existing DM to the expanded conversation - `channels.spec.ts:940` — drops an expanded DM after the first message fails ## Root Cause Race condition: under fast CI execution, mock command completions (create_managed_agent, open_dm) can resolve in non-deterministic order, causing assertions to observe stale or mid-transition state. ## Fix - **:652** — Move the `new-message-recipient-popover` hidden assertion after `chat-title` settles (both names present), so it runs post-transition rather than mid-transition. - **:760, :940** — Add `createManagedAgentDelayMs: 100` to ensure persona provisioning doesn't collapse into the same tick as the expanded-DM open/start sequence. - **:815** — Add `openDmDelayMs: 100` so the two open_dm calls resolve in deterministic order. ## Validation All 4 tests pass with `--repeat-each=3` (12/12 green) locally. Biome lint clean. ## Scope Test-only change: 12 insertions, 1 deletion in `desktop/tests/e2e/channels.spec.ts`. --- Investigated by Ferret, reviewed by Grumplestiltzkin. Signed-off-by: Cameron Hotchkies <[email protected]> Co-authored-by: Goose <[email protected]>
1 parent 122e060 commit 4637c60

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎desktop/tests/e2e/channels.spec.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,14 +712,16 @@ test("creates the DM before preparing a persona mention", async ({ page }) => {
712712
page.getByTestId(`new-dm-selected-${TEST_IDENTITIES.charlie.pubkey}`),
713713
).toBeDisabled();
714714
await expect(page.getByTestId("new-dm-search")).toBeDisabled();
715-
await expect(page.getByTestId("new-message-recipient-popover")).toBeHidden();
716715
await expect
717716
.poll(async () =>
718717
commandCount(await readCommandLog(page), "create_managed_agent"),
719718
)
720719
.toBeGreaterThan(baselineCreateCount);
721720
await expect(page.getByTestId("chat-title")).toContainText("charlie");
722721
await expect(page.getByTestId("chat-title")).toContainText("Fizz");
722+
// Assert popover hidden after chat-title settles — by this point the send
723+
// flow has completed and the UI has fully transitioned away from the popover.
724+
await expect(page.getByTestId("new-message-recipient-popover")).toBeHidden();
723725

724726
const sendCommands = (await readCommandLog(page)).slice(
725727
baselineCommands.length,
@@ -782,8 +784,11 @@ test("creates the DM before preparing a persona mention", async ({ page }) => {
782784
test("routes an agent mention from an existing DM to the expanded conversation", async ({
783785
page,
784786
}) => {
787+
// Delay persona provisioning so the follow-up expanded-DM open/start sequence
788+
// cannot collapse into the same fast CI tick before assertions observe it.
785789
await installMockBridge(page, {
786790
activePersonaIds: ["builtin:fizz"],
791+
createManagedAgentDelayMs: 100,
787792
});
788793
await page.goto("/");
789794

@@ -837,7 +842,10 @@ test("routes an agent mention from an existing DM to the expanded conversation",
837842
test("routes a managed relay-agent mention from an existing DM to the expanded conversation", async ({
838843
page,
839844
}) => {
845+
// Delay the expanded open_dm call so routing/navigation settles
846+
// deterministically under fast CI execution.
840847
await installMockBridge(page, {
848+
openDmDelayMs: 100,
841849
managedAgents: [
842850
{
843851
pubkey: DM_RELAY_AGENT_PUBKEY,
@@ -967,8 +975,11 @@ test("does not reroute an expanded DM after the channel pane unmounts", async ({
967975
test("drops an expanded DM after the first message fails", async ({ page }) => {
968976
const retryMessage = "Retry without the agent";
969977
const sendError = "Mock first DM send failed.";
978+
// Delay persona provisioning so the follow-up expanded-DM open/start sequence
979+
// cannot collapse into the same fast CI tick before assertions observe it.
970980
await installMockBridge(page, {
971981
activePersonaIds: ["builtin:fizz"],
982+
createManagedAgentDelayMs: 100,
972983
sendMessageErrors: [sendError],
973984
});
974985
await page.goto("/");

0 commit comments

Comments
 (0)