Skip to content

Commit

Permalink
Spsh 1059 config eslint (#89)
Browse files Browse the repository at this point in the history
* added ellinter rules

* new rules for eslint

* minor changes
  • Loading branch information
jakobmadp authored Nov 19, 2024
1 parent 6623393 commit eca479e
Show file tree
Hide file tree
Showing 22 changed files with 186 additions and 124 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'
}
}
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
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
4 changes: 4 additions & 0 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
16 changes: 8 additions & 8 deletions tests/Klasse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ import { HeaderPage } from "../pages/Header.page";
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 Down
12 changes: 6 additions & 6 deletions tests/MenuBar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import { MenuPage } from '../pages/MenuBar.page';
import { HeaderPage } from "../pages/Header.page";
import { LONG, SHORT, STAGE, BROWSER } from '../base/tags';

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 Hauptmenue-Leiste: Umgebung: ${process.env.UMGEBUNG}: URL: ${process.env.FRONTEND_URL}:`, () => {
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 Down
32 changes: 16 additions & 16 deletions tests/Person.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import { LONG, SHORT, STAGE, BROWSER } from "../base/tags";
import { deletePersonByUsername, deleteRolleById, deleteRolleByName } from "../base/testHelperDeleteTestdata.ts";
import { landesadminRolle, schuelerRolle, schuladminOeffentlichRolle } from "../base/roles.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 || "";

let username: string[] = []; // Im afterEach Block werden alle Testdaten gelöscht
let roleId: string[] = []; // Im afterEach Block werden alle Testdaten gelöscht
Expand All @@ -39,9 +39,9 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro

test.afterEach(async ({ page }) => {
const header = new HeaderPage(page);
const landing = new LandingPage(page);
const login = new LoginPage(page);
const startseite = new StartPage(page);
const landing: LandingPage = new LandingPage(page);
const login: LoginPage = new LoginPage(page);
const startseite: StartPage = new StartPage(page);

await test.step(`Testdaten(Benutzer) löschen via API`, async () => {
if (username) { // nur wenn der Testfall auch mind. einen Benutzer angelegt hat
Expand Down Expand Up @@ -84,9 +84,9 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro
test("Einen Benutzer mit der Rolle Lehrkraft anlegen als Landesadmin und anschließend mit diesem Benutzer anmelden", {tag: [LONG, SHORT, STAGE]}, async ({
page,
}) => {
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);
const menue = new MenuPage(page);
const personCreationView = new PersonCreationViewPage(page);
const personManagementView = new PersonManagementViewPage(page);
Expand Down Expand Up @@ -140,7 +140,7 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro
});

test("Einen Benutzer mit der Rolle Landesadmin anlegen", {tag: [LONG, SHORT, STAGE]}, async ({ page }) => {
const startseite = new StartPage(page);
const startseite: StartPage = new StartPage(page);
const menue = new MenuPage(page);
const personCreationView = new PersonCreationViewPage(page);

Expand Down Expand Up @@ -175,7 +175,7 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro
});

test("Einen Benutzer mit der Rolle LiV anlegen als Landesadmin", {tag: [LONG, SHORT, STAGE]}, async ({ page }) => {
const startseite = new StartPage(page);
const startseite: StartPage = new StartPage(page);
const menue = new MenuPage(page);
const personCreationView = new PersonCreationViewPage(page);

Expand Down Expand Up @@ -268,7 +268,7 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro
);

test("Einen Benutzer mit der Rolle Schueler anlegen als Landesadmin", {tag: [LONG, SHORT, STAGE]}, async ({ page }) => {
const startseite = new StartPage(page);
const startseite: StartPage = new StartPage(page);
const menue = new MenuPage(page);
const personCreationView = new PersonCreationViewPage(page);

Expand Down Expand Up @@ -328,7 +328,7 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro
});

test("Prüfung auf korrekte Rollen in dem Dropdown 'Rolle' nach Auswahl der Organisation bei Anlage eines Benutzer in der Rolle Landesadmin", {tag: [LONG, STAGE]}, async ({page}) => {
const startseite = new StartPage(page);
const startseite: StartPage = new StartPage(page);
const menue = new MenuPage(page);
const personCreationView = new PersonCreationViewPage(page);

Expand Down Expand Up @@ -509,9 +509,9 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro
});

test("Mehrere Benutzer hintereinander anlegen in der Rolle Landesadmin für die Rollenarten LERN und LEHR und die Bestätigungsseiten vollständig prüfen", {tag: [LONG, SHORT, STAGE]}, async ({ page }) => {
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);
const header = new HeaderPage(page);
const personCreationView = new PersonCreationViewPage(page);
let userInfo: UserInfo;
Expand Down
12 changes: 6 additions & 6 deletions tests/PersonBearbeiten.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ let rolleId: string[] = []; // Im afterEach Block werden alle Testdaten gelösch
test.describe(`Testfälle für die Administration von Personen": Umgebung: ${process.env.UMGEBUNG}: URL: ${process.env.FRONTEND_URL}:`, () => {
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('/');
await landing.button_Anmelden.click();
await login.login(ADMIN, PW);
Expand Down Expand Up @@ -75,9 +75,9 @@ test.describe(`Testfälle für die Administration von Personen": Umgebung: ${pro
const personManagementView = new PersonManagementViewPage(page);
const PersonDetailsView = new PersonDetailsViewPage(page);
const header = new HeaderPage(page);
const landing = new LandingPage(page);
const login = new LoginPage(page);
const startseite = new StartPage(page);
const landing: LandingPage = new LandingPage(page);
const login: LoginPage = new LoginPage(page);
const startseite: StartPage = new StartPage(page);

const addminVorname = "TAuto-PW-V-" + faker.person.firstName();
const adminNachname = "TAuto-PW-N-" + faker.person.lastName();
Expand Down
Loading

0 comments on commit eca479e

Please sign in to comment.