Refine archive preview and PDF defaults

This commit is contained in:
kl
2026-04-13 20:54:27 +08:00
parent b246bfdac7
commit 7757729efd
8 changed files with 1019 additions and 84 deletions

View File

@@ -26,10 +26,38 @@ public class PdfViewerCompatibilityTests {
assertTrue(workerScript.contains("import \"../web/compatibility.mjs\";"));
}
@Test
void shouldOpenPdfPreviewWithThumbnailSidebarByDefault() throws IOException {
String pdfTemplate = readWebResource("/web/pdf.ftl");
assertTrue(pdfTemplate.contains("#page=1&pagemode=thumbs"));
}
@Test
void shouldPreferPdfForOfficePreviewByDefault() throws IOException {
String properties = readConfigResource("/application.properties");
assertTrue(properties.contains("office.preview.type = ${KK_OFFICE_PREVIEW_TYPE:pdf}"));
}
private String readResource(String resourcePath) throws IOException {
try (InputStream inputStream = getClass().getResourceAsStream(resourcePath)) {
assertNotNull(inputStream);
return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
}
}
private String readWebResource(String resourcePath) throws IOException {
try (InputStream inputStream = getClass().getResourceAsStream(resourcePath)) {
assertNotNull(inputStream);
return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
}
}
private String readConfigResource(String resourcePath) throws IOException {
try (InputStream inputStream = getClass().getResourceAsStream(resourcePath)) {
assertNotNull(inputStream);
return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
}
}
}