mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-07-21 06:02:04 -04:00
Improve Playwright/E2E testing setup (#5056)
Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
parent
01210ce88d
commit
3d9bbe1a62
6 changed files with 168 additions and 46 deletions
|
@ -246,6 +246,36 @@ let needSetup = false;
|
|||
log.debug("test", request.body);
|
||||
response.send("OK");
|
||||
});
|
||||
|
||||
const fs = require("fs");
|
||||
|
||||
app.get("/_e2e/take-sqlite-snapshot", async (request, response) => {
|
||||
await Database.close();
|
||||
try {
|
||||
fs.cpSync(Database.sqlitePath, `${Database.sqlitePath}.e2e-snapshot`);
|
||||
} catch (err) {
|
||||
throw new Error("Unable to copy SQLite DB.");
|
||||
}
|
||||
await Database.connect();
|
||||
|
||||
response.send("Snapshot taken.");
|
||||
});
|
||||
|
||||
app.get("/_e2e/restore-sqlite-snapshot", async (request, response) => {
|
||||
if (!fs.existsSync(`${Database.sqlitePath}.e2e-snapshot`)) {
|
||||
throw new Error("Snapshot doesn't exist.");
|
||||
}
|
||||
|
||||
await Database.close();
|
||||
try {
|
||||
fs.cpSync(`${Database.sqlitePath}.e2e-snapshot`, Database.sqlitePath);
|
||||
} catch (err) {
|
||||
throw new Error("Unable to copy snapshot file.");
|
||||
}
|
||||
await Database.connect();
|
||||
|
||||
response.send("Snapshot restored.");
|
||||
});
|
||||
}
|
||||
|
||||
// Robots.txt
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue