desktop: take app screenshot if test fails

This commit is contained in:
Abdullah Atta
2024-11-19 11:55:37 +05:00
parent ac659b05e4
commit daa60939c3
4 changed files with 45 additions and 12 deletions

View File

@@ -79,6 +79,14 @@ jobs:
EXECUTABLE_PATH=output/mac/Notesnook.app/Contents/MacOS/Notesnook npm run test EXECUTABLE_PATH=output/mac/Notesnook.app/Contents/MacOS/Notesnook npm run test
working-directory: ./apps/desktop working-directory: ./apps/desktop
- name: Upload test results
uses: actions/upload-artifact@v4
if: failure()
with:
name: test-results-macos
path: apps/desktop/test-results
retention-days: 5
test-linux: test-linux:
name: Test for Linux name: Test for Linux
needs: build needs: build

View File

@@ -20,21 +20,34 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import test from "node:test"; import test from "node:test";
import { launchApp } from "./utils.mjs"; import { launchApp } from "./utils.mjs";
import assert from "assert"; import assert from "assert";
import slugify from "slugify";
import path from "path";
import { mkdir } from "fs/promises";
test("make sure app loads", async () => { test("make sure app loads", async (t) => {
const { app, page } = await launchApp(); const { app, page } = await launchApp();
try {
await page.waitForSelector("#authForm");
await page.waitForSelector("#authForm"); assert.ok(
await page.getByRole("button", { name: "Create account" }).isVisible()
);
assert.ok( await page
await page.getByRole("button", { name: "Create account" }).isVisible() .getByRole("button", { name: "Skip & go directly to the app" })
); .click();
await page await page.waitForSelector(".ProseMirror");
.getByRole("button", { name: "Skip & go directly to the app" }) } catch (e) {
.click(); await mkdir("test-results", { recursive: true });
await page.screenshot({
await page.waitForSelector(".ProseMirror"); path: path.join(
"test-results",
await app.close(); `${slugify(t.name)}-${process.platform}-${process.arch}-error.png`
)
});
throw e;
} finally {
await app.close();
}
}); });

View File

@@ -35,6 +35,7 @@
"node-gyp-build": "^4.8.2", "node-gyp-build": "^4.8.2",
"playwright": "^1.48.2", "playwright": "^1.48.2",
"prebuildify": "^6.0.1", "prebuildify": "^6.0.1",
"slugify": "^1.6.6",
"tree-kill": "^1.2.2", "tree-kill": "^1.2.2",
"undici": "^6.19.8", "undici": "^6.19.8",
"vitest": "^2.1.5" "vitest": "^2.1.5"
@@ -6324,6 +6325,16 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/slugify": {
"version": "1.6.6",
"resolved": "https://registry.npmjs.org/slugify/-/slugify-1.6.6.tgz",
"integrity": "sha512-h+z7HKHYXj6wJU+AnS/+IH8Uh9fdcX1Lrhg1/VMdf9PwoBQXFcXiAdsy2tSK0P6gKwJLXp02r90ahUCqHk9rrw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/smart-buffer": { "node_modules/smart-buffer": {
"version": "4.2.0", "version": "4.2.0",
"resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz",

View File

@@ -50,6 +50,7 @@
"node-gyp-build": "^4.8.2", "node-gyp-build": "^4.8.2",
"playwright": "^1.48.2", "playwright": "^1.48.2",
"prebuildify": "^6.0.1", "prebuildify": "^6.0.1",
"slugify": "^1.6.6",
"tree-kill": "^1.2.2", "tree-kill": "^1.2.2",
"undici": "^6.19.8", "undici": "^6.19.8",
"vitest": "^2.1.5" "vitest": "^2.1.5"