Tests
This commit is contained in:
@@ -35,6 +35,14 @@ export default defineConfig({
|
|||||||
on("task", {
|
on("task", {
|
||||||
async verbrauchsausweisWohnen(query) {
|
async verbrauchsausweisWohnen(query) {
|
||||||
return await prisma.verbrauchsausweisWohnen.findFirst(query)
|
return await prisma.verbrauchsausweisWohnen.findFirst(query)
|
||||||
|
},
|
||||||
|
async plz() {
|
||||||
|
const total = await prisma.postleitzahlen.count()
|
||||||
|
const result = await prisma.postleitzahlen.findFirst({
|
||||||
|
skip: Math.floor(Math.random() * total)
|
||||||
|
})
|
||||||
|
|
||||||
|
return result?.plz
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -13,28 +13,28 @@ 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"),
|
||||||
"aufnahme": await import("../src/pages/api/aufnahme/index.ts"),
|
"aufnahme": await import("../src/pages/api/aufnahme/index.ts"),
|
||||||
|
"bedarfsausweis-gewerbe/[id]": await import("../src/pages/api/bedarfsausweis-gewerbe/[id].ts"),
|
||||||
|
"bedarfsausweis-gewerbe": await import("../src/pages/api/bedarfsausweis-gewerbe/index.ts"),
|
||||||
|
"ausweise": await import("../src/pages/api/ausweise/index.ts"),
|
||||||
|
"bedarfsausweis-wohnen/[id]": await import("../src/pages/api/bedarfsausweis-wohnen/[id].ts"),
|
||||||
|
"bedarfsausweis-wohnen": await import("../src/pages/api/bedarfsausweis-wohnen/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"),
|
||||||
"bedarfsausweis-gewerbe/[uid]": await import("../src/pages/api/bedarfsausweis-gewerbe/[uid].ts"),
|
|
||||||
"bedarfsausweis-gewerbe": await import("../src/pages/api/bedarfsausweis-gewerbe/index.ts"),
|
|
||||||
"bedarfsausweis-wohnen/[id]": await import("../src/pages/api/bedarfsausweis-wohnen/[id].ts"),
|
|
||||||
"bedarfsausweis-wohnen": await import("../src/pages/api/bedarfsausweis-wohnen/index.ts"),
|
|
||||||
"ausweise": await import("../src/pages/api/ausweise/index.ts"),
|
|
||||||
"bilder/[id]": await import("../src/pages/api/bilder/[id].ts"),
|
"bilder/[id]": await import("../src/pages/api/bilder/[id].ts"),
|
||||||
"geg-nachweis-gewerbe/[uid]": await import("../src/pages/api/geg-nachweis-gewerbe/[uid].ts"),
|
"geg-nachweis-wohnen/[id]": await import("../src/pages/api/geg-nachweis-wohnen/[id].ts"),
|
||||||
"geg-nachweis-gewerbe": await import("../src/pages/api/geg-nachweis-gewerbe/index.ts"),
|
|
||||||
"geg-nachweis-wohnen/[uid]": await import("../src/pages/api/geg-nachweis-wohnen/[uid].ts"),
|
|
||||||
"geg-nachweis-wohnen": await import("../src/pages/api/geg-nachweis-wohnen/index.ts"),
|
"geg-nachweis-wohnen": await import("../src/pages/api/geg-nachweis-wohnen/index.ts"),
|
||||||
|
"geg-nachweis-gewerbe/[id]": await import("../src/pages/api/geg-nachweis-gewerbe/[id].ts"),
|
||||||
|
"geg-nachweis-gewerbe": await import("../src/pages/api/geg-nachweis-gewerbe/index.ts"),
|
||||||
"objekt": await import("../src/pages/api/objekt/index.ts"),
|
"objekt": await import("../src/pages/api/objekt/index.ts"),
|
||||||
"rechnung/[id]": await import("../src/pages/api/rechnung/[id].ts"),
|
"rechnung/[id]": await import("../src/pages/api/rechnung/[id].ts"),
|
||||||
"rechnung/anfordern": await import("../src/pages/api/rechnung/anfordern.ts"),
|
"rechnung/anfordern": await import("../src/pages/api/rechnung/anfordern.ts"),
|
||||||
"rechnung": await import("../src/pages/api/rechnung/index.ts"),
|
"rechnung": await import("../src/pages/api/rechnung/index.ts"),
|
||||||
"ticket": await import("../src/pages/api/ticket/index.ts"),
|
"ticket": await import("../src/pages/api/ticket/index.ts"),
|
||||||
"user": await import("../src/pages/api/user/index.ts"),
|
|
||||||
"user/self": await import("../src/pages/api/user/self.ts"),
|
|
||||||
"verbrauchsausweis-gewerbe/[id]": await import("../src/pages/api/verbrauchsausweis-gewerbe/[id].ts"),
|
"verbrauchsausweis-gewerbe/[id]": await import("../src/pages/api/verbrauchsausweis-gewerbe/[id].ts"),
|
||||||
"verbrauchsausweis-gewerbe": await import("../src/pages/api/verbrauchsausweis-gewerbe/index.ts"),
|
"verbrauchsausweis-gewerbe": await import("../src/pages/api/verbrauchsausweis-gewerbe/index.ts"),
|
||||||
|
"user": await import("../src/pages/api/user/index.ts"),
|
||||||
|
"user/self": await import("../src/pages/api/user/self.ts"),
|
||||||
"verbrauchsausweis-wohnen/[id]": await import("../src/pages/api/verbrauchsausweis-wohnen/[id].ts"),
|
"verbrauchsausweis-wohnen/[id]": await import("../src/pages/api/verbrauchsausweis-wohnen/[id].ts"),
|
||||||
"verbrauchsausweis-wohnen": await import("../src/pages/api/verbrauchsausweis-wohnen/index.ts"),
|
"verbrauchsausweis-wohnen": await import("../src/pages/api/verbrauchsausweis-wohnen/index.ts"),
|
||||||
"webhooks/mollie": await import("../src/pages/api/webhooks/mollie.ts"),
|
"webhooks/mollie": await import("../src/pages/api/webhooks/mollie.ts"),
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ export async function nachweisSpeichern(
|
|||||||
} else {
|
} else {
|
||||||
const { id } = await putRoute.fetch({
|
const { id } = await putRoute.fetch({
|
||||||
nachweis,
|
nachweis,
|
||||||
uid_aufnahme: aufnahme.id
|
aufnahme_id: aufnahme.id
|
||||||
}, {
|
}, {
|
||||||
headers: {
|
headers: {
|
||||||
"Authorization": `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}`
|
"Authorization": `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}`
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
import Overlay from "#components/Overlay.svelte";
|
import Overlay from "#components/Overlay.svelte";
|
||||||
import EmbeddedAuthFlowModule from "#modules/EmbeddedAuthFlowModule.svelte";
|
import EmbeddedAuthFlowModule from "#modules/EmbeddedAuthFlowModule.svelte";
|
||||||
|
|
||||||
import { AusweisTyp, BedarfsausweisGewerbe, Enums } from "#lib/client/prisma.js";
|
import { AusweisTyp, BedarfsausweisGewerbe, Enums, GEGNachweisGewerbe, GEGNachweisWohnen } from "#lib/client/prisma.js";
|
||||||
import { openWindowWithPost } from "#lib/helpers/window.js";
|
import { openWindowWithPost } from "#lib/helpers/window.js";
|
||||||
import { PRICES } from "#lib/constants.js";
|
import { PRICES } from "#lib/constants.js";
|
||||||
import { nachweisSpeichern } from "#client/lib/nachweisSpeichern.js";
|
import { nachweisSpeichern } from "#client/lib/nachweisSpeichern.js";
|
||||||
|
|
||||||
export let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnenClient | BedarfsausweisGewerbe;
|
export let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnenClient | BedarfsausweisGewerbe | GEGNachweisWohnen | GEGNachweisGewerbe;
|
||||||
export let bilder: BildClient[];
|
export let bilder: BildClient[];
|
||||||
export let unterlagen: UnterlageClient[] = [];
|
export let unterlagen: UnterlageClient[] = [];
|
||||||
export let user: BenutzerClient | null;
|
export let user: BenutzerClient | null;
|
||||||
@@ -46,16 +46,27 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ausweisart === Enums.Ausweisart.GEGNachweisWohnen || ausweisart === Enums.Ausweisart.GEGNachweisGewerbe || ausweisart === Enums.Ausweisart.BedarfsausweisGewerbe) {
|
||||||
openWindowWithPost("/kundendaten", {
|
openWindowWithPost("/kundendaten", {
|
||||||
ausweis: { ...ausweis, ausweistyp },
|
ausweis: { ...ausweis, nachweistyp: ausweistyp },
|
||||||
objekt,
|
objekt,
|
||||||
aufnahme,
|
aufnahme,
|
||||||
bilder,
|
bilder,
|
||||||
unterlagen,
|
unterlagen,
|
||||||
ausweisart,
|
ausweisart,
|
||||||
ausweistyp
|
ausweistyp
|
||||||
}, "")
|
}, "")
|
||||||
|
} else {
|
||||||
|
openWindowWithPost("/kundendaten", {
|
||||||
|
ausweis: { ...ausweis, ausweistyp },
|
||||||
|
objekt,
|
||||||
|
aufnahme,
|
||||||
|
bilder,
|
||||||
|
unterlagen,
|
||||||
|
ausweisart,
|
||||||
|
ausweistyp
|
||||||
|
}, "")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let loginAction: () => any = ausweisAbschicken;
|
let loginAction: () => any = ausweisAbschicken;
|
||||||
|
|||||||
@@ -26,6 +26,10 @@
|
|||||||
Bedarfsausweis Wohnen
|
Bedarfsausweis Wohnen
|
||||||
{:else if ausweisart === Enums.Ausweisart.BedarfsausweisGewerbe}
|
{:else if ausweisart === Enums.Ausweisart.BedarfsausweisGewerbe}
|
||||||
Bedarfsausweis Gewerbe
|
Bedarfsausweis Gewerbe
|
||||||
|
{:else if ausweisart === Enums.Ausweisart.GEGNachweisWohnen}
|
||||||
|
GEG Nachweis Wohngebäude
|
||||||
|
{:else if ausweisart === Enums.Ausweisart.GEGNachweisGewerbe}
|
||||||
|
GEG Nachweis Gewerbegebäude
|
||||||
{/if}
|
{/if}
|
||||||
{#if ausweistyp === Enums.AusweisTyp.Beratung}
|
{#if ausweistyp === Enums.AusweisTyp.Beratung}
|
||||||
mit Beratung
|
mit Beratung
|
||||||
|
|||||||
@@ -4,15 +4,15 @@
|
|||||||
import HelpLabel from "#components/labels/HelpLabel.svelte";
|
import HelpLabel from "#components/labels/HelpLabel.svelte";
|
||||||
|
|
||||||
export let kategorie: string = "";
|
export let kategorie: string = "";
|
||||||
export let files: UnterlageClient[] = [];
|
export let files: Unterlage[] = [];
|
||||||
export let max: number = Infinity;
|
export let max: number = Infinity;
|
||||||
export let min: number = 1;
|
export let min: number = 1;
|
||||||
export let name: string = "";
|
export let name: string = "";
|
||||||
export let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnenClient | BedarfsausweisGewerbe;
|
export let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnenClient | BedarfsausweisGewerbe | GEGNachweisWohnen | GEGNachweisGewerbe;
|
||||||
export let objekt: ObjektClient;
|
export let objekt: ObjektClient;
|
||||||
import mime from "mime-types";
|
import mime from "mime-types";
|
||||||
import { api } from "astro-typesafe-api/client";
|
import { api } from "astro-typesafe-api/client";
|
||||||
import { BedarfsausweisGewerbe } from "#lib/client/prisma.js";
|
import { BedarfsausweisGewerbe, GEGNachweisGewerbe, GEGNachweisWohnen, Unterlage } from "#lib/client/prisma.js";
|
||||||
|
|
||||||
|
|
||||||
function getAllFiles(this: HTMLInputElement) {
|
function getAllFiles(this: HTMLInputElement) {
|
||||||
@@ -43,14 +43,14 @@
|
|||||||
|
|
||||||
const mimeType = mime.types[file.name.split(".").pop() as string]
|
const mimeType = mime.types[file.name.split(".").pop() as string]
|
||||||
|
|
||||||
const { uid } = await api.unterlage.PUT.fetch({
|
const { id } = await api.unterlage.PUT.fetch({
|
||||||
data: reader.result as string,
|
data: reader.result as string,
|
||||||
kategorie,
|
kategorie,
|
||||||
mime: mimeType,
|
mime: mimeType,
|
||||||
name: file.name
|
name: file.name
|
||||||
})
|
})
|
||||||
|
|
||||||
files.push({ uid, kategorie, name: file.name, mime: mimeType });
|
files.push({ id, kategorie, name: file.name, mime: mimeType, aufnahme_id: null });
|
||||||
files = files;
|
files = files;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
import { auditHeizungGebaeudeBaujahr } from "../Verbrauchsausweis/audits/HeizungGebaeudeBaujahr.js";
|
import { auditHeizungGebaeudeBaujahr } from "../Verbrauchsausweis/audits/HeizungGebaeudeBaujahr.js";
|
||||||
import { addNotification, deleteNotification } from "#components/Notifications/shared.js";
|
import { addNotification, deleteNotification } from "#components/Notifications/shared.js";
|
||||||
import TagInput from "../TagInput.svelte";
|
import TagInput from "../TagInput.svelte";
|
||||||
import { BedarfsausweisGewerbe, Enums } from "#lib/client/prisma.js";
|
import { BedarfsausweisGewerbe, Enums, GEGNachweisGewerbe, GEGNachweisWohnen } from "#lib/client/prisma.js";
|
||||||
import {
|
import {
|
||||||
AufnahmeClient,
|
AufnahmeClient,
|
||||||
ObjektClient,
|
ObjektClient,
|
||||||
@@ -15,8 +15,8 @@
|
|||||||
} from "../Ausweis/types.js";
|
} from "../Ausweis/types.js";
|
||||||
|
|
||||||
export let objekt: ObjektClient;
|
export let objekt: ObjektClient;
|
||||||
export let ausweis:
|
export let nachweis:
|
||||||
BedarfsausweisGewerbe;
|
BedarfsausweisGewerbe | GEGNachweisWohnen | GEGNachweisGewerbe;
|
||||||
export let aufnahme: AufnahmeClient;
|
export let aufnahme: AufnahmeClient;
|
||||||
|
|
||||||
export let ausweisart: Enums.Ausweisart;
|
export let ausweisart: Enums.Ausweisart;
|
||||||
@@ -38,7 +38,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
|
|||||||
class="rounded-e-none"
|
class="rounded-e-none"
|
||||||
name="ausstellgrund"
|
name="ausstellgrund"
|
||||||
placeholder="Anlass"
|
placeholder="Anlass"
|
||||||
bind:value={ausweis.ausstellgrund}
|
bind:value={nachweis.ausstellgrund}
|
||||||
required
|
required
|
||||||
data-cy="ausstellgrund"
|
data-cy="ausstellgrund"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -8,123 +8,116 @@ 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.", () => {
|
||||||
cy.visit("/angebot-anfragen/geg-nachweis-gewerbe-anfragen");
|
cy.task("plz").then(plz => {
|
||||||
|
cy.visit("/angebot-anfragen/geg-nachweis-gewerbe-anfragen");
|
||||||
|
|
||||||
cy.wait(2000);
|
cy.wait(2000);
|
||||||
|
|
||||||
// Wir überprüfen, ob alle Ausstelgründe vorhanden sind, diese sollten genau so viele sein wie in der Datenbank vorhanden sind.
|
// 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']")
|
cy.get("select[data-cy='ausstellgrund']")
|
||||||
.select(
|
.select(
|
||||||
faker.number.int({
|
faker.number.int({
|
||||||
min: 1,
|
min: 1,
|
||||||
max: [Enums.Ausstellgrund.Modernisierung, Enums.Ausstellgrund.Neubau].length - 1,
|
max: [Enums.Ausstellgrund.Modernisierung, Enums.Ausstellgrund.Neubau].length - 1,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
// Gebäudetyp
|
// Gebäudetyp
|
||||||
cy.get("select[name='gebaeudetyp']").then(($dropdown) => {
|
cy.get("select[name='gebaeudetyp']").then(($dropdown) => {
|
||||||
const options = $dropdown.find('option');
|
const options = $dropdown.find('option');
|
||||||
// Select the option at the random index
|
// 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);
|
cy.get("select[name='gebaeudetyp']").select(options.eq(faker.number.int({ min: 1, max: options.length - 1 })).val() as string);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Sanierungsstatus
|
// Sanierungsstatus
|
||||||
cy.get("select[name='saniert']").select(
|
cy.get("select[name='saniert']").select(
|
||||||
Math.random() > 0.5 ? "true" : "false"
|
Math.random() > 0.5 ? "true" : "false"
|
||||||
);
|
|
||||||
|
|
||||||
// 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.
|
// Jetzt Füllen wir das Baujahr vom Gebäude aus.
|
||||||
cy.get("input[name='baujahr_heizung']")
|
cy.get("input[name='baujahr_gebaeude']")
|
||||||
.should("have.attr", "type", "number")
|
.should("have.attr", "type", "number")
|
||||||
.type(
|
.type(
|
||||||
faker.number.int({ min: 1900, max: 2021 }).toString() +
|
faker.number.int({ min: 1900, max: 2021 }).toString() +
|
||||||
"{enter}",
|
"{enter}",
|
||||||
{ delay: 50 }
|
{ 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(
|
||||||
|
plz as string
|
||||||
);
|
);
|
||||||
|
|
||||||
// Adresse
|
// TODO: Ort - Dieser wird aus der Datenbank abgefragt, wir müssen also warten, bis der Dropdown da ist.
|
||||||
cy.get("input[name='adresse']").type(faker.location.streetAddress());
|
cy.get("[data-cy='plz-container']").find("button").first().click()
|
||||||
|
|
||||||
// Postleitzahl
|
// Gebäudeteil
|
||||||
cy.get("input[name='plz']").type(
|
cy.get("select[name='gebaeudeteil']").then(($dropdown) => {
|
||||||
faker.location.zipCode({
|
const options = $dropdown.find('option');
|
||||||
format: "#####",
|
// Select the option at the random index
|
||||||
})
|
cy.get("select[name='gebaeudeteil']").select(options.eq(faker.number.int({ min: 1, max: options.length - 1 })).val() as string);
|
||||||
);
|
});
|
||||||
|
|
||||||
// TODO: Ort - Dieser wird aus der Datenbank abgefragt, wir müssen also warten, bis der Dropdown da ist.
|
// Keller
|
||||||
cy.get("[data-cy='plz-container']").find("button").first().click()
|
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
|
||||||
|
}));
|
||||||
|
|
||||||
// Nutzflaeche
|
// Dachgeschoss
|
||||||
cy.get("input[name='nutzflaeche']")
|
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({
|
||||||
.should("have.attr", "type", "number")
|
max: Object.values(Enums.Heizungsstatus).length,
|
||||||
.type(faker.number.int({ min: 50, max: 1000 }).toString());
|
min: 1
|
||||||
|
}));
|
||||||
|
|
||||||
// Keller
|
cy.get("[data-cy='beschreibung']").type(faker.lorem.paragraphs({ min: 2, max: 10 }))
|
||||||
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
|
// Wärmedämmung Bilder
|
||||||
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({
|
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" });
|
||||||
max: Object.values(Enums.Heizungsstatus).length,
|
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" });
|
||||||
min: 1
|
|
||||||
}));
|
|
||||||
|
|
||||||
cy.get("[data-cy='beschreibung']").type(faker.lorem.paragraphs({ min: 2, max: 10 }))
|
// Jetzt können wir den Verbrauchsausweis erstellen.
|
||||||
|
cy.get("form[data-cy='nachweis'] button[data-cy='weiter']").click({ force: true });
|
||||||
|
|
||||||
// Wärmedämmung Bilder
|
cy.url().should("contain", "/kundendaten");
|
||||||
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.
|
const email = faker.internet.email();
|
||||||
cy.get("form[data-cy='nachweis'] button[data-cy='weiter']").click({ force: true });
|
const passwort = "test1234";
|
||||||
|
const vorname = faker.person.firstName();
|
||||||
|
const nachname = faker.person.lastName();
|
||||||
|
const telefon = faker.phone.number()
|
||||||
|
|
||||||
cy.url().should("contain", "/kundendaten");
|
const strasse = faker.location.streetAddress({ useFullAddress: true })
|
||||||
|
|
||||||
const email = faker.internet.email();
|
cy.get("input[name='vorname']").should("have.attr", "type", "text").type(vorname);
|
||||||
const passwort = "test1234";
|
cy.get("input[name='name']").should("have.attr", "type", "text").type(nachname);
|
||||||
const vorname = faker.person.firstName();
|
cy.get("input[name='telefon']").should("have.attr", "type", "text").type(telefon);
|
||||||
const nachname = faker.person.lastName();
|
// Rechnung
|
||||||
const telefon = faker.phone.number()
|
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 as string);
|
||||||
|
cy.get("[data-cy='plz-container']").children().first().click()
|
||||||
|
cy.get("input[name='rechnung_email']").should("have.attr", "type", "email").type(email);
|
||||||
|
|
||||||
const strasse = faker.location.streetAddress({ useFullAddress: true })
|
cy.get("button[data-cy='bestellen']").click();
|
||||||
const plz = faker.location.zipCode("#####")
|
|
||||||
|
|
||||||
cy.get("input[name='vorname']").should("have.attr", "type", "text").type(vorname);
|
cy.intercept({ method: "PUT", url: "**/api/rechnung/anfordern" }).as("anfordern")
|
||||||
cy.get("input[name='name']").should("have.attr", "type", "text").type(nachname);
|
cy["form:signup"](email, passwort, vorname, nachname)
|
||||||
cy.get("input[name='telefon']").should("have.attr", "type", "text").type(telefon);
|
cy.wait("@anfordern")
|
||||||
// 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.url().should("contain", "/einpreisung/success")
|
||||||
|
})
|
||||||
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")
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,118 +8,111 @@ 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.", () => {
|
||||||
cy.visit("/angebot-anfragen/geg-nachweis-wohnen-anfragen");
|
cy.task("plz").then(plz => {
|
||||||
|
cy.visit("/angebot-anfragen/geg-nachweis-wohnen-anfragen");
|
||||||
|
|
||||||
cy.wait(2000);
|
cy.wait(2000);
|
||||||
|
|
||||||
// Wir überprüfen, ob alle Ausstelgründe vorhanden sind, diese sollten genau so viele sein wie in der Datenbank vorhanden sind.
|
// 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']")
|
cy.get("select[data-cy='ausstellgrund']")
|
||||||
.select(
|
.select(
|
||||||
faker.number.int({
|
faker.number.int({
|
||||||
min: 1,
|
min: 1,
|
||||||
max: [Enums.Ausstellgrund.Modernisierung, Enums.Ausstellgrund.Neubau].length - 1,
|
max: [Enums.Ausstellgrund.Modernisierung, Enums.Ausstellgrund.Neubau].length - 1,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
// Gebäudetyp
|
// Gebäudetyp
|
||||||
cy.get("select[name='gebaeudetyp']").then(($dropdown) => {
|
cy.get("select[name='gebaeudetyp']").then(($dropdown) => {
|
||||||
const options = $dropdown.find('option');
|
const options = $dropdown.find('option');
|
||||||
// Select the option at the random index
|
// 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);
|
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(
|
||||||
|
plz as string
|
||||||
|
);
|
||||||
|
|
||||||
|
// 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()
|
||||||
|
|
||||||
|
// Gebäudeteil
|
||||||
|
cy.get("select[name='gebaeudeteil']").then(($dropdown) => {
|
||||||
|
const options = $dropdown.find('option');
|
||||||
|
// Select the option at the random index
|
||||||
|
cy.get("select[name='gebaeudeteil']").select(options.eq(faker.number.int({ min: 1, max: options.length - 1 })).val() as string);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 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 })
|
||||||
|
|
||||||
|
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 as string);
|
||||||
|
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.intercept({ method: "PUT", url: "**/api/rechnung/anfordern" }).as("anfordern")
|
||||||
|
cy["form:signup"](email, passwort, vorname, nachname)
|
||||||
|
cy.wait("@anfordern")
|
||||||
|
|
||||||
|
cy.url().should("contain", "/einpreisung/success")
|
||||||
});
|
});
|
||||||
|
|
||||||
// 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")
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,312 +1,296 @@
|
|||||||
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 { type 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", () => {
|
||||||
const ausstellgrund = (["Modernisierung", "Neubau", "Sonstiges", "Verkauf", "Vermietung"] as Enums.Ausstellgrund[]);
|
|
||||||
const heizungsstatus = (["BEHEIZT", "NICHT_VORHANDEN", "UNBEHEIZT"] as Enums.Heizungsstatus[]);
|
|
||||||
|
|
||||||
it("erstellt einen neuen Verbrauchsausweis Wohngebäude.", () => {
|
it("erstellt einen neuen Verbrauchsausweis Wohngebäude.", () => {
|
||||||
cy.visit("/energieausweis-erstellen/verbrauchsausweis-gewerbe");
|
cy.task("plz").then(plz => {
|
||||||
|
cy.visit("/energieausweis-erstellen/verbrauchsausweis-gewerbe");
|
||||||
|
|
||||||
cy.wait(1000);
|
cy.wait(1000);
|
||||||
|
|
||||||
// Wir überprüfen, ob alle Ausstelgründe vorhanden sind, diese sollten genau so viele sein wie in der Datenbank vorhanden sind.
|
// 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']")
|
cy.get("select[data-cy='ausstellgrund']")
|
||||||
.select(
|
.select(
|
||||||
faker.number.int({
|
faker.number.int({
|
||||||
min: 1,
|
min: 1,
|
||||||
max: (["Modernisierung", "Neubau", "Sonstiges", "Verkauf", "Vermietung"] as Enums.Ausstellgrund[]).length,
|
max: (["Modernisierung", "Neubau", "Sonstiges", "Verkauf", "Vermietung"] as Enums.Ausstellgrund[]).length,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
// Jetzt Füllen wir das Baujahr vom Gebäude aus.
|
// Jetzt Füllen wir das Baujahr vom Gebäude aus.
|
||||||
cy.get("input[name='baujahr_gebaeude']")
|
cy.get("input[name='baujahr_gebaeude']")
|
||||||
.should("have.attr", "type", "number")
|
.should("have.attr", "type", "number")
|
||||||
.type(
|
.type(
|
||||||
faker.number.int({ min: 1900, max: 2021 }).toString() +
|
faker.number.int({ min: 1900, max: 2021 }).toString() +
|
||||||
"{enter}",
|
"{enter}",
|
||||||
{ delay: 50 }
|
{ 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 }
|
||||||
|
);
|
||||||
|
|
||||||
|
// // Anzahl Einheiten
|
||||||
|
// cy.get("input[name='einheiten']")
|
||||||
|
// .should("have.attr", "type", "number")
|
||||||
|
// .type(faker.number.int({ min: 1, max: 5 }).toString());
|
||||||
|
|
||||||
|
// Sanierungsstatus
|
||||||
|
cy.get("select[name='saniert']").select(
|
||||||
|
Math.random() > 0.5 ? "true" : "false"
|
||||||
);
|
);
|
||||||
|
|
||||||
// Jetzt Füllen wir das Baujahr der Heizung aus.
|
// Adresse
|
||||||
cy.get("input[name='baujahr_heizung']")
|
cy.get("input[name='adresse']").type(faker.location.streetAddress());
|
||||||
.should("have.attr", "type", "number")
|
|
||||||
.type(
|
// Postleitzahl
|
||||||
faker.number.int({ min: 1900, max: 2021 }).toString() +
|
cy.get("input[name='plz']").type(
|
||||||
"{enter}",
|
plz as string
|
||||||
{ delay: 50 }
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// // Anzahl Einheiten
|
// TODO: Ort - Dieser wird aus der Datenbank abgefragt, wir müssen also warten, bis der Dropdown da ist.
|
||||||
// cy.get("input[name='einheiten']")
|
cy.get("[data-cy='plz-container']").find("button").first().click()
|
||||||
// .should("have.attr", "type", "number")
|
|
||||||
// .type(faker.number.int({ min: 1, max: 5 }).toString());
|
|
||||||
|
|
||||||
// Sanierungsstatus
|
// // Flaeche
|
||||||
cy.get("select[name='saniert']").select(
|
// cy.get("input[name='flaeche']")
|
||||||
Math.random() > 0.5 ? "true" : "false"
|
// .should("have.attr", "type", "number")
|
||||||
);
|
// .type(faker.number.int({ min: 50, max: 1000 }).toString());
|
||||||
|
|
||||||
// Adresse
|
// Nutzlaeche
|
||||||
cy.get("input[name='adresse']").type(faker.location.streetAddress());
|
cy.get("input[name='nutzflaeche']")
|
||||||
|
.should("have.attr", "type", "number")
|
||||||
|
.type(faker.number.int({ min: 50, max: 1000 }).toString());
|
||||||
|
|
||||||
// Postleitzahl
|
// Keller
|
||||||
cy.get("input[name='plz']").type(
|
cy.get("select[name='keller']").find("option:not([disabled])").should("have.length", Object.keys(Enums.Heizungsstatus).length).parent().select(faker.number.int({
|
||||||
faker.location.zipCode({
|
max: Object.keys(Enums.Heizungsstatus).length,
|
||||||
format: "#####",
|
min: 1
|
||||||
})
|
}));
|
||||||
);
|
|
||||||
|
|
||||||
// TODO: Ort - Dieser wird aus der Datenbank abgefragt, wir müssen also warten, bis der Dropdown da ist.
|
// Dachgeschoss
|
||||||
cy.get("[data-cy='plz-container']").find("button").first().click()
|
cy.get("select[name='dachgeschoss']").find("option:not([disabled])").should("have.length", Object.keys(Enums.Heizungsstatus).length).parent().select(faker.number.int({
|
||||||
|
max: Object.keys(Enums.Heizungsstatus).length,
|
||||||
|
min: 1
|
||||||
|
}));
|
||||||
|
|
||||||
// // Flaeche
|
// Brennstoff und Einheit 1
|
||||||
// cy.get("input[name='flaeche']")
|
const brennstoffKombo = fuelList[faker.number.int({ min: 0, max: fuelList.length - 1 })];
|
||||||
// .should("have.attr", "type", "number")
|
|
||||||
// .type(faker.number.int({ min: 50, max: 1000 }).toString());
|
|
||||||
|
|
||||||
// Nutzlaeche
|
cy.get("select[name='brennstoff_1']").select(brennstoffKombo[0]);
|
||||||
cy.get("input[name='nutzflaeche']")
|
cy.get("select[name='einheit_1']").select(brennstoffKombo[1]);
|
||||||
.should("have.attr", "type", "number")
|
|
||||||
.type(faker.number.int({ min: 50, max: 1000 }).toString());
|
|
||||||
|
|
||||||
// Keller
|
let availableDates = [];
|
||||||
cy.get("select[name='keller']").find("option:not([disabled])").should("have.length", heizungsstatus.length).parent().select(faker.number.int({
|
const startDate = moment()
|
||||||
max: heizungsstatus.length,
|
.subtract(4, "years")
|
||||||
min: 1
|
.subtract(6, "months");
|
||||||
}));
|
const endDate = moment().subtract(3, "years");
|
||||||
|
|
||||||
// Dachgeschoss
|
for (let m = moment(startDate); m.isBefore(endDate); m.add(1, "month")) {
|
||||||
cy.get("select[name='dachgeschoss']").find("option:not([disabled])").should("have.length", heizungsstatus.length).parent().select(faker.number.int({
|
availableDates.push({
|
||||||
max: heizungsstatus.length,
|
year: m.year(),
|
||||||
min: 1
|
month: m.month(),
|
||||||
}));
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Brennstoff und Einheit 1
|
// Verbrauchszeitraum
|
||||||
const brennstoffKombo = fuelList[faker.number.int({ min: 0, max: fuelList.length - 1 })];
|
cy.get("select[name='energieverbrauch_zeitraum_jahr']").select(availableDates[0].year.toString());
|
||||||
|
cy.get("select[name='energieverbrauch_zeitraum_monat']").select(availableDates[0].month.toString());
|
||||||
cy.get("select[name='brennstoff_1']").select(brennstoffKombo[0]);
|
|
||||||
cy.get("select[name='einheit_1']").select(brennstoffKombo[1]);
|
|
||||||
|
|
||||||
let availableDates = [];
|
|
||||||
const startDate = moment()
|
|
||||||
.subtract(4, "years")
|
|
||||||
.subtract(6, "months");
|
|
||||||
const endDate = moment().subtract(3, "years");
|
|
||||||
|
|
||||||
for (let m = moment(startDate); m.isBefore(endDate); m.add(1, "month")) {
|
|
||||||
availableDates.push({
|
|
||||||
year: m.year(),
|
|
||||||
month: m.month(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verbrauchszeitraum
|
|
||||||
cy.get("select[name='energieverbrauch_zeitraum_jahr']").select(availableDates[0].year.toString());
|
|
||||||
cy.get("select[name='energieverbrauch_zeitraum_monat']").select(availableDates[0].month.toString());
|
|
||||||
|
|
||||||
// Verbrauch
|
|
||||||
cy.get("input[name='verbrauch_1']").type(faker.number.int({ min: 4000, max: 15000 }).toString());
|
|
||||||
cy.get("input[name='verbrauch_2']").type(faker.number.int({ min: 4000, max: 15000 }).toString());
|
|
||||||
cy.get("input[name='verbrauch_3']").type(faker.number.int({ min: 4000, max: 15000 }).toString());
|
|
||||||
|
|
||||||
|
|
||||||
const zusaetzlicheHeizquelle = Math.random() > 0.5;
|
|
||||||
|
|
||||||
if (zusaetzlicheHeizquelle) {
|
|
||||||
cy.get("[data-cy='zusaetzliche_heizquelle']").check();
|
|
||||||
|
|
||||||
// Brennstoff und Einheit 2
|
|
||||||
const brennstoffKombo2 = fuelList[faker.number.int({ min: 0, max: fuelList.length - 1 })];
|
|
||||||
|
|
||||||
cy.get("[data-cy='brennstoff_2']").select(brennstoffKombo2[0], { force: true });
|
|
||||||
cy.get("[data-cy='einheit_2']").select(brennstoffKombo2[1], { force: true });
|
|
||||||
|
|
||||||
// Verbrauch
|
// Verbrauch
|
||||||
cy.get("input[name='verbrauch_4']").type(faker.number.int({ min: 4000, max: 15000 }).toString(), { force: true });
|
cy.get("input[name='verbrauch_1']").type(faker.number.int({ min: 4000, max: 15000 }).toString());
|
||||||
cy.get("input[name='verbrauch_5']").type(faker.number.int({ min: 4000, max: 15000 }).toString(), { force: true });
|
cy.get("input[name='verbrauch_2']").type(faker.number.int({ min: 4000, max: 15000 }).toString());
|
||||||
cy.get("input[name='verbrauch_6']").type(faker.number.int({ min: 4000, max: 15000 }).toString(), { force: true });
|
cy.get("input[name='verbrauch_3']").type(faker.number.int({ min: 4000, max: 15000 }).toString());
|
||||||
}
|
|
||||||
|
|
||||||
// Gebäudestrom
|
|
||||||
cy.get("input[name='strom_1']").type(faker.number.int({ min: 4000, max: 15000 }).toString());
|
|
||||||
cy.get("input[name='strom_2']").type(faker.number.int({ min: 4000, max: 15000 }).toString());
|
|
||||||
cy.get("input[name='strom_3']").type(faker.number.int({ min: 4000, max: 15000 }).toString());
|
|
||||||
|
|
||||||
// Stromverbrauch Enthält
|
const zusaetzlicheHeizquelle = Math.random() > 0.5;
|
||||||
if (Math.random() > 0.5) cy.get("input[name='stromverbrauch_enthaelt_heizung']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='stromverbrauch_enthaelt_warmwasser']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='stromverbrauch_enthaelt_lueftung']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='stromverbrauch_enthaelt_beleuchtung']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='stromverbrauch_enthaelt_kuehlung']").check();
|
|
||||||
|
|
||||||
// Warmwasser enthalten und bekannt
|
if (zusaetzlicheHeizquelle) {
|
||||||
const warmwasserEnthalten = Math.random() > 0.5;
|
cy.get("[data-cy='zusaetzliche_heizquelle']").check();
|
||||||
const anteilBekannt = Math.random() > 0.5;
|
|
||||||
|
|
||||||
if (warmwasserEnthalten) {
|
// Brennstoff und Einheit 2
|
||||||
cy.get("input[name='warmwasser_enthalten']").check();
|
const brennstoffKombo2 = fuelList[faker.number.int({ min: 0, max: fuelList.length - 1 })];
|
||||||
|
|
||||||
if (anteilBekannt) {
|
cy.get("[data-cy='brennstoff_2']").select(brennstoffKombo2[0], { force: true });
|
||||||
// Der Anteil ist bekannt, wir müssen ihn also angeben.
|
cy.get("[data-cy='einheit_2']").select(brennstoffKombo2[1], { force: true });
|
||||||
cy.get("input[name='warmwasser_anteil_bekannt']").check();
|
|
||||||
|
|
||||||
cy.get("input[name='anteil_warmwasser_1']").type(faker.number.int({ min: 0, max: 50 }).toString());
|
// Verbrauch
|
||||||
|
cy.get("input[name='verbrauch_4']").type(faker.number.int({ min: 4000, max: 15000 }).toString(), { force: true });
|
||||||
|
cy.get("input[name='verbrauch_5']").type(faker.number.int({ min: 4000, max: 15000 }).toString(), { force: true });
|
||||||
|
cy.get("input[name='verbrauch_6']").type(faker.number.int({ min: 4000, max: 15000 }).toString(), { force: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gebäudestrom
|
||||||
|
cy.get("input[name='strom_1']").type(faker.number.int({ min: 4000, max: 15000 }).toString());
|
||||||
|
cy.get("input[name='strom_2']").type(faker.number.int({ min: 4000, max: 15000 }).toString());
|
||||||
|
cy.get("input[name='strom_3']").type(faker.number.int({ min: 4000, max: 15000 }).toString());
|
||||||
|
|
||||||
|
// Stromverbrauch Enthält
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='stromverbrauch_enthaelt_heizung']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='stromverbrauch_enthaelt_warmwasser']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='stromverbrauch_enthaelt_lueftung']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='stromverbrauch_enthaelt_beleuchtung']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='stromverbrauch_enthaelt_kuehlung']").check();
|
||||||
|
|
||||||
|
// Warmwasser enthalten und bekannt
|
||||||
|
const warmwasserEnthalten = Math.random() > 0.5;
|
||||||
|
const anteilBekannt = Math.random() > 0.5;
|
||||||
|
|
||||||
|
if (warmwasserEnthalten) {
|
||||||
|
cy.get("input[name='warmwasser_enthalten']").check();
|
||||||
|
|
||||||
|
if (anteilBekannt) {
|
||||||
|
// Der Anteil ist bekannt, wir müssen ihn also angeben.
|
||||||
|
cy.get("input[name='warmwasser_anteil_bekannt']").check();
|
||||||
|
|
||||||
|
cy.get("input[name='anteil_warmwasser_1']").type(faker.number.int({ min: 0, max: 50 }).toString());
|
||||||
|
|
||||||
|
if (zusaetzlicheHeizquelle) {
|
||||||
|
// Zusätzliche Heizquelle existiert, also müssen wir auch hier den Anteil angeben.
|
||||||
|
cy.get("input[name='anteil_warmwasser_1']").type(faker.number.int({ min: 0, max: 50 }).toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Thermische Kühlung enthalten
|
||||||
|
const kuehlungEnthalten = Math.random() > 0.5;
|
||||||
|
|
||||||
|
if (kuehlungEnthalten) {
|
||||||
|
cy.get("input[name='kuehlung_enthalten']").check();
|
||||||
|
|
||||||
|
cy.get("input[name='anteil_kuehlung_1']").type(faker.number.int({ min: 0, max: 50 }).toString());
|
||||||
|
|
||||||
if (zusaetzlicheHeizquelle) {
|
if (zusaetzlicheHeizquelle) {
|
||||||
// Zusätzliche Heizquelle existiert, also müssen wir auch hier den Anteil angeben.
|
// Zusätzliche Heizquelle existiert, also müssen wir auch hier den Anteil angeben.
|
||||||
cy.get("input[name='anteil_warmwasser_1']").type(faker.number.int({ min: 0, max: 50 }).toString());
|
cy.get("input[name='anteil_kuehlung_2']").type(faker.number.int({ min: 0, max: 50 }).toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Thermische Kühlung enthalten
|
// Alternative Energieversorgungssysteme
|
||||||
const kuehlungEnthalten = Math.random() > 0.5;
|
if (Math.random() > 0.5) cy.get("input[name='alternative_heizung']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='alternative_warmwasser']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='alternative_lueftung']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='alternative_kuehlung']").check();
|
||||||
|
|
||||||
if (kuehlungEnthalten) {
|
// Gebäudetyp
|
||||||
cy.get("input[name='kuehlung_enthalten']").check();
|
cy.get("select[name='gebaeudetyp']").then(($dropdown) => {
|
||||||
|
const options = $dropdown.find('option:not([disabled])');
|
||||||
|
// 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);
|
||||||
|
});
|
||||||
|
|
||||||
cy.get("input[name='anteil_kuehlung_1']").type(faker.number.int({ min: 0, max: 50 }).toString());
|
// Gebäudeteil
|
||||||
|
cy.get("select[name='gebaeudeteil']").then(($dropdown) => {
|
||||||
|
const options = $dropdown.find('option');
|
||||||
|
// Select the option at the random index
|
||||||
|
cy.get("select[name='gebaeudeteil']").select(options.eq(faker.number.int({ min: 1, max: options.length - 1 })).val() as string);
|
||||||
|
});
|
||||||
|
|
||||||
if (zusaetzlicheHeizquelle) {
|
// Lüftung
|
||||||
// Zusätzliche Heizquelle existiert, also müssen wir auch hier den Anteil angeben.
|
cy.get("select[name='lueftung']").then(($dropdown) => {
|
||||||
cy.get("input[name='anteil_kuehlung_2']").type(faker.number.int({ min: 0, max: 50 }).toString());
|
const options = $dropdown.find('option');
|
||||||
}
|
// Select the option at the random index
|
||||||
}
|
cy.get("select[name='lueftung']").select(options.eq(faker.number.int({ min: 1, max: options.length - 1 })).val() as string);
|
||||||
|
});
|
||||||
|
|
||||||
// Alternative Energieversorgungssysteme
|
// Kühlung
|
||||||
if (Math.random() > 0.5) cy.get("input[name='alternative_heizung']").check();
|
cy.get("select[name='kuehlung']").then(($dropdown) => {
|
||||||
if (Math.random() > 0.5) cy.get("input[name='alternative_warmwasser']").check();
|
const options = $dropdown.find('option');
|
||||||
if (Math.random() > 0.5) cy.get("input[name='alternative_lueftung']").check();
|
// Select the option at the random index
|
||||||
if (Math.random() > 0.5) cy.get("input[name='alternative_kuehlung']").check();
|
cy.get("select[name='kuehlung']").select(options.eq(faker.number.int({ min: 1, max: options.length - 1 })).val() as string);
|
||||||
|
});
|
||||||
|
|
||||||
// Gebäudetyp
|
// Leerstand
|
||||||
cy.get("select[name='gebaeudetyp']").then(($dropdown) => {
|
cy.get("input[name='leerstand']").should("have.attr", "type", "number").type(faker.number.int({ min: 0, max: 30 }).toString());
|
||||||
const options = $dropdown.find('option:not([disabled])');
|
|
||||||
// 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);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Gebäudeteil
|
// Heizungsanlage Daten
|
||||||
cy.get("select[name='gebaeudeteil']").then(($dropdown) => {
|
if (Math.random() > 0.5) cy.get("input[name='zentralheizung']").check();
|
||||||
const options = $dropdown.find('option');
|
if (Math.random() > 0.5) cy.get("input[name='einzelofen']").check();
|
||||||
// Select the option at the random index
|
if (Math.random() > 0.5) cy.get("input[name='durchlauf_erhitzer']").check();
|
||||||
cy.get("select[name='gebaeudeteil']").select(options.eq(faker.number.int({ min: 1, max: options.length - 1 })).val() as string);
|
if (Math.random() > 0.5) cy.get("input[name='standard_kessel']").check();
|
||||||
});
|
if (Math.random() > 0.5) cy.get("input[name='solarsystem_warmwasser']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='waermepumpe']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='niedertemperatur_kessel']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='brennwert_kessel']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='warmwasser_rohre_gedaemmt']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='heizungsrohre_gedaemmt']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='zirkulation']").check();
|
||||||
|
// if (Math.random() > 0.5) cy.get("input[name='raum_temperatur_regler']").check();
|
||||||
|
|
||||||
// Lüftung
|
// Heizungsanlage Bilder
|
||||||
cy.get("select[name='lueftung']").then(($dropdown) => {
|
cy.get("input[name='heizung_image']").should("have.attr", "type", "file").attachFile("images/heizungsanlage/1.jpeg", { subjectType: "input" });
|
||||||
const options = $dropdown.find('option');
|
cy.get("input[name='heizung_image']").should("have.attr", "type", "file").attachFile("images/heizungsanlage/2.jpeg", { subjectType: "input" });
|
||||||
// Select the option at the random index
|
|
||||||
cy.get("select[name='lueftung']").select(options.eq(faker.number.int({ min: 1, max: options.length - 1 })).val() as string);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Kühlung
|
// Fenster Daten
|
||||||
cy.get("select[name='kuehlung']").then(($dropdown) => {
|
if (Math.random() > 0.5) cy.get("input[name='einfach_verglasung']").check();
|
||||||
const options = $dropdown.find('option');
|
if (Math.random() > 0.5) cy.get("input[name='doppel_verglasung']").check();
|
||||||
// Select the option at the random index
|
if (Math.random() > 0.5) cy.get("input[name='isolier_verglasung']").check();
|
||||||
cy.get("select[name='kuehlung']").select(options.eq(faker.number.int({ min: 1, max: options.length - 1 })).val() as string);
|
if (Math.random() > 0.5) cy.get("input[name='dreifach_verglasung']").check();
|
||||||
});
|
if (Math.random() > 0.5) cy.get("input[name='fenster_dicht']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='fenster_teilweise_undicht']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='tueren_dicht']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='tueren_undicht']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='rolllaeden_kaesten_gedaemmt']").check();
|
||||||
|
|
||||||
// Leerstand
|
// Fenster Bilder
|
||||||
cy.get("input[name='leerstand']").should("have.attr", "type", "number").type(faker.number.int({ min: 0, max: 30 }).toString());
|
cy.get("input[name='fenster_image']").should("have.attr", "type", "file").attachFile("images/fenster/1.jpeg", { subjectType: "input" });
|
||||||
|
cy.get("input[name='fenster_image']").should("have.attr", "type", "file").attachFile("images/fenster/2.jpeg", { subjectType: "input" });
|
||||||
|
|
||||||
// Heizungsanlage Daten
|
// Wärmedämmung Daten
|
||||||
if (Math.random() > 0.5) cy.get("input[name='zentralheizung']").check();
|
if (Math.random() > 0.5) cy.get("input[name='aussenwand_gedaemmt']").check();
|
||||||
if (Math.random() > 0.5) cy.get("input[name='einzelofen']").check();
|
if (Math.random() > 0.5) cy.get("input[name='keller_wand_gedaemmt']").check();
|
||||||
if (Math.random() > 0.5) cy.get("input[name='durchlauf_erhitzer']").check();
|
if (Math.random() > 0.5) cy.get("input[name='keller_decke_gedaemmt']").check();
|
||||||
if (Math.random() > 0.5) cy.get("input[name='standard_kessel']").check();
|
if (Math.random() > 0.5) cy.get("input[name='dachgeschoss_gedaemmt']").check();
|
||||||
if (Math.random() > 0.5) cy.get("input[name='solarsystem_warmwasser']").check();
|
if (Math.random() > 0.5) cy.get("input[name='oberste_geschossdecke_gedaemmt']").check();
|
||||||
if (Math.random() > 0.5) cy.get("input[name='waermepumpe']").check();
|
if (Math.random() > 0.5) cy.get("input[name='oberste_geschossdecke_min_12cm_gedaemmt']").check();
|
||||||
if (Math.random() > 0.5) cy.get("input[name='niedertemperatur_kessel']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='brennwert_kessel']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='warmwasser_rohre_gedaemmt']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='heizungsrohre_gedaemmt']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='zirkulation']").check();
|
|
||||||
// if (Math.random() > 0.5) cy.get("input[name='raum_temperatur_regler']").check();
|
|
||||||
|
|
||||||
// Heizungsanlage Bilder
|
// Wärmedämmung Bilder
|
||||||
cy.get("input[name='heizung_image']").should("have.attr", "type", "file").attachFile("images/heizungsanlage/1.jpeg", { subjectType: "input" });
|
cy.get("input[name='daemmung_image']").should("have.attr", "type", "file").attachFile("images/daemmung/1.jpeg", { subjectType: "input" });
|
||||||
cy.get("input[name='heizung_image']").should("have.attr", "type", "file").attachFile("images/heizungsanlage/2.jpeg", { subjectType: "input" });
|
cy.get("input[name='daemmung_image']").should("have.attr", "type", "file").attachFile("images/daemmung/2.jpeg", { subjectType: "input" });
|
||||||
|
|
||||||
// Fenster Daten
|
// Gebäude Bild
|
||||||
if (Math.random() > 0.5) cy.get("input[name='einfach_verglasung']").check();
|
cy.get("input[name='gebaeude_image']").should("have.attr", "type", "file").attachFile("images/gebaeude/1.jpeg", { subjectType: "input" });
|
||||||
if (Math.random() > 0.5) cy.get("input[name='doppel_verglasung']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='isolier_verglasung']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='dreifach_verglasung']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='fenster_dicht']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='fenster_teilweise_undicht']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='tueren_dicht']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='tueren_undicht']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='rolllaeden_kaesten_gedaemmt']").check();
|
|
||||||
|
|
||||||
// Fenster Bilder
|
cy.get("form[data-cy='ausweis'] button[data-cy='weiter']").click({ force: true });
|
||||||
cy.get("input[name='fenster_image']").should("have.attr", "type", "file").attachFile("images/fenster/1.jpeg", { subjectType: "input" });
|
|
||||||
cy.get("input[name='fenster_image']").should("have.attr", "type", "file").attachFile("images/fenster/2.jpeg", { subjectType: "input" });
|
|
||||||
|
|
||||||
// Wärmedämmung Daten
|
cy.url().should("contain", "/kundendaten");
|
||||||
if (Math.random() > 0.5) cy.get("input[name='aussenwand_gedaemmt']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='keller_wand_gedaemmt']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='keller_decke_gedaemmt']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='dachgeschoss_gedaemmt']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='oberste_geschossdecke_gedaemmt']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='oberste_geschossdecke_min_12cm_gedaemmt']").check();
|
|
||||||
|
|
||||||
// Wärmedämmung Bilder
|
const email = faker.internet.email();
|
||||||
cy.get("input[name='daemmung_image']").should("have.attr", "type", "file").attachFile("images/daemmung/1.jpeg", { subjectType: "input" });
|
const passwort = "test1234";
|
||||||
cy.get("input[name='daemmung_image']").should("have.attr", "type", "file").attachFile("images/daemmung/2.jpeg", { subjectType: "input" });
|
const vorname = faker.person.firstName();
|
||||||
|
const nachname = faker.person.lastName();
|
||||||
|
const telefon = faker.phone.number()
|
||||||
|
|
||||||
// Gebäude Bild
|
const strasse = faker.location.streetAddress({ useFullAddress: true })
|
||||||
cy.get("input[name='gebaeude_image']").should("have.attr", "type", "file").attachFile("images/gebaeude/1.jpeg", { subjectType: "input" });
|
|
||||||
|
|
||||||
cy.get("form[data-cy='ausweis'] button[data-cy='weiter']").click({ force: true });
|
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 as string);
|
||||||
|
cy.get("[data-cy='plz-container']").children().first().click()
|
||||||
|
cy.get("input[name='rechnung_email']").should("have.attr", "type", "email").type(email);
|
||||||
|
|
||||||
cy.url().should("contain", "/kundendaten");
|
cy.get("[data-cy='paypal']").click()
|
||||||
|
|
||||||
const email = faker.internet.email();
|
cy.get("button[data-cy='bestellen']").click();
|
||||||
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 })
|
cy["form:signup"](email, passwort, vorname, nachname)
|
||||||
const plz = faker.location.zipCode("#####")
|
|
||||||
|
|
||||||
cy.get("input[name='vorname']").should("have.attr", "type", "text").type(vorname);
|
cy.origin('https://www.mollie.com', () => {
|
||||||
cy.get("input[name='name']").should("have.attr", "type", "text").type(nachname);
|
// Jetzt sind wir auf der Mollie Seite, dort wählen wir den "paid" status aus
|
||||||
cy.get("input[name='telefon']").should("have.attr", "type", "text").type(telefon);
|
cy.get("input[type='radio'][name='final_state'][value='paid']").check();
|
||||||
// Rechnung
|
// Da wird unser Test fehlschlagen, da die localhost domain von Mollie aus nicht erreichbar ist.
|
||||||
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("[data-cy='paypal']").click()
|
|
||||||
|
|
||||||
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.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
|
|
||||||
cy.get("input[type='radio'][name='final_state'][value='paid']").check();
|
|
||||||
// Da wird unser Test fehlschlagen, da die localhost domain von Mollie aus nicht erreichbar ist.
|
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,296 +6,283 @@ 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();
|
cy.task("plz").then(plz => {
|
||||||
const passwort = "test1234";
|
const email = faker.internet.email();
|
||||||
const vorname = faker.person.firstName();
|
const passwort = "test1234";
|
||||||
const nachname = faker.person.lastName();
|
const vorname = faker.person.firstName();
|
||||||
const telefon = faker.phone.number()
|
const nachname = faker.person.lastName();
|
||||||
|
const telefon = faker.phone.number()
|
||||||
|
|
||||||
const strasse = faker.location.streetAddress({ useFullAddress: true })
|
const strasse = faker.location.streetAddress({ useFullAddress: true })
|
||||||
const plz = faker.location.zipCode("#####")
|
|
||||||
|
|
||||||
const preLogin = Math.random() > 0.5;
|
const preLogin = Math.random() > 0.5;
|
||||||
|
|
||||||
if (preLogin) {
|
if (preLogin) {
|
||||||
cy.signup(email, passwort, vorname, nachname)
|
cy.signup(email, passwort, vorname, nachname)
|
||||||
cy.login(email, passwort)
|
cy.login(email, passwort)
|
||||||
}
|
}
|
||||||
|
|
||||||
cy.visit("/energieausweis-erstellen/verbrauchsausweis-wohngebaeude");
|
cy.visit("/energieausweis-erstellen/verbrauchsausweis-wohngebaeude");
|
||||||
|
|
||||||
cy.wait(2000);
|
cy.wait(2000);
|
||||||
|
|
||||||
// Wir überprüfen, ob alle Ausstelgründe vorhanden sind, diese sollten genau so viele sein wie in der Datenbank vorhanden sind.
|
// 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']")
|
cy.get("select[data-cy='ausstellgrund']")
|
||||||
.select(
|
.select(
|
||||||
faker.number.int({
|
faker.number.int({
|
||||||
min: 1,
|
min: 1,
|
||||||
max: Object.values(Enums.Ausstellgrund).length - 1,
|
max: Object.values(Enums.Ausstellgrund).length - 1,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
// Jetzt Füllen wir das Baujahr vom Gebäude aus.
|
// Jetzt Füllen wir das Baujahr vom Gebäude aus.
|
||||||
cy.get("input[name='baujahr_gebaeude']")
|
cy.get("input[name='baujahr_gebaeude']")
|
||||||
.should("have.attr", "type", "number")
|
.should("have.attr", "type", "number")
|
||||||
.type(
|
.type(
|
||||||
faker.number.int({ min: 1900, max: 2021 }).toString() +
|
faker.number.int({ min: 1900, max: 2021 }).toString() +
|
||||||
"{enter}",
|
"{enter}",
|
||||||
{ delay: 50 }
|
{ 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 }
|
||||||
|
);
|
||||||
|
|
||||||
|
// Anzahl Einheiten
|
||||||
|
cy.get("input[name='einheiten']")
|
||||||
|
.should("have.attr", "type", "number")
|
||||||
|
.type(faker.number.int({ min: 1, max: 5 }).toString());
|
||||||
|
|
||||||
|
// Sanierungsstatus
|
||||||
|
cy.get("select[name='saniert']").select(
|
||||||
|
Math.random() > 0.5 ? "true" : "false"
|
||||||
);
|
);
|
||||||
|
|
||||||
// Jetzt Füllen wir das Baujahr der Heizung aus.
|
// Adresse
|
||||||
cy.get("input[name='baujahr_heizung']")
|
cy.get("input[name='adresse']").type(faker.location.streetAddress());
|
||||||
.should("have.attr", "type", "number")
|
|
||||||
.type(
|
// Postleitzahl
|
||||||
faker.number.int({ min: 1900, max: 2021 }).toString() +
|
cy.get("input[name='plz']").type(
|
||||||
"{enter}",
|
plz as string
|
||||||
{ delay: 50 }
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Anzahl Einheiten
|
// TODO: Ort - Dieser wird aus der Datenbank abgefragt, wir müssen also warten, bis der Dropdown da ist.
|
||||||
cy.get("input[name='einheiten']")
|
cy.get("[data-cy='plz-container']").find("button").first().click()
|
||||||
.should("have.attr", "type", "number")
|
|
||||||
.type(faker.number.int({ min: 1, max: 5 }).toString());
|
|
||||||
|
|
||||||
// Sanierungsstatus
|
// Flaeche
|
||||||
cy.get("select[name='saniert']").select(
|
cy.get("input[name='flaeche']")
|
||||||
Math.random() > 0.5 ? "true" : "false"
|
.should("have.attr", "type", "number")
|
||||||
);
|
.type(faker.number.int({ min: 50, max: 1000 }).toString());
|
||||||
|
|
||||||
// Adresse
|
// Nutzflaeche
|
||||||
cy.get("input[name='adresse']").type(faker.location.streetAddress());
|
cy.get("input[name='nutzflaeche']")
|
||||||
|
.should("have.attr", "type", "number")
|
||||||
|
.type(faker.number.int({ min: 50, max: 1000 }).toString());
|
||||||
|
|
||||||
// Postleitzahl
|
// Keller
|
||||||
cy.get("input[name='plz']").type(
|
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({
|
||||||
faker.location.zipCode({
|
max: (["BEHEIZT", "NICHT_VORHANDEN", "UNBEHEIZT"] as Enums.Heizungsstatus[]).length,
|
||||||
format: "#####",
|
min: 1
|
||||||
})
|
}));
|
||||||
);
|
|
||||||
|
|
||||||
// TODO: Ort - Dieser wird aus der Datenbank abgefragt, wir müssen also warten, bis der Dropdown da ist.
|
// Dachgeschoss
|
||||||
cy.get("[data-cy='plz-container']").find("button").first().click()
|
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: (["BEHEIZT", "NICHT_VORHANDEN", "UNBEHEIZT"] as Enums.Heizungsstatus[]).length,
|
||||||
|
min: 1
|
||||||
|
}));
|
||||||
|
|
||||||
// Flaeche
|
// Brennstoff und Einheit 1
|
||||||
cy.get("input[name='flaeche']")
|
const brennstoffKombo = fuelList[faker.number.int({ min: 0, max: fuelList.length - 1 })];
|
||||||
.should("have.attr", "type", "number")
|
|
||||||
.type(faker.number.int({ min: 50, max: 1000 }).toString());
|
|
||||||
|
|
||||||
// Nutzflaeche
|
cy.get("select[name='brennstoff_1']").select(brennstoffKombo[0]);
|
||||||
cy.get("input[name='nutzflaeche']")
|
cy.get("select[name='einheit_1']").select(brennstoffKombo[1]);
|
||||||
.should("have.attr", "type", "number")
|
|
||||||
.type(faker.number.int({ min: 50, max: 1000 }).toString());
|
|
||||||
|
|
||||||
// Keller
|
let availableDates = [];
|
||||||
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({
|
const startDate = moment()
|
||||||
max: (["BEHEIZT", "NICHT_VORHANDEN", "UNBEHEIZT"] as Enums.Heizungsstatus[]).length,
|
.subtract(4, "years")
|
||||||
min: 1
|
.subtract(6, "months");
|
||||||
}));
|
const endDate = moment().subtract(3, "years");
|
||||||
|
|
||||||
// Dachgeschoss
|
for (let m = moment(startDate); m.isBefore(endDate); m.add(1, "month")) {
|
||||||
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({
|
availableDates.push({
|
||||||
max: (["BEHEIZT", "NICHT_VORHANDEN", "UNBEHEIZT"] as Enums.Heizungsstatus[]).length,
|
year: m.year(),
|
||||||
min: 1
|
month: m.month(),
|
||||||
}));
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Brennstoff und Einheit 1
|
// Verbrauchszeitraum
|
||||||
const brennstoffKombo = fuelList[faker.number.int({ min: 0, max: fuelList.length - 1 })];
|
cy.get("select[name='energieverbrauch_zeitraum_jahr']").select(availableDates[0].year.toString());
|
||||||
|
cy.get("select[name='energieverbrauch_zeitraum_monat']").select(availableDates[0].month.toString());
|
||||||
|
|
||||||
cy.get("select[name='brennstoff_1']").select(brennstoffKombo[0]);
|
|
||||||
cy.get("select[name='einheit_1']").select(brennstoffKombo[1]);
|
|
||||||
|
|
||||||
let availableDates = [];
|
|
||||||
const startDate = moment()
|
|
||||||
.subtract(4, "years")
|
|
||||||
.subtract(6, "months");
|
|
||||||
const endDate = moment().subtract(3, "years");
|
|
||||||
|
|
||||||
for (let m = moment(startDate); m.isBefore(endDate); m.add(1, "month")) {
|
|
||||||
availableDates.push({
|
|
||||||
year: m.year(),
|
|
||||||
month: m.month(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verbrauchszeitraum
|
|
||||||
cy.get("select[name='energieverbrauch_zeitraum_jahr']").select(availableDates[0].year.toString());
|
|
||||||
cy.get("select[name='energieverbrauch_zeitraum_monat']").select(availableDates[0].month.toString());
|
|
||||||
|
|
||||||
|
|
||||||
// Verbrauch
|
|
||||||
cy.get("input[name='verbrauch_1']").type(faker.number.int({ min: 4000, max: 15000 }).toString(), { force: true });
|
|
||||||
cy.get("input[name='verbrauch_2']").type(faker.number.int({ min: 4000, max: 15000 }).toString(), { force: true });
|
|
||||||
cy.get("input[name='verbrauch_3']").type(faker.number.int({ min: 4000, max: 15000 }).toString(), { force: true });
|
|
||||||
|
|
||||||
|
|
||||||
const zusaetzlicheHeizquelle = Math.random() > 0.5;
|
|
||||||
|
|
||||||
if (zusaetzlicheHeizquelle) {
|
|
||||||
cy.get("[data-cy='zusaetzliche_heizquelle']").check();
|
|
||||||
|
|
||||||
// Brennstoff und Einheit 2
|
|
||||||
const brennstoffKombo2 = fuelList[faker.number.int({ min: 0, max: fuelList.length - 1 })];
|
|
||||||
|
|
||||||
cy.get("[data-cy='brennstoff_2']").select(brennstoffKombo2[0], { force: true });
|
|
||||||
cy.get("[data-cy='einheit_2']").select(brennstoffKombo2[1], { force: true });
|
|
||||||
|
|
||||||
// Verbrauch
|
// Verbrauch
|
||||||
cy.get("input[name='verbrauch_4']").type(faker.number.int({ min: 4000, max: 15000 }).toString(), { force: true });
|
cy.get("input[name='verbrauch_1']").type(faker.number.int({ min: 4000, max: 15000 }).toString(), { force: true });
|
||||||
cy.get("input[name='verbrauch_5']").type(faker.number.int({ min: 4000, max: 15000 }).toString(), { force: true });
|
cy.get("input[name='verbrauch_2']").type(faker.number.int({ min: 4000, max: 15000 }).toString(), { force: true });
|
||||||
cy.get("input[name='verbrauch_6']").type(faker.number.int({ min: 4000, max: 15000 }).toString(), { force: true });
|
cy.get("input[name='verbrauch_3']").type(faker.number.int({ min: 4000, max: 15000 }).toString(), { force: true });
|
||||||
}
|
|
||||||
|
|
||||||
// Warmwasser enthalten und bekannt
|
|
||||||
const warmwasserEnthalten = Math.random() > 0.5;
|
|
||||||
const anteilBekannt = Math.random() > 0.5;
|
|
||||||
|
|
||||||
if (warmwasserEnthalten) {
|
const zusaetzlicheHeizquelle = Math.random() > 0.5;
|
||||||
cy.get("input[name='warmwasser_enthalten']").check();
|
|
||||||
|
|
||||||
if (anteilBekannt) {
|
if (zusaetzlicheHeizquelle) {
|
||||||
// Der Anteil ist bekannt, wir müssen ihn also angeben.
|
cy.get("[data-cy='zusaetzliche_heizquelle']").check();
|
||||||
cy.get("input[name='warmwasser_anteil_bekannt']").check();
|
|
||||||
|
|
||||||
cy.get("input[name='anteil_warmwasser_1']").type(faker.number.int({ min: 0, max: 50 }).toString());
|
// Brennstoff und Einheit 2
|
||||||
|
const brennstoffKombo2 = fuelList[faker.number.int({ min: 0, max: fuelList.length - 1 })];
|
||||||
|
|
||||||
if (zusaetzlicheHeizquelle) {
|
cy.get("[data-cy='brennstoff_2']").select(brennstoffKombo2[0], { force: true });
|
||||||
// Zusätzliche Heizquelle existiert, also müssen wir auch hier den Anteil angeben.
|
cy.get("[data-cy='einheit_2']").select(brennstoffKombo2[1], { force: true });
|
||||||
cy.get("input[name='anteil_warmwasser_2']").type(faker.number.int({ min: 0, max: 50 }).toString(), {force: true});
|
|
||||||
|
// Verbrauch
|
||||||
|
cy.get("input[name='verbrauch_4']").type(faker.number.int({ min: 4000, max: 15000 }).toString(), { force: true });
|
||||||
|
cy.get("input[name='verbrauch_5']").type(faker.number.int({ min: 4000, max: 15000 }).toString(), { force: true });
|
||||||
|
cy.get("input[name='verbrauch_6']").type(faker.number.int({ min: 4000, max: 15000 }).toString(), { force: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Warmwasser enthalten und bekannt
|
||||||
|
const warmwasserEnthalten = Math.random() > 0.5;
|
||||||
|
const anteilBekannt = Math.random() > 0.5;
|
||||||
|
|
||||||
|
if (warmwasserEnthalten) {
|
||||||
|
cy.get("input[name='warmwasser_enthalten']").check();
|
||||||
|
|
||||||
|
if (anteilBekannt) {
|
||||||
|
// Der Anteil ist bekannt, wir müssen ihn also angeben.
|
||||||
|
cy.get("input[name='warmwasser_anteil_bekannt']").check();
|
||||||
|
|
||||||
|
cy.get("input[name='anteil_warmwasser_1']").type(faker.number.int({ min: 0, max: 50 }).toString());
|
||||||
|
|
||||||
|
if (zusaetzlicheHeizquelle) {
|
||||||
|
// Zusätzliche Heizquelle existiert, also müssen wir auch hier den Anteil angeben.
|
||||||
|
cy.get("input[name='anteil_warmwasser_2']").type(faker.number.int({ min: 0, max: 50 }).toString(), {force: true});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Alternative Energieversorgungssysteme
|
// Alternative Energieversorgungssysteme
|
||||||
if (Math.random() > 0.5) cy.get("input[name='alternative_heizung']").check();
|
if (Math.random() > 0.5) cy.get("input[name='alternative_heizung']").check();
|
||||||
if (Math.random() > 0.5) cy.get("input[name='alternative_warmwasser']").check();
|
if (Math.random() > 0.5) cy.get("input[name='alternative_warmwasser']").check();
|
||||||
if (Math.random() > 0.5) cy.get("input[name='alternative_lueftung']").check();
|
if (Math.random() > 0.5) cy.get("input[name='alternative_lueftung']").check();
|
||||||
if (Math.random() > 0.5) cy.get("input[name='alternative_kuehlung']").check();
|
if (Math.random() > 0.5) cy.get("input[name='alternative_kuehlung']").check();
|
||||||
|
|
||||||
// Gebäudetyp
|
// Gebäudetyp
|
||||||
cy.get("select[name='gebaeudetyp']").then(($dropdown) => {
|
cy.get("select[name='gebaeudetyp']").then(($dropdown) => {
|
||||||
const options = $dropdown.find('option');
|
const options = $dropdown.find('option');
|
||||||
// Select the option at the random index
|
// 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);
|
cy.get("select[name='gebaeudetyp']").select(options.eq(faker.number.int({ min: 1, max: options.length - 1 })).val() as string);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Gebäudeteil
|
||||||
|
cy.get("select[name='gebaeudeteil']").then(($dropdown) => {
|
||||||
|
const options = $dropdown.find('option');
|
||||||
|
// Select the option at the random index
|
||||||
|
cy.get("select[name='gebaeudeteil']").select(options.eq(faker.number.int({ min: 1, max: options.length - 1 })).val() as string);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Lüftung
|
||||||
|
cy.get("select[name='lueftung']").then(($dropdown) => {
|
||||||
|
const options = $dropdown.find('option');
|
||||||
|
// Select the option at the random index
|
||||||
|
cy.get("select[name='lueftung']").select(options.eq(faker.number.int({ min: 1, max: options.length - 1 })).val() as string);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Kühlung
|
||||||
|
cy.get("select[name='kuehlung']").then(($dropdown) => {
|
||||||
|
const options = $dropdown.find('option');
|
||||||
|
// Select the option at the random index
|
||||||
|
cy.get("select[name='kuehlung']").select(options.eq(faker.number.int({ min: 1, max: options.length - 1 })).val() as string, { force: true });
|
||||||
|
});
|
||||||
|
|
||||||
|
// Leerstand
|
||||||
|
cy.get("input[name='leerstand']").should("have.attr", "type", "number").type(faker.number.int({ min: 0, max: 30 }).toString());
|
||||||
|
|
||||||
|
// Heizungsanlage Daten
|
||||||
|
if (Math.random() > 0.5) cy.get("[data-cy='zentralheizung']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("[data-cy='einzelofen']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("[data-cy='durchlauf_erhitzer']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("[data-cy='standard_kessel']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("[data-cy='solarsystem_warmwasser']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("[data-cy='waermepumpe']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("[data-cy='niedertemperatur_kessel']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("[data-cy='brennwert_kessel']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("[data-cy='warmwasser_rohre_gedaemmt']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("[data-cy='heizungsrohre_gedaemmt']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("[data-cy='zirkulation']").check();
|
||||||
|
// if (Math.random() > 0.5) cy.get("[data-cy='raum_temperatur_regler']").check();
|
||||||
|
|
||||||
|
// Heizungsanlage Bilder
|
||||||
|
cy.get("input[name='heizung_image']").should("have.attr", "type", "file").attachFile("images/heizungsanlage/1.jpeg", { subjectType: "input" });
|
||||||
|
cy.get("input[name='heizung_image']").should("have.attr", "type", "file").attachFile("images/heizungsanlage/2.jpeg", { subjectType: "input" });
|
||||||
|
|
||||||
|
// Fenster Daten
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='einfach_verglasung']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='doppel_verglasung']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='isolier_verglasung']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='dreifach_verglasung']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='fenster_dicht']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='fenster_teilweise_undicht']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='tueren_dicht']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='tueren_undicht']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='rolllaeden_kaesten_gedaemmt']").check();
|
||||||
|
|
||||||
|
// Fenster Bilder
|
||||||
|
cy.get("input[name='fenster_image']").should("have.attr", "type", "file").attachFile("images/fenster/1.jpeg", { subjectType: "input" });
|
||||||
|
cy.get("input[name='fenster_image']").should("have.attr", "type", "file").attachFile("images/fenster/2.jpeg", { subjectType: "input" });
|
||||||
|
|
||||||
|
// Wärmedämmung Daten
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='aussenwand_gedaemmt']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='keller_wand_gedaemmt']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='keller_decke_gedaemmt']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='dachgeschoss_gedaemmt']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='oberste_geschossdecke_gedaemmt']").check();
|
||||||
|
if (Math.random() > 0.5) cy.get("input[name='oberste_geschossdecke_min_12cm_gedaemmt']").check();
|
||||||
|
|
||||||
|
// Wärmedämmung Bilder
|
||||||
|
cy.get("input[name='daemmung_image']").should("have.attr", "type", "file").attachFile("images/daemmung/1.jpeg", { subjectType: "input" });
|
||||||
|
cy.get("input[name='daemmung_image']").should("have.attr", "type", "file").attachFile("images/daemmung/2.jpeg", { subjectType: "input" });
|
||||||
|
|
||||||
|
// Gebäude Bild
|
||||||
|
cy.get("input[name='gebaeude_image']").should("have.attr", "type", "file").attachFile("images/gebaeude/1.jpeg", { subjectType: "input" });
|
||||||
|
|
||||||
|
// Jetzt können wir den Verbrauchsausweis erstellen.
|
||||||
|
cy.get("form[data-cy='ausweis'] button[data-cy='weiter']").click({ force: true });
|
||||||
|
|
||||||
|
cy.url().should("contain", "/kundendaten");
|
||||||
|
|
||||||
|
cy.get("input[name='telefon']").should("have.attr", "type", "text").type(telefon);
|
||||||
|
// Rechnung
|
||||||
|
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 as string);
|
||||||
|
cy.get("[data-cy='plz-container']").children().first().click()
|
||||||
|
|
||||||
|
cy.get("[data-cy='paypal']").click()
|
||||||
|
|
||||||
|
cy.get("button[data-cy='bestellen']").click();
|
||||||
|
|
||||||
|
if (!preLogin) {
|
||||||
|
cy["form:signup"](email, passwort, vorname, nachname)
|
||||||
|
}
|
||||||
|
|
||||||
|
cy.origin('https://www.mollie.com', () => {
|
||||||
|
// Jetzt sind wir auf der Mollie Seite, dort wählen wir den "paid" status aus
|
||||||
|
cy.get("input[type='radio'][name='final_state'][value='paid']").check();
|
||||||
|
// Da wird unser Test fehlschlagen, da die localhost domain von Mollie aus nicht erreichbar ist.
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
// Gebäudeteil
|
|
||||||
cy.get("select[name='gebaeudeteil']").then(($dropdown) => {
|
|
||||||
const options = $dropdown.find('option');
|
|
||||||
// Select the option at the random index
|
|
||||||
cy.get("select[name='gebaeudeteil']").select(options.eq(faker.number.int({ min: 1, max: options.length - 1 })).val() as string);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Lüftung
|
|
||||||
cy.get("select[name='lueftung']").then(($dropdown) => {
|
|
||||||
const options = $dropdown.find('option');
|
|
||||||
// Select the option at the random index
|
|
||||||
cy.get("select[name='lueftung']").select(options.eq(faker.number.int({ min: 1, max: options.length - 1 })).val() as string);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Kühlung
|
|
||||||
cy.get("select[name='kuehlung']").then(($dropdown) => {
|
|
||||||
const options = $dropdown.find('option');
|
|
||||||
// Select the option at the random index
|
|
||||||
cy.get("select[name='kuehlung']").select(options.eq(faker.number.int({ min: 1, max: options.length - 1 })).val() as string, { force: true });
|
|
||||||
});
|
|
||||||
|
|
||||||
// Leerstand
|
|
||||||
cy.get("input[name='leerstand']").should("have.attr", "type", "number").type(faker.number.int({ min: 0, max: 30 }).toString());
|
|
||||||
|
|
||||||
// Heizungsanlage Daten
|
|
||||||
if (Math.random() > 0.5) cy.get("[data-cy='zentralheizung']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("[data-cy='einzelofen']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("[data-cy='durchlauf_erhitzer']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("[data-cy='standard_kessel']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("[data-cy='solarsystem_warmwasser']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("[data-cy='waermepumpe']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("[data-cy='niedertemperatur_kessel']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("[data-cy='brennwert_kessel']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("[data-cy='warmwasser_rohre_gedaemmt']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("[data-cy='heizungsrohre_gedaemmt']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("[data-cy='zirkulation']").check();
|
|
||||||
// if (Math.random() > 0.5) cy.get("[data-cy='raum_temperatur_regler']").check();
|
|
||||||
|
|
||||||
// Heizungsanlage Bilder
|
|
||||||
cy.get("input[name='heizung_image']").should("have.attr", "type", "file").attachFile("images/heizungsanlage/1.jpeg", { subjectType: "input" });
|
|
||||||
cy.get("input[name='heizung_image']").should("have.attr", "type", "file").attachFile("images/heizungsanlage/2.jpeg", { subjectType: "input" });
|
|
||||||
|
|
||||||
// Fenster Daten
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='einfach_verglasung']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='doppel_verglasung']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='isolier_verglasung']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='dreifach_verglasung']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='fenster_dicht']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='fenster_teilweise_undicht']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='tueren_dicht']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='tueren_undicht']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='rolllaeden_kaesten_gedaemmt']").check();
|
|
||||||
|
|
||||||
// Fenster Bilder
|
|
||||||
cy.get("input[name='fenster_image']").should("have.attr", "type", "file").attachFile("images/fenster/1.jpeg", { subjectType: "input" });
|
|
||||||
cy.get("input[name='fenster_image']").should("have.attr", "type", "file").attachFile("images/fenster/2.jpeg", { subjectType: "input" });
|
|
||||||
|
|
||||||
// Wärmedämmung Daten
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='aussenwand_gedaemmt']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='keller_wand_gedaemmt']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='keller_decke_gedaemmt']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='dachgeschoss_gedaemmt']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='oberste_geschossdecke_gedaemmt']").check();
|
|
||||||
if (Math.random() > 0.5) cy.get("input[name='oberste_geschossdecke_min_12cm_gedaemmt']").check();
|
|
||||||
|
|
||||||
// Wärmedämmung Bilder
|
|
||||||
cy.get("input[name='daemmung_image']").should("have.attr", "type", "file").attachFile("images/daemmung/1.jpeg", { subjectType: "input" });
|
|
||||||
cy.get("input[name='daemmung_image']").should("have.attr", "type", "file").attachFile("images/daemmung/2.jpeg", { subjectType: "input" });
|
|
||||||
|
|
||||||
// Gebäude Bild
|
|
||||||
cy.get("input[name='gebaeude_image']").should("have.attr", "type", "file").attachFile("images/gebaeude/1.jpeg", { subjectType: "input" });
|
|
||||||
|
|
||||||
// Jetzt können wir den Verbrauchsausweis erstellen.
|
|
||||||
cy.get("form[data-cy='ausweis'] button[data-cy='weiter']").click({ force: true });
|
|
||||||
|
|
||||||
cy.url().should("contain", "/kundendaten");
|
|
||||||
|
|
||||||
cy.get("input[name='telefon']").should("have.attr", "type", "text").type(telefon);
|
|
||||||
// Rechnung
|
|
||||||
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("[data-cy='paypal']").click()
|
|
||||||
|
|
||||||
cy.get("button[data-cy='bestellen']").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);
|
|
||||||
|
|
||||||
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
|
|
||||||
cy.get("input[type='radio'][name='final_state'][value='paid']").check();
|
|
||||||
// Da wird unser Test fehlschlagen, da die localhost domain von Mollie aus nicht erreichbar ist.
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -30,11 +30,28 @@ Cypress.Commands.add("signup", (email, passwort, vorname, name) => {
|
|||||||
cy.url().should("include", "/auth/login")
|
cy.url().should("include", "/auth/login")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Cypress.Commands.add("form:signup", (email, passwort, vorname, name) => {
|
||||||
|
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(name);
|
||||||
|
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();
|
||||||
|
})
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
namespace Cypress {
|
namespace Cypress {
|
||||||
interface Chainable {
|
interface Chainable {
|
||||||
login(email: string, passwort: string): Chainable<void>
|
login(email: string, passwort: string): Chainable<void>
|
||||||
signup(email: string, passwort: string, vorname: string, name: string): Chainable<void>
|
signup(email: string, passwort: string, vorname: string, name: string): Chainable<void>
|
||||||
|
"form:signup"(email: string, passwort: string, vorname: string, name: string): Chainable<void>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Aufnahme, BedarfsausweisGewerbe, BedarfsausweisWohnen, Bild, Objekt, prisma, Unterlage, VerbrauchsausweisGewerbe, VerbrauchsausweisWohnen } from "./prisma.js";
|
import { Aufnahme, BedarfsausweisGewerbe, BedarfsausweisWohnen, Bild, GEGNachweisGewerbe, GEGNachweisWohnen, Objekt, prisma, Unterlage, VerbrauchsausweisGewerbe, VerbrauchsausweisWohnen } from "./prisma.js";
|
||||||
|
|
||||||
export async function getVerbrauchsausweisWohnen(id: string): Promise<VerbrauchsausweisWohnen | null> {
|
export async function getVerbrauchsausweisWohnen(id: string): Promise<VerbrauchsausweisWohnen | null> {
|
||||||
return await prisma.verbrauchsausweisWohnen.findUnique({
|
return await prisma.verbrauchsausweisWohnen.findUnique({
|
||||||
@@ -32,6 +32,22 @@ export async function getBedarfsausweisGewerbe(id: string): Promise<Bedarfsauswe
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getGEGNachweisWohnen(id: string): Promise<GEGNachweisWohnen | null> {
|
||||||
|
return await prisma.gEGNachweisWohnen.findUnique({
|
||||||
|
where: {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getGEGNachweisGewerbe(id: string): Promise<GEGNachweisGewerbe | null> {
|
||||||
|
return await prisma.gEGNachweisGewerbe.findUnique({
|
||||||
|
where: {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export async function getAufnahme(id: string): Promise<Aufnahme | null> {
|
export async function getAufnahme(id: string): Promise<Aufnahme | null> {
|
||||||
return await prisma.aufnahme.findUnique({
|
return await prisma.aufnahme.findUnique({
|
||||||
where: {
|
where: {
|
||||||
|
|||||||
@@ -111,7 +111,7 @@
|
|||||||
<GEGAusweisart
|
<GEGAusweisart
|
||||||
bind:objekt
|
bind:objekt
|
||||||
bind:aufnahme
|
bind:aufnahme
|
||||||
bind:ausweis={nachweis}
|
bind:nachweis={nachweis}
|
||||||
{ausweisart}
|
{ausweisart}
|
||||||
/>
|
/>
|
||||||
</Bereich>
|
</Bereich>
|
||||||
|
|||||||
@@ -9,64 +9,50 @@
|
|||||||
BildClient,
|
BildClient,
|
||||||
} from "#components/Ausweis/types.js";
|
} from "#components/Ausweis/types.js";
|
||||||
import Bereich from "#components/labels/Bereich.svelte";
|
import Bereich from "#components/labels/Bereich.svelte";
|
||||||
import { Enums } from "#lib/client/prisma.js";
|
import { Enums, Unterlage } from "#lib/client/prisma.js";
|
||||||
import InputLabel from "#components/labels/InputLabel.svelte";
|
import InputLabel from "#components/labels/InputLabel.svelte";
|
||||||
import HelpLabel from "#components/labels/HelpLabel.svelte";
|
import HelpLabel from "#components/labels/HelpLabel.svelte";
|
||||||
import Progressbar from "#components/Ausweis/Progressbar.svelte";
|
import Progressbar from "#components/Ausweis/Progressbar.svelte";
|
||||||
import FileGrid from "#components/FileGrid.svelte";
|
import FileGrid from "#components/FileGrid.svelte";
|
||||||
import ButtonWeiterHilfe from "#components/Ausweis/ButtonWeiterHilfe.svelte";
|
import ButtonWeiterHilfe from "#components/Ausweis/ButtonWeiterHilfe.svelte";
|
||||||
import GEGAusweisart from "#components/GEGNachweis/GEGAusweisart.svelte";
|
import GEGAusweisart from "#components/GEGNachweis/GEGAusweisart.svelte";
|
||||||
|
import moment from "moment";
|
||||||
|
|
||||||
export let nachweis: GEGNachweisWohnenClient;
|
export let nachweis: GEGNachweisWohnenClient;
|
||||||
export let objekt: ObjektClient;
|
export let objekt: ObjektClient;
|
||||||
export let aufnahme: AufnahmeClient;
|
export let aufnahme: AufnahmeClient;
|
||||||
export let user: BenutzerClient = {} as BenutzerClient;
|
export let user: BenutzerClient = {} as BenutzerClient;
|
||||||
export let bilder: BildClient[] = [];
|
export let bilder: BildClient[] = [];
|
||||||
export let plaene: UnterlageClient[] = [];
|
export let plaene: Unterlage[] = [];
|
||||||
export let unterlagen: UnterlageClient[] = [];
|
export let unterlagen: Unterlage[] = [];
|
||||||
|
export let nachweistyp: Enums.AusweisTyp = Enums.AusweisTyp.Standard;
|
||||||
|
export let id: string | null;
|
||||||
|
|
||||||
if (Object.keys(nachweis).length === 0) {
|
if ((user && user.rolle !== Enums.BenutzerRolle.ADMIN) && !id && (!nachweis.updated_at || moment(localStorage.getItem("geg-nachweis-wohnen.updated_at") || new Date()).isAfter(nachweis.updated_at))) {
|
||||||
const localStorageAusweis = localStorage.getItem(
|
const localStorageNachweis = localStorage.getItem("geg-nachweis-wohnen.ausweis");
|
||||||
"geg-nachweis-wohnen.ausweis"
|
if (localStorageNachweis) {
|
||||||
);
|
nachweis = JSON.parse(localStorageNachweis)
|
||||||
if (localStorageAusweis) {
|
nachweis.nachweistyp = nachweistyp;
|
||||||
nachweis = JSON.parse(localStorageAusweis);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (Object.keys(aufnahme).length === 0) {
|
const localStorageAufnahme = localStorage.getItem("geg-nachweis-wohnen.aufnahme");
|
||||||
const localStorageAufnahme = localStorage.getItem(
|
|
||||||
"geg-nachweis-wohnen.aufnahme"
|
|
||||||
);
|
|
||||||
if (localStorageAufnahme) {
|
if (localStorageAufnahme) {
|
||||||
aufnahme = JSON.parse(localStorageAufnahme);
|
aufnahme = JSON.parse(localStorageAufnahme)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (Object.keys(objekt).length === 0) {
|
const localStorageObjekt = localStorage.getItem("geg-nachweis-wohnen.objekt");
|
||||||
const localStorageObjekt = localStorage.getItem(
|
|
||||||
"geg-nachweis-wohnen.objekt"
|
|
||||||
);
|
|
||||||
if (localStorageObjekt) {
|
if (localStorageObjekt) {
|
||||||
objekt = JSON.parse(localStorageObjekt);
|
objekt = JSON.parse(localStorageObjekt)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (Object.keys(bilder).length === 0) {
|
const localStorageBilder = localStorage.getItem("geg-nachweis-wohnen.bilder");
|
||||||
const localStorageBilder = localStorage.getItem(
|
|
||||||
"geg-nachweis-wohnen.bilder"
|
|
||||||
);
|
|
||||||
if (localStorageBilder) {
|
if (localStorageBilder) {
|
||||||
bilder = JSON.parse(localStorageBilder);
|
bilder = JSON.parse(localStorageBilder)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (Object.keys(unterlagen).length === 0) {
|
const localStorageUnterlagen = localStorage.getItem("geg-nachweis-wohnen.unterlagen");
|
||||||
const localStorageUnterlagen = localStorage.getItem(
|
|
||||||
"geg-nachweis-wohnen.unterlagen"
|
|
||||||
);
|
|
||||||
if (localStorageUnterlagen) {
|
if (localStorageUnterlagen) {
|
||||||
unterlagen = JSON.parse(localStorageUnterlagen);
|
unterlagen = JSON.parse(localStorageUnterlagen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,6 +96,7 @@
|
|||||||
{ausweisart}
|
{ausweisart}
|
||||||
{anliegen}
|
{anliegen}
|
||||||
steps={["Gebäudedaten", "Kundendaten", "Anfragebestätigung"]}
|
steps={["Gebäudedaten", "Kundendaten", "Anfragebestätigung"]}
|
||||||
|
ausweistyp={nachweistyp}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -121,7 +108,7 @@
|
|||||||
<GEGAusweisart
|
<GEGAusweisart
|
||||||
bind:objekt
|
bind:objekt
|
||||||
bind:aufnahme
|
bind:aufnahme
|
||||||
bind:ausweis={nachweis}
|
bind:nachweis
|
||||||
{ausweisart}
|
{ausweisart}
|
||||||
/>
|
/>
|
||||||
</Bereich>
|
</Bereich>
|
||||||
|
|||||||
@@ -1,90 +1,87 @@
|
|||||||
---
|
---
|
||||||
import AusweisLayout from "#layouts/AusweisLayoutDaten.astro";
|
import AusweisLayout from "#layouts/AusweisLayoutDaten.astro";
|
||||||
import { AufnahmeClient, BildClient, GEGNachweisWohnenClient, ObjektClient, UnterlageClient } from "#components/Ausweis/types";
|
|
||||||
import { createCaller } from "src/astro-typesafe-api-caller";
|
|
||||||
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants.js";
|
|
||||||
import { validateAccessTokenServer } from "#server/lib/validateAccessToken.js";
|
|
||||||
import GEGNachweisWohnenModule from "#modules/angebot-anfragen/GEGNachweisWohnenModule.svelte";
|
import GEGNachweisWohnenModule from "#modules/angebot-anfragen/GEGNachweisWohnenModule.svelte";
|
||||||
|
import { getGEGNachweisWohnen, getAufnahme, getObjekt, getBilder } from "#lib/server/db";
|
||||||
|
import { Enums, Aufnahme, Objekt, Bild, GEGNachweisWohnen, Unterlage } from "#lib/server/prisma";
|
||||||
|
import { getCurrentUser } from "#lib/server/user";
|
||||||
|
import { getUnterlagen } from "#lib/server/db";
|
||||||
|
|
||||||
const uid = Astro.url.searchParams.get("uid");
|
const id = Astro.url.searchParams.get("id");
|
||||||
let nachweis: GEGNachweisWohnenClient = {} as GEGNachweisWohnenClient;
|
const aufnahme_id = Astro.url.searchParams.get("aufnahme")
|
||||||
let aufnahme: AufnahmeClient = {} as AufnahmeClient;
|
let ausweistyp = Astro.url.searchParams.get("ausweistyp") as Enums.AusweisTyp || Enums.AusweisTyp.Standard;
|
||||||
let objekt: ObjektClient = {} as ObjektClient;
|
|
||||||
let bilder: BildClient[] = []
|
|
||||||
let unterlagen: UnterlageClient[] = []
|
|
||||||
|
|
||||||
const valid = validateAccessTokenServer(Astro);
|
let nachweis: GEGNachweisWohnen = {} as GEGNachweisWohnen;
|
||||||
|
let aufnahme: Aufnahme = {} as Aufnahme;
|
||||||
|
let objekt: Objekt = {} as Objekt;
|
||||||
|
let bilder: Bild[] = []
|
||||||
|
let unterlagen: Unterlage[] = []
|
||||||
|
|
||||||
const caller = createCaller(Astro);
|
const user = await getCurrentUser(Astro)
|
||||||
|
|
||||||
if (uid) {
|
if (id) {
|
||||||
if (!valid) {
|
if (!user) {
|
||||||
return Astro.redirect(
|
return Astro.redirect(
|
||||||
`/auth/login?redirect=${Astro.url.toString()}`
|
`/auth/login?redirect=${Astro.url.toString()}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
nachweis = await getGEGNachweisWohnen(id) as GEGNachweisWohnen
|
||||||
nachweis = await caller["geg-nachweis-wohnen"]._uid.GET.fetch(null, {
|
|
||||||
headers: {
|
|
||||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
|
||||||
},
|
|
||||||
params: {
|
|
||||||
uid
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
aufnahme = await caller.aufnahme._uid.GET.fetch(null, {
|
if (!nachweis || nachweis.benutzer_id !== user.id) {
|
||||||
headers: {
|
// Der Ausweis scheint nicht zu existieren.
|
||||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
// Wir leiten auf die generische Ausweisseite ohne ID weiter.
|
||||||
},
|
|
||||||
params: {
|
|
||||||
uid: nachweis.uid_aufnahme
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
objekt = await caller.objekt._uid.GET.fetch(null, {
|
|
||||||
headers: {
|
|
||||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
|
||||||
},
|
|
||||||
params: {
|
|
||||||
uid: nachweis.uid_objekt
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
bilder = await caller.aufnahme._uid.bilder.GET.fetch(null, {
|
|
||||||
headers: {
|
|
||||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
|
||||||
},
|
|
||||||
params: {
|
|
||||||
uid: nachweis.uid_aufnahme
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
unterlagen = await caller.aufnahme._uid.unterlagen.GET.fetch(null, {
|
|
||||||
headers: {
|
|
||||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
|
||||||
},
|
|
||||||
params: {
|
|
||||||
uid: nachweis.uid_aufnahme
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!nachweis) {
|
|
||||||
// Der Ausweis scheint nicht zu existieren.
|
|
||||||
// Wir leiten auf die generische Ausweisseite ohne UID weiter.
|
|
||||||
return Astro.redirect(
|
|
||||||
"/angebot-anfragen/geg-nachweis-wohnen-anfragen"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch(e) {
|
|
||||||
return Astro.redirect(
|
return Astro.redirect(
|
||||||
"/angebot-anfragen/geg-nachweis-wohnen-anfragen"
|
"/energieausweis-erstellen/verbrauchsausweis-wohngebaeude"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
aufnahme = await getAufnahme(nachweis.aufnahme_id) as Aufnahme
|
||||||
|
|
||||||
|
if (!aufnahme) {
|
||||||
|
// Die Aufnahme existiert nicht, das sollte eigentlich nicht passieren aber so können wir nicht fortfahren.
|
||||||
|
return Astro.redirect(
|
||||||
|
"/energieausweis-erstellen/verbrauchsausweis-wohngebaeude"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
objekt = await getObjekt(aufnahme.objekt_id) as Objekt
|
||||||
|
|
||||||
|
if (!objekt) {
|
||||||
|
// Das Objekt existiert nicht, das sollte eigentlich nicht passieren aber so können wir nicht fortfahren.
|
||||||
|
return Astro.redirect(
|
||||||
|
"/energieausweis-erstellen/verbrauchsausweis-wohngebaeude"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
bilder = await getBilder(aufnahme.id);
|
||||||
|
unterlagen = await getUnterlagen(aufnahme.id);
|
||||||
|
} else if (aufnahme_id) {
|
||||||
|
if (!user) {
|
||||||
|
return Astro.redirect(
|
||||||
|
`/auth/login?redirect=${Astro.url.toString()}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
aufnahme = await getAufnahme(nachweis.aufnahme_id) as Aufnahme
|
||||||
|
|
||||||
|
if (!aufnahme) {
|
||||||
|
// Die Aufnahme existiert wohl nicht.
|
||||||
|
return Astro.redirect(
|
||||||
|
"/energieausweis-erstellen/verbrauchsausweis-wohngebaeude"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
objekt = await getObjekt(aufnahme.objekt_id) as Objekt
|
||||||
|
|
||||||
|
if (!objekt) {
|
||||||
|
// Das Objekt existiert nicht.
|
||||||
|
return Astro.redirect(
|
||||||
|
"/energieausweis-erstellen/verbrauchsausweis-wohngebaeude"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
---
|
---
|
||||||
|
|
||||||
<AusweisLayout title="GEG Nachweis Wohnen anfragen">
|
<AusweisLayout title="GEG Nachweis Wohnen anfragen">
|
||||||
<GEGNachweisWohnenModule client:only {nachweis} {objekt} {aufnahme} {bilder} {unterlagen} />
|
<GEGNachweisWohnenModule client:only {nachweis} {objekt} {aufnahme} {bilder} {unterlagen} {id} />
|
||||||
</AusweisLayout>
|
</AusweisLayout>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { UUidWithPrefix } from "#components/Ausweis/types.js";
|
import { UUidWithPrefix } from "#components/Ausweis/types.js";
|
||||||
|
import { VALID_UUID_PREFIXES } from "#lib/constants.js";
|
||||||
|
import { generatePrefixedId } from "#lib/db.js";
|
||||||
import { authorizationHeaders, authorizationMiddleware } from "#lib/middleware/authorization.js";
|
import { authorizationHeaders, authorizationMiddleware } from "#lib/middleware/authorization.js";
|
||||||
import { prisma } from "#lib/server/prisma.js";
|
import { prisma } from "#lib/server/prisma.js";
|
||||||
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
||||||
@@ -16,24 +18,25 @@ export const PUT = defineApiRoute({
|
|||||||
nachweis: GEGNachweisGewerbeSchema.omit({
|
nachweis: GEGNachweisGewerbeSchema.omit({
|
||||||
id: true,
|
id: true,
|
||||||
benutzer_id: true,
|
benutzer_id: true,
|
||||||
uid: true,
|
|
||||||
aufnahme_id: true,
|
aufnahme_id: true,
|
||||||
|
created_at: true,
|
||||||
|
updated_at: true,
|
||||||
geg_einpreisung_id: true,
|
geg_einpreisung_id: true,
|
||||||
rechnung_id: true
|
rechnung_id: true
|
||||||
}),
|
}),
|
||||||
uid_aufnahme: UUidWithPrefix
|
aufnahme_id: UUidWithPrefix
|
||||||
}),
|
}),
|
||||||
output: z.object({
|
output: z.object({
|
||||||
uid: UUidWithPrefix,
|
id: UUidWithPrefix,
|
||||||
objekt_uid: UUidWithPrefix,
|
objekt_id: UUidWithPrefix,
|
||||||
aufnahme_uid: UUidWithPrefix,
|
aufnahme_id: UUidWithPrefix,
|
||||||
}),
|
}),
|
||||||
headers: authorizationHeaders,
|
headers: authorizationHeaders,
|
||||||
middleware: authorizationMiddleware,
|
middleware: authorizationMiddleware,
|
||||||
async fetch(input, ctx, user) {
|
async fetch(input, ctx, user) {
|
||||||
const aufnahme = await prisma.aufnahme.findUnique({
|
const aufnahme = await prisma.aufnahme.findUnique({
|
||||||
where: {
|
where: {
|
||||||
uid: input.uid_aufnahme
|
id: input.aufnahme_id
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -44,8 +47,11 @@ export const PUT = defineApiRoute({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const id = generatePrefixedId(6, VALID_UUID_PREFIXES.GEGNachweisGewerbe)
|
||||||
|
|
||||||
const nachweis = await prisma.gEGNachweisGewerbe.create({
|
const nachweis = await prisma.gEGNachweisGewerbe.create({
|
||||||
data: {
|
data: {
|
||||||
|
id,
|
||||||
...input.nachweis,
|
...input.nachweis,
|
||||||
benutzer: {
|
benutzer: {
|
||||||
connect: {
|
connect: {
|
||||||
@@ -59,13 +65,13 @@ export const PUT = defineApiRoute({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
uid: true,
|
id: true,
|
||||||
aufnahme: {
|
aufnahme: {
|
||||||
select: {
|
select: {
|
||||||
uid: true,
|
id: true,
|
||||||
objekt: {
|
objekt: {
|
||||||
select: {
|
select: {
|
||||||
uid: true,
|
id: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -74,9 +80,9 @@ export const PUT = defineApiRoute({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
uid: nachweis.uid,
|
id: nachweis.id,
|
||||||
objekt_uid: nachweis.aufnahme.objekt.uid,
|
objekt_id: nachweis.aufnahme.objekt.id,
|
||||||
aufnahme_uid: nachweis.aufnahme.uid,
|
aufnahme_id: nachweis.aufnahme.id,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -101,11 +107,11 @@ export const GET = defineApiRoute({
|
|||||||
headers: authorizationHeaders,
|
headers: authorizationHeaders,
|
||||||
middleware: authorizationMiddleware,
|
middleware: authorizationMiddleware,
|
||||||
async fetch(input, context, user) {
|
async fetch(input, context, user) {
|
||||||
const { uid } = context.params;
|
const { id } = context.params;
|
||||||
|
|
||||||
const nachweis = await prisma.gEGNachweisGewerbe.findUnique({
|
const nachweis = await prisma.gEGNachweisGewerbe.findUnique({
|
||||||
where: {
|
where: {
|
||||||
uid,
|
id,
|
||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
benutzer: true,
|
benutzer: true,
|
||||||
@@ -115,7 +121,7 @@ export const GET = defineApiRoute({
|
|||||||
include: {
|
include: {
|
||||||
benutzer: {
|
benutzer: {
|
||||||
select: {
|
select: {
|
||||||
uid: true,
|
id: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
import { GEGNachweisWohnenClient, OptionalNullable, UUidWithPrefix, ZodOverlap } from "#components/Ausweis/types.js";
|
import { UUidWithPrefix } from "#components/Ausweis/types.js";
|
||||||
|
import { VALID_UUID_PREFIXES } from "#lib/constants.js";
|
||||||
|
import { generatePrefixedId } from "#lib/db.js";
|
||||||
import { exclude } from "#lib/exclude.js";
|
import { exclude } from "#lib/exclude.js";
|
||||||
import { authorizationHeaders, authorizationMiddleware } from "#lib/middleware/authorization.js";
|
import { authorizationHeaders, authorizationMiddleware } from "#lib/middleware/authorization.js";
|
||||||
import { GEGNachweisWohnenSchema, prisma } from "#lib/server/prisma";
|
import { prisma } from "#lib/server/prisma.js";
|
||||||
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
||||||
|
import { GEGNachweisWohnenSchema } from "src/generated/zod/gegnachweiswohnen.js";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
export const PATCH = defineApiRoute({
|
export const PATCH = defineApiRoute({
|
||||||
input: GEGNachweisWohnenSchema.omit({
|
input: GEGNachweisWohnenSchema.omit({
|
||||||
uid: true,
|
|
||||||
id: true,
|
id: true,
|
||||||
benutzer_id: true,
|
benutzer_id: true,
|
||||||
geg_einpreisung_id: true,
|
geg_einpreisung_id: true,
|
||||||
@@ -21,7 +23,7 @@ export const PATCH = defineApiRoute({
|
|||||||
async fetch(input, ctx, user) {
|
async fetch(input, ctx, user) {
|
||||||
const objekt = await prisma.gEGNachweisWohnen.findUnique({
|
const objekt = await prisma.gEGNachweisWohnen.findUnique({
|
||||||
where: {
|
where: {
|
||||||
uid: ctx.params.uid,
|
id: ctx.params.id,
|
||||||
benutzer: {
|
benutzer: {
|
||||||
id: user.id
|
id: user.id
|
||||||
}
|
}
|
||||||
@@ -37,7 +39,7 @@ export const PATCH = defineApiRoute({
|
|||||||
|
|
||||||
await prisma.gEGNachweisWohnen.update({
|
await prisma.gEGNachweisWohnen.update({
|
||||||
where: {
|
where: {
|
||||||
uid: ctx.params.uid
|
id: ctx.params.id
|
||||||
},
|
},
|
||||||
data: input
|
data: input
|
||||||
})
|
})
|
||||||
@@ -51,9 +53,9 @@ export const DELETE = defineApiRoute({
|
|||||||
headers: authorizationHeaders,
|
headers: authorizationHeaders,
|
||||||
middleware: authorizationMiddleware,
|
middleware: authorizationMiddleware,
|
||||||
async fetch(input, ctx, user) {
|
async fetch(input, ctx, user) {
|
||||||
const { uid } = ctx.params;
|
const { id } = ctx.params;
|
||||||
|
|
||||||
if (!UUidWithPrefix.safeParse(uid).success) {
|
if (!UUidWithPrefix.safeParse(id).success) {
|
||||||
throw new APIError({
|
throw new APIError({
|
||||||
code: "BAD_REQUEST",
|
code: "BAD_REQUEST",
|
||||||
message: "UID konnte nicht verifiziert werden."
|
message: "UID konnte nicht verifiziert werden."
|
||||||
@@ -64,7 +66,7 @@ export const DELETE = defineApiRoute({
|
|||||||
// Dieser MUSS mit dem Nutzer verknüpft sein.
|
// Dieser MUSS mit dem Nutzer verknüpft sein.
|
||||||
const nachweis = await prisma.gEGNachweisWohnen.findUnique({
|
const nachweis = await prisma.gEGNachweisWohnen.findUnique({
|
||||||
where: {
|
where: {
|
||||||
uid,
|
id,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -111,10 +113,13 @@ export const DELETE = defineApiRoute({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const event_id =
|
||||||
|
|
||||||
// Wir erstellen ein Event, dass der Nachweis storniert wurde
|
// Wir erstellen ein Event, dass der Nachweis storniert wurde
|
||||||
// Dann können wir das in der Historie anzeigen
|
// Dann können wir das in der Historie anzeigen
|
||||||
await prisma.event.create({
|
await prisma.event.create({
|
||||||
data: {
|
data: {
|
||||||
|
id: generatePrefixedId(6, VALID_UUID_PREFIXES.Event),
|
||||||
title: "Nachweis storniert",
|
title: "Nachweis storniert",
|
||||||
description: ((user.rolle === "ADMIN") && (nachweis.benutzer_id !== user.id)) ? "Nachweis wurde von einem Administrator storniert." : "Nachweis wurde vom Besitzer storniert.",
|
description: ((user.rolle === "ADMIN") && (nachweis.benutzer_id !== user.id)) ? "Nachweis wurde von einem Administrator storniert." : "Nachweis wurde vom Besitzer storniert.",
|
||||||
benutzer: {
|
benutzer: {
|
||||||
@@ -150,9 +155,9 @@ export const GET = defineApiRoute({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
output: GEGNachweisWohnenSchema.merge(z.object({
|
output: GEGNachweisWohnenSchema.merge(z.object({
|
||||||
uid_aufnahme: UUidWithPrefix,
|
aufnahme_id: UUidWithPrefix,
|
||||||
uid_objekt: UUidWithPrefix,
|
objekt_id: UUidWithPrefix,
|
||||||
uid_benutzer: UUidWithPrefix.optional()
|
benutzer_id: UUidWithPrefix.optional()
|
||||||
})).omit({
|
})).omit({
|
||||||
id: true,
|
id: true,
|
||||||
aufnahme_id: true,
|
aufnahme_id: true,
|
||||||
@@ -160,32 +165,32 @@ export const GET = defineApiRoute({
|
|||||||
}),
|
}),
|
||||||
middleware: authorizationMiddleware,
|
middleware: authorizationMiddleware,
|
||||||
async fetch(input, context, user) {
|
async fetch(input, context, user) {
|
||||||
const { uid } = context.params;
|
const { id } = context.params;
|
||||||
|
|
||||||
if (!uid) {
|
if (!id) {
|
||||||
throw new APIError({
|
throw new APIError({
|
||||||
code: "BAD_REQUEST",
|
code: "BAD_REQUEST",
|
||||||
message: "Missing uid in request params"
|
message: "Missing uid in request params"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const Nachweis = await prisma.gEGNachweisWohnen.findUnique({
|
const nachweis = await prisma.gEGNachweisWohnen.findUnique({
|
||||||
where: {
|
where: {
|
||||||
uid,
|
id,
|
||||||
benutzer_id: user.id
|
benutzer_id: user.id
|
||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
benutzer: {
|
benutzer: {
|
||||||
select: {
|
select: {
|
||||||
uid: true
|
id: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
aufnahme: {
|
aufnahme: {
|
||||||
select: {
|
select: {
|
||||||
uid: true,
|
id: true,
|
||||||
objekt: {
|
objekt: {
|
||||||
select: {
|
select: {
|
||||||
uid: true
|
id: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -193,7 +198,7 @@ export const GET = defineApiRoute({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!Nachweis) {
|
if (!nachweis) {
|
||||||
// Falls wir den Nachweis nicht finden können, werfen wir einen Fehler
|
// Falls wir den Nachweis nicht finden können, werfen wir einen Fehler
|
||||||
throw new APIError({
|
throw new APIError({
|
||||||
code: "NOT_FOUND",
|
code: "NOT_FOUND",
|
||||||
@@ -202,10 +207,10 @@ export const GET = defineApiRoute({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
uid_aufnahme: Nachweis.aufnahme.uid,
|
aufnahme_id: nachweis.aufnahme.id,
|
||||||
uid_objekt: Nachweis.aufnahme.objekt.uid,
|
objekt_id: nachweis.aufnahme.objekt.id,
|
||||||
uid_benutzer: Nachweis.benutzer?.uid,
|
benutzer_id: nachweis.benutzer?.id,
|
||||||
...exclude(Nachweis, ["id", "aufnahme_id", "benutzer_id", "aufnahme"])
|
...exclude(nachweis, ["id", "aufnahme_id", "benutzer_id", "aufnahme"])
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
import { UUidWithPrefix } from "#components/Ausweis/types.js";
|
import { UUidWithPrefix } from "#components/Ausweis/types.js";
|
||||||
|
import { VALID_UUID_PREFIXES } from "#lib/constants.js";
|
||||||
|
import { generatePrefixedId } from "#lib/db.js";
|
||||||
import { authorizationHeaders, authorizationMiddleware } from "#lib/middleware/authorization.js";
|
import { authorizationHeaders, authorizationMiddleware } from "#lib/middleware/authorization.js";
|
||||||
import { prisma } from "#lib/server/prisma.js";
|
import { prisma } from "#lib/server/prisma.js";
|
||||||
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
||||||
@@ -16,24 +18,25 @@ export const PUT = defineApiRoute({
|
|||||||
nachweis: GEGNachweisWohnenSchema.omit({
|
nachweis: GEGNachweisWohnenSchema.omit({
|
||||||
id: true,
|
id: true,
|
||||||
benutzer_id: true,
|
benutzer_id: true,
|
||||||
uid: true,
|
|
||||||
aufnahme_id: true,
|
aufnahme_id: true,
|
||||||
|
updated_at: true,
|
||||||
|
created_at: true,
|
||||||
geg_einpreisung_id: true,
|
geg_einpreisung_id: true,
|
||||||
rechnung_id: true
|
rechnung_id: true
|
||||||
}),
|
}),
|
||||||
uid_aufnahme: UUidWithPrefix
|
aufnahme_id: UUidWithPrefix
|
||||||
}),
|
}),
|
||||||
output: z.object({
|
output: z.object({
|
||||||
uid: UUidWithPrefix,
|
id: UUidWithPrefix,
|
||||||
objekt_uid: UUidWithPrefix,
|
objekt_id: UUidWithPrefix,
|
||||||
aufnahme_uid: UUidWithPrefix,
|
aufnahme_id: UUidWithPrefix,
|
||||||
}),
|
}),
|
||||||
headers: authorizationHeaders,
|
headers: authorizationHeaders,
|
||||||
middleware: authorizationMiddleware,
|
middleware: authorizationMiddleware,
|
||||||
async fetch(input, ctx, user) {
|
async fetch(input, ctx, user) {
|
||||||
const aufnahme = await prisma.aufnahme.findUnique({
|
const aufnahme = await prisma.aufnahme.findUnique({
|
||||||
where: {
|
where: {
|
||||||
uid: input.uid_aufnahme
|
id: input.aufnahme_id
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -44,8 +47,11 @@ export const PUT = defineApiRoute({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const id = generatePrefixedId(6, VALID_UUID_PREFIXES.GEGNachweisWohnen)
|
||||||
|
|
||||||
const nachweis = await prisma.gEGNachweisWohnen.create({
|
const nachweis = await prisma.gEGNachweisWohnen.create({
|
||||||
data: {
|
data: {
|
||||||
|
id,
|
||||||
...input.nachweis,
|
...input.nachweis,
|
||||||
benutzer: {
|
benutzer: {
|
||||||
connect: {
|
connect: {
|
||||||
@@ -59,13 +65,13 @@ export const PUT = defineApiRoute({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
uid: true,
|
id: true,
|
||||||
aufnahme: {
|
aufnahme: {
|
||||||
select: {
|
select: {
|
||||||
uid: true,
|
id: true,
|
||||||
objekt: {
|
objekt: {
|
||||||
select: {
|
select: {
|
||||||
uid: true,
|
id: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -74,9 +80,9 @@ export const PUT = defineApiRoute({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
uid: nachweis.uid,
|
id: nachweis.id,
|
||||||
objekt_uid: nachweis.aufnahme.objekt.uid,
|
objekt_id: nachweis.aufnahme.objekt.id,
|
||||||
aufnahme_uid: nachweis.aufnahme.uid,
|
aufnahme_id: nachweis.aufnahme.id,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -101,11 +107,11 @@ export const GET = defineApiRoute({
|
|||||||
headers: authorizationHeaders,
|
headers: authorizationHeaders,
|
||||||
middleware: authorizationMiddleware,
|
middleware: authorizationMiddleware,
|
||||||
async fetch(input, context, user) {
|
async fetch(input, context, user) {
|
||||||
const { uid } = context.params;
|
const { id } = context.params;
|
||||||
|
|
||||||
const nachweis = await prisma.gEGNachweisGewerbe.findUnique({
|
const nachweis = await prisma.gEGNachweisGewerbe.findUnique({
|
||||||
where: {
|
where: {
|
||||||
uid,
|
id,
|
||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
benutzer: true,
|
benutzer: true,
|
||||||
@@ -115,7 +121,7 @@ export const GET = defineApiRoute({
|
|||||||
include: {
|
include: {
|
||||||
benutzer: {
|
benutzer: {
|
||||||
select: {
|
select: {
|
||||||
uid: true,
|
id: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import { getAusweisartFromId, UUidWithPrefix } from "#components/Ausweis/types.js";
|
import { getAusweisartFromId, UUidWithPrefix } from "#components/Ausweis/types.js";
|
||||||
|
import { VALID_UUID_PREFIXES } from "#lib/constants.js";
|
||||||
|
import { generatePrefixedId } from "#lib/db.js";
|
||||||
import { omit } from "#lib/helpers.js";
|
import { omit } from "#lib/helpers.js";
|
||||||
import { authorizationHeaders, authorizationMiddleware } from "#lib/middleware/authorization.js";
|
import { authorizationHeaders, authorizationMiddleware } from "#lib/middleware/authorization.js";
|
||||||
import { sendGEGAnforderungsMail } from "#lib/server/mail/geg-anfordern.js";
|
import { sendGEGAnforderungsMail } from "#lib/server/mail/geg-anfordern.js";
|
||||||
import { Enums, GEGNachweisGewerbe, GEGNachweisWohnen, prisma } from "#lib/server/prisma.js";
|
import { BedarfsausweisGewerbe, Enums, GEGNachweisGewerbe, GEGNachweisWohnen, prisma } from "#lib/server/prisma.js";
|
||||||
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
||||||
import { GEGEinpreisungSchema } from "src/generated/zod/gegeinpreisung.js";
|
import { GEGEinpreisungSchema } from "src/generated/zod/gegeinpreisung.js";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
@@ -21,7 +23,7 @@ export const PUT = defineApiRoute({
|
|||||||
const ausweisart = getAusweisartFromId(input.nachweis_id);
|
const ausweisart = getAusweisartFromId(input.nachweis_id);
|
||||||
|
|
||||||
let einpreisung;
|
let einpreisung;
|
||||||
let nachweis: GEGNachweisWohnen | GEGNachweisGewerbe;
|
let nachweis: GEGNachweisWohnen | GEGNachweisGewerbe | BedarfsausweisGewerbe;
|
||||||
if (ausweisart === Enums.Ausweisart.GEGNachweisWohnen) {
|
if (ausweisart === Enums.Ausweisart.GEGNachweisWohnen) {
|
||||||
nachweis = await prisma.gEGNachweisWohnen.findUnique({
|
nachweis = await prisma.gEGNachweisWohnen.findUnique({
|
||||||
where: {
|
where: {
|
||||||
@@ -55,9 +57,12 @@ export const PUT = defineApiRoute({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const id = generatePrefixedId(6, VALID_UUID_PREFIXES.GEGEinpreisung)
|
||||||
|
|
||||||
if (ausweisart === Enums.Ausweisart.GEGNachweisWohnen) {
|
if (ausweisart === Enums.Ausweisart.GEGNachweisWohnen) {
|
||||||
einpreisung = await prisma.gEGEinpreisung.create({
|
einpreisung = await prisma.gEGEinpreisung.create({
|
||||||
data: {
|
data: {
|
||||||
|
id,
|
||||||
...omit(input, ["nachweis_id"]),
|
...omit(input, ["nachweis_id"]),
|
||||||
status: Enums.Einpreisungsstatus.open,
|
status: Enums.Einpreisungsstatus.open,
|
||||||
benutzer: {
|
benutzer: {
|
||||||
@@ -75,6 +80,7 @@ export const PUT = defineApiRoute({
|
|||||||
} else if (ausweisart === Enums.Ausweisart.GEGNachweisGewerbe) {
|
} else if (ausweisart === Enums.Ausweisart.GEGNachweisGewerbe) {
|
||||||
einpreisung = await prisma.gEGEinpreisung.create({
|
einpreisung = await prisma.gEGEinpreisung.create({
|
||||||
data: {
|
data: {
|
||||||
|
id,
|
||||||
...omit(input, ["nachweis_id"]),
|
...omit(input, ["nachweis_id"]),
|
||||||
status: Enums.Einpreisungsstatus.open,
|
status: Enums.Einpreisungsstatus.open,
|
||||||
benutzer: {
|
benutzer: {
|
||||||
@@ -92,6 +98,7 @@ export const PUT = defineApiRoute({
|
|||||||
} else if (ausweisart === Enums.Ausweisart.BedarfsausweisGewerbe) {
|
} else if (ausweisart === Enums.Ausweisart.BedarfsausweisGewerbe) {
|
||||||
einpreisung = await prisma.gEGEinpreisung.create({
|
einpreisung = await prisma.gEGEinpreisung.create({
|
||||||
data: {
|
data: {
|
||||||
|
id,
|
||||||
...omit(input, ["nachweis_id"]),
|
...omit(input, ["nachweis_id"]),
|
||||||
status: Enums.Einpreisungsstatus.open,
|
status: Enums.Einpreisungsstatus.open,
|
||||||
benutzer: {
|
benutzer: {
|
||||||
@@ -111,7 +118,7 @@ export const PUT = defineApiRoute({
|
|||||||
await sendGEGAnforderungsMail(nachweis, user)
|
await sendGEGAnforderungsMail(nachweis, user)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: einpreisung.id
|
id
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -1,10 +1,8 @@
|
|||||||
import { AufnahmeClient, BenutzerClient, getAusweisartFromId, ObjektClient, UploadedGebaeudeBild, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js";
|
import { BenutzerClient, getAusweisartFromId, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js";
|
||||||
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants.js";
|
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants.js";
|
||||||
import { pdfDatenblattVerbrauchsausweisGewerbe } from "#lib/pdf/pdfDatenblattVerbrauchsausweisGewerbe.js";
|
import { pdfDatenblattVerbrauchsausweisGewerbe } from "#lib/pdf/pdfDatenblattVerbrauchsausweisGewerbe.js";
|
||||||
import { pdfDatenblattVerbrauchsausweisWohnen } from "#lib/pdf/pdfDatenblattVerbrauchsausweisWohnen.js";
|
import { pdfDatenblattVerbrauchsausweisWohnen } from "#lib/pdf/pdfDatenblattVerbrauchsausweisWohnen.js";
|
||||||
import { pdfVerbrauchsausweisGewerbe } from "#lib/pdf/pdfVerbrauchsausweisGewerbe.js";
|
import { Aufnahme, Benutzer, Bild, Enums, Objekt, VerbrauchsausweisGewerbe, VerbrauchsausweisWohnen } from "#lib/client/prisma.js";
|
||||||
import { pdfVerbrauchsausweisWohnen } from "#lib/pdf/pdfVerbrauchsausweisWohnen.js";
|
|
||||||
import { Enums } from "#lib/client/prisma.js";
|
|
||||||
import { APIRoute } from "astro";
|
import { APIRoute } from "astro";
|
||||||
import { createCaller } from "src/astro-typesafe-api-caller.js";
|
import { createCaller } from "src/astro-typesafe-api-caller.js";
|
||||||
import { getS3File } from "#lib/s3.js";
|
import { getS3File } from "#lib/s3.js";
|
||||||
@@ -20,11 +18,11 @@ export const GET: APIRoute = async (Astro) => {
|
|||||||
|
|
||||||
const ausweisart = getAusweisartFromId(ausweis_id)
|
const ausweisart = getAusweisartFromId(ausweis_id)
|
||||||
|
|
||||||
let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | null = null;
|
let ausweis: VerbrauchsausweisWohnen | VerbrauchsausweisGewerbe | null = null;
|
||||||
let aufnahme: AufnahmeClient = {} as AufnahmeClient;
|
let aufnahme: Aufnahme = {} as Aufnahme;
|
||||||
let objekt: ObjektClient = {} as ObjektClient;
|
let objekt: Objekt = {} as Objekt;
|
||||||
let user: BenutzerClient = {} as BenutzerClient;
|
let user: Benutzer = {} as Benutzer;
|
||||||
let bilder: UploadedGebaeudeBild[] = []
|
let bilder: Bild[] = []
|
||||||
|
|
||||||
if (ausweisart === Enums.Ausweisart.VerbrauchsausweisWohnen) {
|
if (ausweisart === Enums.Ausweisart.VerbrauchsausweisWohnen) {
|
||||||
ausweis = await getVerbrauchsausweisWohnen(ausweis_id)
|
ausweis = await getVerbrauchsausweisWohnen(ausweis_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user