Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions frontend/app/view/preview/preview-streaming.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2026, Command Line Inc.
// SPDX-License-Identifier: Apache-2.0

import { Provider, atom } from "jotai";
import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it, vi } from "vitest";
import { StreamingPreview } from "./preview-streaming";

vi.mock("@/util/endpoints", () => ({
getWebServerEndpoint: () => "http://wave.test",
}));

vi.mock("@/util/waveutil", () => ({
formatRemoteUri: (path: string, conn: string) => `wsh://${conn}${path}`,
}));

describe("StreamingPreview", () => {
it("renders PDFs with an object/embed viewer instead of an iframe", () => {
const model = {
refreshCallback: null,
refreshVersion: atom(0),
connection: atom("local"),
statFile: atom({
path: "/docs/guide.pdf",
mimetype: "application/pdf",
}),
};

const markup = renderToStaticMarkup(
<Provider>
<StreamingPreview model={model as any} parentRef={{ current: null }} />
</Provider>
);

expect(markup).toContain("<object");
expect(markup).toContain("<embed");
expect(markup).not.toContain("<iframe");
expect(markup).toContain("http://wave.test/wave/stream-file?path=wsh%3A%2F%2Flocal%2Fdocs%2Fguide.pdf");
});
});
6 changes: 4 additions & 2 deletions frontend/app/view/preview/preview-streaming.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025, Command Line Inc.
// Copyright 2026, Command Line Inc.
// SPDX-License-Identifier: Apache-2.0

import { Button } from "@/app/element/button";
Expand Down Expand Up @@ -65,7 +65,9 @@ function StreamingPreview({ model }: SpecializedViewProps) {
if (fileInfo.mimetype === "application/pdf") {
return (
<div className="flex flex-row h-full overflow-hidden items-center justify-center p-[5px]">
<iframe src={streamingUrl} width="100%" height="100%" name="pdfview" />
<object data={streamingUrl} type="application/pdf" width="100%" height="100%">
<embed src={streamingUrl} type="application/pdf" width="100%" height="100%" />
</object>
</div>
);
}
Expand Down