2022-12-21 12:06:13 -05:00
|
|
|
import child_process from "child_process";
|
|
|
|
import fs from "fs";
|
|
|
|
|
|
|
|
// screenshot
|
|
|
|
|
2024-04-15 13:43:08 -07:00
|
|
|
function screenshotWarcExists(name) {
|
|
|
|
const warcList = fs.readdirSync(`test-crawls/collections/${name}/archive/`);
|
|
|
|
|
|
|
|
for (const warc of warcList) {
|
|
|
|
if (warc.startsWith("screenshots-")) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-12-21 12:06:13 -05:00
|
|
|
test("ensure basic crawl run with --screenshot passes", async () => {
|
2023-11-09 19:11:11 -05:00
|
|
|
child_process.execSync(
|
2024-04-15 13:43:08 -07:00
|
|
|
"docker run -v $PWD/test-crawls:/crawls webrecorder/browsertrix-crawler crawl --collection test-with-screenshots --url http://www.example.com/ --screenshot view --workers 2",
|
2023-11-09 19:11:11 -05:00
|
|
|
);
|
2022-12-21 12:06:13 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test("check that a screenshots warc file exists in the test collection", () => {
|
2024-04-15 13:43:08 -07:00
|
|
|
expect(screenshotWarcExists("test-with-screenshots")).toBe(true);
|
2022-12-21 12:06:13 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
// fullPageScreenshot
|
|
|
|
|
|
|
|
test("ensure basic crawl run with --fullPageScreenshot passes", async () => {
|
2023-11-09 19:11:11 -05:00
|
|
|
child_process.execSync(
|
|
|
|
"docker run -v $PWD/test-crawls:/crawls webrecorder/browsertrix-crawler crawl --collection fullpage --url http://www.example.com/ --screenshot fullPage --workers 2",
|
|
|
|
);
|
2022-12-21 12:06:13 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test("check that a screenshots warc file exists in the fullpage collection", () => {
|
2024-04-15 13:43:08 -07:00
|
|
|
expect(screenshotWarcExists("fullpage")).toBe(true);
|
2022-12-21 12:06:13 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
// thumbnail
|
|
|
|
|
|
|
|
test("ensure basic crawl run with --thumbnail passes", async () => {
|
2023-11-09 19:11:11 -05:00
|
|
|
child_process.execSync(
|
|
|
|
"docker run -v $PWD/test-crawls:/crawls webrecorder/browsertrix-crawler crawl --collection thumbnail --url http://www.example.com/ --screenshot thumbnail --workers 2",
|
|
|
|
);
|
2022-12-21 12:06:13 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test("check that a screenshots warc file exists in the thumbnail collection", () => {
|
2024-04-15 13:43:08 -07:00
|
|
|
expect(screenshotWarcExists("thumbnail")).toBe(true);
|
2022-12-21 12:06:13 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
// combination
|
|
|
|
|
|
|
|
test("ensure basic crawl run with multiple screenshot types and --generateWACZ passes", async () => {
|
2023-11-09 19:11:11 -05:00
|
|
|
child_process.execSync(
|
|
|
|
"docker run -v $PWD/test-crawls:/crawls webrecorder/browsertrix-crawler crawl --collection combined --url http://www.example.com/ --screenshot thumbnail,view,fullPage --generateWACZ --workers 2",
|
|
|
|
);
|
2022-12-21 12:06:13 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test("check that a screenshots warc file exists in the combined collection", () => {
|
2024-04-15 13:43:08 -07:00
|
|
|
expect(screenshotWarcExists("combined")).toBe(true);
|
2022-12-21 12:06:13 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test("check that a wacz file exists in the combined collection", () => {
|
2023-11-09 19:11:11 -05:00
|
|
|
const waczExists = fs.existsSync(
|
|
|
|
"test-crawls/collections/combined/combined.wacz",
|
|
|
|
);
|
2022-12-21 12:06:13 -05:00
|
|
|
expect(waczExists).toBe(true);
|
|
|
|
});
|