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

Playwright test #88

Merged
merged 78 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
2750c1e
implemented playwright. created few new tests. wip
stefanak-michal May 7, 2024
3c5d469
added more tests. small fix of pagination.
stefanak-michal May 7, 2024
c2fcdbd
created spec file for every test category to be implemented.
stefanak-michal May 7, 2024
8287fba
changed masking filter. added rel type tests.
stefanak-michal May 7, 2024
843fe9f
added test for rel type table. small code improvements.
stefanak-michal May 8, 2024
766157b
search input has own X
stefanak-michal May 8, 2024
c07e35b
screenshot mask optimization
stefanak-michal May 8, 2024
dad32d1
separated tests into two groups with tag. added tests for node tab.
stefanak-michal May 8, 2024
aaa83e2
extended workflow. added more node tab tests.
stefanak-michal May 9, 2024
dcca11d
added check for successful add to stash
stefanak-michal May 9, 2024
23b2a2d
test and check remove from stash after adding
stefanak-michal May 9, 2024
31161e9
added test for relationship tab. added test for node label changes.
stefanak-michal May 9, 2024
bc4819c
added env variables for running tests. removed class Input.
stefanak-michal May 9, 2024
f81e999
formatted code
stefanak-michal May 9, 2024
ee3f40a
history tests
stefanak-michal May 9, 2024
54fb986
added copy tests. reorganized.
stefanak-michal May 10, 2024
b9d1640
added new fixture to check start tab was fully loaded. added query te…
stefanak-michal May 10, 2024
4536164
fixed some issues
stefanak-michal May 10, 2024
e1b6e21
added settings tests and some more
stefanak-michal May 10, 2024
0813bc4
added stash tests. and some more.
stefanak-michal May 10, 2024
8ce99fe
function to switch tabs
stefanak-michal May 13, 2024
7a01d95
workflow tests organization
stefanak-michal May 13, 2024
dd3a256
finished read-only tests
stefanak-michal May 13, 2024
ffaf1b2
wip read-write tests
stefanak-michal May 13, 2024
b898501
crated write test. fixed minor bugs.
stefanak-michal May 15, 2024
cc5d060
reorganized tests
stefanak-michal May 15, 2024
1a7b44f
updated workflow
stefanak-michal May 15, 2024
5c6e436
added multi database tests
stefanak-michal May 16, 2024
5551603
formatted code
stefanak-michal May 16, 2024
65293e5
disabled memgraph test
stefanak-michal May 16, 2024
f24b0fd
formatted
stefanak-michal May 16, 2024
4fa9efa
added cypher shell
stefanak-michal May 16, 2024
953a3ab
added cypher shell
stefanak-michal May 16, 2024
5f0f1a4
added host
stefanak-michal May 16, 2024
09f203c
fixed script keys
stefanak-michal May 16, 2024
4bd6f80
Merge branch 'refs/heads/master' into 80-tests
stefanak-michal May 16, 2024
dcbdeb3
temporary disabled some workflow
stefanak-michal May 16, 2024
42169fc
try change url
stefanak-michal May 16, 2024
d9028d3
enable trace
stefanak-michal May 16, 2024
ab9c4e7
fix url
stefanak-michal May 16, 2024
2e15c14
updated snapshots and workflow
stefanak-michal May 16, 2024
a5da7d6
updated workflow
stefanak-michal May 16, 2024
40047fd
added basic memgraph test
stefanak-michal May 16, 2024
8bd9f5b
fixed some screenshots
stefanak-michal May 16, 2024
c7e18e1
fixed login with empty env vars
stefanak-michal May 16, 2024
ca7ecc5
concurrency
stefanak-michal May 16, 2024
bc0f380
updated CONTRIBUTING.md
stefanak-michal May 16, 2024
5f7699d
implemented sharding to speed up neo4j-read tests
stefanak-michal May 16, 2024
0a43387
update
stefanak-michal May 16, 2024
393198f
stop on failure in CI
stefanak-michal May 16, 2024
de63d8f
one movies import per all shards
stefanak-michal May 16, 2024
6f4beef
permission problem
stefanak-michal May 16, 2024
46f767b
test use cypher shell from service
stefanak-michal May 16, 2024
59db6f9
formatting
stefanak-michal May 16, 2024
a66d147
service name
stefanak-michal May 16, 2024
315f9d5
get movies inside of service
stefanak-michal May 16, 2024
c7a28b5
update
stefanak-michal May 16, 2024
d317bee
retry
stefanak-michal May 16, 2024
565c107
retry
stefanak-michal May 16, 2024
0cb08f2
maybe
stefanak-michal May 16, 2024
bc46fd3
maybe
stefanak-michal May 16, 2024
dbe7f7e
maybe
stefanak-michal May 16, 2024
22bc8b1
maybe
stefanak-michal May 16, 2024
daa0f09
maybe
stefanak-michal May 16, 2024
fe89591
maybe
stefanak-michal May 16, 2024
7124c6c
format
stefanak-michal May 16, 2024
7583d76
stupid CI
stefanak-michal May 16, 2024
7f2be12
stupid CI
stefanak-michal May 16, 2024
29be305
stupid CI
stefanak-michal May 16, 2024
fbfba2c
stupid CI
stefanak-michal May 16, 2024
f429ebb
asking for miracle
stefanak-michal May 17, 2024
48172e3
asking for miracle
stefanak-michal May 17, 2024
f320fe3
removed some screenshots in tests.
stefanak-michal May 17, 2024
92b8d74
url fix
stefanak-michal May 17, 2024
7f79c66
small update
stefanak-michal May 17, 2024
9c5c16a
small update
stefanak-michal May 17, 2024
31f9ee2
removed two screenshots
stefanak-michal May 17, 2024
a24ff17
fix test
stefanak-michal May 17, 2024
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
206 changes: 206 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
name: Playwright e2e tests

on:
pull_request:
branches: [master]
workflow_run:
workflows: ['Prettier and linter']
types:
- completed

concurrency:
group: ${{ github.head_ref }}
cancel-in-progress: true

jobs:
neo4j-read:
timeout-minutes: 60
runs-on: ubuntu-latest
services:
neo4j:
image: neo4j:latest
env:
NEO4J_AUTH: neo4j/nothing123
ports:
- 7687:7687
- 7474:7474
options: >-
--name "neo4j_service"
--health-cmd "wget --spider http://localhost:7474 || exit 1"
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8]
shardTotal: [8]

steps:
- name: Load movies dataset
run: |
docker exec neo4j_service wget -O /tmp/movies.cypher https://raw.githubusercontent.com/neo4j-graph-examples/movies/main/scripts/movies.cypher
docker exec neo4j_service cypher-shell -a bolt://localhost:7687 -u "neo4j" -p "nothing123" "MATCH (n) DETACH DELETE n"
docker exec neo4j_service cypher-shell -a bolt://localhost:7687 -u "neo4j" -p "nothing123" -f /tmp/movies.cypher
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: latest
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps chromium
- name: Run Playwright tests (neo4j-read)
run: npx playwright test --grep @neo4j-read --reporter=blob --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
env:
DB_HOSTNAME: 'bolt://localhost:7687'
DB_USERNAME: 'neo4j'
DB_PASSWORD: 'nothing123'
# - uses: actions/upload-artifact@v4
# if: ${{ failure() }}
# with:
# name: playwright-report
# path: playwright-report/
# retention-days: 1
- name: Upload blob report to GitHub Actions Artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: blob-report-${{ matrix.shardIndex }}
path: blob-report
retention-days: 1

build:
timeout-minutes: 60
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.44.0-jammy

services:
neo4j:
image: neo4j:latest
env:
NEO4J_AUTH: neo4j/nothing123
ports:
- 7687:7687
- 7474:7474
options: >-
--health-cmd "wget --spider http://localhost:7474 || exit 1"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: latest
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps chromium
- name: Build
run: npm run build
- name: Run Playwright tests (build)
run: npx playwright test --grep @build
env:
DB_HOSTNAME: 'bolt://neo4j:7687'
DB_USERNAME: 'neo4j'
DB_PASSWORD: 'nothing123'

neo4j-write:
timeout-minutes: 60
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.44.0-jammy

services:
neo4j:
image: neo4j:latest
env:
NEO4J_AUTH: neo4j/nothing123
ports:
- 7687:7687
- 7474:7474
options: >-
--health-cmd "wget --spider http://localhost:7474 || exit 1"

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: latest
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps chromium
- name: Run Playwright tests (neo4j-write)
run: npx playwright test --grep @neo4j-write
env:
DB_HOSTNAME: 'bolt://neo4j:7687'
DB_USERNAME: 'neo4j'
DB_PASSWORD: 'nothing123'

neo4j-multidb:
timeout-minutes: 60
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.44.0-jammy

services:
neo4j:
image: neo4j:enterprise
env:
NEO4J_AUTH: neo4j/nothing123
NEO4J_ACCEPT_LICENSE_AGREEMENT: yes
ports:
- 7687:7687
- 7474:7474
options: >-
--health-cmd "wget --spider http://localhost:7474 || exit 1"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: latest
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps chromium
- name: Run Playwright tests (neo4j-multidb)
run: npx playwright test --grep @neo4j-multidb
env:
DB_HOSTNAME: 'bolt://neo4j:7687'
DB_USERNAME: 'neo4j'
DB_PASSWORD: 'nothing123'

memgraph:
timeout-minutes: 60
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.44.0-jammy

services:
memgraph:
image: memgraph/memgraph:latest
ports:
- 7687:7687
options: >-
--health-cmd "echo 'RETURN 0;' | mgconsole || exit 1"

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: latest
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps chromium
- name: Run Playwright tests (memgraph)
run: npx playwright test --grep @memgraph
env:
DB_HOSTNAME: 'bolt://memgraph:7687'
2 changes: 1 addition & 1 deletion .github/workflows/prettier-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
Expand Down
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
.env

npm-debug.log*
yarn-debug.log*
yarn-error.log*

/.idea
/playwright-report/
/test-results/
11 changes: 8 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,17 @@ This will start the development server and open the application in your default
- We follow standard React code style conventions.
- We use TypeScript for type checking and code clarity. (non-strict)
- Bulma CSS framework is used for styling.
- Prettier is used. `npm run format`

**Contributing Code:**

1. Create a new branch for your feature or bug fix.
2. Make your changes and commit them with descriptive messages.
3. Push your changes to your forked repository.
4. Create a pull request from your forked repository to the upstream cypherGUI repository.
2. Make your changes.
3. Test your code.
4. Check your code with prettier and linter.
5. Commit them with descriptive messages.
6. Push your changes to your forked repository.
7. Create a pull request from your forked repository to the upstream cypherGUI repository.

**Pull Request Review:**

Expand All @@ -53,6 +57,7 @@ This will start the development server and open the application in your default
**Testing:**

- Make sure to check project functionality in your browser.
- Playwright is used. `npx playwright test`
- Verify your change towards different ecosystems (Neo4j, Memgraph, etc.).

**Licensing:**
Expand Down
16 changes: 16 additions & 0 deletions e2e/fixtures/login.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { expect, test as base } from '@playwright/test';

export const test = base.extend({
page: async ({ page }, use) => {
await page.goto(process.env.URL || '/');
await page.getByLabel('URL').fill(process.env.DB_HOSTNAME || 'bolt://localhost:7687');
await page.getByLabel('Username').fill(process.env.DB_USERNAME || '');
await page.getByLabel('Password').fill(process.env.DB_PASSWORD || '');
await page.getByRole('button', { name: 'Login' }).click();
await expect(page.getByLabel('main navigation')).toHaveCount(1);

await use(page);
},
});

export { expect };
25 changes: 25 additions & 0 deletions e2e/fixtures/neo4j-movies.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { expect, test as base } from './login';
import { containerLocator, switchToTab } from '../helpers';

export const test = base.extend({
page: async ({ page }, use) => {
await switchToTab(page, 'Start');
await expect(containerLocator(page, 'button.is-link').filter({ hasText: '*' })).toHaveCount(1);
await expect(containerLocator(page, 'button.is-link').filter({ hasText: ':Person' })).toHaveCount(1);
await expect(containerLocator(page, 'button.is-link').filter({ hasText: ':Movie' })).toHaveCount(1);

await expect(containerLocator(page, 'button.is-info').filter({ hasText: '*' })).toHaveCount(1);
await expect(containerLocator(page, 'button.is-info').filter({ hasText: ':ACTED_IN' })).toHaveCount(1);
await expect(containerLocator(page, 'button.is-info').filter({ hasText: ':DIRECTED' })).toHaveCount(1);
await expect(containerLocator(page, 'button.is-info').filter({ hasText: ':PRODUCED' })).toHaveCount(1);
await expect(containerLocator(page, 'button.is-info').filter({ hasText: ':WROTE' })).toHaveCount(1);
await expect(containerLocator(page, 'button.is-info').filter({ hasText: ':FOLLOWS' })).toHaveCount(1);
await expect(containerLocator(page, 'button.is-info').filter({ hasText: ':REVIEWED' })).toHaveCount(1);

await expect(containerLocator(page, 'button.is-primary')).toContainText(['Create node', 'Create relationship']);

await use(page);
},
});

export { expect };
31 changes: 31 additions & 0 deletions e2e/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Page, expect } from '@playwright/test';

export function containerLocator(page: Page, selector: string = '') {
const l = page.locator('.container > div').locator('visible=true');
return selector ? l.locator(selector) : l;
}

export function modalLocator(page: Page) {
return page.locator('.modal .modal-card').locator('visible=true');
}

export async function checkActiveTab(page: Page, text: string | RegExp) {
await expect(page.locator('.tabs .is-active')).toHaveText(text);
}

export async function switchToTab(page: Page, text: string | RegExp) {
await page.locator('.tabs a', { hasText: text }).click();
await checkActiveTab(page, text);
}

export async function checkErrorMessage(page: Page, text: string) {
await expect(containerLocator(page)).toContainText(text);
await containerLocator(page, '.message').getByRole('button').click();
await expect(containerLocator(page, '.message')).toHaveCount(0);
}

export async function checkNotification(page: Page, text: string | RegExp = 'Copied to clipboard') {
await expect(page.getByRole('region', { name: 'notifications' })).toHaveText(text);
await page.getByRole('region', { name: 'notifications' }).getByRole('button').click();
await expect(page.getByRole('region', { name: 'notifications' })).toBeEmpty();
}
7 changes: 7 additions & 0 deletions e2e/memgraph/memgraph.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { expect, test } from '../fixtures/login';

test.describe('Memgraph Tests', { tag: '@memgraph' }, () => {
test('Login successful', async ({ page }) => {
await expect(page.locator('#basicNavbar')).toBeVisible();
});
});
12 changes: 12 additions & 0 deletions e2e/neo4j-build/build.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { expect, test } from '@playwright/test';

test.describe('Access cypherGUI as file', { tag: '@build' }, () => {
test('Open and login', async ({ page }) => {
await page.goto('file://' + require('node:path').resolve('./build/index.html'));
await page.getByLabel('URL').fill(process.env.DB_HOSTNAME || 'bolt://localhost:7687');
await page.getByLabel('Username').fill(process.env.DB_USERNAME);
await page.getByLabel('Password').fill(process.env.DB_PASSWORD);
await page.getByRole('button', { name: 'Login' }).click();
await expect(page.locator('#basicNavbar')).toBeVisible();
});
});
Loading