fix(orders): review modal preview review fixes (mixed tests, decorative chip comment)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
parent
32237f52c7
commit
f8784e3ba9
2 changed files with 97 additions and 1 deletions
|
|
@ -333,4 +333,97 @@ describe("OrdersReviewModal", () => {
|
|||
expect(screen.getByText(/no preview/i)).toBeInTheDocument();
|
||||
expect(screen.getByText("doc.docx")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("PDF wins over image when attachments are mixed [pdf, image]", () => {
|
||||
render(
|
||||
<OrdersReviewModal
|
||||
{...baseProps()}
|
||||
attachments={[
|
||||
{
|
||||
id: "att-pdf",
|
||||
created: "",
|
||||
updated: "",
|
||||
collectionId: "coll-1",
|
||||
collectionName: "quote_attachments",
|
||||
quote: "quote-1",
|
||||
filename: "Acme-RFQ.pdf",
|
||||
file: ["pdf-token"],
|
||||
content_type: "application/pdf",
|
||||
size_bytes: 1000,
|
||||
email_message_id: "",
|
||||
kind: "pdf",
|
||||
},
|
||||
{
|
||||
id: "att-img",
|
||||
created: "",
|
||||
updated: "",
|
||||
collectionId: "coll-1",
|
||||
collectionName: "quote_attachments",
|
||||
quote: "quote-1",
|
||||
filename: "site-photo.jpg",
|
||||
file: ["photo-token"],
|
||||
content_type: "image/jpeg",
|
||||
size_bytes: 1000,
|
||||
email_message_id: "",
|
||||
kind: "image",
|
||||
},
|
||||
]}
|
||||
/>,
|
||||
);
|
||||
const iframe = document.querySelector(
|
||||
'[data-testid="review-attachment-iframe"]',
|
||||
);
|
||||
expect(iframe).toBeInTheDocument();
|
||||
expect(iframe?.getAttribute("src")).toBe(
|
||||
"/api/v1/files/coll-1/att-pdf/pdf-token",
|
||||
);
|
||||
expect(document.querySelector('[data-testid="review-attachment-img"]')).toBeNull();
|
||||
});
|
||||
|
||||
it("image renders with a '+N unpreviewable' hint when mixed [image, doc]", () => {
|
||||
render(
|
||||
<OrdersReviewModal
|
||||
{...baseProps()}
|
||||
attachments={[
|
||||
{
|
||||
id: "att-img",
|
||||
created: "",
|
||||
updated: "",
|
||||
collectionId: "coll-1",
|
||||
collectionName: "quote_attachments",
|
||||
quote: "quote-1",
|
||||
filename: "site-photo.jpg",
|
||||
file: ["photo-token"],
|
||||
content_type: "image/jpeg",
|
||||
size_bytes: 1000,
|
||||
email_message_id: "",
|
||||
kind: "image",
|
||||
},
|
||||
{
|
||||
id: "att-doc",
|
||||
created: "",
|
||||
updated: "",
|
||||
collectionId: "coll-1",
|
||||
collectionName: "quote_attachments",
|
||||
quote: "quote-1",
|
||||
filename: "doc.docx",
|
||||
file: ["docx-token"],
|
||||
content_type:
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
size_bytes: 1000,
|
||||
email_message_id: "",
|
||||
kind: "doc",
|
||||
},
|
||||
]}
|
||||
/>,
|
||||
);
|
||||
const img = document.querySelector(
|
||||
'[data-testid="review-attachment-img"]',
|
||||
);
|
||||
expect(img).toBeInTheDocument();
|
||||
expect(img?.getAttribute("src")).toBe(
|
||||
"/api/v1/files/coll-1/att-img/photo-token",
|
||||
);
|
||||
expect(screen.getByText(/unpreviewable attachment/i)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -549,7 +549,10 @@ function SourceOfTruth({
|
|||
Attachments ({attachments.length})
|
||||
</div>
|
||||
|
||||
{/* Tab strip — one chip per attachment, primary chip = previewTarget */}
|
||||
{/* Tab strip — DECORATIVE in v1 (no click handler, no activeId state).
|
||||
Only the first previewable attachment (PDF > image) is rendered below;
|
||||
the chips are visual context. Future v2 could wire them with
|
||||
`useState<activeId>` inside `SourceOfTruth` to swap the preview. */}
|
||||
{attachments.length > 1 && (
|
||||
<div className="px-3 flex flex-wrap gap-1.5 border-b border-border/40 pb-2">
|
||||
{attachments.map((a) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue