160 lines
5.0 KiB
JavaScript
160 lines
5.0 KiB
JavaScript
import { 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-Baloise"]').click();
|
|
cy.get('[data-cy="continue-button"]').click();
|
|
|
|
// 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").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("Iterativ 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");
|
|
});
|
|
|
|
// 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");
|
|
});
|
|
});
|
|
|
|
it.only("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();
|
|
|
|
// Adressdaten ausfüllen
|
|
cy.get('[data-cy="account-checkout-title"]').should(
|
|
"contain",
|
|
"Lehrgang kaufen"
|
|
);
|
|
cy.get('[data-cy="cembra-switch"]').click();
|
|
|
|
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("#birth-date").type("1982-06-09");
|
|
|
|
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.phone_number).to.equal("+41792018586");
|
|
expect(ci.birth_date).to.equal("1982-06-09");
|
|
expect(ci.cembra_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;
|
|
});
|
|
});
|
|
});
|