-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4979ba9
Showing
12 changed files
with
1,859 additions
and
0 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,29 @@ | ||
name: Lint | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
type-check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 'lts/iron' # '20.x' | ||
cache: 'yarn' | ||
- run: yarn install --frozen-lockfile | ||
- run: yarn type-check | ||
|
||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 'lts/iron' # '20.x' | ||
cache: 'yarn' | ||
- run: yarn install --frozen-lockfile | ||
- run: yarn lint |
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 @@ | ||
node_modules/ | ||
/test-results/ | ||
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ | ||
/playwright/.auth/ | ||
.vscode | ||
.env |
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 @@ | ||
yarn lint |
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,90 @@ | ||
## Code style | ||
This project uses the recommended rules from [typescript-eslint](https://typescript-eslint.io/) and [Stylistic](https://eslint.style/) to enforce a consistent code style. | ||
|
||
Together with lint-staged and husky, the code style is enforced on every commit. | ||
To check the code style manually, you can run: | ||
|
||
```bash | ||
yarn lint # or yarn lint:fix to automatically fix some issues | ||
``` | ||
|
||
If you are using VSCode, you can install the [ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) to see the errors in the editor. Also here's a configuration for the editor to automatically fix some issues on save: | ||
|
||
<details> | ||
<summary>VSCode config</summary> | ||
You can save this configuration on `.vscode/settings.json` file | ||
|
||
```jsonc | ||
{ | ||
// Disable the default formatter, use eslint instead | ||
"prettier.enable": false, | ||
"editor.formatOnSave": false, | ||
|
||
// Auto fix | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": "explicit", | ||
"source.organizeImports": "never" | ||
}, | ||
|
||
// Silent the stylistic rules in you IDE, but still auto fix them | ||
"eslint.rules.customizations": [ | ||
{ "rule": "style/*", "severity": "off", "fixable": true }, | ||
{ "rule": "format/*", "severity": "off", "fixable": true }, | ||
{ "rule": "*-indent", "severity": "off", "fixable": true }, | ||
{ "rule": "*-spacing", "severity": "off", "fixable": true }, | ||
{ "rule": "*-spaces", "severity": "off", "fixable": true }, | ||
{ "rule": "*-order", "severity": "off", "fixable": true }, | ||
{ "rule": "*-dangle", "severity": "off", "fixable": true }, | ||
{ "rule": "*-newline", "severity": "off", "fixable": true }, | ||
{ "rule": "*quotes", "severity": "off", "fixable": true }, | ||
{ "rule": "*semi", "severity": "off", "fixable": true }, | ||
{ "rule": "*-lines", "severity": "off", "fixable": true }, | ||
], | ||
|
||
// Enable eslint for all supported languages | ||
"eslint.validate": [ | ||
"javascript", | ||
"javascriptreact", | ||
"typescript", | ||
"typescriptreact", | ||
"vue", | ||
"html", | ||
"markdown", | ||
"json", | ||
"jsonc", | ||
"yaml", | ||
"toml", | ||
"xml", | ||
"gql", | ||
"graphql", | ||
"astro", | ||
"css", | ||
"less", | ||
"scss", | ||
"pcss", | ||
"postcss" | ||
], | ||
"files.exclude": { | ||
"**/.git": true, | ||
"**/.svn": true, | ||
"**/.hg": true, | ||
"**/CVS": true, | ||
"**/.DS_Store": true, | ||
"**/Thumbs.db": true, | ||
"**/node_modules": true | ||
} | ||
} | ||
``` | ||
|
||
</details> | ||
|
||
## Writing tests | ||
|
||
Follow the Playwright [best practices](https://playwright.dev/docs/best-practices) when writting tests. Use the UI mode for faster development leveraing the [locator picker](https://playwright.dev/docs/test-ui-mode#pick-locator) to easily find elements on the page. | ||
|
||
|
||
### Page Object Model | ||
|
||
To improve test readability and maintainability, we use the [Page Object Model](https://playwright.dev/docs/pom) pattern. This pattern allows us to encapsulate the logic of the pages in classes, making the tests more readable and easier to maintain. | ||
|
||
Page objects are located in the `/pages` directory. Each page object should have a class that represents the page and its methods. The page object should not contain assertions, only methods that interact with the page. |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Red Hat, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,55 @@ | ||
# End-to-end Playwright tests for OSIM | ||
This repository contains end-to-end tests for [OSIM](https://github.com/RedHatProductSecurity/osim) using [Playwright](https://playwright.dev/). | ||
|
||
## Required environment variables | ||
|
||
- `OSIM_URL`: URL of the OSIM instance to test | ||
- `OSIDB_URL`: URL of the OSIDB instance to test | ||
- `JIRA_USERNAME`: Username of the authenticated user in JIRA | ||
- `JIRA_API_KEY`: API key for jira | ||
- `BUGZILLA_API_KEY`: API key for bugzilla | ||
|
||
The project uses [dotenv](https://www.npmjs.com/package/dotenv) to load the environment variables from a `.env` file. | ||
|
||
## Installation | ||
|
||
Clone the repository and install the dependencies: | ||
|
||
```bash | ||
git clone [email protected]:RedHatProductSecurity/osim-ui-tests.git | ||
cd osim-ui-tests | ||
yarn install | ||
``` | ||
|
||
This should download the browser binaries for Playwright, if having problems, you can do it manually by running: | ||
|
||
```bash | ||
yarn playwright install | ||
``` | ||
|
||
## Running the tests | ||
|
||
You can run Playwright in [UI mode](https://playwright.dev/docs/test-ui-mode) by running: | ||
|
||
```bash | ||
yarn dev | ||
``` | ||
This mode allows you to run the tests in a browser and see the results in the Playwright UI. Perfect for development and debugging. | ||
|
||
To run the tests in headless mode, you can run: | ||
|
||
```bash | ||
yarn test | ||
``` | ||
|
||
or specify the browser to use: | ||
|
||
```bash | ||
yarn test:firefox # see package.json for more options | ||
``` | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. | ||
|
||
### See the [CONTRIBUTING.md](CONTRIBUTING.md) file for more information on how to contribute to this project. |
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,13 @@ | ||
declare global { | ||
namespace NodeJS { | ||
interface ProcessEnv { | ||
JIRA_API_KEY: string; | ||
BUGZILLA_API_KEY: string; | ||
JIRA_USERNAME: string; | ||
OSIDB_URL: string; | ||
OSIM_URL: string; | ||
} | ||
} | ||
} | ||
|
||
export {}; |
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,37 @@ | ||
import eslint from '@eslint/js'; | ||
import tseslint from 'typescript-eslint'; | ||
import stylistic from '@stylistic/eslint-plugin' | ||
|
||
export default tseslint.config( | ||
eslint.configs.recommended, | ||
...tseslint.configs.strictTypeChecked, | ||
...tseslint.configs.stylisticTypeChecked, | ||
stylistic.configs.customize({ | ||
braceStyle:'1tbs', | ||
commaDangle:'always-multiline', | ||
indent: 2, | ||
quotes: 'single', | ||
semi: true, | ||
}), | ||
{ | ||
rules: { | ||
'@typescript-eslint/restrict-template-expressions': ['error',{ allow: [{ name: 'undefined', from: 'lib' }] }], | ||
} | ||
}, | ||
{ | ||
languageOptions: { | ||
parserOptions: { | ||
projectService: true, | ||
tsconfigRootDir: import.meta.dirname | ||
} | ||
} | ||
}, | ||
{ | ||
ignores: [ | ||
'eslint.config.mjs', | ||
'playwright.config.ts', | ||
'tests-results/**/*', | ||
'playwright-report/**/*' | ||
] | ||
} | ||
); |
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,45 @@ | ||
{ | ||
"name": "osim-integration-tests", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"private": true, | ||
"devDependencies": { | ||
"@faker-js/faker": "^9.2.0", | ||
"@playwright/browser-chromium": "^1.48.2", | ||
"@playwright/browser-firefox": "^1.48.2", | ||
"@playwright/test": "^1.48.2", | ||
"@stylistic/eslint-plugin": "^2.10.1", | ||
"@types/eslint__js": "^8.42.3", | ||
"@types/kerberos": "^1.1.5", | ||
"@types/node": "^22.9.0", | ||
"@typescript-eslint/eslint-plugin": "^8.14.1-alpha.8", | ||
"@typescript-eslint/parser": "^8.14.1-alpha.8", | ||
"dayjs": "^1.11.13", | ||
"dotenv": "^16.4.5", | ||
"eslint": "^9.14", | ||
"husky": "^9.1.6", | ||
"kerberos": "^2.2.0", | ||
"lint-staged": "^15.2.10", | ||
"typescript": "^5.6.3", | ||
"typescript-eslint": "^8.14.1-alpha.8", | ||
"undici": "^6.21.0" | ||
}, | ||
"scripts": { | ||
"test": "playwright test --reporter=list", | ||
"test:chrome": "playwright test --reporter=list --project=chrome", | ||
"test:firefox": "playwright test --reporter=list --project=firefox", | ||
"dev": "playwright test --ui", | ||
"lint": "eslint . ", | ||
"lint:fix": "eslint . --fix", | ||
"type-check": "tsc --noEmit", | ||
"postinstall": "husky" | ||
}, | ||
"engines": { | ||
"node": ">=20.0.0" | ||
}, | ||
"lint-staged": { | ||
"*.ts": "eslint" | ||
}, | ||
"dependencies": {} | ||
} |
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,63 @@ | ||
import { defineConfig, devices, type Project } from '@playwright/test'; | ||
import dotenv from 'dotenv'; | ||
import path from 'path'; | ||
|
||
dotenv.config({ path: path.resolve(__dirname, '.env') }); | ||
|
||
const browsers: Project[] = [ | ||
{ | ||
name: 'firefox', | ||
use: { | ||
...devices['Desktop Firefox'], | ||
launchOptions: { | ||
firefoxUserPrefs: { | ||
'network.negotiate-auth.trusted-uris': '.redhat.com', | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: 'chromium', | ||
use: { | ||
...devices['Desktop Chrome'], | ||
launchOptions: { | ||
args: ['--auth-server-whitelist="*.redhat.com"'], | ||
}, | ||
}, | ||
}, | ||
]; | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
testDir: './tests', | ||
fullyParallel: true, | ||
forbidOnly: !!process.env.CI, | ||
retries: process.env.CI ? 2 : 0, | ||
workers: process.env.CI ? 1 : undefined, | ||
reporter: 'html', | ||
use: { | ||
storageState: 'playwright/.auth/user.json', | ||
ignoreHTTPSErrors: true, | ||
trace: 'on-first-retry', | ||
baseURL: `https://${process.env.OSIM_URL}`, | ||
}, | ||
timeout: 60000, | ||
expect: { | ||
timeout: 20000, | ||
}, | ||
projects: [ | ||
{ | ||
name: 'setup', | ||
testMatch: /.*\.setup\.ts/, | ||
}, | ||
...browsers.map(browser => ({ | ||
name: browser.name, | ||
use: { | ||
...browser.use, | ||
}, | ||
dependencies: ['setup'], | ||
})), | ||
], | ||
}); |
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,15 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowJs": false, | ||
"baseUrl": ".", | ||
"strict": true, | ||
"strictNullChecks": true, | ||
"esModuleInterop": true, | ||
}, | ||
"include": [ | ||
"tests/**/*.ts", | ||
"pages/**/*.ts", | ||
"playwright/**/*.ts", | ||
"environment.d.ts" | ||
] | ||
} |
Oops, something went wrong.