Skip to content
This repository was archived by the owner on Mar 17, 2024. It is now read-only.

Commit e96a7df

Browse files
authored
Feature/3/update to latest interface (#4)
* (#3) Adjust to latest interface * (#3) Mock jimp package * (#3) Use npm pack result in e2e test to avoid wrong module resolution * (#3) Run pretest setup before Docker e2e tests * (#3) Run pretest setup before Docker e2e tests * (#3) Change working directory instead of using --prefix on npm to avoid path errors on install * (#3) Use dedicated install script for flexible installation * (#3) Limit Docker tests to e2e tests * (#3) Run install in build script * (#3) Use npm cit on build script * (#3) Revert using npm cit * (#3) Disable Docker E2E tests until problems have been resolved * (#3) Refined E2E setup * (#3) Fixed tests * (#3) Refined result image * (#3) Removed screen tests from plugin
1 parent e07dd8c commit e96a7df

34 files changed

+1535
-5967
lines changed

.build/build.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,9 @@ echo "Installing node version $nodeVersion"
2323
nvm install $nodeVersion
2424

2525
npm ci
26-
npm --prefix e2e/plugin-test ci
26+
npm run pretest
27+
pushd e2e/plugin-test
28+
npm ci
29+
node install.js
30+
popd
2731
E2E_TEST=1 npm test

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
strategy:
3838
matrix:
3939
os: [ ubuntu-latest, windows-latest, macos-latest ]
40-
node: [ 12, 14, 16 ]
40+
node: [ 14, 16 ]
4141
exclude:
4242
- os: ubuntu-latest
4343
node: 14
@@ -53,7 +53,7 @@ jobs:
5353
if: ${{matrix.os == 'ubuntu-latest'}}
5454
run: |
5555
docker pull s1hofmann/nut-ci:latest
56-
docker run -it -d --name nut-ci --shm-size 8gb --user $(id -u):$(id -g) -v ${PWD}:${PWD}:rw s1hofmann/nut-ci:latest bash
56+
docker run -it -d --name nut-ci --shm-size 8gb -e VNC_COL_DEPT=32 --user $(id -u):$(id -g) -v ${PWD}:${PWD}:rw s1hofmann/nut-ci:latest bash
5757
- name: Install
5858
run: npm ci
5959
- name: Compile

.github/workflows/snapshot_release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
matrix:
1414
os: [ ubuntu-latest, windows-latest, macos-latest ]
15-
node: [ 12, 14, 16 ]
15+
node: [ 16 ]
1616
runs-on: ${{matrix.os}}
1717
steps:
1818
- name: Set up Git repository
@@ -48,7 +48,7 @@ jobs:
4848
- name: Set up node
4949
uses: actions/setup-node@v2
5050
with:
51-
node-version: 14
51+
node-version: 16
5252
registry-url: 'https://registry.npmjs.org'
5353
- name: Install
5454
run: npm ci

.github/workflows/tagged_release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
matrix:
1111
os: [ ubuntu-latest, windows-latest, macos-latest ]
12-
node: [ 12, 14, 16 ]
12+
node: [ 16 ]
1313
runs-on: ${{matrix.os}}
1414
steps:
1515
- name: Set up Git repository
@@ -45,7 +45,7 @@ jobs:
4545
- name: Set up node
4646
uses: actions/setup-node@v2
4747
with:
48-
node-version: 14
48+
node-version: 16
4949
registry-url: 'https://registry.npmjs.org'
5050
- name: Install
5151
run: npm ci

e2e/assets/desktop.png

-2.45 KB
Loading

e2e/assets/equals.png

8 Bytes
Loading

e2e/assets/menu.png

191 Bytes
Loading

e2e/assets/moved_trash.png

1.13 KB
Loading

e2e/assets/one.png

-25 Bytes
Loading

e2e/assets/plus.png

-4 Bytes
Loading

e2e/assets/result.png

724 Bytes
Loading

e2e/assets/zero.png

5 Bytes
Loading

e2e/plugin-test/index.e2e.spec.ts

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,88 @@
11
import {
2-
assert,
3-
centerOf,
4-
down,
5-
Key,
6-
keyboard,
7-
mouse,
8-
Region,
9-
right,
10-
screen,
11-
sleep,
12-
straightTo,
2+
assert,
3+
centerOf,
4+
down, imageResource,
5+
Key,
6+
keyboard,
7+
mouse,
8+
Region,
9+
right,
10+
screen,
11+
sleep,
12+
straightTo,
1313
} from "@nut-tree/nut-js";
1414

1515
import "@nut-tree/template-matcher";
1616

1717
jest.setTimeout(60000);
1818

1919
const openXfceMenu = async () => {
20-
await mouse.move(straightTo(centerOf(screen.find("menu.png"))));
21-
await mouse.leftClick();
22-
await mouse.leftClick();
20+
await mouse.move(straightTo(centerOf(screen.find(imageResource("menu.png")))));
21+
await mouse.leftClick();
22+
await mouse.leftClick();
2323
};
2424

2525
const run = async (cmd: string) => {
26-
await keyboard.type(Key.LeftAlt, Key.F2);
27-
await keyboard.type(cmd);
28-
await keyboard.type(Key.Enter);
26+
await keyboard.type(Key.LeftAlt, Key.F2);
27+
await keyboard.type(cmd);
28+
await keyboard.type(Key.Enter);
2929
};
3030

3131
const calculate = async () => {
32-
await mouse.move(straightTo(centerOf(screen.find("plus.png"))));
33-
await mouse.leftClick();
34-
await mouse.move(straightTo(centerOf(screen.find("one.png"))));
35-
await mouse.leftClick();
36-
await mouse.move(straightTo(centerOf(screen.find("zero.png"))));
37-
await mouse.leftClick();
38-
await mouse.leftClick();
39-
await mouse.move(straightTo(centerOf(screen.find("equals.png"))));
40-
await mouse.leftClick();
32+
await mouse.move(straightTo(centerOf(screen.find(imageResource("plus.png")))));
33+
await mouse.leftClick();
34+
await mouse.move(straightTo(centerOf(screen.find(imageResource("one.png")))));
35+
await mouse.leftClick();
36+
await mouse.move(straightTo(centerOf(screen.find(imageResource("zero.png")))));
37+
await mouse.leftClick();
38+
await mouse.leftClick();
39+
await mouse.move(straightTo(centerOf(screen.find(imageResource("equals.png")))));
40+
await mouse.leftClick();
4141
};
4242

4343
const close = async () => {
44-
await mouse.move(straightTo(centerOf(screen.find("close.png"))));
45-
await mouse.leftClick();
44+
await mouse.move(straightTo(centerOf(screen.find(imageResource("close.png")))));
45+
await mouse.leftClick();
4646
};
4747

4848
describe("E2E tests", () => {
49-
afterEach(async () => {
50-
await keyboard.type(Key.LeftControl, Key.LeftAlt, Key.Left);
51-
});
49+
afterEach(async () => {
50+
await keyboard.type(Key.LeftControl, Key.LeftAlt, Key.Left);
51+
});
5252

53-
it("should throw on invalid images", async () => {
54-
await expect(screen.find("mouse.png")).rejects.toContain("Failed to load image");
55-
});
53+
it("should throw on invalid images", async () => {
54+
await expect(screen.find(imageResource("mouse.png"))).rejects.toContain("Failed to load image");
55+
});
5656

57-
it("should perform some calculations", async () => {
58-
screen.config.resourceDirectory = "./e2e/assets";
59-
await assert.isVisible("mouse.png");
60-
await assert.isVisible("desktop.png");
61-
await openXfceMenu();
62-
await run("gnome-calculator");
63-
await sleep(1500);
64-
await assert.isVisible("calculator.png");
65-
await keyboard.type("525");
66-
await calculate();
67-
await screen.waitFor("result.png");
68-
await close();
69-
});
57+
it("should perform some calculations", async () => {
58+
screen.config.resourceDirectory = "./e2e/assets";
59+
await assert.isVisible(imageResource("mouse.png"));
60+
await assert.isVisible(imageResource("desktop.png"));
61+
await openXfceMenu();
62+
await run("gnome-calculator");
63+
await sleep(1500);
64+
await assert.isVisible(imageResource("calculator.png"));
65+
await keyboard.type("525");
66+
await calculate();
67+
await screen.waitFor(imageResource("result.png"));
68+
await close();
69+
});
7070

71-
it("drag & drop", async () => {
72-
screen.config.resourceDirectory = "./e2e/assets";
71+
it("drag & drop", async () => {
72+
screen.config.resourceDirectory = "./e2e/assets";
7373

74-
const expected = new Region(38, 585, 70, 86);
75-
const maxDiff = 1;
74+
const expected = new Region(34, 574, 75, 107);
75+
const maxDiff = 1;
7676

77-
await assert.isVisible("trash.png");
78-
await mouse.move(straightTo(centerOf(screen.find("trash.png"))));
79-
await mouse.drag(down(500));
80-
await mouse.move(right(100));
81-
await mouse.leftClick();
82-
const dest = await screen.waitFor("moved_trash.png");
83-
expect(Math.abs(dest.left - expected.left)).toBeLessThanOrEqual(maxDiff);
84-
expect(Math.abs(dest.top - expected.top)).toBeLessThanOrEqual(maxDiff);
85-
expect(Math.abs(dest.width - expected.width)).toBeLessThanOrEqual(maxDiff);
86-
expect(Math.abs(dest.height - expected.height)).toBeLessThanOrEqual(maxDiff);
87-
});
77+
await assert.isVisible(imageResource("trash.png"));
78+
await mouse.move(straightTo(centerOf(screen.find(imageResource("trash.png")))));
79+
await mouse.drag(down(500));
80+
await mouse.move(right(100));
81+
await mouse.leftClick();
82+
const dest = await screen.waitFor(imageResource("moved_trash.png"));
83+
expect(Math.abs(dest.left - expected.left)).toBeLessThanOrEqual(maxDiff);
84+
expect(Math.abs(dest.top - expected.top)).toBeLessThanOrEqual(maxDiff);
85+
expect(Math.abs(dest.width - expected.width)).toBeLessThanOrEqual(maxDiff);
86+
expect(Math.abs(dest.height - expected.height)).toBeLessThanOrEqual(maxDiff);
87+
});
8888
});

e2e/plugin-test/install.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const parentPackageJson = require("../../package.json");
2+
const {execSync} = require("child_process");
3+
const {join} = require("path");
4+
5+
const version = parentPackageJson.version;
6+
const packageName = parentPackageJson.name.replace("@", "").replace("\/", "-");
7+
const fullPackageName = `${packageName}-${version}.tgz`;
8+
const packagePath = join(__dirname, "..", "..", fullPackageName);
9+
10+
execSync(`npm i --no-save ${packagePath}`);

0 commit comments

Comments
 (0)