Skip to content

Commit 4b69299

Browse files
sshvetasjd78
andcommitted
🧪 First PR to move UI tests (konveyor#2656)
Resolves: konveyor#2668 Setup workspace `cypress` that will hold all of the e2e cypress tests. The baseline login test is included to make sure everything runs properly. Some libraries in use have been updated. Related change: To make sure jest, currently only used by the client workspace, does not conflict with cypress, the jest devDependencies were moved to `client/pacakge.json`. ## Summary by CodeRabbit * **New Features** * Added end-to-end Cypress framework: initial login test, test helpers, UI selectors, custom commands, reporters, and utilities for downloads and tagging. * **Documentation** * Added comprehensive Cypress README and an example environment file. * **Chores** * CI change-detection updated to include Cypress files. * Added Cypress workspace, scripts, lint/format configs and tooling. * Husky install now skips in CI/production. * VCS and formatting ignores updated; testing deps added to client. --------- Signed-off-by: Shveta Sachdeva <[email protected]> Signed-off-by: Scott J Dickerson <[email protected]> Co-authored-by: Scott J Dickerson <[email protected]>
1 parent 57c930e commit 4b69299

File tree

20 files changed

+17470
-8180
lines changed

20 files changed

+17470
-8180
lines changed

.github/workflows/ci-repo.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,21 @@ jobs:
3737
builder=$(grep 'as builder' Dockerfile | sed -e 's/^FROM \(.*\) as builder$/\1/')
3838
echo "builder=$builder" >> "$GITHUB_OUTPUT"
3939
40-
- name: Did docs and hacks change?
41-
id: docs-and-hacks
40+
- name: Did cypress, docs and hacks change?
41+
id: cypress-docs-and-hacks
4242
uses: tj-actions/changed-files@823fcebdb31bb35fdf2229d9f769b400309430d0 # v46
4343
with:
4444
files: |
4545
docs/**
4646
hack/**
4747
*.md
48+
cypress/**
4849
49-
- name: Check if only docs and hacks changes have been made in a PR
50+
- name: Check if only cypress, docs and hacks changes have been made in a PR
5051
id: check-changes
5152
env:
5253
IS_PR: ${{ !!github.event.pull_request }}
53-
ONLY_DOCS: ${{ steps.docs-and-hacks.outputs.only_modified }}
54+
ONLY_DOCS: ${{ steps.cypress-docs-and-hacks.outputs.only_modified }}
5455
run: |
5556
SHOULD_TEST=$(
5657
if [[ $IS_PR == true ]] && [[ $ONLY_DOCS == true ]]; then
@@ -66,8 +67,8 @@ jobs:
6667
6768
- name: Summarize findings
6869
env:
69-
ONLY_DOCS: ${{ steps.docs-and-hacks.outputs.only_modified }}
70-
MODIFIED_FILES: ${{ steps.docs-and-hacks.outputs.all_modified_files }}
70+
ONLY_DOCS: ${{ steps.cypress-docs-and-hacks.outputs.only_modified }}
71+
MODIFIED_FILES: ${{ steps.cypress-docs-and-hacks.outputs.all_modified_files }}
7172
run: |
7273
cat >> "$GITHUB_STEP_SUMMARY" <<EOF
7374
## Build container

.husky/install.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Skip Husky install in production and CI
2+
if (process.env.NODE_ENV === "production" || process.env.CI === "true") {
3+
process.exit(0);
4+
}
5+
const husky = (await import("husky")).default;
6+
console.log(husky());

.prettierignore

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
.eslintcache/
88

99
#
10-
# NOTE: Could ignore anything that eslint will look at since eslint also applies
11-
# prettier.
10+
# Ignore anything that eslint will look at since eslint also applies prettier.
1211
#
12+
**/*.js
13+
**/*.jsx
14+
**/*.cjs
15+
**/*.mjs
16+
17+
**/*.ts
18+
**/*.tsx

client/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"@testing-library/react": "^16.3.0",
6767
"@testing-library/user-event": "^14.6.1",
6868
"@types/file-saver": "^2.0.7",
69+
"@types/jest": "^29.5.4",
6970
"@types/js-yaml": "^4.0.9",
7071
"@types/react": "^18.0.0",
7172
"@types/react-dom": "^18.0.0",
@@ -79,6 +80,10 @@
7980
"css-minimizer-webpack-plugin": "^7.0.2",
8081
"fork-ts-checker-webpack-plugin": "^9.1.0",
8182
"html-webpack-plugin": "^5.6.3",
83+
"jest-environment-jsdom": "^29.7.0",
84+
"jest-resolve": "^29.7.0",
85+
"jest-watch-typeahead": "^2.2.2",
86+
"jest": "^29.7.0",
8287
"mini-css-extract-plugin": "^2.8.1",
8388
"monaco-editor-webpack-plugin": "^7.0.1",
8489
"msw": "^1.2.3",

cypress/.env.example

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Application base URL (the default it development server URL: "http://localhost:9000", comment
2+
# out the definition to use the default)
3+
CYPRESS_BASE_URL=https://example.com
4+
5+
# Login credentials
6+
CYPRESS_USER=admin
7+
CYPRESS_PASSWORD=Dog8code
8+
9+
# Git credentials
10+
CYPRESS_GIT_USER=gituser
11+
CYPRESS_GIT_PASSWORD=gitpass123
12+
13+
# SVN credentials
14+
CYPRESS_SVN_USER=svnuser
15+
CYPRESS_SVN_PASSWORD=svnpass123
16+
17+
# Only needed if authentication is enabled: Keycloak and initial user password
18+
CYPRESS_INITIAL_PASSWORD=Passw0rd!
19+
CYPRESS_KEYCLOAK_ADMIN_PASSWORD=admin123

cypress/.eslintrc.cjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* eslint-env node */
2+
3+
module.exports = {
4+
root: false,
5+
6+
rules: {
7+
"@typescript-eslint/no-var-requires": "warn",
8+
"@typescript-eslint/no-namespace": "warn",
9+
},
10+
};

cypress/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cypress/
2+
run/
3+
.env*
4+
!.env.example
5+

cypress/README.md

Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
## End-to-end Cypress tests for Konveyor UI
2+
3+
## Getting Started
4+
5+
### Requirements
6+
7+
1. Operating system (typically Fedora or macOS)
8+
2. Install Node.js 20 or above (OS native packages, or [nodejs](https://nodejs.org/en/download), or [nvm](https://github.com/nvm-sh/nvm) managed installs are all ok)
9+
10+
### Install and run automation
11+
12+
1. Clone automation repository and setup
13+
14+
```sh
15+
git clone https://github.com/konveyor/tackle2-ui.git
16+
cd tackle2-ui
17+
npm clean-install
18+
```
19+
20+
2. Setup your cypress environment
21+
Copy the sample `cypress/.env.example` to `cypress/.env` and update for your environment. The variables
22+
in this file will not override and existing exported environment variables.
23+
24+
```sh
25+
cp cypress/.env.example cypress/.env
26+
```
27+
28+
3. Open Cypress and run test cases
29+
```sh
30+
cd cypress
31+
npx cypress open
32+
```
33+
34+
## Required Parameters for Tests
35+
36+
Some tests require certain configuration parameters to be correctly defined in the `cypress.config.ts` file. Below is a list of tests and the parameters they require.
37+
38+
- `export_to_jira_datacenter.test.ts`
39+
- `jira_stage_datacenter_project_id`
40+
- `jira_stage_bearer_token`
41+
- `jira_stage_datacenter_url`
42+
43+
- `export_to_jira_cloud.test.ts`
44+
- `jira_atlassian_cloud_project`
45+
- `jira_atlassian_cloud_email`
46+
- `jira_atlassian_cloud_token`
47+
- `jira_atlassian_cloud_url`
48+
49+
- `source_analysis.test.ts` and `binary_analysis.test.ts`
50+
- `git_user`
51+
- `git_password`
52+
53+
## Code formatting using Prettier tool
54+
55+
Husky and lint-staged are used to format staged files when committing.
56+
57+
To manually check the code formatting: `npm run lint`
58+
59+
To manually format the cypress code: `npm run lint:fix`
60+
61+
## Pull request testing
62+
63+
1. Update Pull request with upstream main branch
64+
2. Pull requests will be tested against environment before merging to main codebase
65+
3. Pull request's owner must add **RFR** label once pull request is ready to test against environment
66+
4. After adding **RFR** label, the PR owner should force push the pull request to trigger GitHub action
67+
5. In some cases, the reviewer wants to trigger the PR test GH action but they can't force push to the PR branch. Hence added feature of triggering GH action manually. Steps to trigger GH action for PR testing manually:
68+
- Go to Actions tab
69+
- Click on GH action(Pull request test)
70+
- Click on run workflow dropdown
71+
- select PR branch
72+
- Click on button Run workflow
73+
74+
## Tag based test execution
75+
76+
This repository uses the package [cypress-tags](https://www.npmjs.com/package/cypress-tags) to slice up test runs.
77+
78+
1. To run tests based on tags, use below command
79+
80+
```sh
81+
CYPRESS_INCLUDE_TAGS=@tagName npx cypress run
82+
```
83+
84+
2. To run multiple tags(tiers) in a single run, provide tag names separated by commas
85+
```sh
86+
CYPRESS_INCLUDE_TAGS=@tier1,@tier2 npx cypress run
87+
```
88+
89+
## Running tests locally with Konveyor operator installed to minikube
90+
91+
1. Install minikube on your local machine by referring to [docs](https://minikube.sigs.k8s.io/docs/start/)
92+
93+
1. Setup recommended minikube configurations and start minikube with the ingress addon
94+
95+
```sh
96+
minikube config set memory 10240
97+
minikube config set cpus 4
98+
minikube start --addons=ingress
99+
```
100+
101+
1. Install kubectl if needed, or substitute `minikube kubectl --` for all `kubectl` commands.
102+
103+
1. Install [OLM manually](https://github.com/operator-framework/operator-lifecycle-manager/releases)
104+
105+
```sh
106+
curl -L https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.28.0/install.sh -o install.sh
107+
chmod +x install.sh
108+
./install.sh v0.28.0
109+
```
110+
111+
1. Install the Konveyor operator ([operator install](https://github.com/konveyor/operator?tab=readme-ov-file#konveyor-operator-installation-on-k8s)) to the default namespace **konveyor-tackle**
112+
113+
```sh
114+
kubectl apply -f https://raw.githubusercontent.com/konveyor/operator/main/tackle-k8s.yaml
115+
```
116+
117+
1. Create a Tackle CR (setting the spec values as needed)
118+
119+
```sh
120+
cat << EOF | kubectl apply -f -
121+
kind: Tackle
122+
apiVersion: tackle.konveyor.io/v1alpha1
123+
metadata:
124+
name: tackle
125+
namespace: konveyor-tackle
126+
spec:
127+
feature_auth_required: false
128+
EOF
129+
```
130+
131+
1. Wait for the tackle ingress to become available
132+
133+
```sh
134+
kubectl wait -n konveyor-tackle ingress/tackle --for=jsonpath='{.status.loadBalancer.ingress[0]}' --timeout=600s
135+
```
136+
137+
1. Once the Konveyor UI ingress is running, tests can be run against this local instance, with video captures of the tests turned on, using the command
138+
```sh
139+
CYPRESS_baseUrl=https://$(minikube ip) npx cypress run --config video=true
140+
```
141+
142+
## Tags and Tiers in Konveyor UI tests
143+
144+
### Tags
145+
146+
### `@interOp` tag: (Used by interOp team, rosa, rosa-sts, aro clusters)
147+
148+
Tests include:
149+
150+
- “Creating source control credentials with username/password”
151+
- “Custom Migration Targets CRUD operations”
152+
- “Analysis for acmeair app upload binary”
153+
- “Test inheritance after discarding application assessment and review”
154+
- “Business service CRUD operations”
155+
- “Stakeholder CRUD operations”
156+
- “Migration Waves CRUD operations”
157+
158+
### `@ci` tag:
159+
160+
- Runs on minikube for CI testing https://github.com/konveyor/ci
161+
- Running tests on GitHub Actions on minikube has some constraints like
162+
1. Limited resources
163+
2. Cannot run tests with credentials
164+
3. Time taken to run CI tests
165+
166+
Considering the above factors, we are including tests that are most necessary to test functionality of MTA while merging a PR. More tests will be added here once they're stabilized.
167+
168+
Tests include:
169+
170+
- “Business service CRUD”
171+
- "Jobfunction CRUD"
172+
- "Stakeholder , Stakeholder Group , Tag and Archetype CRUD operations"
173+
- "Application assessment, review, analyze and validate efforts and issues"
174+
175+
### `@tier0` tag:
176+
177+
Basic sanity tests. Runs on stage and production and nightly runs on [Konveyor CI](https://github.com/konveyor/ci).
178+
179+
Tests include:
180+
181+
- “Creating source control credentials with username/password
182+
- ”Custom Migration Targets CRUD operations
183+
- “Source Analysis on bookserver app and its issues validation”
184+
- “Source analysis on bookserver app with EAP8 target”
185+
- “Test inheritance after discarding application assessment and review”
186+
- “Business service CRUD operations”
187+
- “Migration Waves CRUD operations”
188+
189+
### `@tier1` tag:
190+
191+
Includes analysis tests like binary and source+dependencies with credentials, runs on nightly [Konveyor CI](https://github.com/konveyor/ci).
192+
193+
### `@tier2` tag:
194+
195+
CRUD tests for all functionality
196+
197+
### `@tier3` tag:
198+
199+
Sorting/filtering for all functionality
200+
201+
### `@tier4` tag:
202+
203+
Load and performance tests.
204+
205+
## License's header management
206+
207+
To check if the license's header is available in all eligible files, execute:
208+
209+
```shell
210+
yarn license-check-and-add check
211+
```
212+
213+
To add the license's header to all eligible files, execute:
214+
215+
```shell
216+
yarn license-check-and-add add
217+
```
218+
219+
## Code of Conduct
220+
221+
Refer to Konveyor's Code of Conduct [here](https://github.com/konveyor/community/blob/main/CODE_OF_CONDUCT.md).

0 commit comments

Comments
 (0)