getMain #465
@@ -9,7 +9,7 @@ export default defineConfig({
|
||||
baseUrl: "http://localhost:3000",
|
||||
viewportHeight: 900,
|
||||
viewportWidth: 1660,
|
||||
supportFile: false,
|
||||
supportFile: fileURLToPath(new URL("./src/cypress/support/commands.ts", import.meta.url)),
|
||||
specPattern: "./src/cypress/e2e/**/*.{ts,js}",
|
||||
setupNodeEvents(on, config) {
|
||||
on("file:preprocessor", vitePreprocessor({
|
||||
|
||||
@@ -5,7 +5,6 @@ export const createCaller = createCallerFactory({
|
||||
"klimafaktoren": await import("../src/pages/api/klimafaktoren.ts"),
|
||||
"postleitzahlen": await import("../src/pages/api/postleitzahlen.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/bestellbestaetigung": await import("../src/pages/api/admin/bestellbestaetigung.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/stornieren": await import("../src/pages/api/admin/stornieren.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/passwort-vergessen": await import("../src/pages/api/auth/passwort-vergessen.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 { faker } from "@faker-js/faker";
|
||||
import { Enums } from "#lib/client/prisma.js";
|
||||
|
||||
|
||||
import "cypress-file-upload"
|
||||
import moment from "moment";
|
||||
|
||||
describe("Verbrauchsausweis erstellen Schritt 1", () => {
|
||||
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.wait(2000);
|
||||
@@ -241,42 +255,42 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
|
||||
|
||||
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);
|
||||
// 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_plz']").should("have.attr", "type", "text").type(plz);
|
||||
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("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.
|
||||
// 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='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='passwort']").should("be.visible").should("have.attr", "type", "password").type(passwort);
|
||||
// Wir sind jetzt registriert und können uns nun einloggen.
|
||||
// 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='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='passwort']").should("be.visible").should("have.attr", "type", "password").type(passwort);
|
||||
|
||||
cy.intercept({ method: "PUT", url: "**/api/user" }).as("signup")
|
||||
cy.get("form[name='signup'] button[type='submit']").click();
|
||||
cy.wait("@signup")
|
||||
cy.get("form[name='login'] button[type='submit']").click();
|
||||
cy.intercept({ method: "PUT", url: "**/api/user" }).as("signup")
|
||||
cy.get("form[name='signup'] button[type='submit']").click();
|
||||
cy.wait("@signup")
|
||||
cy.get("form[name='login'] button[type='submit']").click();
|
||||
}
|
||||
|
||||
cy.origin('https://www.mollie.com', () => {
|
||||
// Jetzt sind wir auf der Mollie Seite, dort wählen wir den "paid" status aus
|
||||
|
||||
@@ -1,37 +1,40 @@
|
||||
/// <reference types="cypress" />
|
||||
// ***********************************************
|
||||
// This example commands.ts shows you how to
|
||||
// create various custom commands and overwrite
|
||||
// existing commands.
|
||||
//
|
||||
// For more comprehensive examples of custom
|
||||
// commands please read more here:
|
||||
// https://on.cypress.io/custom-commands
|
||||
// ***********************************************
|
||||
//
|
||||
//
|
||||
// -- This is a parent command --
|
||||
// Cypress.Commands.add('login', (email, password) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a child command --
|
||||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a dual command --
|
||||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This will overwrite an existing command --
|
||||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
||||
//
|
||||
// declare global {
|
||||
// namespace Cypress {
|
||||
// interface Chainable {
|
||||
// login(email: string, password: string): Chainable<void>
|
||||
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
|
||||
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
|
||||
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
import { API_ACCESS_TOKEN_COOKIE_NAME, API_REFRESH_TOKEN_COOKIE_NAME } from "#lib/constants.js"
|
||||
|
||||
Cypress.Commands.add("login", (email, passwort) => {
|
||||
cy.visit("/auth/login")
|
||||
|
||||
cy.get('input[name="email"]').type(email)
|
||||
cy.get('input[name="passwort"]').type(passwort)
|
||||
|
||||
cy.get('button[type="submit"]').click()
|
||||
|
||||
cy.url().should("include", "/dashboard")
|
||||
|
||||
// Wir sollten nun einen Access Token und Refresh Token in unseren Cookies sehen.
|
||||
cy.getCookie(API_ACCESS_TOKEN_COOKIE_NAME).should("exist")
|
||||
cy.getCookie(API_REFRESH_TOKEN_COOKIE_NAME).should("exist")
|
||||
})
|
||||
|
||||
Cypress.Commands.add("signup", (email, passwort, vorname, name) => {
|
||||
cy.visit("/auth/signup")
|
||||
|
||||
cy.get('input[name="email"]').type(email)
|
||||
cy.get('input[name="passwort"]').type(passwort)
|
||||
cy.get('input[name="vorname"]').type(vorname)
|
||||
cy.get('input[name="name"]').type(name)
|
||||
|
||||
cy.get('button[type="submit"]').click()
|
||||
|
||||
cy.url().should("include", "/auth/login")
|
||||
})
|
||||
|
||||
declare global {
|
||||
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);
|
||||
|
||||
---
|
||||
Reference in New Issue
Block a user