Skip to content

Commit c55ab52

Browse files
fix(dashboard): Let the snooze picker wait for a pull request's card
The snooze picker read a found pull request's draft state from its live card as soon as the row showed. Before the card arrived it said "not a draft", so a fast pick watched an open draft as a ready pull request. An open pull request row in the picker now waits for its card, as the `#` menu does. Co-Authored-By: BYK <[email protected]>
1 parent 40641d7 commit c55ab52

2 files changed

Lines changed: 44 additions & 1 deletion

File tree

‎packages/junior-dashboard/e2e/inbox/inbox-snoozes.spec.ts‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,45 @@ test.describe("new UI", { tag: "@new" }, () => {
539539
).toHaveCount(0);
540540
});
541541

542+
test("a found open pull request is picked only once its card says whether it is a draft", async ({
543+
dashboard,
544+
page,
545+
}) => {
546+
// Hold the live cards until the test lets them through.
547+
let release = () => {};
548+
const held = new Promise<void>((resolve) => {
549+
release = resolve;
550+
});
551+
await page.route(
552+
(url) => url.pathname === "/api/objects",
553+
async (route) => {
554+
await held;
555+
await route.continue();
556+
},
557+
);
558+
await mockInboxItems(page, { open: [license, rollout] });
559+
await page.goto(`${dashboard.baseURL}/inbox`);
560+
await expandRow(rowHead(page, checkout));
561+
await openRowOf(page).getByRole("button", { name: "Snooze" }).click();
562+
await page
563+
.getByRole("dialog", { name: "Snooze until" })
564+
.getByRole("button", { name: "Custom…" })
565+
.click();
566+
await customOf(page).getByRole("button", { name: "Add condition" }).click();
567+
await page
568+
.getByPlaceholder("Search pull requests or paste a link")
569+
.fill("reference chips");
570+
const found = page.getByRole("option", { name: /getsentry\/junior#3838/ });
571+
await expect(found).toHaveAttribute("aria-disabled", "true");
572+
573+
release();
574+
await expect(found).not.toHaveAttribute("aria-disabled", "true");
575+
await pickOption(found);
576+
await expect(
577+
customOf(page).getByRole("combobox", { name: "Event" }),
578+
).toBeVisible();
579+
});
580+
542581
test("a pull request row snoozes until an Event on its pull request or an issue that the viewer pastes", async ({
543582
dashboard,
544583
page,

‎packages/junior-dashboard/src/client/inbox/SnoozeDialog.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,9 @@ function WatchPicker(props: {
373373
{search.changes.length > 0 ? (
374374
<CommandGroup heading="Pull requests">
375375
{search.changes.map((change) => {
376+
const listed = listedOf(change.url);
376377
const reference: ComposerReference = {
377-
draft: listedDraft(listedOf(change.url)),
378+
draft: listedDraft(listed),
378379
kind: "code_change",
379380
number: change.number,
380381
repository: change.repository,
@@ -383,6 +384,9 @@ function WatchPicker(props: {
383384
};
384385
return (
385386
<CommandItem
387+
// An open change is saved with its draft state, so it
388+
// waits for its card.
389+
disabled={change.state === "open" && !listed.settled}
386390
key={change.url}
387391
onSelect={() =>
388392
props.onPick({ kind: "page", reference, url: change.url })

0 commit comments

Comments
 (0)