Skip to content

Commit

Permalink
Merge branch 'main' of github.com:dBildungsplattform/schulportal-test…
Browse files Browse the repository at this point in the history
…automatisierung into SPSH-1131
  • Loading branch information
jaggarnaut committed Nov 19, 2024
2 parents ca640f7 + 5c258d7 commit 53ae459
Show file tree
Hide file tree
Showing 42 changed files with 693 additions and 316 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 '../rollen';

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
2 changes: 2 additions & 0 deletions base/organisation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const testschule = "Testschule Schulportal";
export const testschule665 = "Testschule-PW665";
1 change: 1 addition & 0 deletions base/rollentypen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const typelehrer = "LEHR";
1 change: 1 addition & 0 deletions base/sp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const email = "E-Mail";
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';
15 changes: 15 additions & 0 deletions base/testHelperGenerateTestdataNames.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { faker } from "@faker-js/faker/locale/de";

export async function generateLehrerVorname(){
return "TAuto-PW-V-" + faker.person.firstName();
}

export async function generateLehrerNachname(){
return "TAuto-PW-N-" + faker.person.lastName();
}

export async function generateRolleName(){
return "TAuto-PW-R-" + faker.lorem.word({ length: { min: 8, max: 12 }});
}


13 changes: 13 additions & 0 deletions base/testHelperUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import moment from 'moment';

export async function gotoTargetURL(page, target: string) {
await page.goto(target);
}

export async function generateDateToday() {
return moment().format('DD.MM.YYYY');
}

export async function generateDateFuture(days: number, months: number) {
return moment().add({ days: days, months: months }).format('DD.MM.YYYY');
}
11 changes: 10 additions & 1 deletion package-lock.json

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

20 changes: 16 additions & 4 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,15 +23,13 @@
"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",
"@fast-csv/parse": "^4.3.6",
"fast-csv": "^4.3.6",
"generate-password-ts": "^1.6.5"
"generate-password-ts": "^1.6.5",
"moment": "^2.30.1"
},
"name": "schulportal-testautomatisierung",
"description": "",
Expand Down
2 changes: 1 addition & 1 deletion pages/FromAnywhere.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function FromAnywhere(page: Page) {
return {
async start(): Promise<LandingPage> {
return page
.goto(process.env.FRONTEND_URL as string)
.goto('/')
.then(() => new LandingPage(page));
},
};
Expand Down
4 changes: 1 addition & 3 deletions pages/MenuBar.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,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/KlasseCreationView.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class KlasseCreationViewPage{
this.button_Schliessen = page.getByTestId('close-layout-card-button');
this.combobox_Schulstrukturknoten = page.getByTestId('schule-select').locator('.v-input__control');
this.input_Klassenname = page.getByTestId('klassenname-input').locator('input');
this.button_KlasseAnlegen = page.getByTestId('klasse-form-create-button');
this.button_KlasseAnlegen = page.getByTestId('klasse-form-submit-button');
// Bestätigungsseite Klasse
this.text_success = page.getByTestId('klasse-success-text');
this.icon_success = page.locator('.mdi-check-circle');
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
Loading

0 comments on commit 53ae459

Please sign in to comment.