Skip to content

Commit

Permalink
Merge branch 'main' into SPSH-1359
Browse files Browse the repository at this point in the history
  • Loading branch information
phaelcg committed Nov 19, 2024
2 parents 1b0995d + eca479e commit c23890b
Show file tree
Hide file tree
Showing 28 changed files with 265 additions and 159 deletions.
54 changes: 48 additions & 6 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,57 @@
/* eslint-env node */
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/stylistic',
'plugin:playwright/recommended'
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/stylistic',
'plugin:playwright/recommended'
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
root: true,
parserOptions: {
sourceType: 'module'
ecmaVersion: 'latest',
parser: '@typescript-eslint/parser'
},
rules: {
// 'prettier/prettier': ['warn'],
// 'import/no-extraneous-dependencies': ['error', { devDependencies: false }],
// 'import/no-cycle': ['error'],
// ...typescriptConfigs.recommended.rules,
// ...playwright.configs['flat/recommended'].rules
'no-void': ['error', { allowAsStatement: true }],
'no-console': ['warn'],
'max-classes-per-file': ['error', 1],
'class-methods-use-this': 'off',
'no-param-reassign': 'warn',
'no-underscore-dangle': 'error',
'@typescript-eslint/no-inferrable-types': ['off'],
'@typescript-eslint/typedef': [
'warn',
{
arrayDestructuring: true,
arrowParameter: true,
memberVariableDeclaration: true,
objectDestructuring: true,
parameter: true,
propertyDeclaration: true,
variableDeclaration: true,
variableDeclarationIgnoreFunction: true
}
],
// '@typescript-eslint/unbound-method': 'error',
// '@typescript-eslint/explicit-member-accessibility': 'error',
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '_.+' }],
// "@typescript-eslint/no-unnecessary-condition": "error",
'@typescript-eslint/no-empty-interface': [
'error',
{
allowSingleExtends: true
}
],

// currently disabled rules - TODO: fix them
'playwright/no-conditional-in-test': 'off'
}
}
4 changes: 2 additions & 2 deletions .github/workflows/manuell_staging.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Manuell alle Tests(staging)
name: Manuell stage long
on:
workflow_dispatch:
jobs:
Expand All @@ -19,7 +19,7 @@ jobs:
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: ENV='stage' FRONTEND_URL='https://spsh.staging.spsh.dbildungsplattform.de/' npx playwright test -g "@stage"
run: ENV='stage' FRONTEND_URL='https://spsh.staging.spsh.dbildungsplattform.de/' npx playwright test -g "@stage" --project "chromium"
env:
USER: '${{ secrets.USER }}'
PW: '${{ secrets.PW }}'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: List Playwright tests
run: npx playwright test --list --grep "@short"
- name: Run Playwright tests
run: npx playwright test --config=playwright.config.ts --grep "@short"
run: npx playwright test --config=playwright.config.ts --grep "@short" --project "chromium"

env:
USER: '${{ secrets.USER }}'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/schedule_dev.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Scheduled Playwright Alle Tests(main)
name: Scheduled main long
on:
workflow_dispatch:
schedule:
Expand All @@ -21,7 +21,7 @@ jobs:
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: ENV='dev' FRONTEND_URL='https://main.dev.spsh.dbildungsplattform.de/' npx playwright test -g "@long"
run: ENV='dev' FRONTEND_URL='https://main.dev.spsh.dbildungsplattform.de/' npx playwright test -g "@long" --project "chromium"
env:
USER: '${{ secrets.USER }}'
PW: '${{ secrets.PW }}'
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/schedule_dev_crossBrowser_Firefox.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Scheduled main crossBrowser Firefox
on:
workflow_dispatch:
schedule:
- cron: '10 6 * * *'
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Remove Microsoft APT and Update Packages
run: |
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update || true
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: ENV='dev' FRONTEND_URL='https://main.dev.spsh.dbildungsplattform.de/' npx playwright test -g "@crossBrowser" --project "firefox"
env:
USER: '${{ secrets.USER }}'
PW: '${{ secrets.PW }}'
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30npm login
- uses: RocketChat/[email protected]
if: failure()
with:
type: ${{ job.status }}
job_name: 'Playwright Job Status: '
url: ${{ secrets.RC_WEBHOOK }}
channel: '#SPSH-Test-Automation'
username: Playwright Notificator
4 changes: 2 additions & 2 deletions .github/workflows/schedule_staging.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Scheduled Playwright Smoketest(staging)
name: Scheduled stage smoke
on:
workflow_dispatch:
schedule:
Expand All @@ -21,7 +21,7 @@ jobs:
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: ENV='stage' FRONTEND_URL='https://spsh.staging.spsh.dbildungsplattform.de/' npx playwright test -g "@smoke"
run: ENV='stage' FRONTEND_URL='https://spsh.staging.spsh.dbildungsplattform.de/' npx playwright test -g "@smoke" --project "chromium"
env:
USER: '${{ secrets.USER }}'
PW: '${{ secrets.PW }}'
Expand Down
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"printWidth": 120,
"singleAttributePerLine": true,
"singleQuote": true
}
2 changes: 1 addition & 1 deletion base/api/testHelperOrganisation.page.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Page, expect } from '@playwright/test';
import { faker } from "@faker-js/faker/locale/de";

const FRONTEND_URL = process.env.FRONTEND_URL || "";
const FRONTEND_URL: string | undefined = process.env.FRONTEND_URL || "";

export async function createOrganisation(page: Page, name: string): Promise<string> {
const response = await page.request.post(FRONTEND_URL + 'api/organisationen/', {
Expand Down
4 changes: 2 additions & 2 deletions base/api/testHelperPerson.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { LoginPage } from '../../pages/LoginView.page';
import { faker } from '@faker-js/faker';
import { lehrkraftOeffentlichRolle } from '../roles';

const FRONTEND_URL = process.env.FRONTEND_URL || "";
const FRONTEND_URL: string | undefined = process.env.FRONTEND_URL || "";

export async function createPerson(page: Page, familienname: string, vorname: string, organisationId: string, rolleId: string, koPersNr?: string): Promise<UserInfo> {
const requestData = {
Expand Down Expand Up @@ -94,7 +94,7 @@ export async function getPersonId(page: Page, Benutzername: string): Promise<str

export async function createTeacherAndLogin(page) {
const header = new HeaderPage(page);
const login = new LoginPage(page);
const login: LoginPage = new LoginPage(page);
const vorname = "TAuto-PW-V-" + faker.person.firstName();
const nachname = "TAuto-PW-N-" + faker.person.lastName();
const organisation = 'Testschule Schulportal';
Expand Down
2 changes: 1 addition & 1 deletion base/api/testHelperRolle.page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Page, expect } from '@playwright/test';

const FRONTEND_URL = process.env.FRONTEND_URL || "";
const FRONTEND_URL: string | undefined = process.env.FRONTEND_URL || "";

export async function createRolle(page: Page, rollenArt: string, organisationId: string, rolleName?: string): Promise<string> {
const response = await page.request.post(FRONTEND_URL + 'api/rolle/', {
Expand Down
2 changes: 1 addition & 1 deletion base/api/testHelperServiceprovider.page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Page, expect } from '@playwright/test';

const FRONTEND_URL = process.env.FRONTEND_URL || "";
const FRONTEND_URL: string | undefined = process.env.FRONTEND_URL || "";

export async function getSPId(page: Page, nameSP: string): Promise<string> {
const response = await page.request.get(FRONTEND_URL + `api/provider/all`, {});
Expand Down
3 changes: 2 additions & 1 deletion base/tags.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const LONG = '@long';
export const SHORT = '@short';
export const STAGE = '@stage';
export const SMOKE = '@smoke';
export const SMOKE = '@smoke';
export const BROWSER = '@crossBrowser';
17 changes: 14 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
{
"name": "schulportal-testautomatisierung",
"description": "",
"version": "0.6.0",
"main": "index.js",
"type": "module",
"directories": {
"test": "tests"
},
"keywords": [],
"author": "Dataport AöR",
"license": "EUPL-1.2",
"scripts": {
"lint": "eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
},
"devDependencies": {
"@playwright/test": "^1.47.2",
"@types/node": "^20.16.10",
Expand All @@ -9,9 +23,6 @@
"eslint-plugin-playwright": "^0.18.0",
"typescript": "^5.6.2"
},
"scripts": {
"lint": "eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
},
"dependencies": {
"@faker-js/faker": "^8.4.1",
"@fast-csv/format": "^4.3.5",
Expand Down
5 changes: 2 additions & 3 deletions pages/MenuBar.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { RolleCreationViewPage } from "./admin/RolleCreationView.page";
import {RolleManagementViewPage} from "./admin/RolleManagementView.page";
import { SchuleManagementViewPage } from "./admin/SchuleManagementView.page";
import { SchuleCreationViewPage } from "./admin/SchuleCreationView.page";
import { HeaderPage } from "./Header.page";

export class MenuPage {
readonly page: Page;
Expand All @@ -24,9 +25,7 @@ export class MenuPage {

constructor(page) {
this.page = page;
this.header_label_Navigation = page.locator(
'[data-testid="menu-bar-title"] .v-list-item-title',
);
this.header_label_Navigation = page.locator('[data-testid="menu-bar-title"] .v-list-item-title');
this.button_BackStartpage = page.getByTestId("back-to-start-link");
this.label_Benutzerverwaltung = page.locator(
'[data-testid="person-management-title"] .v-list-item-title',
Expand Down
2 changes: 1 addition & 1 deletion pages/admin/KlasseManagementView.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class KlasseManagementViewPage{
readonly button_KlasseLoeschen: Locator;
readonly button_SchliesseKlasseLoeschenDialog: Locator;

constructor(page){
constructor(page: Page){
this.page = page;
this.text_h1_Administrationsbereich = page.getByTestId('admin-headline');
this.text_h2_Klassenverwaltung = page.getByTestId('layout-card-headline');
Expand Down
2 changes: 1 addition & 1 deletion pages/admin/RolleCreationConfirm.page.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Locator, Page } from "@playwright/test";
import { type Locator, Page } from "@playwright/test";
import { RolleManagementViewPage } from "./RolleManagementView.page";

export class RolleCreationConfirmPage {
Expand Down
2 changes: 1 addition & 1 deletion pages/admin/RolleManagementView.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class RolleManagementViewPage {
readonly table_header_Administrationsebene: Locator;
private readonly rolleOverviewTable: Locator;

constructor(page) {
constructor(page: Page) {
this.page = page;
this.text_h1_Administrationsbereich = page.getByTestId("admin-headline");
this.text_h2_Rollenverwaltung = page.getByTestId("layout-card-headline");
Expand Down
30 changes: 18 additions & 12 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { defineConfig, devices } from "@playwright/test";
import dotenv from "dotenv";
import * as path from "node:path";
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const FRONTEND_URL = process.env.FRONTEND_URL || "";

Expand Down Expand Up @@ -34,20 +38,22 @@ export default defineConfig({
use: {
...devices["Desktop Chrome"],
viewport: { width: 1280, height: 720 },
ignoreHTTPSErrors: true,
},
ignoreHTTPSErrors: true
}
},

{
name: "firefox",
use: {
...devices["Desktop Firefox"],
ignoreHTTPSErrors: true
}
}

// {
// name: 'firefox',
// use: { ...devices['Desktop Firefox'] },
// },
/*
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
*/
// name: 'webkit',
// use: { ...devices['Desktop Safari'] },
// }

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
Expand Down
20 changes: 10 additions & 10 deletions tests/Klasse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ import { KlasseCreationViewPage } from "../pages/admin/KlasseCreationView.page";
import { KlasseManagementViewPage } from "../pages/admin/KlasseManagementView.page";
import { faker } from "@faker-js/faker/locale/de";
import { HeaderPage } from "../pages/Header.page";
import { LONG, SHORT, STAGE } from "../base/tags";
import { LONG, SHORT, STAGE, BROWSER } from "../base/tags";
import { deleteClassByName } from "../base/testHelperDeleteTestdata.ts";

const PW = process.env.PW;
const ADMIN = process.env.USER;
const FRONTEND_URL = process.env.FRONTEND_URL || "";
const PW: string | undefined = process.env.PW;
const ADMIN: string | undefined = process.env.USER;
const FRONTEND_URL: string | undefined = process.env.FRONTEND_URL || "";

test.describe(`Testfälle für die Administration von Klassen: Umgebung: ${process.env.UMGEBUNG}: URL: ${process.env.FRONTEND_URL}:`, () => {
let className: string[] = []; // Im afterEach Block werden alle Testdaten gelöscht

test.beforeEach(async ({ page }) => {
await test.step(`Login`, async () => {
const landing = new LandingPage(page);
const startseite = new StartPage(page);
const login = new LoginPage(page);
const landing: LandingPage = new LandingPage(page);
const startseite: StartPage = new StartPage(page);
const login: LoginPage = new LoginPage(page);

await page.goto(FRONTEND_URL);
await landing.button_Anmelden.click();
Expand All @@ -45,7 +45,7 @@ test.describe(`Testfälle für die Administration von Klassen: Umgebung: ${proce
});

test("Eine Klasse als Landesadmin anlegen und die Klasse anschließend in der Ergebnisliste suchen und dann löschen", {tag: [LONG, SHORT, STAGE]}, async ({ page }) => {
const startseite = new StartPage(page);
const startseite: StartPage = new StartPage(page);
const menue = new MenuPage(page);
const klasseCreationView = new KlasseCreationViewPage(page);
const klasseManagementView = new KlasseManagementViewPage(page);
Expand Down Expand Up @@ -84,7 +84,7 @@ test.describe(`Testfälle für die Administration von Klassen: Umgebung: ${proce
});

test("Ergebnisliste Klassen als Landesadmin auf Vollständigkeit prüfen", {tag: [LONG, SHORT, STAGE]}, async ({ page }) => {
const startseite = new StartPage(page);
const startseite: StartPage = new StartPage(page);
const menue = new MenuPage(page);
const klasseManagementView = new KlasseManagementViewPage(page);

Expand All @@ -100,7 +100,7 @@ test.describe(`Testfälle für die Administration von Klassen: Umgebung: ${proce
});
});

test("Eine Klasse als Landesadmin anlegen und die Bestätigungsseite vollständig prüfen", {tag: [LONG, STAGE]}, async ({ page }) => {
test("Eine Klasse als Landesadmin anlegen und die Bestätigungsseite vollständig prüfen", {tag: [LONG, STAGE, BROWSER]}, async ({ page }) => {
const klasseCreationView = new KlasseCreationViewPage(page);
const dienststellennummer = '1111111';
const nameSchule = "Testschule Schulportal";
Expand Down
Loading

0 comments on commit c23890b

Please sign in to comment.