Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

24 changes: 0 additions & 24 deletions .eslintrc.cjs

This file was deleted.

10 changes: 5 additions & 5 deletions .github/workflows/manual-test-matrix-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- name: "Setup NodeJS"
uses: actions/setup-node@v4
with:
node-version: "16"
node-version: "22"
- name: "Setup JDK"
uses: actions/setup-java@v4
with:
Expand All @@ -71,7 +71,7 @@ jobs:
- name: "Run compile"
run: "npm run compile"
- name: "Run test(s)"
run: "cd packages/testsuite && npm test -- --browser=firefox --specs=cypress/e2e/${{ matrix.specs }}"
run: "npm run test:compiled -- --browser=firefox --specs=packages/testsuite/cypress/e2e/${{ matrix.specs }}"
- name: "Archive test report(s) and video(s)"
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
Expand All @@ -91,13 +91,13 @@ jobs:
- name: "Setup NodeJS"
uses: actions/setup-node@v4
with:
node-version: "16"
node-version: "22"
- name: "Install necessary tools"
run: npm install -g copyfiles gh-pages@3.0.0 mochawesome-merge mochawesome-report-generator
- name: "Generate Mochawesome Report"
run: mochawesome-merge "./*-artifacts/results/cypress/e2e/*.json" > mochawesome.json
run: mochawesome-merge "./*-artifacts/results/packages/testsuite/cypress/e2e/*.json" > mochawesome.json
- name: "Copy video assets"
run: copyfiles -u 3 "./*-artifacts/cypress/videos/*.mp4" mochawesome-report/assets/videos
run: copyfiles -u 3 "./*-artifacts/packages/testsuite/cypress/videos/*.mp4" mochawesome-report/assets/videos
- name: "Create GH Pages content"
run: marge mochawesome.json -f index.html
- name: "Get time info"
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/on-pull-request-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: "Setup NodeJS"
uses: actions/setup-node@v4
with:
node-version: "16"
node-version: "22"
- name: "Setup JDK"
uses: actions/setup-java@v4
with:
Expand All @@ -36,6 +36,5 @@ jobs:
- name: "Run tests of modified files"
if: steps.changed-files-specific.outputs.any_changed == 'true'
run: |
cd packages/testsuite
SPECS=$(echo ${{ steps.changed-files-specific.outputs.all_changed_files }} | sed "s|packages/testsuite/||g")
KEYCLOAK_IMAGE=quay.io/keycloak/keycloak:24.0 npm run test-compiled -- --browser=chrome --specs=$SPECS
SPECS="${{ steps.changed-files-specific.outputs.all_changed_files }}"
KEYCLOAK_IMAGE=quay.io/keycloak/keycloak:24.0 npm run test -- --browser=chrome --specs=$SPECS
6 changes: 3 additions & 3 deletions .github/workflows/reusable-build-project-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: "Setup NodeJS"
uses: actions/setup-node@v4
with:
node-version: "16"
node-version: "22"
- name: "Setup JDK"
uses: actions/setup-java@v4
with:
Expand All @@ -36,7 +36,7 @@ jobs:
run: "npm run compile"
- name: "Run all tests"
if: "${{ github.event.inputs.spec == '' }}"
run: "cd packages/testsuite && npm test"
run: "npm run test:compiled"
- name: "Run specific test"
if: "${{ github.event.inputs.spec != '' }}"
run: "cd packages/testsuite && npm test -- --specs=${{ inputs.spec }}"
run: "npm run test:compiled -- --specs=${{ inputs.spec }}"
10 changes: 5 additions & 5 deletions .github/workflows/scheduled-run-all-tests-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- name: "Setup NodeJS"
uses: actions/setup-node@v4
with:
node-version: "16"
node-version: "22"
- name: "Setup JDK"
uses: actions/setup-java@v4
with:
Expand All @@ -71,7 +71,7 @@ jobs:
- name: "Run compile"
run: "npm run compile"
- name: "Run test(s)"
run: "cd packages/testsuite && npm test -- --browser=chrome --specs=cypress/e2e/${{ matrix.specs }}/*.cy.ts"
run: "npm run test:compiled -- --browser=chrome --specs=packages/testsuite/cypress/e2e/${{ matrix.specs }}/*.cy.ts"
- name: "Archive test report(s) and video(s)"
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
Expand All @@ -91,13 +91,13 @@ jobs:
- name: "Setup NodeJS"
uses: actions/setup-node@v4
with:
node-version: "16"
node-version: "22"
- name: "Install necessary tools"
run: npm install -g copyfiles gh-pages@3.0.0 mochawesome-merge mochawesome-report-generator
- name: "Generate Mochawesome Report"
run: mochawesome-merge "./*-artifacts/results/cypress/e2e/*.json" > mochawesome.json
run: mochawesome-merge "./*-artifacts/results/packages/testsuite/cypress/e2e/*.json" > mochawesome.json
- name: "Copy video assets"
run: copyfiles -u 3 "./*-artifacts/cypress/videos/*.mp4" mochawesome-report/assets/videos
run: copyfiles -u 3 "./*-artifacts/packages/testsuite/cypress/videos/*.mp4" mochawesome-report/assets/videos
- name: "Create GH Pages content"
run: marge mochawesome.json -f index.html
- name: "Get time info"
Expand Down
40 changes: 27 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,33 @@ in the root directory to download all of the NPM dependencies specified in `pack
npm run develop
```

- If you want to execute whole testsuite, navigate to `packages/testsuite` and from within that directory execute `npm test`
- It is also possible to run on specific browser by supplying `--browser` argument, e.g
```
npm test -- --browser=chrome
```
- It is also possible to reduce the amount of specs executed by passing `--specs` flag. This flag must be relative to the `packages/testsuite` directory and supports glob patterns, e.g to execute only `ejb` related tests, run
```
npm test -- --specs="cypress/e2e/ejb/*.cy.ts"
```
- If you wish to run the test suite against custom HAL or WildFly images, you can use `HAL_IMAGE` and `WILDFLY_IMAGE` environment variables to specify custom images, e.g
```
HAL_IMAGE=quay.io/myorg/hal WILDFLY_IMAGE=quay.io/myorg/wildfly npm test ...
```
- If you want to execute whole testsuite execute `npm test`

- It is also possible to run on specific browser by supplying `--browser` argument, e.g

```
npm test -- --browser=chrome
```

- It is possible to reduce the amount of specs executed by passing `--specs` flag. It also supports glob patterns, e.g to execute only `homepage` related tests, run

```
npm test -- --specs="packages/testsuite/cypress/e2e/homepage/test-homepage.cy.ts"
or
npm test -- --specs="packages/testsuite/cypress/e2e/homepage/*.cy.ts"
```

- If you want to run tests without cleaning and a resources compilations (useful for CI), use

```
npm run test:compiled -- --specs="packages/testsuite/cypress/e2e/homepage/test-homepage.cy.ts"
```

- If you wish to run the test suite against custom HAL or WildFly images, you can use `HAL_IMAGE` and `WILDFLY_IMAGE` environment variables to specify custom images, e.g

```
HAL_IMAGE=quay.io/myorg/hal WILDFLY_IMAGE=quay.io/myorg/wildfly npm test ...
```

- For debugging purposes videos (and screenshots) of failed tests are stored after the test run (works only with chrome).

Expand Down
48 changes: 25 additions & 23 deletions packages/testsuite/cypress.config.ts → cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from "cypress";
import { PullPolicy, GenericContainer, StartedTestContainer, StoppedTestContainer, Wait } from "testcontainers";
import { Environment } from "testcontainers/build/types";
import { findAPortNotInUse } from "portscanner";
import fs from "fs";
import * as fs from "fs";

export default defineConfig({
defaultCommandTimeout: 16000,
Expand All @@ -14,6 +14,8 @@ export default defineConfig({
video: true,
videoCompression: false,
e2e: {
supportFile: "packages/testsuite/cypress/support/e2e.ts",
specPattern: "packages/testsuite/cypress/e2e/**/*.cy.ts",
setupNodeEvents(on, config) {
const startedContainers: Map<string, StartedTestContainer> = new Map<string, StartedTestContainer>();
const startedContainersManagementPorts: Map<string, number> = new Map<string, number>();
Expand All @@ -22,13 +24,13 @@ export default defineConfig({
return new Promise((resolve, reject) => {
let portOffset = 0;
const wildfly = new GenericContainer(
process.env.WILDFLY_IMAGE || "quay.io/halconsole/wildfly-development:latest"
process.env.WILDFLY_IMAGE || "quay.io/halconsole/wildfly-development:latest",
)
.withPullPolicy(PullPolicy.alwaysPull())
.withName(name as string)
.withCopyDirectoriesToContainer([
{
source: __dirname + "/cypress/fixtures",
source: __dirname + "/packages/testsuite/cypress/fixtures",
target: "/home/fixtures",
mode: parseInt("0777", 8),
},
Expand Down Expand Up @@ -121,7 +123,7 @@ export default defineConfig({
const interval = setInterval(() => {
if (new Date().getTime() - startTime > 10000) {
clearInterval(interval);
reject();
reject(new Error("Timeout waiting for WildFly to start"));
}
axios
.post(managementApi, {
Expand All @@ -143,9 +145,9 @@ export default defineConfig({
});
}
})
.catch((err) => {
.catch((err: unknown) => {
console.log(err);
reject(err);
reject(err instanceof Error ? err : new Error(JSON.stringify(err)));
});
});
},
Expand All @@ -161,7 +163,7 @@ export default defineConfig({
})
.withBindMounts([
{
source: __dirname + "/cypress/fixtures/realm-configuration.json",
source: __dirname + "/packages/testsuite/cypress/fixtures/realm-configuration.json",
target: "/opt/keycloak/data/import/realm-configuration.json",
mode: "z",
},
Expand All @@ -181,9 +183,9 @@ export default defineConfig({
console.log(`Keycloak is ready: ${keycloakServer}`);
resolve(keycloakServer);
})
.catch((err) => {
.catch((err: unknown) => {
console.log(err);
reject(err);
reject(err instanceof Error ? err : new Error(JSON.stringify(err)));
});
});
});
Expand All @@ -195,7 +197,7 @@ export default defineConfig({
.withNetworkAliases(name as string)
.withNetworkMode(config.env.NETWORK_NAME as string)
.withWaitStrategy(
Wait.forLogMessage(new RegExp(".*PostgreSQL init process complete; ready for start up.*"))
Wait.forLogMessage(new RegExp(".*PostgreSQL init process complete; ready for start up.*")),
)
.withExposedPorts(5432)
.withEnvironment(environmentProperties as Environment);
Expand All @@ -207,9 +209,9 @@ export default defineConfig({
startedContainers.set("postgres", postgreContainer);
resolve(postgreContainer);
})
.catch((err) => {
.catch((err: unknown) => {
console.log(err);
reject(err);
reject(err instanceof Error ? err : new Error(JSON.stringify(err)));
});
});
},
Expand All @@ -230,9 +232,9 @@ export default defineConfig({
startedContainers.set("mysql", mysqlContainer);
resolve(mysqlContainer);
})
.catch((err) => {
.catch((err: unknown) => {
console.log(err);
reject(err);
reject(err instanceof Error ? err : new Error(JSON.stringify(err)));
});
});
},
Expand All @@ -253,15 +255,15 @@ export default defineConfig({
startedContainers.set("mariadb", mariadbContainer);
resolve(mariadbContainer);
})
.catch((err) => {
.catch((err: unknown) => {
console.log(err);
reject(err);
reject(err instanceof Error ? err : new Error(JSON.stringify(err)));
});
});
},
"start:sqlserver:container": ({ name, environmentProperties }) => {
const sqlserverContainerBuilder = new GenericContainer(
process.env.MSSQL_IMAGE || "mcr.microsoft.com/mssql/server:2022-latest"
process.env.MSSQL_IMAGE || "mcr.microsoft.com/mssql/server:2022-latest",
)
.withPullPolicy(PullPolicy.alwaysPull())
.withName(name as string)
Expand All @@ -278,9 +280,9 @@ export default defineConfig({
startedContainers.set("sqlserver", sqlServerContainer);
resolve(sqlServerContainer);
})
.catch((err) => {
.catch((err: unknown) => {
console.log(err);
reject(err);
reject(err instanceof Error ? err : new Error(JSON.stringify(err)));
});
});
},
Expand All @@ -292,7 +294,7 @@ export default defineConfig({
managementPort = managementPort ?? 9990;
containerToExec
?.exec([
"/bin/bash",
"/bin/sh",
"-c",
`$JBOSS_HOME/bin/jboss-cli.sh --connect --controller=localhost:${managementPort} --commands=${
command as string
Expand All @@ -303,10 +305,10 @@ export default defineConfig({
resolve(value);
} else {
console.log(value);
reject(value);
reject(new Error(`Command failed with exit code ${value.exitCode}: ${value.output || ""}`));
}
})
.catch((err: { response: { data: string } }) => reject(err.response.data));
.catch((err: { response: { data: string } }) => reject(new Error(err.response.data)));
});
},
"execute:cli": ({ managementApi, operation, address, ...args }) => {
Expand All @@ -321,7 +323,7 @@ export default defineConfig({
resolve(response.data);
})
.catch((err: { response: { data: string } }) => {
reject(err.response.data);
reject(new Error(err.response.data));
});
}).catch((error) => {
console.log(error);
Expand Down
31 changes: 31 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import eslintConfigPrettier from "eslint-config-prettier";

export default [
{
ignores: ["**/dist/**", "**/node_modules/**", "eslint.config.mjs"],
},
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
eslintConfigPrettier,
{
languageOptions: {
parserOptions: {
projectService: {
allowDefaultProject: ["cypress.config.ts"],
},
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
"@typescript-eslint/no-floating-promises": [
"error",
{
ignoreIIFE: true,
},
],
"@typescript-eslint/no-namespace": "off",
},
},
];
Loading
Loading