Project

General

Profile

Agama and Puppeteer Need To Know » History » Version 4

rainerkoenig, 2024-09-05 10:31
Updated new findings as of Septebmer 5, 2024

1 1 rainerkoenig
# Agama and Puppeteer Need To Know
2
3
## Basic ideas and concepts
4
- Agama should be tested by using the [Puppeteer](https://pptr.dev/) library instead of the Playwright framework
5
- Puppeteer is **JavaScript**
6
- Nevertheless we would like to use [TypeScript](https://www.typescriptlang.org/) for our tests, because TypeScript has the advantage of data types that can be checked
7
8 2 rainerkoenig
## Typescript to JavaScript conversion (outdated)
9
This is left here for tracking history, as of September 2024 and later move on to the next seection.
10
11 1 rainerkoenig
I watched [this video](https://www.youtube.com/watch?v=O6JNTocH0y0) which explains how we can convert TypeScript sources to JavaScript:
12
13
- `npx tsc` converts files to JavaScript.
14
- `npx tsc --watch` triggers the watch mode, so every time you modify a `*.ts` file it will be translated to JavaScript automatically.
15
16 3 rainerkoenig
## New GitHub repo using webpack
17
Agama development switched to a [new repository](https://github.com/jknphy/agama-integration-test-webpack/tree/main) where we make use of [webpack](https://webpack.js.org/). 
18
19
Webpack  bundles all the JavaScript modules so that at the end we just have one `default-installation.cjs` file to use and deploy if the test environement is on another machine.
20
21
**Caution**: The files with `.cjs` extension should not be held in the Git repository. I had troubles because my Pull Request had of course an updated `.cjs` file, but `git mergetool` was not able to open in a reasonable time. Besides that, what shall i merge here, this is like an object module that drops out of a build process, you won't put that into a git repo, would you?
22
23
To not get crazy about filenmae extension we needed to do slight configuration changes at the `tsconfig.json` file, thanks to Leo Manfredi for figuring this out. With this you have the big advantage, that you just need to write the imports in your TypeScript files without file extension. Example:
24
```
25
 // classes for Page Object Model
26
import { LoginAsRootPage } from "../pages/login-as-root-page";
27
import { ProductSelectionPage } from "../pages/product-selection-page";
28
```
29
30 4 rainerkoenig
## Testing on a virtual machine in the local environment
31 2 rainerkoenig
32 4 rainerkoenig
My tests were performed on `agama-installer.x86_64-9.0.0-openSUSE-Build11.9.iso`.
33 1 rainerkoenig
34 4 rainerkoenig
What you need to do when booting
35
- Edit the bootloader settings and append `live.password=nots3cr3t` to the kernel parameter line. If you want to avoid doing this on every boot, there is [a way to patch the ISO image with a custom password](https://github.com/openSUSE/agama/blob/f2f704e3fa3b6808275f30ec9d8a69ae781cab66/doc/live_iso.md#injecting-the-default-password-into-the-iso-image).
36 1 rainerkoenig
- After the machine is up switch to a virtual console and check the IP settings, in my case the IP of the VM was 192.168.0.50
37
38
Then switch to your local repo and use this commands:
39
```
40
export AGAMA_SERVER=http:/192.168.0.50  # or whatever your VM has as an IP
41
export AGAMA_HEADLESS=0 # so you see a browser window
42
43 4 rainerkoenig
$ node --test-timeout=60000 dist/default_installation.cjs
44 1 rainerkoenig
```
45
The last line starts the test script which is already installed and put into the `build` directory.
46
47
## My findings
48 4 rainerkoenig
Despite my first impression that Firefox does not work on Leap 15.6 for testing I have to say, that with the new approach Firefox seems to be the **only** Browser that works. I tried both ´Chrome` and `Chromium` and had problems, that in my local browser the test steps did not advance. With Firefox I was able to repeatedly perform a successful installation.
49 1 rainerkoenig
50
```
51 4 rainerkoenig
 node --test-timeout=60000 dist/default_installation.cjs 
52
▶ Agama test
53
  ✔ should have Agama page title (55.365252ms)
54
  ✔ allows logging in (13.519967ms)
55
  ✔ should optionally display the product selection dialog (26794.771274ms)
56
  ✔ should display overview section (61.994939ms)
57
  ✔ should display user dialog (215.073205ms)
58
  ✔ should enter root password dialog (286.97696ms)
59
  ✔ should set root password (627.430631ms)
60
  ✔ should switch to overview (349.829644ms)
61
  ✔ should be ready for installation (253.257252ms)
62
  ✔ can launch installation (203.614128ms)
63
  ✔ can confirm installation (226.882324ms)
64
  ✔ should start installation (532.787203ms)
65
  ✔ should finish installation (833424.512108ms)
66
▶ Agama test (868837.009718ms)
67
ℹ tests 13
68
ℹ suites 1
69
ℹ pass 13
70
ℹ fail 0
71
ℹ cancelled 0
72
ℹ skipped 0
73
ℹ todo 0
74
ℹ duration_ms 868847.424757
75 2 rainerkoenig
```