Tests
This commit is contained in:
@@ -9,7 +9,7 @@ export default defineConfig({
|
|||||||
baseUrl: "http://localhost:3000",
|
baseUrl: "http://localhost:3000",
|
||||||
viewportHeight: 900,
|
viewportHeight: 900,
|
||||||
viewportWidth: 1660,
|
viewportWidth: 1660,
|
||||||
supportFile: false,
|
supportFile: fileURLToPath(new URL("./src/cypress/support/commands.ts", import.meta.url)),
|
||||||
specPattern: "./src/cypress/e2e/**/*.{ts,js}",
|
specPattern: "./src/cypress/e2e/**/*.{ts,js}",
|
||||||
setupNodeEvents(on, config) {
|
setupNodeEvents(on, config) {
|
||||||
on("file:preprocessor", vitePreprocessor({
|
on("file:preprocessor", vitePreprocessor({
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ export const createCaller = createCallerFactory({
|
|||||||
"klimafaktoren": await import("../src/pages/api/klimafaktoren.ts"),
|
"klimafaktoren": await import("../src/pages/api/klimafaktoren.ts"),
|
||||||
"postleitzahlen": await import("../src/pages/api/postleitzahlen.ts"),
|
"postleitzahlen": await import("../src/pages/api/postleitzahlen.ts"),
|
||||||
"unterlage": await import("../src/pages/api/unterlage.ts"),
|
"unterlage": await import("../src/pages/api/unterlage.ts"),
|
||||||
"aufnahme": await import("../src/pages/api/aufnahme/index.ts"),
|
|
||||||
"admin/ausstellen": await import("../src/pages/api/admin/ausstellen.ts"),
|
"admin/ausstellen": await import("../src/pages/api/admin/ausstellen.ts"),
|
||||||
"admin/bestellbestaetigung": await import("../src/pages/api/admin/bestellbestaetigung.ts"),
|
"admin/bestellbestaetigung": await import("../src/pages/api/admin/bestellbestaetigung.ts"),
|
||||||
"admin/erinnern": await import("../src/pages/api/admin/erinnern.ts"),
|
"admin/erinnern": await import("../src/pages/api/admin/erinnern.ts"),
|
||||||
@@ -14,6 +13,7 @@ export const createCaller = createCallerFactory({
|
|||||||
"admin/registriernummer": await import("../src/pages/api/admin/registriernummer.ts"),
|
"admin/registriernummer": await import("../src/pages/api/admin/registriernummer.ts"),
|
||||||
"admin/stornieren": await import("../src/pages/api/admin/stornieren.ts"),
|
"admin/stornieren": await import("../src/pages/api/admin/stornieren.ts"),
|
||||||
"ausweise": await import("../src/pages/api/ausweise/index.ts"),
|
"ausweise": await import("../src/pages/api/ausweise/index.ts"),
|
||||||
|
"aufnahme": await import("../src/pages/api/aufnahme/index.ts"),
|
||||||
"auth/access-token": await import("../src/pages/api/auth/access-token.ts"),
|
"auth/access-token": await import("../src/pages/api/auth/access-token.ts"),
|
||||||
"auth/passwort-vergessen": await import("../src/pages/api/auth/passwort-vergessen.ts"),
|
"auth/passwort-vergessen": await import("../src/pages/api/auth/passwort-vergessen.ts"),
|
||||||
"auth/refresh-token": await import("../src/pages/api/auth/refresh-token.ts"),
|
"auth/refresh-token": await import("../src/pages/api/auth/refresh-token.ts"),
|
||||||
|
|||||||
@@ -1,13 +1,27 @@
|
|||||||
import fuelList from "#components/Ausweis/brennstoffListe.js";
|
import fuelList from "#components/Ausweis/brennstoffListe.js";
|
||||||
import { faker } from "@faker-js/faker";
|
import { faker } from "@faker-js/faker";
|
||||||
import { Enums } from "#lib/client/prisma.js";
|
import { Enums } from "#lib/client/prisma.js";
|
||||||
|
|
||||||
|
|
||||||
import "cypress-file-upload"
|
import "cypress-file-upload"
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
|
|
||||||
describe("Verbrauchsausweis erstellen Schritt 1", () => {
|
describe("Verbrauchsausweis erstellen Schritt 1", () => {
|
||||||
it("erstellt einen neuen Verbrauchsausweis Wohngebäude.", () => {
|
it("erstellt einen neuen Verbrauchsausweis Wohngebäude.", () => {
|
||||||
|
const email = faker.internet.email();
|
||||||
|
const passwort = "test1234";
|
||||||
|
const vorname = faker.person.firstName();
|
||||||
|
const nachname = faker.person.lastName();
|
||||||
|
const telefon = faker.phone.number()
|
||||||
|
|
||||||
|
const strasse = faker.location.streetAddress({ useFullAddress: true })
|
||||||
|
const plz = faker.location.zipCode("#####")
|
||||||
|
|
||||||
|
const preLogin = Math.random() > 0.5;
|
||||||
|
|
||||||
|
if (preLogin) {
|
||||||
|
cy.signup(email, passwort, vorname, nachname)
|
||||||
|
cy.login(email, passwort)
|
||||||
|
}
|
||||||
|
|
||||||
cy.visit("/energieausweis-erstellen/verbrauchsausweis-wohngebaeude");
|
cy.visit("/energieausweis-erstellen/verbrauchsausweis-wohngebaeude");
|
||||||
|
|
||||||
cy.wait(2000);
|
cy.wait(2000);
|
||||||
@@ -241,42 +255,42 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
|
|||||||
|
|
||||||
cy.url().should("contain", "/kundendaten");
|
cy.url().should("contain", "/kundendaten");
|
||||||
|
|
||||||
const email = faker.internet.email();
|
|
||||||
const passwort = "test1234";
|
|
||||||
const vorname = faker.person.firstName();
|
|
||||||
const nachname = faker.person.lastName();
|
|
||||||
const telefon = faker.phone.number()
|
|
||||||
|
|
||||||
const strasse = faker.location.streetAddress({ useFullAddress: true })
|
|
||||||
const plz = faker.location.zipCode("#####")
|
|
||||||
|
|
||||||
cy.get("input[name='vorname']").should("have.attr", "type", "text").type(vorname);
|
|
||||||
cy.get("input[name='name']").should("have.attr", "type", "text").type(nachname);
|
|
||||||
cy.get("input[name='telefon']").should("have.attr", "type", "text").type(telefon);
|
cy.get("input[name='telefon']").should("have.attr", "type", "text").type(telefon);
|
||||||
// Rechnung
|
// Rechnung
|
||||||
cy.get("input[name='rechnung_empfaenger']").should("have.attr", "type", "text").type(`${vorname} ${nachname}`);
|
if (preLogin) {
|
||||||
|
cy.get("input[name='rechnung_empfaenger']").should("have.attr", "type", "text").should("contain.value", `${vorname} ${nachname}`);
|
||||||
|
cy.get("input[name='vorname']").should("have.attr", "type", "text").should("contain.value", vorname);
|
||||||
|
cy.get("input[name='name']").should("have.attr", "type", "text").should("contain.value", nachname);
|
||||||
|
cy.get("input[name='rechnung_email']").should("have.attr", "type", "email").should("contain.value", email);
|
||||||
|
} else {
|
||||||
|
cy.get("input[name='rechnung_empfaenger']").should("have.attr", "type", "text").type(`${vorname} ${nachname}`);
|
||||||
|
cy.get("input[name='vorname']").should("have.attr", "type", "text").type(vorname);
|
||||||
|
cy.get("input[name='name']").should("have.attr", "type", "text").type(nachname);
|
||||||
|
cy.get("input[name='rechnung_email']").should("have.attr", "type", "email").type(email);
|
||||||
|
}
|
||||||
cy.get("input[name='rechnung_strasse']").should("have.attr", "type", "text").type(strasse);
|
cy.get("input[name='rechnung_strasse']").should("have.attr", "type", "text").type(strasse);
|
||||||
cy.get("input[name='rechnung_plz']").should("have.attr", "type", "text").type(plz);
|
cy.get("input[name='rechnung_plz']").should("have.attr", "type", "text").type(plz);
|
||||||
cy.get("[data-cy='plz-container']").children().first().click()
|
cy.get("[data-cy='plz-container']").children().first().click()
|
||||||
cy.get("input[name='rechnung_email']").should("have.attr", "type", "email").type(email);
|
|
||||||
|
|
||||||
cy.get("[data-cy='paypal']").click()
|
cy.get("[data-cy='paypal']").click()
|
||||||
|
|
||||||
cy.get("button[data-cy='bestellen']").click();
|
cy.get("button[data-cy='bestellen']").click();
|
||||||
|
|
||||||
cy.get("a[data-cy='registrieren']").should("be.visible").click();
|
if (!preLogin) {
|
||||||
|
cy.get("a[data-cy='registrieren']").should("be.visible").click();
|
||||||
|
|
||||||
// Wir sind jetzt registriert und können uns nun einloggen.
|
// Wir sind jetzt registriert und können uns nun einloggen.
|
||||||
// Die Email sollte automatisch eingetragen sein, da wir uns gerade registriert haben.
|
// Die Email sollte automatisch eingetragen sein, da wir uns gerade registriert haben.
|
||||||
cy.get("form[name='signup'] input[name='vorname']").should("be.visible").should("have.attr", "type", "text").type(vorname);
|
cy.get("form[name='signup'] input[name='vorname']").should("be.visible").should("have.attr", "type", "text").type(vorname);
|
||||||
cy.get("form[name='signup'] input[name='nachname']").should("be.visible").should("have.attr", "type", "text").type(nachname);
|
cy.get("form[name='signup'] input[name='nachname']").should("be.visible").should("have.attr", "type", "text").type(nachname);
|
||||||
cy.get("form[name='signup'] input[name='email']").should("be.visible").should("have.attr", "type", "email").should("contain.value", email);
|
cy.get("form[name='signup'] input[name='email']").should("be.visible").should("have.attr", "type", "email").should("contain.value", email);
|
||||||
cy.get("form[name='signup'] input[name='passwort']").should("be.visible").should("have.attr", "type", "password").type(passwort);
|
cy.get("form[name='signup'] input[name='passwort']").should("be.visible").should("have.attr", "type", "password").type(passwort);
|
||||||
|
|
||||||
cy.intercept({ method: "PUT", url: "**/api/user" }).as("signup")
|
cy.intercept({ method: "PUT", url: "**/api/user" }).as("signup")
|
||||||
cy.get("form[name='signup'] button[type='submit']").click();
|
cy.get("form[name='signup'] button[type='submit']").click();
|
||||||
cy.wait("@signup")
|
cy.wait("@signup")
|
||||||
cy.get("form[name='login'] button[type='submit']").click();
|
cy.get("form[name='login'] button[type='submit']").click();
|
||||||
|
}
|
||||||
|
|
||||||
cy.origin('https://www.mollie.com', () => {
|
cy.origin('https://www.mollie.com', () => {
|
||||||
// Jetzt sind wir auf der Mollie Seite, dort wählen wir den "paid" status aus
|
// Jetzt sind wir auf der Mollie Seite, dort wählen wir den "paid" status aus
|
||||||
|
|||||||
@@ -1,37 +1,40 @@
|
|||||||
/// <reference types="cypress" />
|
/// <reference types="cypress" />
|
||||||
// ***********************************************
|
|
||||||
// This example commands.ts shows you how to
|
import { API_ACCESS_TOKEN_COOKIE_NAME, API_REFRESH_TOKEN_COOKIE_NAME } from "#lib/constants.js"
|
||||||
// create various custom commands and overwrite
|
|
||||||
// existing commands.
|
Cypress.Commands.add("login", (email, passwort) => {
|
||||||
//
|
cy.visit("/auth/login")
|
||||||
// For more comprehensive examples of custom
|
|
||||||
// commands please read more here:
|
cy.get('input[name="email"]').type(email)
|
||||||
// https://on.cypress.io/custom-commands
|
cy.get('input[name="passwort"]').type(passwort)
|
||||||
// ***********************************************
|
|
||||||
//
|
cy.get('button[type="submit"]').click()
|
||||||
//
|
|
||||||
// -- This is a parent command --
|
cy.url().should("include", "/dashboard")
|
||||||
// Cypress.Commands.add('login', (email, password) => { ... })
|
|
||||||
//
|
// Wir sollten nun einen Access Token und Refresh Token in unseren Cookies sehen.
|
||||||
//
|
cy.getCookie(API_ACCESS_TOKEN_COOKIE_NAME).should("exist")
|
||||||
// -- This is a child command --
|
cy.getCookie(API_REFRESH_TOKEN_COOKIE_NAME).should("exist")
|
||||||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
|
})
|
||||||
//
|
|
||||||
//
|
Cypress.Commands.add("signup", (email, passwort, vorname, name) => {
|
||||||
// -- This is a dual command --
|
cy.visit("/auth/signup")
|
||||||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
|
|
||||||
//
|
cy.get('input[name="email"]').type(email)
|
||||||
//
|
cy.get('input[name="passwort"]').type(passwort)
|
||||||
// -- This will overwrite an existing command --
|
cy.get('input[name="vorname"]').type(vorname)
|
||||||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
cy.get('input[name="name"]').type(name)
|
||||||
//
|
|
||||||
// declare global {
|
cy.get('button[type="submit"]').click()
|
||||||
// namespace Cypress {
|
|
||||||
// interface Chainable {
|
cy.url().should("include", "/auth/login")
|
||||||
// login(email: string, password: string): Chainable<void>
|
})
|
||||||
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
|
|
||||||
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
|
declare global {
|
||||||
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
|
namespace Cypress {
|
||||||
// }
|
interface Chainable {
|
||||||
// }
|
login(email: string, passwort: string): Chainable<void>
|
||||||
// }
|
signup(email: string, passwort: string, vorname: string, name: string): Chainable<void>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
---
|
---
|
||||||
return Astro.redirect("/dashboard/objekte/1", 301);
|
return Astro.redirect("/dashboard/objekte/1", 301);
|
||||||
|
|
||||||
---
|
---
|
||||||
Reference in New Issue
Block a user