e2e Tests für Verbrauchsausweis Wohnen und Gewerbe vollständig
BIN
persistent/images/img-03e4258e-2fb5-422d-b435-2a7129bcabf3.webp
Normal file
|
After Width: | Height: | Size: 48 KiB |
BIN
persistent/images/img-06b354f2-1314-4f66-8c6d-b8e4834a6090.webp
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
persistent/images/img-12cefef0-5406-4fa5-8b47-cbdf5940b2b3.webp
Normal file
|
After Width: | Height: | Size: 48 KiB |
BIN
persistent/images/img-1cb30f8a-d662-47a1-8107-d09c0069a023.webp
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
persistent/images/img-2944c8e8-6d98-4bed-8392-4f6d0d580aaa.webp
Normal file
|
After Width: | Height: | Size: 48 KiB |
BIN
persistent/images/img-29e650e4-c16a-4ad1-b136-967180359809.webp
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
persistent/images/img-2d2dcc3f-2815-4294-a651-43248ba9585f.webp
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
persistent/images/img-2d5c83d6-023e-4848-bef1-44fd988098c3.webp
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
persistent/images/img-2db2d211-3119-4f2a-b6c4-2af1c0a29682.webp
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
persistent/images/img-2e9e796c-2805-4c3c-b8aa-6fce85a44fc5.webp
Normal file
|
After Width: | Height: | Size: 48 KiB |
BIN
persistent/images/img-30288120-6f40-4419-87ba-a0efd59960b8.webp
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
persistent/images/img-3af4bd33-ae3f-4a62-94f2-c43ffccb2fd1.webp
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
persistent/images/img-3f384947-1020-41f7-bce0-7f0a496422c7.webp
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
persistent/images/img-40d15e43-94a3-429c-86be-671f77666094.webp
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
persistent/images/img-4219127e-38ad-4ef1-bdd7-6aaa1bba15e5.webp
Normal file
|
After Width: | Height: | Size: 48 KiB |
BIN
persistent/images/img-4387f4e8-4a93-4fc9-9ba4-e5129bb682cc.webp
Normal file
|
After Width: | Height: | Size: 48 KiB |
BIN
persistent/images/img-461f1e91-33b3-45a6-93d6-ca4ce423af34.webp
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
persistent/images/img-486b00ac-5c3a-4f53-90de-8c0a2f9ad486.webp
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
persistent/images/img-50622919-3829-4e97-b231-e32a32e5342c.webp
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
persistent/images/img-54ad8b76-c545-4da3-9beb-2838c6f9b37a.webp
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
persistent/images/img-5771a1f3-64bc-4ccc-8d8b-fd7eb91ab57b.webp
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
persistent/images/img-61d719ce-8fca-4569-b094-1f23552078c5.webp
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
persistent/images/img-69978803-a0f5-4f1e-97fb-05e7335a0212.webp
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
persistent/images/img-6d6b2565-56a4-4ebd-a41d-3e41d356c9ab.webp
Normal file
|
After Width: | Height: | Size: 48 KiB |
BIN
persistent/images/img-6e61e1ec-b531-45fd-be65-70174cc3c7d3.webp
Normal file
|
After Width: | Height: | Size: 48 KiB |
BIN
persistent/images/img-6ea9fadd-975c-4189-be05-5b539b1a7321.webp
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
persistent/images/img-7541c7d6-c2b3-4501-a671-e53d6bf0a6f2.webp
Normal file
|
After Width: | Height: | Size: 48 KiB |
BIN
persistent/images/img-790bb080-9041-4095-82a0-e7c7d8b84d84.webp
Normal file
|
After Width: | Height: | Size: 48 KiB |
BIN
persistent/images/img-7a27716e-f935-4677-ac38-e2db8f39e4ff.webp
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
persistent/images/img-7a4aa035-c9b1-4126-b4ec-e7b5e93be812.webp
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
persistent/images/img-7b84aae5-c90f-46c2-afd9-41c572b116bf.webp
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
persistent/images/img-7ba05951-aebd-45e6-bcb7-b70a29fef512.webp
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
persistent/images/img-7edbdd0b-dca8-4db8-8a82-3df2b451669b.webp
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
persistent/images/img-87064632-ef07-4fb9-b02c-72521db6ac75.webp
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
persistent/images/img-88d7a851-b49e-413f-aebd-1f4ca386c44a.webp
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
persistent/images/img-8bae768b-e642-4672-ba74-88e0de619131.webp
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
persistent/images/img-91a8a9df-de56-41f5-80cd-f60852c240d8.webp
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
persistent/images/img-93040a69-8b48-4749-8c8d-581d76e74cae.webp
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
persistent/images/img-9528ab28-6588-4703-bbc8-3509e3c97cd3.webp
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
persistent/images/img-9b941945-bfbe-4ca9-b57b-240abc7ae6d4.webp
Normal file
|
After Width: | Height: | Size: 48 KiB |
BIN
persistent/images/img-a5e90e6b-9793-4127-a44c-3129abe91815.webp
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
persistent/images/img-a6837d4d-87c7-4af5-8956-c2642f652b41.webp
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
persistent/images/img-ab21f3f6-82c1-44c4-ba01-6d0ea32ba0b9.webp
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
persistent/images/img-ade4310c-ac6c-49e1-9348-57b8ba155cc4.webp
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
persistent/images/img-ae368fad-72ed-482d-a210-8319f5404b2c.webp
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
persistent/images/img-b51adbda-0ca2-441e-a40d-b3e6027c23df.webp
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
persistent/images/img-b5a715ac-38a8-4a2b-86d0-fb1d3b20213f.webp
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
persistent/images/img-b9e2bf27-2330-45c9-afa1-e97429151eb8.webp
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
persistent/images/img-bd5d3046-7f93-485b-8b7b-2f4844144736.webp
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
persistent/images/img-c66402e7-1bc5-4d44-82c8-5d682ef9694e.webp
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
persistent/images/img-d4c272b1-977c-4ce8-9821-ead67bce7cc4.webp
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
persistent/images/img-e1c07d92-2272-45f6-a7c9-1e94022c5814.webp
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
persistent/images/img-e2b2f430-4cd8-4042-accb-e4bef9eee68c.webp
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
persistent/images/img-e813ba90-fa2d-4de9-85ee-5d9a4e26dfc6.webp
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
persistent/images/img-f0c5a307-5901-4837-aba7-ab6379fa0163.webp
Normal file
|
After Width: | Height: | Size: 24 KiB |
@@ -1,10 +1,9 @@
|
||||
|
||||
import { api } from "astro-typesafe-api/client"
|
||||
|
||||
import { exclude } from "#lib/exclude.js";
|
||||
import Cookies from "js-cookie";
|
||||
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants.js";
|
||||
import { AufnahmeClient, BedarfsausweisWohnenClient, getAusweisartFromUUID, ObjektClient, UploadedGebaeudeBild, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient, } from "#components/Ausweis/types.js";
|
||||
import { AufnahmeClient, BedarfsausweisWohnenClient, ObjektClient, UploadedGebaeudeBild, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient, } from "#components/Ausweis/types.js";
|
||||
import { Enums } from "@ibcornelsen/database/client";
|
||||
|
||||
export async function ausweisSpeichern(
|
||||
@@ -65,13 +64,13 @@ export async function ausweisSpeichern(
|
||||
|
||||
let patchRoute: any;
|
||||
let putRoute: any;
|
||||
if (ausweisart = Enums.Ausweisart.VerbrauchsausweisWohnen) {
|
||||
if (ausweisart == Enums.Ausweisart.VerbrauchsausweisWohnen) {
|
||||
patchRoute = api["verbrauchsausweis-wohnen"]._uid.PATCH
|
||||
putRoute = api["verbrauchsausweis-wohnen"].PUT
|
||||
} else if (ausweisart = Enums.Ausweisart.VerbrauchsausweisGewerbe) {
|
||||
} else if (ausweisart == Enums.Ausweisart.VerbrauchsausweisGewerbe) {
|
||||
patchRoute = api["verbrauchsausweis-gewerbe"]._uid.PATCH
|
||||
putRoute = api["verbrauchsausweis-gewerbe"].PUT
|
||||
} else if (ausweisart = Enums.Ausweisart.BedarfsausweisWohnen) {
|
||||
} else if (ausweisart == Enums.Ausweisart.BedarfsausweisWohnen) {
|
||||
patchRoute = api["bedarfsausweis-wohnen"]._uid.PATCH
|
||||
putRoute = api["bedarfsausweis-wohnen"].PUT
|
||||
}
|
||||
|
||||
@@ -14,27 +14,17 @@ sm:grid-cols-2 sm:gap-x-6 sm:gap-y-8
|
||||
xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
|
||||
">
|
||||
|
||||
<!-- Anrede *
|
||||
|
||||
<!-- Anrede * -->
|
||||
<!--
|
||||
<div class="input-standard order-3 md:order-3 xl:order-3">
|
||||
<Inputlabel title="Anrede *"></Inputlabel>
|
||||
|
||||
<select name="anrede" bind:value={user.anrede}>
|
||||
<option>bitte auswählen</option>
|
||||
<option disabled selected>bitte auswählen</option>
|
||||
<option value="Herr">Herr</option>
|
||||
<option value="Frau">Frau</option>
|
||||
<option value="Frau">Frau</option>
|
||||
</select>
|
||||
|
||||
<div class="help-label">
|
||||
<HelpLabel>
|
||||
Bitte geben Sie hier die beheizte Wohnfläche in m² ein.
|
||||
Dabei handelt es sich um die Wohnfläche abzüglich
|
||||
vorhandener Flächen die sich außerhalb des Gebäudes
|
||||
befinden. (Balkone, Terassen,etc.).
|
||||
</HelpLabel>
|
||||
</div>
|
||||
</div>-->
|
||||
</div> -->
|
||||
|
||||
|
||||
<!-- Vorname * -->
|
||||
|
||||
@@ -137,14 +137,15 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
|
||||
>
|
||||
{#if !ausweis.zusaetzliche_heizquelle}
|
||||
<input
|
||||
id="zusaetzliche_heizquelle_1"
|
||||
id="zusaetzliche_heizquelle"
|
||||
type="checkbox"
|
||||
class="checkbox"
|
||||
name="zusaetzliche_heizquelle_1"
|
||||
name="zusaetzliche_heizquelle"
|
||||
data-cy="zusaetzliche_heizquelle"
|
||||
bind:checked={ausweis.zusaetzliche_heizquelle}
|
||||
/>
|
||||
<label
|
||||
for="zusaetzliche_heizquelle_1"
|
||||
for="zusaetzliche_heizquelle"
|
||||
class="cursor-pointer">zusätzliche Heizquelle</label
|
||||
>
|
||||
{/if}
|
||||
@@ -236,6 +237,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
|
||||
<select
|
||||
class="rounded-e-none"
|
||||
name="brennstoff_1"
|
||||
data-cy="brennstoff_1"
|
||||
bind:value={aufnahme.brennstoff_1}
|
||||
required
|
||||
>
|
||||
@@ -267,6 +269,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
|
||||
<select
|
||||
class="rounded-s-none"
|
||||
name="einheit_1"
|
||||
data-cy="einheit_1"
|
||||
bind:value={ausweis.einheit_1}
|
||||
disabled={!aufnahme.brennstoff_1}
|
||||
required
|
||||
@@ -416,6 +419,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
|
||||
<select
|
||||
class="rounded-e-none"
|
||||
name="brennstoff_2"
|
||||
data-cy="brennstoff_2"
|
||||
bind:value={aufnahme.brennstoff_2}
|
||||
required
|
||||
>
|
||||
@@ -449,6 +453,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
|
||||
<select
|
||||
class="rounded-s-none"
|
||||
name="einheit_2"
|
||||
data-cy="einheit_2"
|
||||
bind:value={ausweis.einheit_2}
|
||||
disabled={!aufnahme.brennstoff_2}
|
||||
required
|
||||
@@ -665,9 +670,9 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
|
||||
<Inputlabel title="Sonstige"></Inputlabel>
|
||||
|
||||
<input
|
||||
name="strom_3"
|
||||
name="stromverbrauch_enthaelt_sonstige"
|
||||
type="number"
|
||||
bind:value={ausweis.strom_3}
|
||||
bind:value={ausweis.stromverbrauch_enthaelt_sonstige}
|
||||
required
|
||||
/>
|
||||
|
||||
|
||||
@@ -51,7 +51,11 @@ export type VerbrauchsausweisWohnenClient = OmitKeys<
|
||||
export type VerbrauchsausweisGewerbeClient = OmitKeys<
|
||||
VerbrauchsausweisGewerbe,
|
||||
"id" | "aufnahme_id" | "benutzer_id"
|
||||
>;
|
||||
> & {
|
||||
uid_objekt: string,
|
||||
uid_aufnahme: string,
|
||||
uid_benutzer?: string
|
||||
};
|
||||
|
||||
/**
|
||||
* Das ist der Typescript Type für den Verbrauchsausweis Gewerbe mit allen Feldern die
|
||||
@@ -66,7 +70,11 @@ export type VerbrauchsausweisGewerbeClient = OmitKeys<
|
||||
export type BedarfsausweisWohnenClient = OmitKeys<
|
||||
BedarfsausweisWohnen,
|
||||
"id" | "aufnahme_id" | "benutzer_id"
|
||||
>;
|
||||
> & {
|
||||
uid_objekt: string,
|
||||
uid_aufnahme: string,
|
||||
uid_benutzer?: string
|
||||
};
|
||||
|
||||
/**
|
||||
* Das ist der Typescript Type für die Gebäude Stammdaten mit allen Feldern die
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
<div>
|
||||
|
||||
<input type="radio" data-test={paymentType} id={paymentType} name="paymentType" on:change={() => selectedPaymentType = paymentType} />
|
||||
<input type="radio" data-cy={paymentType} id={paymentType} name="paymentType" on:change={() => selectedPaymentType = paymentType} />
|
||||
|
||||
<label for={paymentType}>
|
||||
<div class="grid grid-rows-[1fr_20px] justify-items-center items-center cursor-pointer">
|
||||
|
||||
@@ -2,6 +2,7 @@ import fuelList from "#components/Ausweis/brennstoffListe.js";
|
||||
import { faker } from "@faker-js/faker";
|
||||
import { type Enums } from "@ibcornelsen/database/client";
|
||||
import "cypress-file-upload"
|
||||
import moment from "moment";
|
||||
|
||||
describe("Verbrauchsausweis erstellen Schritt 1", () => {
|
||||
const ausstellgrund = (["Modernisierung", "Neubau", "Sonstiges", "Verkauf", "Vermietung"] as Enums.Ausstellgrund[]);
|
||||
@@ -13,15 +14,13 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
|
||||
cy.wait(1000);
|
||||
|
||||
// Wir überprüfen, ob alle Ausstelgründe vorhanden sind, diese sollten genau so viele sein wie in der Datenbank vorhanden sind.
|
||||
cy.get("input[name='ausstellgrund']")
|
||||
.should("have.length", ausstellgrund.length)
|
||||
.eq(
|
||||
cy.get("select[data-cy='ausstellgrund']")
|
||||
.select(
|
||||
faker.number.int({
|
||||
min: 0,
|
||||
max: ausstellgrund.length - 1,
|
||||
max: (["Modernisierung", "Neubau", "Sonstiges", "Verkauf", "Vermietung"] as Enums.Ausstellgrund[]).length - 1,
|
||||
})
|
||||
)
|
||||
.check();
|
||||
|
||||
// Jetzt Füllen wir das Baujahr vom Gebäude aus.
|
||||
cy.get("input[name='baujahr_gebaeude']")
|
||||
@@ -91,9 +90,22 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
|
||||
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_monat']").select(faker.number.int({ min: 1, max: 12 }).toString());
|
||||
cy.get("select[name='energieverbrauch_zeitraum_jahr']").select(faker.number.int({ min: 2018, max: 2019 }).toString());
|
||||
cy.get("select[name='energieverbrauch_zeitraum_monat']").select(availableDates[0].month.toString());
|
||||
cy.get("select[name='energieverbrauch_zeitraum_jahr']").select(availableDates[0].year.toString());
|
||||
|
||||
// Verbrauch
|
||||
cy.get("input[name='verbrauch_1']").type(faker.number.int({ min: 4000, max: 15000 }).toString());
|
||||
@@ -104,18 +116,18 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
|
||||
const zusaetzlicheHeizquelle = Math.random() > 0.5;
|
||||
|
||||
if (zusaetzlicheHeizquelle) {
|
||||
cy.get("input[name='zusaetzliche_heizquelle']").check();
|
||||
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("select[name='brennstoff_2']").select(brennstoffKombo2[0]);
|
||||
cy.get("select[name='einheit_2']").select(brennstoffKombo2[1]);
|
||||
cy.get("[data-cy='brennstoff_2']").select(brennstoffKombo2[0], { force: true });
|
||||
cy.get("[data-cy='einheit_2']").select(brennstoffKombo2[1], { force: true });
|
||||
|
||||
// Verbrauch
|
||||
cy.get("input[name='verbrauch_4']").type(faker.number.int({ min: 4000, max: 15000 }).toString());
|
||||
cy.get("input[name='verbrauch_5']").type(faker.number.int({ min: 4000, max: 15000 }).toString());
|
||||
cy.get("input[name='verbrauch_6']").type(faker.number.int({ min: 4000, max: 15000 }).toString());
|
||||
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
|
||||
@@ -172,7 +184,7 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
|
||||
|
||||
// Gebäudetyp
|
||||
cy.get("select[name='gebaeudetyp']").then(($dropdown) => {
|
||||
const options = $dropdown.find('option');
|
||||
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);
|
||||
});
|
||||
@@ -213,7 +225,7 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
|
||||
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();
|
||||
// if (Math.random() > 0.5) cy.get("input[name='raum_temperatur_regler']").check();
|
||||
|
||||
// Heizungsanlage Bilder
|
||||
cy.get("input[name='heizung_image']").should("have.attr", "type", "file").attachFile("images/heizungsanlage/1.jpeg", { subjectType: "input" });
|
||||
@@ -250,14 +262,14 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
|
||||
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[name='ausweis'] button[type='submit']").click({ force: true });
|
||||
cy.get("form[name='ausweis'] button[data-cy='weiter']").click({ force: true });
|
||||
|
||||
// Wir sind nicht eingeloggt also sollte jetzt ein Login Screen erscheinen.
|
||||
// Wir klicken auf registrieren und erstellen einen neuen Benutzer, danach loggen wir uns mit diesem ein.
|
||||
cy.get("button[name='registrieren']").click();
|
||||
cy.get("[data-cy='registrieren']").click();
|
||||
|
||||
const email = faker.internet.email();
|
||||
const passwort = faker.internet.password();
|
||||
const passwort = "test1234";
|
||||
const vorname = faker.person.firstName();
|
||||
const nachname = faker.person.lastName();
|
||||
|
||||
@@ -275,6 +287,37 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
|
||||
|
||||
cy.get("form[name='login'] button[type='submit']").click();
|
||||
|
||||
// Der Ausweis sollte jetzt schon erstellt worden sein.
|
||||
// Der Ausweis sollte jetzt schon erstellt worden sein und wir sollten auf die kundendaten seite weitergeleitet worden sein.
|
||||
cy.url().should("contain", "/kundendaten");
|
||||
|
||||
cy.wait(1000)
|
||||
|
||||
// Wir füllen jetzt die Kundendaten aus.
|
||||
// cy.get("select[name='anrede']").select(Math.random() > 0.5 ? "Herr" : "Frau");
|
||||
cy.get("input[name='vorname']").should("contain.value", vorname);
|
||||
cy.get("input[name='name']").should("contain.value", nachname);
|
||||
// cy.get("input[name='email']").should("contain.value", email);
|
||||
// cy.get("input[name='telefon']").type(faker.phone.number());
|
||||
|
||||
cy.get("input[name='rechnung_empfaenger']").type(`${vorname} ${nachname}`);
|
||||
cy.get("input[name='rechnung_strasse']").type(faker.location.streetAddress());
|
||||
// TODO: Random Plz generieren, allerdings muss die auch in der Datenbank vorhanden sein...
|
||||
cy.get("input[name='rechnung_plz']").type("2103");
|
||||
// Jetzt sollte der PLZ Container erscheinen, dort klicken wir einfach das erste Element an.
|
||||
cy.get("div[data-test='plz-container']").children().first().click();
|
||||
// cy.get("input[name='rechnung_telefon']").type(faker.phone.number());
|
||||
cy.get("input[name='rechnung_email']").should("contain.value", email);
|
||||
cy.get("input[data-cy='paypal']").click();
|
||||
|
||||
// Datenschutz und AGB akzeptieren, dann schicken wir das Formular ab.
|
||||
// cy.get("input[name='agb-akzeptieren']").check()
|
||||
// cy.get("input[name='datenschutz-akzeptieren']").check()
|
||||
cy.get("button[data-cy='bestellen']").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.
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
@@ -266,11 +266,11 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
|
||||
cy.wait(1000)
|
||||
|
||||
// Wir füllen jetzt die Kundendaten aus.
|
||||
cy.get("select[name='anrede']").select(Math.random() > 0.5 ? "Herr" : "Frau");
|
||||
// cy.get("select[name='anrede']").select(Math.random() > 0.5 ? "Herr" : "Frau");
|
||||
cy.get("input[name='vorname']").should("contain.value", vorname);
|
||||
cy.get("input[name='name']").should("contain.value", nachname);
|
||||
cy.get("input[name='email']").should("contain.value", email);
|
||||
cy.get("input[name='telefon']").type(faker.phone.number());
|
||||
// cy.get("input[name='email']").should("contain.value", email);
|
||||
// cy.get("input[name='telefon']").type(faker.phone.number());
|
||||
|
||||
cy.get("input[name='rechnung_empfaenger']").type(`${vorname} ${nachname}`);
|
||||
cy.get("input[name='rechnung_strasse']").type(faker.location.streetAddress());
|
||||
@@ -278,14 +278,14 @@ describe("Verbrauchsausweis erstellen Schritt 1", () => {
|
||||
cy.get("input[name='rechnung_plz']").type("2103");
|
||||
// Jetzt sollte der PLZ Container erscheinen, dort klicken wir einfach das erste Element an.
|
||||
cy.get("div[data-test='plz-container']").children().first().click();
|
||||
cy.get("input[name='rechnung_telefon']").type(faker.phone.number());
|
||||
cy.get("input[name='rechnung_email']").type(faker.internet.email());
|
||||
cy.get("button[data-test='paypal']").click();
|
||||
// cy.get("input[name='rechnung_telefon']").type(faker.phone.number());
|
||||
cy.get("input[name='rechnung_email']").should("contain.value", email);
|
||||
cy.get("input[data-cy='paypal']").click();
|
||||
|
||||
// Datenschutz und AGB akzeptieren, dann schicken wir das Formular ab.
|
||||
cy.get("input[name='agb-akzeptieren']").check()
|
||||
cy.get("input[name='datenschutz-akzeptieren']").check()
|
||||
cy.get("button[type='submit']").click();
|
||||
// cy.get("input[name='agb-akzeptieren']").check()
|
||||
// cy.get("input[name='datenschutz-akzeptieren']").check()
|
||||
cy.get("button[data-cy='bestellen']").click();
|
||||
|
||||
cy.origin('https://www.mollie.com', () => {
|
||||
// Jetzt sind wir auf der Mollie Seite, dort wählen wir den "paid" status aus
|
||||
|
||||
@@ -260,7 +260,7 @@
|
||||
|
||||
<button class="button">Speichern</button>
|
||||
|
||||
<button class="button" on:click={bestellen}>kostenpflichtig bestellen</button>
|
||||
<button class="button" data-cy="bestellen" on:click={bestellen}>kostenpflichtig bestellen</button>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -26,32 +26,11 @@
|
||||
export let objekt: ObjektClient = {} as ObjektClient;
|
||||
export let aufnahme: AufnahmeClient = {} as AufnahmeClient;
|
||||
export let bilder: UploadedGebaeudeBild[] = [];
|
||||
export let ausweisart = "Verbrauchsausweis Gewerbe";
|
||||
export let ausweisart = Enums.Ausweisart.VerbrauchsausweisGewerbe;
|
||||
|
||||
function automatischAusfüllen() {}
|
||||
|
||||
async function spaeterWeitermachen() {
|
||||
const result = await verbrauchsausweisWohnenSpeichern(
|
||||
ausweis,
|
||||
objekt,
|
||||
aufnahme,
|
||||
bilder,
|
||||
user
|
||||
);
|
||||
|
||||
if (result !== null) {
|
||||
// Falls der Nutzer zurück navigiert, sollte er wieder auf seinen Vorgang kommen.
|
||||
// Sonst müsste er alles neu eingeben...
|
||||
ausweis.uid = result.uid;
|
||||
objekt.uid = result.objekt_uid;
|
||||
aufnahme.uid = result.objekt_aufnahme_uid;
|
||||
window.history.pushState(
|
||||
{},
|
||||
"",
|
||||
`${location.pathname}?uid=${result.uid}`
|
||||
);
|
||||
speichernOverlayHidden = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -72,7 +51,7 @@
|
||||
<div id="progress-box" class="w-full box relative px-4 py-3 text-center order-1 2xl:order-2 self-stretch">
|
||||
|
||||
<h1 class="text-secondary text-3xl m-0">Energiesausweis erstellen</h1>
|
||||
<h2 class="text-primary text-xl">{ausweisart} {PRICES.VerbrauchsausweisGewerbe[0]} €</h2>
|
||||
<h2 class="text-primary text-xl">Verbrauchsausweis Gewerbe {PRICES.VerbrauchsausweisGewerbe[0]} €</h2>
|
||||
<ProgressBar progress={0} />
|
||||
</div>
|
||||
|
||||
@@ -82,7 +61,7 @@
|
||||
|
||||
<!-- TODO: Submit implementieren in externer Datei wenn Verbrauchsausweis Wohnen fertig ist -->
|
||||
|
||||
<form id="formInput-1" on:submit={ausweisAbschicken} name="ausweis" data-test="ausweis">
|
||||
<form id="formInput-1" data-cy="ausweis" name="ausweis">
|
||||
<div id="formular-box" class="formular-boxen ring-0">
|
||||
|
||||
<ButtonSpaeterHilfe {automatischAusfüllen} {spaeterWeitermachen} />
|
||||
@@ -94,7 +73,7 @@
|
||||
bind:objekt
|
||||
bind:aufnahme
|
||||
bind:ausweis
|
||||
ausweisart={ausweisart}
|
||||
{ausweisart}
|
||||
/>
|
||||
</Bereich>
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { z } from "zod";
|
||||
import { Enums, RechnungSchema, prisma } from "@ibcornelsen/database/server";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { BedarfsausweisWohnen, Enums, RechnungSchema, VerbrauchsausweisGewerbe, VerbrauchsausweisWohnen, prisma } from "@ibcornelsen/database/server";
|
||||
import { mollieClient } from "#lib/mollie.js";
|
||||
import { PaymentMethod } from "@mollie/api-client";
|
||||
import { defineApiRoute } from "astro-typesafe-api/server";
|
||||
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
||||
import {
|
||||
authorizationHeaders,
|
||||
authorizationMiddleware,
|
||||
@@ -51,94 +50,96 @@ export const PUT = defineApiRoute({
|
||||
|
||||
// TODO: Services Implementieren
|
||||
|
||||
let ausweis: VerbrauchsausweisWohnen | VerbrauchsausweisGewerbe | BedarfsausweisWohnen;
|
||||
if (ausweisart === Enums.Ausweisart.BedarfsausweisWohnen) {
|
||||
throw new TRPCError({
|
||||
code: "BAD_REQUEST",
|
||||
message: "Bedarfsausweis Wohnen wird noch nicht unterstützt.",
|
||||
});
|
||||
ausweis = await prisma.bedarfsausweisWohnen.findUnique({
|
||||
where: {
|
||||
uid: ausweis_uid
|
||||
}
|
||||
})
|
||||
} else if (ausweisart === Enums.Ausweisart.VerbrauchsausweisGewerbe) {
|
||||
throw new TRPCError({
|
||||
code: "BAD_REQUEST",
|
||||
message:
|
||||
"Verbrauchsausweis Gewerbe wird noch nicht unterstützt.",
|
||||
});
|
||||
ausweis = await prisma.verbrauchsausweisGewerbe.findUnique({
|
||||
where: {
|
||||
uid: ausweis_uid
|
||||
}
|
||||
})
|
||||
} else if (ausweisart === Enums.Ausweisart.VerbrauchsausweisWohnen) {
|
||||
// Wir müssen überprüfen, ob dem Nutzer der Ausweis tatsächlich gehört.
|
||||
const ausweis = await prisma.verbrauchsausweisWohnen.findUnique({
|
||||
ausweis = await prisma.verbrauchsausweisWohnen.findUnique({
|
||||
where: {
|
||||
uid: ausweis_uid,
|
||||
},
|
||||
});
|
||||
|
||||
if (!ausweis) {
|
||||
throw new TRPCError({
|
||||
code: "NOT_FOUND",
|
||||
message: "Ausweis nicht gefunden.",
|
||||
});
|
||||
}
|
||||
|
||||
if (ausweis.benutzer_id !== user.id) {
|
||||
throw new TRPCError({
|
||||
code: "UNAUTHORIZED",
|
||||
message: "Ausweis gehört nicht dem Nutzer.",
|
||||
});
|
||||
}
|
||||
|
||||
// Wir erstellen eine neue Rechnung in unserer Datenbank.
|
||||
const rechnung = await prisma.rechnung.create({
|
||||
data: {
|
||||
benutzer_id: user.id,
|
||||
betrag: 0,
|
||||
bezahlmethode: bezahlmethode,
|
||||
status: Enums.Rechnungsstatus.open,
|
||||
aufnahme_id: ausweis.aufnahme_id,
|
||||
},
|
||||
select: {
|
||||
uid: true,
|
||||
betrag: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!rechnung) {
|
||||
throw new TRPCError({
|
||||
code: "INTERNAL_SERVER_ERROR",
|
||||
message: "Rechnung konnte nicht erstellt werden.",
|
||||
});
|
||||
}
|
||||
|
||||
// Wir erstellen eine Mollie Payment Referenz.
|
||||
const payment = await mollieClient.payments.create({
|
||||
amount: {
|
||||
value: "45.00",
|
||||
currency: "EUR",
|
||||
},
|
||||
metadata: {
|
||||
rechnung_uid: rechnung.uid,
|
||||
},
|
||||
method: input.bezahlmethode as PaymentMethod,
|
||||
description: "Verbrauchsausweis Wohnen 2016",
|
||||
redirectUrl: "https://ibcornelsen.de/payment/success",
|
||||
webhookUrl: `http://ibcornelsen.de/api/webhooks/mollie?uid=${rechnung.uid}`,
|
||||
});
|
||||
|
||||
const checkoutUrl = payment.getCheckoutUrl();
|
||||
|
||||
if (!checkoutUrl) {
|
||||
throw new TRPCError({
|
||||
code: "INTERNAL_SERVER_ERROR",
|
||||
message: "Checkout URL konnte nicht erstellt werden.",
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
uid: rechnung.uid,
|
||||
checkout_url: checkoutUrl,
|
||||
};
|
||||
} else {
|
||||
throw new TRPCError({
|
||||
throw new APIError({
|
||||
code: "BAD_REQUEST",
|
||||
message: "Ausweisart nicht unterstützt.",
|
||||
});
|
||||
}
|
||||
|
||||
if (!ausweis) {
|
||||
throw new APIError({
|
||||
code: "NOT_FOUND",
|
||||
message: "Ausweis nicht gefunden.",
|
||||
});
|
||||
}
|
||||
|
||||
if (ausweis.benutzer_id !== user.id) {
|
||||
throw new APIError({
|
||||
code: "UNAUTHORIZED",
|
||||
message: "Ausweis gehört nicht dem Nutzer.",
|
||||
});
|
||||
}
|
||||
|
||||
// Wir erstellen eine neue Rechnung in unserer Datenbank.
|
||||
const rechnung = await prisma.rechnung.create({
|
||||
data: {
|
||||
benutzer_id: user.id,
|
||||
betrag: 0,
|
||||
bezahlmethode: bezahlmethode,
|
||||
status: Enums.Rechnungsstatus.open,
|
||||
aufnahme_id: ausweis.aufnahme_id,
|
||||
},
|
||||
select: {
|
||||
uid: true,
|
||||
betrag: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!rechnung) {
|
||||
throw new APIError({
|
||||
code: "INTERNAL_SERVER_ERROR",
|
||||
message: "Rechnung konnte nicht erstellt werden.",
|
||||
});
|
||||
}
|
||||
|
||||
// Wir erstellen eine Mollie Payment Referenz.
|
||||
const payment = await mollieClient.payments.create({
|
||||
amount: {
|
||||
value: "45.00",
|
||||
currency: "EUR",
|
||||
},
|
||||
metadata: {
|
||||
rechnung_uid: rechnung.uid,
|
||||
},
|
||||
method: input.bezahlmethode as PaymentMethod,
|
||||
description: "Verbrauchsausweis Wohnen 2016",
|
||||
redirectUrl: "https://ibcornelsen.de/payment/success",
|
||||
webhookUrl: `http://ibcornelsen.de/api/webhooks/mollie?uid=${rechnung.uid}`,
|
||||
});
|
||||
|
||||
const checkoutUrl = payment.getCheckoutUrl();
|
||||
|
||||
if (!checkoutUrl) {
|
||||
throw new APIError({
|
||||
code: "INTERNAL_SERVER_ERROR",
|
||||
message: "Checkout URL konnte nicht erstellt werden.",
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
uid: rechnung.uid,
|
||||
checkout_url: checkoutUrl,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ import { Enums } from "@ibcornelsen/database/client";
|
||||
import { createCaller } from "../astro-typesafe-api-caller";
|
||||
import { API_ACCESS_TOKEN_COOKIE_NAME, API_REFRESH_TOKEN_COOKIE_NAME } from "#lib/constants";
|
||||
import { validateAccessTokenServer } from "#server/lib/validateAccessToken";
|
||||
import { BedarfsausweisWohnenClient, getAusweisartFromUUID, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types";
|
||||
|
||||
// Man sollte nur auf diese Seite kommen, wenn ein Ausweis bereits vorliegt und in der Datenbank abgespeichert wurde.
|
||||
const uid = Astro.url.searchParams.get("uid");
|
||||
@@ -18,14 +19,39 @@ if (!uid || !valid) {
|
||||
|
||||
const caller = createCaller(Astro)
|
||||
|
||||
const ausweis = await caller["verbrauchsausweis-wohnen"]._uid.GET.fetch(undefined, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
uid
|
||||
}
|
||||
})
|
||||
const ausweisart = getAusweisartFromUUID(uid);
|
||||
|
||||
let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnenClient;
|
||||
if (ausweisart === Enums.Ausweisart.VerbrauchsausweisWohnen) {
|
||||
ausweis = await caller["verbrauchsausweis-wohnen"]._uid.GET.fetch(undefined, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
uid
|
||||
}
|
||||
})
|
||||
} else if (ausweisart === Enums.Ausweisart.VerbrauchsausweisGewerbe) {
|
||||
ausweis = await caller["verbrauchsausweis-gewerbe"]._uid.GET.fetch(undefined, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
uid
|
||||
}
|
||||
})
|
||||
} else if (ausweisart === Enums.Ausweisart.BedarfsausweisWohnen) {
|
||||
ausweis = await caller["bedarfsausweis-wohnen"]._uid.GET.fetch(undefined, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
uid
|
||||
}
|
||||
})
|
||||
} else {
|
||||
return Astro.redirect("/404")
|
||||
}
|
||||
|
||||
const aufnahme = await caller.aufnahme._uid.GET.fetch(undefined, {
|
||||
headers: {
|
||||
|
||||