feat: polish workspace transfers and verify Craft server file workflows

This commit is contained in:
SantaSpeen committed 2026-10-24 02:01:28 +03:00
1 parent 7fd7ae6733
commit c209f1effc
49 files changed
+1459 -670

No files matched your search

+6 -46
View File
@@ -124,29 +124,8 @@ const { chromium } = require(process.env.PLAYWRIGHT_MODULE || "playwright");
await route.fulfill({ response });
});
await page.goto(base + "/settings/profile");
await page.getByLabel("3D preview quality").selectOption("half");
await page.getByLabel("Voxel memory limit").selectOption("512");
await page.getByLabel("Initial opacity").fill("50");
await Promise.all([
page.waitForResponse(
(r) => r.url().endsWith("/api/users/1") && r.status() === 200
),
page.getByRole("button", { name: "Save", exact: true }).click(),
]);
await page.reload();
await page.getByLabel("3D preview quality").waitFor();
if (
(await page.getByLabel("3D preview quality").inputValue()) !== "half" ||
(await page.getByLabel("Voxel memory limit").inputValue()) !== "512"
)
throw new Error("3D profile settings were not restored");
await page.getByLabel("3D preview quality").selectOption("auto");
await Promise.all([
page.waitForResponse(
(r) => r.url().endsWith("/api/users/1") && r.status() === 200
),
page.getByRole("button", { name: "Save", exact: true }).click(),
]);
if (await page.getByLabel("3D preview quality").count())
throw new Error("Disabled 3D settings are still visible");
await page.goto(base + "/files/series/scan_1.dcm");
await page.waitForFunction(
() =>
@@ -155,32 +134,13 @@ const { chromium } = require(process.env.PLAYWRIGHT_MODULE || "playwright");
null,
{ timeout: 20000 }
);
await page
.getByRole("button", { name: "Open as 3D (3)", exact: true })
.click();
await page
.locator(".dicom-volume-stage canvas")
.waitFor({ timeout: 20000 });
if (
(await page.locator('.dicom-volume input[type="range"]').inputValue()) !==
"0.5"
(await page.locator(".dicom-volume-stage").count()) ||
(await page.getByRole("button", { name: /Open as 3D/ }).count())
)
throw new Error("Viewer ignored profile opacity");
for (const label of ["Axial", "Sagittal", "Coronal", "3D"]) {
await page.getByRole("button", { name: label, exact: true }).click();
await page.waitForTimeout(150);
}
await page.getByRole("button", { name: "Back to 2D", exact: true }).click();
await page.waitForFunction(
() =>
!document.querySelector(".dicom-volume-stage") &&
document.querySelector(".dicom-viewer .document-stage canvas")
?.width === 2
);
throw new Error("3D must remain disabled");
if (errors.length) throw new Error(errors.join("\n"));
console.log(
"DICOM preview in embedded server: 2D, series offer, 3D, MPR and return to 2D passed"
);
console.log("DICOM preview: 2D passed; 3D is disabled");
} finally {
await browser.close();
server.close();
+156
View File
@@ -0,0 +1,156 @@
const fs = require("node:fs"),
path = require("node:path"),
{ pathToFileURL } = require("node:url");
const { chromium } = require(process.env.PLAYWRIGHT_MODULE);
(async () => {
const base = process.env.FILEBROWSER_QA_URL,
root = process.env.FILEBROWSER_QA_ROOT,
out = process.env.FILEBROWSER_QA_OUTPUT;
fs.mkdirSync(out, { recursive: true });
const { fixture } = await import(
pathToFileURL(
path.resolve(__dirname, "../src/utils/__tests__/fixtures/dicom.ts")
)
);
fs.writeFileSync(
path.join(root, "scan_1.dcm"),
Buffer.from(fixture(16, { slice: 0 }))
);
const browser = await chromium.launch({
executablePath: process.env.BROWSER_EXECUTABLE,
headless: true,
args: [
"--use-angle=swiftshader",
"--enable-unsafe-swiftshader",
"--autoplay-policy=no-user-gesture-required",
],
});
const results = [];
try {
for (const mobile of [false, true]) {
const context = await browser.newContext({
viewport: mobile
? { width: 390, height: 844 }
: { width: 1440, height: 1000 },
isMobile: mobile,
hasTouch: mobile,
acceptDownloads: true,
});
const page = await context.newPage();
let errors = [];
page.on("pageerror", (e) => errors.push(String(e)));
page.on("response", (r) => {
if (
r.status() >= 400 &&
new URL(r.url()).pathname.startsWith("/static/")
)
errors.push(`${r.status()} ${r.url()}`);
});
await page.goto(base + "/files/");
await page.waitForTimeout(1200);
await page.screenshot({
path: path.join(out, `${mobile ? "mobile" : "desktop"}-listing.png`),
fullPage: true,
});
for (const name of [
"image.png",
"image.jpg",
"image.gif",
"image.bmp",
"image.tiff",
"image.webp",
"image.svg",
"notes.txt",
"report.md",
"table.csv",
"data.json",
"config.xml",
"index.html",
"script.js",
"document.pdf",
"archive.zip",
"book.epub",
"sound.wav",
"scan_1.dcm",
"unsupported.bin",
]) {
errors = [];
await page.goto(base + "/files/" + encodeURIComponent(name));
await page.waitForTimeout(name.endsWith(".epub") ? 1800 : 800);
if (/^image\./.test(name)) {
await page.waitForFunction(
() =>
[...document.querySelectorAll("#previewer img")].some(
(i) => i.naturalWidth > 0
),
null,
{ timeout: 15000 }
);
}
const state = await page.evaluate(() => ({
overflow: document.documentElement.scrollWidth > innerWidth + 1,
text: document.body.innerText.slice(-500),
canvas: [...document.querySelectorAll("canvas")].map((c) => [
c.width,
c.height,
]),
images: [...document.querySelectorAll("#previewer img")].map((i) => [
i.naturalWidth,
i.naturalHeight,
]),
}));
const label =
(mobile ? "mobile" : "desktop") + "-" + name.replaceAll(".", "-");
await page.screenshot({
path: path.join(out, label + ".png"),
fullPage: true,
});
results.push({ mobile, name, ...state, errors: [...errors] });
fs.writeFileSync(
path.join(out, "results.json"),
JSON.stringify(results, null, 2)
);
}
for (const route of [
"/settings/profile",
"/settings/shares",
"/settings/global",
]) {
errors = [];
await page.goto(base + route);
await page.waitForTimeout(800);
await page.screenshot({
path: path.join(
out,
(mobile ? "mobile" : "desktop") +
route.replaceAll("/", "-") +
".png"
),
fullPage: true,
});
results.push({
mobile,
route,
overflow: await page.evaluate(
() => document.documentElement.scrollWidth > innerWidth + 1
),
errors: [...errors],
});
}
await context.close();
}
for (const r of results) {
if (r.overflow || r.errors?.length) throw Error(JSON.stringify(r));
}
console.log("QA completed", results.length);
fs.writeFileSync(
path.join(out, "results.json"),
JSON.stringify(results, null, 2)
);
} finally {
await browser.close();
}
})().catch((e) => {
console.error(e);
process.exitCode = 1;
});
+192
View File
@@ -0,0 +1,192 @@
const fs = require("node:fs"),
path = require("node:path"),
assert = require("node:assert/strict");
const { chromium } = require(process.env.PLAYWRIGHT_MODULE);
(async () => {
const base = process.env.FILEBROWSER_QA_URL,
root = process.env.FILEBROWSER_QA_ROOT,
out = process.env.FILEBROWSER_QA_OUTPUT;
fs.mkdirSync(out, { recursive: true });
const b = await chromium.launch({
executablePath: process.env.BROWSER_EXECUTABLE,
headless: true,
args: ["--use-angle=swiftshader", "--enable-unsafe-swiftshader"],
});
const result = [];
try {
const p = await b.newPage({ viewport: { width: 1440, height: 1000 } });
p.on("dialog", (d) => d.accept());
const request = async (method, url, data) => {
let r = await p.request.fetch(base + url, {
method,
data,
headers: { "X-FB-Request": "1" },
});
assert(
r.ok(),
method + " " + url + ":" + r.status() + " " + (await r.text())
);
return r;
};
await request("POST", "/api/resources/projects/");
await request("POST", "/api/resources/projects/test.txt", "Hello server");
await request(
"PATCH",
"/api/resources/projects/test.txt?action=copy&destination=%2Fprojects%2Fcopy.txt"
);
await request(
"PATCH",
"/api/resources/projects/copy.txt?action=rename&destination=%2Frenamed.txt"
);
await request("PUT", "/api/resources/renamed.txt", "Updated file");
assert.equal(
await (await request("GET", "/api/raw/renamed.txt")).text(),
"Updated file"
);
await request("DELETE", "/api/resources/renamed.txt");
assert(!fs.existsSync(path.join(root, "renamed.txt")));
result.push("create/upload/copy/move/update/download/delete");
await request("POST", "/api/share/notes.txt", { key: "qa-main" });
await request("POST", "/api/share/notes.txt", {
key: "qa-protected",
password: "test-password",
expires: "1",
unit: "hours",
});
let links = await (await request("GET", "/api/share/notes.txt")).json();
assert.equal(links.length, 2);
result.push("multiple shares, optional password and expiration");
await p.goto(base + "/files/");
let video = await p.evaluate(async () => {
const c = document.createElement("canvas");
c.width = 320;
c.height = 180;
let ctx = c.getContext("2d");
ctx.fillStyle = "#21334d";
ctx.fillRect(0, 0, 320, 180);
ctx.fillStyle = "white";
ctx.font = "22px sans-serif";
ctx.fillText("Video preview", 70, 90);
let rec = new MediaRecorder(c.captureStream(10), {
mimeType: "video/webm",
}),
chunks = [];
rec.ondataavailable = (e) => chunks.push(e.data);
let done = new Promise(
(resolve) =>
(rec.onstop = async () =>
resolve([...new Uint8Array(await new Blob(chunks).arrayBuffer())]))
);
rec.start();
await new Promise((r) => setTimeout(r, 1200));
rec.stop();
return done;
});
fs.writeFileSync(path.join(root, "movie.webm"), Buffer.from(video));
await p.route("**/api/tus/**", async (route) => {
if (route.request().method() === "PATCH")
await new Promise((r) => setTimeout(r, 1800));
await route.continue().catch(() => {});
});
let payload = Buffer.alloc(3 * 1024 * 1024, 65);
await p
.locator("#upload-input")
.setInputFiles({
name: "upload-check.txt",
mimeType: "text/plain",
buffer: payload,
});
await p.locator(".upload-files").waitFor();
await p.screenshot({ path: path.join(out, "desktop-upload.png") });
await p.locator(".transfer-header button").first().click();
await p.screenshot({ path: path.join(out, "desktop-upload-expanded.png") });
await p
.locator(".upload-files")
.waitFor({ state: "hidden", timeout: 30000 });
assert(
fs.readFileSync(path.join(root, "upload-check.txt")).equals(payload)
);
result.push("UI chunked upload and transfer panel");
await p
.locator("#upload-input")
.setInputFiles({
name: "cancel-check.txt",
mimeType: "text/plain",
buffer: payload,
});
await p.locator(".upload-files").waitFor();
await p.locator(".transfer-header button").last().click();
await p.locator(".upload-files").waitFor({ state: "hidden" });
await p.waitForTimeout(2300);
assert(!fs.existsSync(path.join(root, "cancel-check.txt")));
result.push("upload cancellation");
await p.unroute("**/api/tus/**");
for (let mobile of [false, true]) {
await p.setViewportSize(
mobile ? { width: 390, height: 844 } : { width: 1440, height: 1000 }
);
for (let route of [
"/files/",
"/files/movie.webm",
"/settings/profile",
"/settings/shares",
"/settings/global",
"/s/qa-main",
"/s/qa-protected",
]) {
await p.goto(base + route);
await p.waitForTimeout(650);
assert.equal(
await p.evaluate(
() => document.documentElement.scrollWidth > innerWidth + 1
),
false,
"overflow " + route
);
await p.screenshot({
path: path.join(
out,
(mobile ? "mobile" : "desktop") +
route.replaceAll("/", "-") +
".png"
),
fullPage: true,
});
}
await p.goto(base + "/settings/global");
await p.locator(".admin-users-tile").click();
await p.locator(".users-management").waitFor();
await p.screenshot({
path: path.join(out, (mobile ? "mobile" : "desktop") + "-users.png"),
fullPage: true,
});
await p.keyboard.press("Escape");
await p.goto(base + "/editor/wordcraft?path=%2Fdocument.docx");
await p.waitForTimeout(5000);
let f = p.frames().find((x) => x !== p.mainFrame());
await f
.locator("canvas")
.click({ position: { x: Math.min(mobile ? 190 : 550, 550), y: 350 } });
await p.keyboard.press("Control+o");
await p.locator(".server-picker").waitFor();
await p.locator(".server-picker li").first().waitFor();
await p.screenshot({
path: path.join(
out,
(mobile ? "mobile" : "desktop") + "-server-picker.png"
),
});
await p.locator(".picker-header button").click();
}
console.log(JSON.stringify(result));
fs.writeFileSync(
path.join(out, "functional.json"),
JSON.stringify(result, null, 2)
);
} finally {
await b.close();
}
})().catch((e) => {
console.error(e);
process.exitCode = 1;
});