-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🤖 Add cypress tests for web UI (#1269)
- Loading branch information
Showing
9 changed files
with
3,356 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
# Run agent in the background to bring the webui up | ||
/usr/bin/kairos-agent webui & | ||
|
||
pushd internal/webui/public || exit 1 | ||
# deps | ||
npm ci | ||
# cypress tests | ||
npx cypress run --e2e -q | ||
popd || exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: WebUI tests | ||
on: | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- '**' | ||
- '!docs/**' | ||
pull_request: | ||
paths: | ||
- '**' | ||
- '!docs/**' | ||
|
||
concurrency: | ||
group: ci-webui-${{ github.head_ref || github.ref }}-${{ github.repository }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
webui: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install earthly | ||
uses: Luet-lab/luet-install-action@v1 | ||
with: | ||
repository: quay.io/kairos/packages | ||
packages: utils/earthly | ||
- name: WebUI tests | ||
run: earthly +webui-tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const { defineConfig } = require("cypress"); | ||
|
||
module.exports = defineConfig({ | ||
e2e: { | ||
supportFile: false, | ||
baseUrl: "http://localhost:8080" | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
describe('Basic Tests for webui', () => { | ||
beforeEach(() => { | ||
cy.visit('/') | ||
cy.intercept({ | ||
method: 'POST', | ||
url: '/validate', | ||
}, {log: false}).as('validate') | ||
}) | ||
it("basic items on the ui exist", () => { | ||
cy.contains('#cloud-config').should("exist").should("be.visible") | ||
cy.contains('Welcome to the Installer!').should("exist").should("be.visible") | ||
cy.contains("p a", "cloud-config config configuration file") | ||
.should("have.attr", "href", "/local/docs/reference/configuration/") | ||
cy.get("#cloud-config-help a") | ||
.should("have.attr", "href", "/local/docs/examples/") | ||
cy.get("#installation-device").should("have.value", "auto") | ||
|
||
// footer | ||
cy.get("a .fa-github").should("exist").parent().should("have.attr", "href", "https://github.com/kairos-io/kairos") | ||
cy.get("a .fa-book").should("exist").parent().should("have.attr", "href", "https://kairos.io/docs") | ||
cy.get("#reboot-checkbox").should("exist").should("not.be.checked") | ||
cy.get("#poweroff-checkbox").should("exist").should("not.be.checked") | ||
cy.get("button").should("exist").invoke("text").should("equal", "Install") | ||
}) | ||
it('validation works', () => { | ||
cy.get('.CodeMirror') | ||
.first() | ||
.then((editor) => { | ||
editor[0].CodeMirror.setValue(''); | ||
}); | ||
|
||
cy.get(".CodeMirror textarea").type("#cloud-config{enter}users:{enter} - name: itxaka", {force: true}) | ||
cy.get("#validator-alert").should("have.text", "Valid YAML syntax") | ||
|
||
}) | ||
it('validation fails ', () => { | ||
cy.get('.CodeMirror') | ||
.first() | ||
.then((editor) => { | ||
editor[0].CodeMirror.setValue(''); | ||
}); | ||
cy.get(".CodeMirror textarea").type("blablabla", {force: true}) | ||
cy.get("#validator-alert").invoke("text").should("match", /Failed validating syntax/) | ||
|
||
}) | ||
it('should install', function () { | ||
cy.get("button").click() | ||
}); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.