test: confirm unassigned sends in classic attachment fixture

This commit is contained in:
cryppadotta committed 2026-10-13 05:33:09 +00:00
1 parent 67e1feee7a
commit f83f2f69a8
1 file changed
+17 -9
+17 -9
View File
@@ -80,6 +80,14 @@ async function setup(page: Page, request: APIRequestContext, classic: boolean) {
composer, composer,
editor, editor,
send, send,
sendComment: async () => {
await send.click();
if (classic) {
const confirm = page.getByTestId("issue-chat-no-assignee-send-anyway");
await expect(confirm).toBeVisible();
await confirm.click();
}
},
attachments: () => attachments: () =>
request request
.get(`/api/issues/${issue.id}/attachments`) .get(`/api/issues/${issue.id}/attachments`)
@@ -185,7 +193,7 @@ for (const classic of [false, true]) {
req.method() === "POST" && req.method() === "POST" &&
new URL(req.url()).pathname.endsWith("/comments"), new URL(req.url()).pathname.endsWith("/comments"),
); );
await fixture.send.click(); await fixture.sendComment();
expect((await outbound).postDataJSON().attachmentIds.sort()).toEqual( expect((await outbound).postDataJSON().attachmentIds.sort()).toEqual(
receipts.map((row) => row.id).sort(), receipts.map((row) => row.id).sort(),
); );
@@ -246,7 +254,7 @@ for (const classic of [false, true]) {
accepted = true; accepted = true;
await route.abort("connectionreset"); await route.abort("connectionreset");
}); });
await fixture.send.click(); await fixture.sendComment();
await expect.poll(() => accepted).toBe(true); await expect.poll(() => accepted).toBe(true);
expect(await fixture.comments()).toHaveLength(1); expect(await fixture.comments()).toHaveLength(1);
expect(acceptedRequestId).toEqual(expect.any(String)); expect(acceptedRequestId).toEqual(expect.any(String));
@@ -278,7 +286,7 @@ for (const classic of [false, true]) {
await fixture.editor.fill( await fixture.editor.fill(
"A deliberately new comment after the original receipt settled.", "A deliberately new comment after the original receipt settled.",
); );
await fixture.send.click(); await fixture.sendComment();
await expect.poll(async () => (await fixture.comments()).length).toBe(2); await expect.poll(async () => (await fixture.comments()).length).toBe(2);
}); });
@@ -300,14 +308,14 @@ for (const classic of [false, true]) {
body: JSON.stringify({ error: "Fixture policy rejected this attempt" }), body: JSON.stringify({ error: "Fixture policy rejected this attempt" }),
}); });
}); });
await fixture.send.click(); await fixture.sendComment();
await expect(fixture.editor).toContainText("Known rejection,"); await expect(fixture.editor).toContainText("Known rejection,");
await expect(fixture.send).toBeEnabled(); await expect(fixture.send).toBeEnabled();
expect(await fixture.comments()).toHaveLength(0); expect(await fixture.comments()).toHaveLength(0);
await page.reload(); await page.reload();
await expect(fixture.editor).toContainText("Known rejection,"); await expect(fixture.editor).toContainText("Known rejection,");
await expect(fixture.composer.getByRole("alert")).toHaveCount(0); await expect(fixture.composer.getByRole("alert")).toHaveCount(0);
await fixture.send.click(); await fixture.sendComment();
await expect.poll(async () => (await fixture.comments()).length).toBe(1); await expect.poll(async () => (await fixture.comments()).length).toBe(1);
expect( expect(
(await fixture.attachments()).find((row) => row.id === receipt.id) (await fixture.attachments()).find((row) => row.id === receipt.id)
@@ -341,7 +349,7 @@ for (const classic of [false, true]) {
await route.fulfill({ response }).catch(() => {}); await route.fulfill({ response }).catch(() => {});
}); });
try { try {
await fixture.send.click(); await fixture.sendComment();
await expect.poll(() => accepted).toBe(true); await expect.poll(() => accepted).toBe(true);
expect(await fixture.comments()).toHaveLength(1); expect(await fixture.comments()).toHaveLength(1);
await fixture.editor.fill("A newer draft written while delivery was pending."); await fixture.editor.fill("A newer draft written while delivery was pending.");
@@ -356,7 +364,7 @@ for (const classic of [false, true]) {
expect(await fixture.comments()).toHaveLength(1); expect(await fixture.comments()).toHaveLength(1);
expect(acceptedRequestId).toEqual(expect.any(String)); expect(acceptedRequestId).toEqual(expect.any(String));
expect((await fixture.comments())[0]!.clientRequestId).toBe(acceptedRequestId); expect((await fixture.comments())[0]!.clientRequestId).toBe(acceptedRequestId);
await fixture.send.click(); await fixture.sendComment();
await expect.poll(async () => (await fixture.comments()).length).toBe(2); await expect.poll(async () => (await fixture.comments()).length).toBe(2);
expect(attempts).toBe(2); expect(attempts).toBe(2);
expect((await fixture.comments()).map((comment) => comment.body).sort()).toEqual([ expect((await fixture.comments()).map((comment) => comment.body).sort()).toEqual([
@@ -414,7 +422,7 @@ for (const classic of [false, true])
req.method() === "POST" && req.method() === "POST" &&
new URL(req.url()).pathname.endsWith("/comments"), new URL(req.url()).pathname.endsWith("/comments"),
); );
await fixture.send.click(); await fixture.sendComment();
expect((await outbound).postDataJSON().attachmentIds).toBeUndefined(); expect((await outbound).postDataJSON().attachmentIds).toBeUndefined();
await expect.poll(async () => (await fixture.comments()).length).toBe(1); await expect.poll(async () => (await fixture.comments()).length).toBe(1);
expect((await fixture.comments())[0]!.body).not.toContain( expect((await fixture.comments())[0]!.body).not.toContain(
@@ -452,7 +460,7 @@ test("legacy failed upload can be removed before sending the retained text", asy
}); });
await expect(remove).toBeVisible(); await expect(remove).toBeVisible();
await remove.click(); await remove.click();
await fixture.send.click(); await fixture.sendComment();
await expect.poll(async () => (await fixture.comments()).length).toBe(1); await expect.poll(async () => (await fixture.comments()).length).toBe(1);
expect((await fixture.comments())[0]!.body).toBe( expect((await fixture.comments())[0]!.body).toBe(
"Keep this text after removing the failed file.", "Keep this text after removing the failed file.",