Skip to content
Open
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
65 changes: 65 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Playwright Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v5
with:
node-version: '24.3.0'
- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.12.0
with:
mongodb-version: 4.4
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
java-version: 21
distribution: 'temurin'
cache: 'maven'
# - name: Install mongosh and import start data in database
# run: |
# sudo apt-get install gnupg
# wget -qO- https://www.mongodb.org/static/pgp/server-7.0.asc | sudo tee /etc/apt/trusted.gpg.d/server-7.0.asc
# echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
# sudo apt-get update
# sudo apt-get install -y mongodb-mongosh
# mongosh --version
# mongosh localhost:27017/myconext playwright/loadusers.js
- name: Set up cache
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# - name: Build with Maven
# run: mvn clean install --file pom.xml
- name: Run myconext-server
run : cd myconext-server && mvn spring-boot:run -Dspring-boot.run.profiles=dev && sleep 30 &
- name: Run account-gui
run: cd account-gui && yarn install && yarn dev && sleep 10 &
- name: Run myconext-gui
run: cd myconext-gui && yarn install && yarn dev && sleep 10 &
- name: Run servicedesk-gui
run: cd servicedesk-gui && yarn install && yarn dev && sleep 10 &
- name: Run public-gui
run: cd public-gui && yarn install && yarn dev && sleep 10 &
- name: Install dependencies for plarwright
run: cd playwright && npm install -g yarn && yarn
- name: Install Playwright Browsers
run: cd playwright && yarn playwright install --with-deps
- name: Run Playwright tests
run: cd playwright && yarn playwright test
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,18 @@ yarn install
yarn dev
```

Browse to the [application homepage](http://localhost:3003/).

### The public-gui

The myconext public gui can also be build with Svelte and to get initially started:

```
cd public-gui
yarn install
yarn dev
```

Browse to the [application homepage](http://localhost:3002).

### Build
Expand Down
27 changes: 27 additions & 0 deletions playwright/.github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Playwright Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm install -g yarn && yarn
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Run Playwright tests
run: yarn playwright test
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30
8 changes: 8 additions & 0 deletions playwright/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

# Playwright
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
/playwright/.auth/
11 changes: 11 additions & 0 deletions playwright/loadusers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const filePath = "./myconext-server/src/test/resources/users.json";

try {
const fileContent = fs.readFileSync(filePath, 'utf8');
const users = JSON.parse(fileContent);
const result = db.users.insertMany(users);

print(`Successfully inserted ${result.insertedCount} documents into the 'users' collection.`);
} catch (e) {
print(`Error loading or inserting data: ${e.message}`);
}
11 changes: 11 additions & 0 deletions playwright/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "playwright",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"devDependencies": {
"@playwright/test": "^1.56.1",
"@types/node": "^24.9.1"
},
"scripts": {}
}
79 changes: 79 additions & 0 deletions playwright/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { defineConfig, devices } from '@playwright/test';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// import dotenv from 'dotenv';
// import path from 'path';
// dotenv.config({ path: path.resolve(__dirname, '.env') });

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('')`. */
// baseURL: 'http://localhost:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://localhost:3000',
// reuseExistingServer: !process.env.CI,
// },
});
53 changes: 53 additions & 0 deletions playwright/tests/myconext-gui-check-for-404s.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { expect, Page, test } from "@playwright/test"

async function getAllLinksFromPage(page: Page) {
// getByRole('link') only matches visible links
//
// if you want to check all links, you can use a CSS selector
// like 'locator("a")'
const links = page.getByRole("link")

const allLinks = await links.all()
const allLinkHrefs = await Promise.all(
allLinks.map((link) => link.getAttribute("href"))
)
const validHrefs = allLinkHrefs.reduce((links, link) => {
expect.soft(link, "link has no a proper href").not.toBeFalsy()

if (link && !link?.startsWith("mailto:") && !link?.startsWith("#"))
links.add(new URL(link, page.url()).href)
return links
}, new Set<string>())

return validHrefs
}

test.describe("No 404s on Checkly pages", () => {
test(`The docs have no 404s`, async ({ page }, testInfo) => {
await page.goto("http://localhost:3002")
const linkUrls = await getAllLinksFromPage(page)

for (const url of linkUrls) {
await test.step(`Checking link: ${url}`, async () => {
try {
// Note that some hosters / firewalls will block plain requests (Cloudflare, etc.)
// if that's the case for you, consider using `page.goto`
// or excluding particular URLs from the test
const response = await page.request.get(url)

expect
.soft(response.ok(), `${url} has no green status code`)
.toBeTruthy()
} catch {
expect.soft(null, `${url} has no green status code`).toBeTruthy()
}
})
}

testInfo.attach("checked-links.txt", {
body: Array.from(linkUrls).join("\n"),
})
})
})

// Source: https://github.com/checkly/playwright-examples/blob/main/404-detection/tests/no-404s.spec.ts
10 changes: 10 additions & 0 deletions playwright/tests/myconext-gui-check-home-page.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { test, expect } from '@playwright/test';

test('check generale page', async ({ page }) => {
await page.goto('http://localhost:3002');
await page.getByRole('link', {name: 'EN'}).click();
await expect(page.getByRole('heading', { name: 'eduID', exact: true })).toBeVisible();
await expect(page.getByRole('button', { name: 'My eduID' })).toBeVisible();
await expect(page.getByRole('button', { name: 'Create an eduID' }).first()).toBeVisible();

});
41 changes: 41 additions & 0 deletions playwright/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


"@playwright/test@^1.56.1":
version "1.56.1"
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.56.1.tgz#6e3bf3d0c90c5cf94bf64bdb56fd15a805c8bd3f"
integrity sha512-vSMYtL/zOcFpvJCW71Q/OEGQb7KYBPAdKh35WNSkaZA75JlAO8ED8UN6GUNTm3drWomcbcqRPFqQbLae8yBTdg==
dependencies:
playwright "1.56.1"

"@types/node@^24.9.1":
version "24.9.1"
resolved "https://registry.yarnpkg.com/@types/node/-/node-24.9.1.tgz#b7360b3c789089e57e192695a855aa4f6981a53c"
integrity sha512-QoiaXANRkSXK6p0Duvt56W208du4P9Uye9hWLWgGMDTEoKPhuenzNcC4vGUmrNkiOKTlIrBoyNQYNpSwfEZXSg==
dependencies:
undici-types "~7.16.0"

fsevents@2.3.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==

playwright-core@1.56.1:
version "1.56.1"
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.56.1.tgz#24a66481e5cd33a045632230aa2c4f0cb6b1db3d"
integrity sha512-hutraynyn31F+Bifme+Ps9Vq59hKuUCz7H1kDOcBs+2oGguKkWTU50bBWrtz34OUWmIwpBTWDxaRPXrIXkgvmQ==

playwright@1.56.1:
version "1.56.1"
resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.56.1.tgz#62e3b99ddebed0d475e5936a152c88e68be55fbf"
integrity sha512-aFi5B0WovBHTEvpM3DzXTUaeN6eN0qWnTkKx4NQaH4Wvcmc153PdaY2UBdSYKaGYw+UyWXSVyxDUg5DoPEttjw==
dependencies:
playwright-core "1.56.1"
optionalDependencies:
fsevents "2.3.2"

undici-types@~7.16.0:
version "7.16.0"
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-7.16.0.tgz#ffccdff36aea4884cbfce9a750a0580224f58a46"
integrity sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==
Loading