Skip to content

Commit

Permalink
Merge branch 'main' into SPSH-1247
Browse files Browse the repository at this point in the history
  • Loading branch information
YoussefBouch authored Nov 19, 2024
2 parents 7eaa634 + 5c258d7 commit e2d66c7
Show file tree
Hide file tree
Showing 30 changed files with 366 additions and 179 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
10 changes: 10 additions & 0 deletions pages/ProfileView.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export class ProfilePage{
readonly cardHeadline_Passwort: Locator;
readonly icon_Schluessel_Passwort: Locator;
readonly button_NeuesPasswortSetzen: Locator;
readonly button_PasswortAendern: Locator;
readonly label_username: Locator;
readonly text_p_LoginPrompt: Locator;
readonly input_password: Locator;
// 2FA
readonly cardHeadline_2FA: Locator;
readonly icon_Schild2FA: Locator;
Expand Down Expand Up @@ -72,9 +76,15 @@ export class ProfilePage{
// Passwort
this.cardHeadline_Passwort = page.getByTestId('new-password-card');
this.button_NeuesPasswortSetzen = page.getByTestId('open-change-password-dialog');
this.button_PasswortAendern = page.getByTestId('change-password-button');
this.label_username = page.locator('#kc-attempted-username');
this.text_p_LoginPrompt = page.getByTestId('login-prompt-text');
this.input_password = page.getByTestId('password-input');

// 2FA
this.cardHeadline_2FA = page.getByTestId('two-factor-card');
this.text_no2FA = page.getByText('Es wurde noch kein zweiter Faktor für Sie eingerichtet.');
this.button_2FAEinrichten = page.getByTestId('open-2FA-self-service-dialog-icon');

}
}
2 changes: 1 addition & 1 deletion pages/admin/KlasseManagementView.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class KlasseManagementViewPage{
readonly tableRows: Locator;
readonly footerDataTable: FooterDataTablePage;

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: 2 additions & 0 deletions pages/admin/PersonCreationView.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class PersonCreationViewPage{
readonly data_Organisationsebene: Locator;
readonly label_Klasse: Locator;
readonly data_Klasse: Locator;
readonly listbox_Rolle: Locator;

constructor(page){
// Anlage Person
Expand Down Expand Up @@ -70,5 +71,6 @@ export class PersonCreationViewPage{
this.input_EinstiegsPasswort = page.locator('[data-testid="password-output-field"] input');
this.button_ZurueckErgebnisliste = page.getByTestId('back-to-list-button');
this.button_WeiterenBenutzerAnlegen = page.getByTestId('create-another-person-button');
this.listbox_Rolle = page.locator('.v-list');
}
}
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
Loading

0 comments on commit e2d66c7

Please sign in to comment.