Skip to content

Commit 0c5f777

Browse files
authored
Add simple testing and some small fixes (#215)
* Add simple testing and some small fixes - Debian is 12, value should be that even if the name is bookworm - Alpine is 3.21 both value and text was wrong - adds some classes to several divs and il/ul to make it more easy to identify them. Currently for testing but could be used for css as well - adds some basic testing with cypress Signed-off-by: Itxaka <itxaka@kairos.io> * Try to run the tests Signed-off-by: Itxaka <itxaka@kairos.io> * test Signed-off-by: Itxaka <itxaka@kairos.io> * Preload the aurora image so it doesnt time out starting the server Signed-off-by: Itxaka <itxaka@kairos.io> * Fix Signed-off-by: Itxaka <itxaka@kairos.io> * Add test for input values and fix input value Signed-off-by: Itxaka <itxaka@kairos.io> --------- Signed-off-by: Itxaka <itxaka@kairos.io>
1 parent 6cea100 commit 0c5f777

File tree

7 files changed

+2151
-20
lines changed

7 files changed

+2151
-20
lines changed

.github/workflows/tests.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,22 @@ jobs:
204204
KVM: true
205205
run: |
206206
export RAW_IMAGE=$(find $PWD/build -name *.raw)
207-
go run github.com/onsi/ginkgo/v2/ginkgo run --label-filter "raw-bootable" -v --fail-fast -r ./e2e
207+
go run github.com/onsi/ginkgo/v2/ginkgo run --label-filter "raw-bootable" -v --fail-fast -r ./e2e
208+
test-ui-builder:
209+
runs-on: ubuntu-latest
210+
needs: build-image
211+
steps:
212+
- name: Checkout code
213+
uses: actions/checkout@v4
214+
with:
215+
fetch-depth: 1
216+
- name: Set up Docker Buildx
217+
id: buildx
218+
uses: docker/setup-buildx-action@master
219+
- name: Preload the Aurora image
220+
run: docker pull quay.io/kairos/ci-temp-images:auroraboot-${{ github.sha }}
221+
- name: Cypress run
222+
uses: cypress-io/github-action@v6
223+
with:
224+
working-directory: e2e/web/
225+
start: docker run --rm -p 8080:8080 quay.io/kairos/ci-temp-images:auroraboot-${{ github.sha }} web > /dev/null 2>&1

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ examples/airgap/data
33
dist/
44
build/
55
coverage.out
6-
coverage.out.*
6+
coverage.out.*
7+
e2e/web/node_modules/
8+
e2e/web/cypress/screenshots/

e2e/web/cypress.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const { defineConfig } = require("cypress");
2+
3+
module.exports = defineConfig({
4+
e2e: {
5+
supportFile: false,
6+
baseUrl: "http://localhost:8080"
7+
},
8+
});

e2e/web/cypress/e2e/scpec.cy.js

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
describe('Basic Tests for webui', () => {
2+
beforeEach(() => {
3+
cy.visit('/')
4+
})
5+
const expectedText = [
6+
"Ubuntu 24.04 LTS",
7+
"Fedora 40",
8+
"Alpine 3.21",
9+
"Rocky Linux 9",
10+
"Debian 12 (Bookworm)",
11+
"AMD64",
12+
"ARM64",
13+
"Core",
14+
"Standard",
15+
"Welcome to the Kairos Factory",
16+
];
17+
18+
expectedText.forEach((text) => {
19+
it(`Checking that ${text} exists and is visible`, () => {
20+
cy.log(`Checking that ${text} exists and is visible`)
21+
cy.contains(text).should("exist").should("be.visible")
22+
});
23+
});
24+
25+
26+
const values = [
27+
"ubuntu:24.04",
28+
"fedora:40",
29+
"alpine:3.21",
30+
"rockylinux:9",
31+
"debian:12",
32+
]
33+
values.forEach((value) => {
34+
it(`Input with value ${value} exists`, () => {
35+
cy.get(`input[type="radio"][name="base_image"][value="${value}"]`, {timeout: 1000}).should("exist")
36+
});
37+
});
38+
39+
40+
it("base images has the proper sizes", () => {
41+
cy.get(".baseimage-list", { timeout: 1000 }).should("exist").should("be.visible")
42+
// Check the number of items in the list 6 flavors + byo
43+
cy.get(".baseimage-list").find("li").should("have.length", 7)
44+
})
45+
46+
it("arch has the proper sizes", () => {
47+
cy.get(".arch-list", { timeout: 1000 }).should("exist").should("be.visible")
48+
cy.get(".arch-list").find("li").should("have.length", 2)
49+
})
50+
51+
it("variant has the proper list sizes", () => {
52+
cy.get(".variant-list", { timeout: 1000 }).should("exist").should("be.visible")
53+
cy.get(".variant-list").find("li").should("have.length", 2)
54+
})
55+
56+
it("models for arm are disabled if we click on amd64 arch", () => {
57+
// Click on the AMD64 architecture
58+
cy.get('ul.arch-list li').contains('AMD64').click()
59+
cy.get("ul.model-list li").then(($lis) => {
60+
cy.wrap($lis).each(($li) => {
61+
cy.wrap($li).find("div.model-title").then(($div) => {
62+
if ($div.text().includes("Generic")) { // Generic is the only model that should be visible always
63+
} else {
64+
cy.wrap($li).should("have.css", "display", "none")
65+
};
66+
});
67+
});
68+
});
69+
});
70+
71+
it("models for arm are enabled if we click on arm64 arch", () => {
72+
// Click on the ARM64 architecture
73+
cy.get('ul.arch-list li').contains('ARM64').click()
74+
cy.get("ul.model-list li").then(($lis) => {
75+
cy.wrap($lis).each(($li) => {
76+
cy.wrap($li).find("div.model-title").then(($div) => {
77+
if ($div.text().includes("Generic")) { // Generic is the only model that should be visible always
78+
} else {
79+
cy.wrap($li).should("have.css", "display", "block")
80+
};
81+
});
82+
});
83+
});
84+
});
85+
})

0 commit comments

Comments
 (0)