|
| 1 | +import { assert, Key, keyboard, Location, mouse, movement, screen } from "./index"; |
| 2 | + |
| 3 | +const openXfceMenu = async () => { |
| 4 | + const menu = await screen.find("menu.png"); |
| 5 | + await mouse.move(await movement.straightTo(Location.centerOf(menu))); |
| 6 | + await mouse.leftClick(); |
| 7 | + await mouse.leftClick(); |
| 8 | +}; |
| 9 | + |
| 10 | +const run = async (cmd: string) => { |
| 11 | + await keyboard.type(Key.LeftAlt, Key.F2); |
| 12 | + await keyboard.type(cmd); |
| 13 | + await keyboard.type(Key.Enter); |
| 14 | +}; |
| 15 | + |
| 16 | +const calculate = async () => { |
| 17 | + const plus = await screen.find("plus.png"); |
| 18 | + await mouse.move(await movement.straightTo(Location.centerOf(plus))); |
| 19 | + await mouse.leftClick(); |
| 20 | + const one = await screen.find("one.png"); |
| 21 | + await mouse.move(await movement.straightTo(Location.centerOf(one))); |
| 22 | + await mouse.leftClick(); |
| 23 | + const zero = await screen.find("zero.png"); |
| 24 | + await mouse.move(await movement.straightTo(Location.centerOf(zero))); |
| 25 | + await mouse.leftClick(); |
| 26 | + await mouse.leftClick(); |
| 27 | + await keyboard.type(Key.Enter); |
| 28 | +}; |
| 29 | + |
| 30 | +const close = async () => { |
| 31 | + const x = await screen.find("close.png"); |
| 32 | + await mouse.move(await movement.straightTo(Location.centerOf(x))); |
| 33 | + await mouse.leftClick(); |
| 34 | +}; |
| 35 | + |
| 36 | +describe("E2E demo", () => { |
| 37 | + it("should run without throwing", async () => { |
| 38 | + jest.setTimeout(30000); |
| 39 | + screen.config.resourceDirectory = "./e2e/assets"; |
| 40 | + await assert.isVisible("mouse.png"); |
| 41 | + await assert.isVisible("desktop.png"); |
| 42 | + await openXfceMenu(); |
| 43 | + await run("gnome-calculator"); |
| 44 | + await assert.isVisible("calculator.png"); |
| 45 | + await keyboard.type("525"); |
| 46 | + await calculate(); |
| 47 | + await assert.isVisible("result.png"); |
| 48 | + await close(); |
| 49 | + }); |
| 50 | +}); |
0 commit comments