feat: polish workspace transfers and verify Craft server file workflows
This commit is contained in:
1 parent
7fd7ae6733
commit
c209f1effc
49 files changed
+1459
-670
No files matched your search
@@ -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;
|
||||
});
|
||||
Reference in new issue
Block a user