Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next GUI E2E Tests #510

Merged
merged 65 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
ff0c380
E2E Tests
z-x Jul 21, 2023
2007c21
Changed tests location
z-x Jul 21, 2023
8f481b4
Moving on with the tests
z-x Jul 24, 2023
730029f
Filtering tests
z-x Jul 25, 2023
232512f
Records filtering tests
z-x Jul 31, 2023
5e3333e
Database filtering and ordering tests
z-x Aug 18, 2023
0ff55e4
Creating, editing and refreshing records
z-x Sep 18, 2023
db0f83d
Users tests
z-x Sep 19, 2023
a2ea415
Don't run Jest tests for new gui
z-x Sep 19, 2023
f384658
Logs tests
z-x Sep 20, 2023
ba38d01
Background Jobs tests
z-x Sep 20, 2023
1305d8a
Constants tests
z-x Sep 21, 2023
b7142e1
Working on flaky tests
z-x Sep 21, 2023
7ff5bca
Experimenting with CI
z-x Sep 22, 2023
9c03da6
Install before build
z-x Sep 22, 2023
bb5da32
First workflow run
z-x Sep 22, 2023
e15505a
Fixing workflow file
z-x Sep 22, 2023
58535db
Checkout both repos
z-x Sep 22, 2023
dff9e1c
Deploy before seed
z-x Sep 22, 2023
8fedeb7
Added workind directory for playwright
z-x Sep 22, 2023
1235df7
Properly install Playwright browsers
z-x Sep 22, 2023
b9cda12
Run in proper env
z-x Sep 22, 2023
5b7e525
Back to using the container
z-x Sep 22, 2023
6bf3a15
The container OS not supported
z-x Sep 22, 2023
b74a070
Fixing the logger?
z-x Sep 25, 2023
9773638
Temporary removing the action?
z-x Sep 29, 2023
f14ece0
Merge branch 'master' into e2e
z-x Sep 29, 2023
7559233
Testing actions on PR
z-x Oct 2, 2023
001cd10
Hm
z-x Oct 2, 2023
c48a98c
Removed actions as they definetly break jenkins
z-x Oct 2, 2023
8f34876
Added development readme
z-x Oct 2, 2023
943b590
test
z-x Oct 5, 2023
511ec1f
No sudo
z-x Oct 5, 2023
fe148db
Fixing name
z-x Oct 5, 2023
711fd32
Nope, still not working
z-x Oct 5, 2023
300c943
Merge branch 'master' into e2e
z-x Oct 5, 2023
bfdb3f5
Added a script for running the tests manually
z-x Oct 5, 2023
79881bf
Update README.md
z-x Oct 5, 2023
0f8241e
Added a script to run tests automatically
z-x Oct 5, 2023
5cc40d2
Eliminating flaky tests
z-x Oct 5, 2023
3587024
Eliminated flaky logs tests
z-x Oct 5, 2023
19b8883
Removed 'prepare' step from npm
z-x Oct 5, 2023
d58ffc9
Cleanup
z-x Oct 9, 2023
b93459d
Testing the test workflow
z-x Oct 9, 2023
518e1ca
Updated tests
z-x Oct 9, 2023
9e89599
Save screenshoots
z-x Oct 9, 2023
0994a67
Screenshoots
z-x Oct 9, 2023
780dfa9
Screen
z-x Oct 9, 2023
c9d20f6
Enabling tests retry
z-x Oct 9, 2023
a49247d
Wait for background job to be scheduled
z-x Oct 9, 2023
9032941
Wait for remote to output
z-x Oct 9, 2023
3d990bc
Test
z-x Oct 9, 2023
9c7ba6a
Merge branch 'e2e' of https://github.com/mdyd-dev/pos-cli into e2e
z-x Oct 9, 2023
134f362
Experimenting with wait
z-x Oct 9, 2023
389809e
Updated test instance data
z-x Oct 9, 2023
5f78f2e
Removed debug
z-x Oct 9, 2023
16018f8
Skip if not needed
z-x Oct 9, 2023
1147581
Build to trigger tests
z-x Oct 9, 2023
230cf00
Better Playwirght config
z-x Oct 9, 2023
8ee1765
More workers
z-x Oct 9, 2023
01c1369
Clearing the waits
z-x Oct 9, 2023
9735d2b
Added missing param to playwright installation readme
z-x Oct 9, 2023
9d6ad0e
Added info about parallelism
z-x Oct 9, 2023
05dfa83
Build to trigger tests
z-x Oct 10, 2023
d9eded1
Merge branch 'master' into e2e
z-x Oct 10, 2023
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
80 changes: 80 additions & 0 deletions .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Pos-cli GUI tests
on:
pull_request:
branches: [ master ]
push:
branches: [ master ]

jobs:
pre_job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
github_token: ${{ github.token }}
paths: '["gui/next/**"]'
paths_ignore: '["gui/next/README.md"]'

tests:
needs: ["pre_job"]
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
timeout-minutes: 15
container:
image: mcr.microsoft.com/playwright:v1.38.0-jammy
env:
MPKIT_EMAIL: ${{ secrets.MPKIT_EMAIL }}
MPKIT_TOKEN: ${{ secrets.MPKIT_TOKEN }}
MPKIT_URL: ${{ secrets.MPKIT_URL }}
CI: true
steps:
- name: Checkout test instance code
uses: actions/checkout@v4
with:
repository: Platform-OS/pos-cli-gui-qa
path: instance
- name: Checkout pos-cli code
uses: actions/checkout@v4
with:
path: pos-cli
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install pos-cli
run: |
npm install -g @platformos/pos-cli
- name: Seed the test instance with test data
working-directory: ./instance
timeout-minutes: 6
shell: sh
run: |
set -eu
pos-cli deploy
pos-cli data clean --auto-confirm
pos-cli data import --path=seed/data.zip --zip
- name: Build GUI
working-directory: ./pos-cli/gui/next
shell: sh
run: |
set -eu
npm install
npm run build
# - name: Install Playwright browsers
# run: npx playwright install --with-deps
- name: Run express server, vite preview server and tests
working-directory: ./pos-cli/gui/next
shell: sh
run: |
set -eu
pos-cli gui serve &
npm run preview &
sleep 5 && npx playwright test
- uses: actions/upload-artifact@v3
if: always()
with:
name: test-results
path: ./pos-cli/gui/next/test-results/
retention-days: 4
4 changes: 4 additions & 0 deletions gui/next/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ node_modules
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
/test-results/
/playwright-report/
/playwright/.cache/
/playwright/pos-cli-gui-qa/
128 changes: 127 additions & 1 deletion gui/next/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,127 @@
TBD
pos-cli gui is an interface built to manage your platformOS instance and related data.

## Tech stack
- [SvelteKit](https://kit.svelte.dev) as front-end framework
- [Vite](https://vitejs.dev) as a development environment
- [Playwright](https://playwright.dev) for end-to-end testing

## Development
Prerequisites: [GIT](https://git-scm.com), [Node.js](https://nodejs.org/en), [pos-cli](https://github.com/mdyd-dev/pos-cli) installed and a [platformOS instance](https://documentation.platformos.com/get-started) configured.

1. Clone the whole pos-cli repository to an empty folder:

```bash
git clone https://github.com/mdyd-dev/pos-cli.git
```
2. Navigate to the `gui/next` subfolder:
```bash
cd gui/next
```
3. Install the dependencies:
```bash
npm install
```

### Run the development server
To run the dev server you just need to run the following command from `gui/next` directory
```bash
npm run dev
```

By default, it runs the server at [http://localhost:5173](http://localhost:5173) and you should be able to view the GUI under this URL. You need to leave the server running in the terminal.

To test things out though, you would like to **connect to an instance** to have some test data appearing in the GUI.

In a new terminal window, run `pos-cli gui serve [instance alias]` from the [authenticated directory](https://documentation.platformos.com/get-started/working-with-the-code-and-files/) where you have your test instance code. The same as you would normally use to run the GUI on daily development.

### Make your changes
You can edit the source code at `gui/next` and while the development server is running, it will refresh the changes in the browser automatically.

### Build the final code
Before publishing or testing the changes you will have to build the final package.

To do that run the following in `gui/next` directory:

```bash
npm run build
```

### Update and run the tests
When making changes and developing new functions, please make sure you will modify or add automated test scenarios placed in the `playwright` directory.

The one rule to follow here is that each test scenario should be completely independent. You cannot rely on the previous tests to prepare any data as each test can be ran in parallel in a random order. The initial data is seeded using the public repository: https://github.com/Platform-OS/pos-cli-gui-qa

#### Manually run tests

To manually run the tests, you would require a test instance that has the testing code deployed and test data seeded.

1. If not done previously, [install Playwright browsers](https://playwright.dev/docs/browsers)
```bash
npx playwright install --with-deps
```
2. Clone the test repository to an empty folder:
```bash
git clone https://github.com/Platform-OS/pos-cli-gui-qa.git
```
3. [Authenticate the directory](https://documentation.platformos.com/get-started/working-with-the-code-and-files/#authenticate-your-environment) to work with platformOS
4. Navigate to that directory and run the following to deploy the code:
```bash
pos-cli deploy <instance alias>
```
5. If the instance data was previously modified, you would have to clean the data to start fresh
```bash
pos-cli data clean <instance alias>
```
6. Seed the test data to the instance
```bash
pos-cli data import <instance alias> --path seed/data.zip --zip
```
7. Build the production-ready code
```bash
npm run build
```
8. Run the preview server
```bash
npm run preview
```

Finally, to run Playwright with an interface use the following command from `gui/next` directory:

```bash
npx playwright test --ui
```

This will run the Playwright interface, where you can run previously available test scenarios and see your changes when modifying the `.spec.js` test files.


#### Use a script to run tests

There is a Bash script prepared to run all the steps needed for automated testing. To use the script just run the following command from the `/gui/next` directory:

```bash
sh sh playwright/run.sh
```

Keep in mind that, by default, it uses an shared instance so if more than one person is running the tests, it might fail. You can change the instance it uses by editing the script.

The output would be a HTML report showing the tests results.


### Publish new version
When you are ready to publish the new GUI version:

1. Merge from `master` to make sure that you have the latest changes to the rest of the code
2. Increase the `pos-cli` version number by running the following from **the parent directory**:
```bash
npm version <minor|path>
```
3. Describe your changes in `CHANGELOG.md`
4. Commit and push your branch to GitHub, pass the review and merge to `master`.
5. Switch to `master` branch
```bash
git checkout master
```
6. Publish the new package to npm (requires you having the permissions):
```bash
npm publish
```
55 changes: 0 additions & 55 deletions gui/next/RELEASE.md

This file was deleted.

1 change: 1 addition & 0 deletions gui/next/build/_app/immutable/assets/12.2eafae4e.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading