297 lines
10 KiB
JavaScript
297 lines
10 KiB
JavaScript
import {
|
|
COURSE_PROFILE_ALL_ID,
|
|
COURSE_PROFILE_NICHTLEBEN_ID,
|
|
TEST_COURSE_SESSION_VV_ID,
|
|
TEST_USER_EMPTY_ID,
|
|
} from "../../consts";
|
|
import { login } from "../helpers";
|
|
|
|
describe("checkout.cy.js", () => {
|
|
beforeEach(() => {
|
|
cy.manageCommand("cypress_reset");
|
|
|
|
login("empty@example.com", "test");
|
|
cy.visit("/");
|
|
});
|
|
|
|
it("can checkout and buy Versicherungsvermittlerin with credit card", () => {
|
|
cy.get('[data-cy="start-vv"]').click();
|
|
|
|
// wähle "Deutsch"
|
|
cy.get('[href="/onboarding/vv-de/account/create"]').click();
|
|
|
|
cy.get('[data-cy="account-confirm-title"]').should(
|
|
"contain",
|
|
"Konto erstellen",
|
|
);
|
|
cy.get('[data-cy="continue-button"]').click();
|
|
|
|
cy.get('[data-cy="account-profile-title"]').should(
|
|
"contain",
|
|
"Profil ergänzen",
|
|
);
|
|
cy.get('[data-cy="dropdown-select"]').click();
|
|
cy.get(
|
|
'[data-cy="dropdown-select-option-andere Krankenversicherer"]',
|
|
).click();
|
|
cy.get("#organisationDetailName").type("FdH GmbH");
|
|
cy.get('[data-cy="continue-button"]').click();
|
|
|
|
cy.get('[data-cy="account-course-profile-title"]').should(
|
|
"have.text",
|
|
"Zulassungsprofil auswählen",
|
|
);
|
|
|
|
cy.get('[data-cy="dropdown-select"]').click();
|
|
cy.get('[data-cy="dropdown-select-option-Nichtleben"]').click();
|
|
cy.get('[data-cy="continue-button"]').click();
|
|
|
|
cy.loadUser("id", TEST_USER_EMPTY_ID).then((u) => {
|
|
expect(u.organisation_detail_name).to.equal("FdH GmbH");
|
|
// 2 -> andere Krankenversicherer
|
|
expect(u.organisation).to.equal(2);
|
|
});
|
|
|
|
// Adressdaten ausfüllen
|
|
cy.get('[data-cy="account-checkout-title"]').should(
|
|
"contain",
|
|
"Lehrgang kaufen",
|
|
);
|
|
cy.get("#street-address").type("Eggersmatt");
|
|
cy.get("#street-number").type("32");
|
|
cy.get("#postal-code").type("1719");
|
|
cy.get("#city").type("Zumholz");
|
|
cy.get('[data-cy="add-company-address"]').click();
|
|
|
|
// cy.get("#company-name").clear().type("Iterativ GmbH");
|
|
cy.get("#company-street-address").type("Brückfeldstrasse");
|
|
cy.get("#company-street-number").type("16");
|
|
cy.get("#company-postal-code").type("3012");
|
|
cy.get("#company-city").type("Bern");
|
|
|
|
cy.get('[data-cy="continue-pay"]').click();
|
|
|
|
// check that results are stored on server
|
|
cy.loadCheckoutInformation("user_id", TEST_USER_EMPTY_ID).then((ci) => {
|
|
expect(ci.first_name).to.equal("Flasche");
|
|
expect(ci.last_name).to.equal("Leer");
|
|
|
|
expect(ci.street).to.equal("Eggersmatt");
|
|
expect(ci.street_number).to.equal("32");
|
|
expect(ci.postal_code).to.equal("1719");
|
|
expect(ci.city).to.equal("Zumholz");
|
|
expect(ci.country).to.equal("CH");
|
|
|
|
expect(ci.invoice_address).to.equal("org");
|
|
expect(ci.organisation_detail_name).to.equal("FdH GmbH");
|
|
expect(ci.organisation_street).to.equal("Brückfeldstrasse");
|
|
expect(ci.organisation_street_number).to.equal("16");
|
|
expect(ci.organisation_postal_code).to.equal("3012");
|
|
expect(ci.organisation_city).to.equal("Bern");
|
|
|
|
expect(ci.product_name).to.equal("Versicherungsvermittler/-in VBV");
|
|
expect(ci.product_price).to.equal(32400);
|
|
|
|
expect(ci.state).to.equal("ongoing");
|
|
});
|
|
|
|
cy.loadUser("id", TEST_USER_EMPTY_ID).then((u) => {
|
|
expect(u.first_name).to.equal("Flasche");
|
|
expect(u.last_name).to.equal("Leer");
|
|
|
|
expect(u.street).to.equal("Eggersmatt");
|
|
expect(u.street_number).to.equal("32");
|
|
expect(u.postal_code).to.equal("1719");
|
|
expect(u.city).to.equal("Zumholz");
|
|
expect(u.country).to.equal("CH");
|
|
|
|
expect(u.invoice_address).to.equal("org");
|
|
expect(u.organisation_detail_name).to.equal("FdH GmbH");
|
|
expect(u.organisation_street).to.equal("Brückfeldstrasse");
|
|
expect(u.organisation_street_number).to.equal("16");
|
|
expect(u.organisation_postal_code).to.equal("3012");
|
|
expect(u.organisation_city).to.equal("Bern");
|
|
// 2 -> andere Krankenversicherer
|
|
expect(u.organisation).to.equal(2);
|
|
});
|
|
|
|
// pay
|
|
cy.get('[data-cy="pay-button"]').click();
|
|
|
|
cy.get('[data-cy="checkout-success-title"]').should(
|
|
"contain",
|
|
"Gratuliere",
|
|
);
|
|
// wait for payment callback
|
|
cy.wait(3000);
|
|
cy.get('[data-cy="start-vv-button"]').click();
|
|
|
|
// back on dashboard page
|
|
cy.get('[data-cy="db-course-title"]').should(
|
|
"contain",
|
|
"Versicherungsvermittler",
|
|
);
|
|
|
|
cy.loadCheckoutInformation("user_id", TEST_USER_EMPTY_ID).then((ci) => {
|
|
expect(ci.state).to.equal("paid");
|
|
});
|
|
|
|
cy.loadCourseSessionUser("user_id", TEST_USER_EMPTY_ID).then((csu) => {
|
|
expect(csu.role).to.equal("MEMBER");
|
|
expect(csu.course_session).to.equal(TEST_COURSE_SESSION_VV_ID);
|
|
expect(csu.chosen_profile).to.equal(COURSE_PROFILE_NICHTLEBEN_ID);
|
|
});
|
|
});
|
|
|
|
it("can checkout and pay Versicherungsvermittlerin with Cembra invoice", () => {
|
|
cy.get('[data-cy="start-vv"]').click();
|
|
|
|
// wähle "Deutsch"
|
|
cy.get('[href="/onboarding/vv-de/account/create"]').click();
|
|
|
|
cy.get('[data-cy="account-confirm-title"]').should(
|
|
"contain",
|
|
"Konto erstellen",
|
|
);
|
|
cy.get('[data-cy="continue-button"]').click();
|
|
|
|
cy.get('[data-cy="account-profile-title"]').should(
|
|
"contain",
|
|
"Profil ergänzen",
|
|
);
|
|
cy.get('[data-cy="dropdown-select"]').click();
|
|
cy.get('[data-cy="dropdown-select-option-Baloise"]').click();
|
|
cy.get('[data-cy="continue-button"]').click();
|
|
|
|
cy.get('[data-cy="account-course-profile-title"]').should(
|
|
"have.text",
|
|
"Zulassungsprofil auswählen",
|
|
);
|
|
|
|
cy.get('[data-cy="dropdown-select"]').click();
|
|
cy.get('[data-cy="dropdown-select-option-Allbranche"]').click();
|
|
cy.get('[data-cy="continue-button"]').click();
|
|
|
|
// Adressdaten ausfüllen
|
|
cy.get('[data-cy="account-checkout-title"]').should(
|
|
"contain",
|
|
"Lehrgang kaufen",
|
|
);
|
|
|
|
cy.get("#paymentMethod").select("cembra_byjuno");
|
|
|
|
cy.get("#street-address").type("Eggersmatt");
|
|
cy.get("#street-number").type("32");
|
|
cy.get("#postal-code").type("1719");
|
|
cy.get("#city").type("Zumholz");
|
|
|
|
cy.get("#phone").type("079 201 85 86");
|
|
cy.get('[data-test="dp-input"]').type("09.06.1982{enter}");
|
|
|
|
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.customer.birthDate).to.equal(
|
|
"1982-06-09",
|
|
);
|
|
|
|
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");
|
|
expect(ci.last_name).to.equal("Leer");
|
|
|
|
expect(ci.street).to.equal("Eggersmatt");
|
|
expect(ci.street_number).to.equal("32");
|
|
expect(ci.postal_code).to.equal("1719");
|
|
expect(ci.city).to.equal("Zumholz");
|
|
expect(ci.country).to.equal("CH");
|
|
expect(ci.phone_number).to.equal("+41792018586");
|
|
expect(ci.birth_date).to.equal("1982-06-09");
|
|
expect(ci.cembra_byjuno_invoice).to.be.true;
|
|
|
|
expect(ci.invoice_address).to.equal("prv");
|
|
|
|
expect(ci.product_name).to.equal("Versicherungsvermittler/-in VBV");
|
|
expect(ci.product_price).to.equal(32400);
|
|
|
|
expect(ci.state).to.equal("ongoing");
|
|
|
|
expect(ci.ip_address).to.not.be.empty;
|
|
expect(ci.device_fingerprint_session_key).to.not.be.empty;
|
|
});
|
|
|
|
cy.loadUser("id", TEST_USER_EMPTY_ID).then((u) => {
|
|
expect(u.first_name).to.equal("Flasche");
|
|
expect(u.last_name).to.equal("Leer");
|
|
|
|
expect(u.street).to.equal("Eggersmatt");
|
|
expect(u.street_number).to.equal("32");
|
|
expect(u.postal_code).to.equal("1719");
|
|
expect(u.city).to.equal("Zumholz");
|
|
expect(u.country).to.equal("CH");
|
|
expect(u.phone_number).to.equal("+41792018586");
|
|
expect(u.birth_date).to.equal("1982-06-09");
|
|
|
|
expect(u.invoice_address).to.equal("prv");
|
|
|
|
// 7 -> Baloise
|
|
expect(u.organisation).to.equal(7);
|
|
});
|
|
|
|
// pay
|
|
cy.get('[data-cy="pay-button"]').click();
|
|
|
|
cy.get('[data-cy="checkout-success-title"]').should(
|
|
"contain",
|
|
"Gratuliere",
|
|
);
|
|
// wait for payment callback
|
|
cy.wait(3000);
|
|
cy.get('[data-cy="start-vv-button"]').click();
|
|
|
|
// back on dashboard page
|
|
cy.get('[data-cy="db-course-title"]').should(
|
|
"contain",
|
|
"Versicherungsvermittler",
|
|
);
|
|
|
|
cy.loadCheckoutInformation("user_id", TEST_USER_EMPTY_ID).then((ci) => {
|
|
expect(ci.state).to.equal("paid");
|
|
});
|
|
|
|
cy.loadCourseSessionUser("user_id", TEST_USER_EMPTY_ID).then((csu) => {
|
|
expect(csu.role).to.equal("MEMBER");
|
|
expect(csu.course_session).to.equal(TEST_COURSE_SESSION_VV_ID);
|
|
expect(csu.chosen_profile).to.equal(COURSE_PROFILE_ALL_ID);
|
|
});
|
|
});
|
|
});
|