Agama and Puppeteer Need To Know » History » Revision 3
Revision 2 (rainerkoenig, 2024-09-05 10:05) → Revision 3/4 (rainerkoenig, 2024-09-05 10:15)
# Agama and Puppeteer Need To Know
## Basic ideas and concepts
- Agama should be tested by using the [Puppeteer](https://pptr.dev/) library instead of the Playwright framework
- Puppeteer is **JavaScript**
- 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
## Typescript to JavaScript conversion (outdated)
This is left here for tracking history, as of September 2024 and later move on to the next seection.
I watched [this video](https://www.youtube.com/watch?v=O6JNTocH0y0) which explains how we can convert TypeScript sources to JavaScript:
- `npx tsc` converts files to JavaScript.
- `npx tsc --watch` triggers the watch mode, so every time you modify a `*.ts` file it will be translated to JavaScript automatically.
## New GitHub repo using webpack
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/).
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.
**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?
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:
```
// classes for Page Object Model
import { LoginAsRootPage } from "../pages/login-as-root-page";
import { ProductSelectionPage } from "../pages/product-selection-page";
```
## The first test runs
To try this out (as of August 23, 2024) I cloned [Joaquin's repo on GitHub](https://github.com/jknphy/agama-puppeteer) to my local machine running Leap 15.6.
The installation test was performed on a VM using the `agama-installer.x86_64-9.0.0-openSUSE-Build11.9.iso` image. What you need to do when booting this:
- Edit the bootloader settings and append `live.password=nots3cr3t` to the kernel parameter line
- 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
Then switch to your local repo and use this commands:
```
export AGAMA_SERVER=http:/192.168.0.50 # or whatever your VM has as an IP
export AGAMA_HEADLESS=0 # so you see a browser window
./agama-integration-tests build/test_install.js
```
The last line starts the test script which is already installed and put into the `build` directory.
## My findings
- On **Leap 15.6** we get failures when using Firefox (which is the default browser defined in the code). So I need to switch by setting `export AGAMA_BROWSER=chromium` (or chrome).
- Running in Chroimium or Chrome on Leap 15.6 looks a bit better, but I stil got failures. Digging into this revealed that the problem were my language settings which caused some parts of the Agama UI to be translated. To solve this I had to set `export LANG=en_US.utf8`.
- With those settings I am able to almost pass the test:
```
Agama test
✔ should have Agama page title
✔ allows logging in
✔ should optionally display the product selection dialog (30760ms)
✔ should have an Overview section
✔ should allow setting the root password
✔ should be ready for installation
✔ should create first user
1) should start installation
7 passing (34s)
1 failing
1) Agama test
should start installation:
AssertionError: expected 'Configuring the product, please wait …' to deeply equal 'Installing the system, please wait ...'
+ expected - actual
-Configuring the product, please wait ...
+Installing the system, please wait ...
at Context.<anonymous> (tests/test_install.ts:237:45)
```
The interesting part is that the installation in this case is really triggered, you can see it in the UI of the Agama VM. So this seems to be just a minor issue.
So my next attempt was using my **Tumbleweed* VM which I first updated. Then cloning my repo to the VM and putting the settings for `AGAMA_SERVER` and `AGAMA_HEADLESS`.
In this configiruation I was able to perform a full installation using Firefox. It was not completely reproducible, some attempts also resulted in errors, but some runs really performed the install.