GEG Nachweis Wohnen Test

This commit is contained in:
Moritz Utcke
2025-03-13 17:23:54 -03:00
parent 9ad163a469
commit 4378f25642
2 changed files with 127 additions and 1 deletions

View File

@@ -0,0 +1,125 @@
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.", () => {
cy.visit("/angebot-anfragen/geg-nachweis-wohnen-anfragen");
cy.wait(2000);
// Wir überprüfen, ob alle Ausstelgründe vorhanden sind, diese sollten genau so viele sein wie in der Datenbank vorhanden sind.
cy.get("select[data-cy='ausstellgrund']")
.select(
faker.number.int({
min: 1,
max: [Enums.Ausstellgrund.Modernisierung, Enums.Ausstellgrund.Neubau].length - 1,
})
)
// Gebäudetyp
cy.get("select[name='gebaeudetyp']").then(($dropdown) => {
const options = $dropdown.find('option');
// Select the option at the random index
cy.get("select[name='gebaeudetyp']").select(options.eq(faker.number.int({ min: 1, max: options.length - 1 })).val() as string);
});
// Jetzt Füllen wir das Baujahr vom Gebäude aus.
cy.get("input[name='baujahr_gebaeude']")
.should("have.attr", "type", "number")
.type(
faker.number.int({ min: 1900, max: 2021 }).toString() +
"{enter}",
{ delay: 50 }
);
// Jetzt Füllen wir das Baujahr der Heizung aus.
cy.get("input[name='baujahr_heizung']")
.should("have.attr", "type", "number")
.type(
faker.number.int({ min: 1900, max: 2021 }).toString() +
"{enter}",
{ delay: 50 }
);
// Adresse
cy.get("input[name='adresse']").type(faker.location.streetAddress());
// Postleitzahl
cy.get("input[name='plz']").type(
faker.location.zipCode({
format: "#####",
})
);
// TODO: Ort - Dieser wird aus der Datenbank abgefragt, wir müssen also warten, bis der Dropdown da ist.
cy.get("[data-cy='plz-container']").find("button").first().click()
// Nutzflaeche
cy.get("input[name='nutzflaeche']")
.should("have.attr", "type", "number")
.type(faker.number.int({ min: 50, max: 1000 }).toString());
// Keller
cy.get("select[name='keller']").find("option:not([disabled])").should("have.length", (["BEHEIZT", "NICHT_VORHANDEN", "UNBEHEIZT"] as Enums.Heizungsstatus[]).length).parent().select(faker.number.int({
max: Object.values(Enums.Heizungsstatus).length,
min: 1
}));
// Dachgeschoss
cy.get("select[name='dachgeschoss']").find("option:not([disabled])").should("have.length", (["BEHEIZT", "NICHT_VORHANDEN", "UNBEHEIZT"] as Enums.Heizungsstatus[]).length).parent().select(faker.number.int({
max: Object.values(Enums.Heizungsstatus).length,
min: 1
}));
cy.get("[data-cy='beschreibung']").type(faker.lorem.paragraphs({ min: 2, max: 10 }))
// Wärmedämmung Bilder
cy.get("input[type='file'][name='plaene']").should("have.attr", "type", "file").attachFile("images/daemmung/1.jpeg", { subjectType: "input" }).attachFile("images/daemmung/2.jpeg", { subjectType: "input" });
cy.get("input[type='file'][name='unterlagen']").should("have.attr", "type", "file").attachFile("images/gebaeude/1.jpeg", { subjectType: "input" }).attachFile("images/daemmung/2.jpeg", { subjectType: "input" });
// Jetzt können wir den Verbrauchsausweis erstellen.
cy.get("form[data-cy='nachweis'] button[data-cy='weiter']").click({ force: true });
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}`);
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("button[data-cy='bestellen']").click();
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);
cy.get("form[name='signup'] button[type='submit']").click();
cy.get("form[name='login'] button[type='submit']").click();
cy.url().should("contain", "/einpreisung/success")
});
});

View File

@@ -113,7 +113,7 @@
/> />
</div> </div>
<form id="formInput-1" name="ausweis" data-test="ausweis" bind:this={form}> <form id="formInput-1" name="ausweis" data-cy="nachweis" bind:this={form}>
<div id="formular-box" class="formular-boxen ring-0"> <div id="formular-box" class="formular-boxen ring-0">
<!-- A Prüfung der Ausweisart --> <!-- A Prüfung der Ausweisart -->
@@ -144,6 +144,7 @@
<textarea <textarea
class="rounded-e-none" class="rounded-e-none"
rows="10" rows="10"
data-cy="beschreibung"
bind:value={nachweis.beschreibung} bind:value={nachweis.beschreibung}
></textarea> ></textarea>