mirror of
https://github.com/Mintplex-Labs/nut.js.git
synced 2026-07-19 22:15:20 -04:00
(#5) Export window API and added E2E test
This commit is contained in:
+19
-1
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
activeWindow,
|
||||
assert,
|
||||
Button,
|
||||
centerOf,
|
||||
@@ -10,7 +11,7 @@ import {
|
||||
right,
|
||||
screen,
|
||||
sleep,
|
||||
straightTo
|
||||
straightTo,
|
||||
} from "./index";
|
||||
|
||||
const openXfceMenu = async () => {
|
||||
@@ -97,3 +98,20 @@ describe("E2E mouse button demo", () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("E2E window demo", () => {
|
||||
it("should list gnome-calculator", async () => {
|
||||
jest.setTimeout(30000);
|
||||
screen.config.resourceDirectory = "./e2e/assets";
|
||||
await assert.isVisible("mouse.png");
|
||||
await assert.isVisible("desktop.png");
|
||||
await openXfceMenu();
|
||||
await run("uxterm");
|
||||
await sleep(1500);
|
||||
const foregroundWindow = await activeWindow();
|
||||
const windowTitle = await foregroundWindow.title;
|
||||
await close();
|
||||
|
||||
expect(windowTitle).toBe("uxterm")
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,6 +7,7 @@ import { Mouse } from "./lib/mouse.class";
|
||||
import { createMovementApi } from "./lib/movement.function";
|
||||
import { Screen } from "./lib/screen.class";
|
||||
import { LineHelper } from "./lib/util/linehelper.class";
|
||||
import { createWindowApi } from "./lib/window.function";
|
||||
|
||||
export { jestMatchers } from "./lib/expect/jest.matcher.function";
|
||||
export { sleep } from "./lib/sleep.function";
|
||||
@@ -19,6 +20,7 @@ export { OptionalSearchParameters } from "./lib/optionalsearchparameters.class";
|
||||
export { linear } from "./lib/movementtype.function";
|
||||
export { Point } from "./lib/point.class";
|
||||
export { Region } from "./lib/region.class";
|
||||
export { Window } from "./lib/window.class";
|
||||
|
||||
const screenActions = new VisionAdapter();
|
||||
const nativeActions = new NativeAdapter();
|
||||
@@ -31,6 +33,7 @@ const screen = new Screen(screenActions);
|
||||
const assert = new Assert(screen);
|
||||
|
||||
const {straightTo, up, down, left, right} = createMovementApi(nativeActions, lineHelper);
|
||||
const {windows, activeWindow } = createWindowApi(nativeActions);
|
||||
|
||||
export {
|
||||
clipboard,
|
||||
@@ -43,4 +46,6 @@ export {
|
||||
down,
|
||||
left,
|
||||
right,
|
||||
windows,
|
||||
activeWindow,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user