Improve Cypress tests
This commit is contained in:
parent
9d91a9102a
commit
3ef1ba18b2
|
|
@ -184,7 +184,10 @@ async function saveAddress() {
|
|||
typedProfileData.organisation_country = countries.value.find(
|
||||
(c) => c.country_code === organisation_country_code
|
||||
);
|
||||
|
||||
if (phone_number) {
|
||||
typedProfileData.phone_number = normalizeSwissPhoneNumber(phone_number);
|
||||
}
|
||||
|
||||
await user.updateUserProfile(typedProfileData);
|
||||
}
|
||||
|
|
@ -204,7 +207,9 @@ const executePayment = async () => {
|
|||
// anyway, so it seems fine to do it here.
|
||||
const fullHost = `${window.location.protocol}//${window.location.host}`;
|
||||
|
||||
if (address.value.phone_number) {
|
||||
address.value.phone_number = normalizeSwissPhoneNumber(address.value.phone_number);
|
||||
}
|
||||
|
||||
itPost("/api/shop/vv/checkout/", {
|
||||
redirect_url: fullHost,
|
||||
|
|
|
|||
|
|
@ -81,6 +81,8 @@ const initialUserState: User = {
|
|||
postal_code: "",
|
||||
city: "",
|
||||
country: null,
|
||||
birth_date: "",
|
||||
phone_number: "",
|
||||
organisation_detail_name: "",
|
||||
organisation_street: "",
|
||||
organisation_street_number: "",
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ describe("checkout.cy.js", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it.only("can checkout and pay Versicherungsvermittlerin with Cembra invoice", () => {
|
||||
it("can checkout and pay Versicherungsvermittlerin with Cembra invoice", () => {
|
||||
cy.get('[data-cy="start-vv"]').click();
|
||||
|
||||
// wähle "Deutsch"
|
||||
|
|
@ -131,6 +131,32 @@ describe("checkout.cy.js", () => {
|
|||
|
||||
cy.get('[data-cy="continue-pay"]').click();
|
||||
|
||||
cy.loadExternalApiRequestLog("request_username", "empty@example.com").then((entry) => {
|
||||
// ends with "/v1/transactions""
|
||||
expect(entry.api_url).to.contain("/v1/transactions");
|
||||
expect(entry.request_username).to.contain("empty@example.com");
|
||||
|
||||
expect(entry.api_request_data.amount).to.equal(32400);
|
||||
expect(entry.api_request_data.currency).to.equal("CHF");
|
||||
expect(entry.api_request_data.autoSettle).to.equal(true);
|
||||
|
||||
expect(entry.api_request_data.customer.firstName).to.equal("Flasche");
|
||||
expect(entry.api_request_data.customer.lastName).to.equal("Leer");
|
||||
expect(entry.api_request_data.customer.street).to.equal("Eggersmatt 32");
|
||||
expect(entry.api_request_data.customer.zipCode).to.equal("1719");
|
||||
expect(entry.api_request_data.customer.city).to.equal("Zumholz");
|
||||
expect(entry.api_request_data.customer.country).to.equal("CH");
|
||||
expect(entry.api_request_data.customer.type).to.equal("P");
|
||||
expect(entry.api_request_data.customer.phone).to.equal("+41792018586");
|
||||
|
||||
expect(entry.api_request_data.INT.repaymentType).to.equal(3);
|
||||
expect(entry.api_request_data.INT.riskOwner).to.equal("IJ");
|
||||
expect(entry.api_request_data.INT.subtype).to.equal("INVOICE");
|
||||
expect(entry.api_request_data.INT.deviceFingerprintId).to.not.be.empty;
|
||||
|
||||
expect(true).to.be.true;
|
||||
});
|
||||
|
||||
// check that results are stored on server
|
||||
cy.loadCheckoutInformation("user_id", TEST_USER_EMPTY_ID).then((ci) => {
|
||||
expect(ci.first_name).to.equal("Flasche");
|
||||
|
|
|
|||
|
|
@ -138,6 +138,26 @@ Cypress.Commands.add("loadAssignmentCompletion", (key, value) => {
|
|||
);
|
||||
});
|
||||
|
||||
Cypress.Commands.add("loadSecurityRequestResponseLog", (key, value) => {
|
||||
return loadObjectJson(
|
||||
key,
|
||||
value,
|
||||
"vbv_lernwelt.core.models.SecurityRequestResponseLog",
|
||||
"vbv_lernwelt.core.serializers.CypressSecurityRequestResponseLogSerializer",
|
||||
true
|
||||
);
|
||||
});
|
||||
|
||||
Cypress.Commands.add("loadExternalApiRequestLog", (key, value) => {
|
||||
return loadObjectJson(
|
||||
key,
|
||||
value,
|
||||
"vbv_lernwelt.core.models.ExternalApiRequestLog",
|
||||
"vbv_lernwelt.core.serializers.CypressExternalApiRequestLogSerializer",
|
||||
true
|
||||
);
|
||||
});
|
||||
|
||||
Cypress.Commands.add("loadFeedbackResponse", (key, value) => {
|
||||
return loadObjectJson(
|
||||
key,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ from datetime import datetime
|
|||
import djclick as click
|
||||
from dateutil.relativedelta import relativedelta, TU
|
||||
from django.contrib.auth.hashers import make_password
|
||||
from django.db import connection
|
||||
from django.utils import timezone
|
||||
|
||||
from vbv_lernwelt.assignment.models import Assignment, AssignmentCompletion
|
||||
|
|
@ -158,6 +159,11 @@ def command(
|
|||
password=make_password("test"),
|
||||
)
|
||||
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("truncate core_securityrequestresponselog;")
|
||||
cursor.execute("truncate core_externalapirequestlog;")
|
||||
cursor.execute("truncate django_cache_table;")
|
||||
|
||||
if create_assignment_completion or create_assignment_evaluation:
|
||||
print("create assignment completion data for test course")
|
||||
create_test_assignment_submitted_data(
|
||||
|
|
|
|||
|
|
@ -3,7 +3,13 @@ from typing import List
|
|||
from rest_framework import serializers
|
||||
from rest_framework.renderers import JSONRenderer
|
||||
|
||||
from vbv_lernwelt.core.models import Country, Organisation, User
|
||||
from vbv_lernwelt.core.models import (
|
||||
Country,
|
||||
ExternalApiRequestLog,
|
||||
Organisation,
|
||||
SecurityRequestResponseLog,
|
||||
User,
|
||||
)
|
||||
from vbv_lernwelt.course.models import CourseSessionUser
|
||||
from vbv_lernwelt.course_session_group.models import CourseSessionGroup
|
||||
|
||||
|
|
@ -142,3 +148,15 @@ class OrganisationSerializer(serializers.ModelSerializer):
|
|||
return obj.name_it
|
||||
|
||||
return obj.name_de
|
||||
|
||||
|
||||
class CypressExternalApiRequestLogSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = ExternalApiRequestLog
|
||||
fields = "__all__"
|
||||
|
||||
|
||||
class CypressSecurityRequestResponseLogSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = SecurityRequestResponseLog
|
||||
fields = "__all__"
|
||||
|
|
|
|||
Loading…
Reference in New Issue