Skip to content

Commit 0d580ad

Browse files
committed
fix tests
1 parent 9b7af0a commit 0d580ad

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

frontend/src/utils/__tests__/download.test.tsx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ describe("getImageDataUrlForCell", () => {
166166
);
167167
});
168168

169-
it("should add printing classes before capture when enablePrintMode is true", async () => {
169+
it("should add printing classes before capture when snappy is false", async () => {
170170
vi.mocked(toPng).mockImplementation(async () => {
171171
// Check classes are applied during capture
172172
expect(mockElement.classList.contains("printing-output")).toBe(true);
@@ -175,36 +175,36 @@ describe("getImageDataUrlForCell", () => {
175175
return mockDataUrl;
176176
});
177177

178-
await getImageDataUrlForCell("cell-1" as CellId, true);
178+
await getImageDataUrlForCell("cell-1" as CellId, false);
179179
});
180180

181-
it("should remove printing classes after capture when enablePrintMode is true", async () => {
181+
it("should remove printing classes after capture when snappy is false", async () => {
182182
vi.mocked(toPng).mockResolvedValue(mockDataUrl);
183183

184-
await getImageDataUrlForCell("cell-1" as CellId, true);
184+
await getImageDataUrlForCell("cell-1" as CellId, false);
185185

186186
expect(mockElement.classList.contains("printing-output")).toBe(false);
187187
expect(document.body.classList.contains("printing")).toBe(false);
188188
});
189189

190-
it("should add printing-output but NOT body.printing when enablePrintMode is false", async () => {
190+
it("should add printing-output but NOT body.printing when snappy is true", async () => {
191191
vi.mocked(toPng).mockImplementation(async () => {
192192
// printing-output should still be added to the element
193193
expect(mockElement.classList.contains("printing-output")).toBe(true);
194-
// but body.printing should NOT be added
194+
// but body.printing should NOT be added when snappy mode is on
195195
expect(document.body.classList.contains("printing")).toBe(false);
196196
expect(mockElement.style.overflow).toBe("auto");
197197
return mockDataUrl;
198198
});
199199

200-
await getImageDataUrlForCell("cell-1" as CellId, false);
200+
await getImageDataUrlForCell("cell-1" as CellId, true);
201201
});
202202

203-
it("should cleanup printing-output when enablePrintMode is false", async () => {
203+
it("should cleanup printing-output when snappy is true", async () => {
204204
mockElement.style.overflow = "hidden";
205205
vi.mocked(toPng).mockResolvedValue(mockDataUrl);
206206

207-
await getImageDataUrlForCell("cell-1" as CellId, false);
207+
await getImageDataUrlForCell("cell-1" as CellId, true);
208208

209209
expect(mockElement.classList.contains("printing-output")).toBe(false);
210210
expect(document.body.classList.contains("printing")).toBe(false);
@@ -239,7 +239,7 @@ describe("getImageDataUrlForCell", () => {
239239
expect(mockElement.style.overflow).toBe("scroll");
240240
});
241241

242-
it("should maintain body.printing during concurrent captures when enablePrintMode is true", async () => {
242+
it("should maintain body.printing during concurrent captures when snappy is false", async () => {
243243
// Create a second element
244244
const mockElement2 = document.createElement("div");
245245
mockElement2.id = CellOutputId.create("cell-2" as CellId);
@@ -273,9 +273,9 @@ describe("getImageDataUrlForCell", () => {
273273
return mockDataUrl;
274274
});
275275

276-
// Start both captures concurrently with enablePrintMode = true
277-
const capture1 = getImageDataUrlForCell("cell-1" as CellId, true);
278-
const capture2 = getImageDataUrlForCell("cell-2" as CellId, true);
276+
// Start both captures concurrently with snappy = false (body.printing should be added)
277+
const capture1 = getImageDataUrlForCell("cell-1" as CellId, false);
278+
const capture2 = getImageDataUrlForCell("cell-2" as CellId, false);
279279

280280
// Let second capture complete first
281281
resolveSecond!();
@@ -297,21 +297,21 @@ describe("getImageDataUrlForCell", () => {
297297
mockElement2.remove();
298298
});
299299

300-
it("should not interfere with body.printing during concurrent captures when enablePrintMode is false", async () => {
300+
it("should not interfere with body.printing during concurrent captures when snappy is true", async () => {
301301
// Create a second element
302302
const mockElement2 = document.createElement("div");
303303
mockElement2.id = CellOutputId.create("cell-2" as CellId);
304304
document.body.append(mockElement2);
305305

306306
vi.mocked(toPng).mockImplementation(async () => {
307-
// body.printing should never be added when enablePrintMode is false
307+
// body.printing should never be added when snappy is true
308308
expect(document.body.classList.contains("printing")).toBe(false);
309309
return mockDataUrl;
310310
});
311311

312-
// Start both captures concurrently with enablePrintMode = false
313-
const capture1 = getImageDataUrlForCell("cell-1" as CellId, false);
314-
const capture2 = getImageDataUrlForCell("cell-2" as CellId, false);
312+
// Start both captures concurrently with snappy = true (body.printing should NOT be added)
313+
const capture1 = getImageDataUrlForCell("cell-1" as CellId, true);
314+
const capture2 = getImageDataUrlForCell("cell-2" as CellId, true);
315315

316316
await Promise.all([capture1, capture2]);
317317

0 commit comments

Comments
 (0)