diff --git a/desktop/tests/e2e/persistent-agent-audience.spec.ts b/desktop/tests/e2e/persistent-agent-audience.spec.ts index db7354873f..1b402c993c 100644 --- a/desktop/tests/e2e/persistent-agent-audience.spec.ts +++ b/desktop/tests/e2e/persistent-agent-audience.spec.ts @@ -534,7 +534,7 @@ test("primary+Shift+M favors the most recently mentioned eligible agent", async await expect(input).toHaveText("@Vogue draft text"); }); -test("the mention button opens settings and can undo an address", async ({ +test("the mention button preserves manual rementions after undo until explicitly readdressed", async ({ page, }) => { await installAudienceFixtures(page); @@ -601,9 +601,9 @@ test("the mention button opens settings and can undo an address", async ({ await expect( composer.getByRole("button", { name: "Mention someone" }), ).toBeVisible(); - await expect( - composer.getByTestId(`composer-address-lock-${AGENT_A}`), - ).toHaveCount(0); + const avatar = composer.getByTestId(`composer-address-lock-${AGENT_A}`); + // Observe the old address exit before testing the manual selection. + await expect(avatar).toHaveCount(0); // Clear through editor transactions before selecting a manual mention. await input.press("ControlOrMeta+A"); await input.press("Backspace"); @@ -615,19 +615,30 @@ test("the mention button opens settings and can undo an address", async ({ await expect(input).toHaveText("@Morgarita "); // Explicitly opting out keeps subsequent mentions manual. The old avatar's // exit animation must not be mistaken for a newly pinned recipient. - await expect( - composer.getByTestId(`composer-address-lock-${AGENT_A}`), - ).toHaveCount(0); + await expect(avatar).toHaveCount(0); await input.type("later"); await input.press("Enter"); await expect(input).toHaveText(""); await expect .poll(() => readOutgoingMentionPubkeys(page, "@Morgarita later")) - .toContain(AGENT_A); + .toEqual([AGENT_A]); await expect( composer.getByTestId(`composer-address-lock-${AGENT_A}`), ).toHaveCount(0); + + // Only the explicit automatic action reinstates the excluded address. + await automaticallyMention(composer, "Morgarita"); + await expect(avatar).toBeVisible(); + await input.type("explicit recovery"); + await input.press("Enter"); + await expect + .poll(() => + readOutgoingMentionPubkeys(page, "@Morgarita explicit recovery"), + ) + .toEqual([AGENT_A]); + await expect(input).toHaveText("@Morgarita "); + await expect(avatar).toBeVisible(); }); test("always-mentioned agents remain selected without replaying their animation while Enter-send resolves", async ({ diff --git a/desktop/tests/e2e/profile-custom-emoji-status.spec.ts b/desktop/tests/e2e/profile-custom-emoji-status.spec.ts index 26b8b8c3da..9cc9f53f82 100644 --- a/desktop/tests/e2e/profile-custom-emoji-status.spec.ts +++ b/desktop/tests/e2e/profile-custom-emoji-status.spec.ts @@ -196,18 +196,39 @@ test("set status dialog uses the desktop modal with shared status choices", asyn test("keeps an open status draft when the saved status expires", async ({ page, }) => { + await page.clock.install(); await page.goto("/"); await waitForMockGlobalKindSubscription(page, 30315); - const nowSeconds = Math.floor(Date.now() / 1_000); + const nowSeconds = await page.evaluate(() => Math.floor(Date.now() / 1_000)); await seedMockStatus(page, { text: "Original draft", emoji: "📝", - expiresAt: nowSeconds + 2, + // Stay below the 120-second status polling backstop so a refetch cannot + // hide the expired status in place of the expiration timer. + expiresAt: nowSeconds + 60, createdAt: nowSeconds, }); await page.getByTestId("profile-popover-set-status").click(); const dialog = page.getByTestId("set-status-dialog"); + await expect(dialog.getByTestId("set-status-input")).toHaveValue( + "Original draft", + ); + await expect(page.getByTestId("sidebar-profile-user-status")).toBeVisible(); + await expect(dialog.getByText("Quick statuses", { exact: true })).toHaveCount( + 0, + ); + await expect(dialog.getByTestId("set-status-clear")).toBeVisible(); await dialog.getByTestId("set-status-input").fill("Unsaved draft"); + await expect(dialog.getByLabel("Save status")).toBeEnabled(); + await expect(dialog.getByRole("alert")).toHaveCount(0); + + // Expire the saved status only after the open dialog has a live, dirty + // baseline. Pause one second before the deadline so incidental renders that + // also re-check expiry run while the status is still valid, then run only + // the final second on a paused clock: the expiration timer must hide it. + await page.clock.pauseAt((nowSeconds + 59) * 1_000); + await expect(page.getByTestId("sidebar-profile-user-status")).toBeVisible(); + await page.clock.runFor(1_500); await expect(page.getByTestId("sidebar-profile-user-status")).toHaveCount(0, { timeout: 5_000, });