diff --git a/src/components/pages/MembershipConfirmation.vue b/src/components/pages/MembershipConfirmation.vue index 1e93090a0..98509b587 100644 --- a/src/components/pages/MembershipConfirmation.vue +++ b/src/components/pages/MembershipConfirmation.vue @@ -1,42 +1,42 @@ + + diff --git a/src/components/pages/membership_confirmation/MembershipConfirmationBannerNotifier.vue b/src/components/pages/membership_confirmation/MembershipConfirmationBannerNotifier.vue index 1108b2f14..7c891b1c8 100644 --- a/src/components/pages/membership_confirmation/MembershipConfirmationBannerNotifier.vue +++ b/src/components/pages/membership_confirmation/MembershipConfirmationBannerNotifier.vue @@ -1,5 +1,5 @@ diff --git a/src/pages/membership_application_confirmation.ts b/src/pages/membership_application_confirmation.ts index 960769bda..b3fe316e5 100644 --- a/src/pages/membership_application_confirmation.ts +++ b/src/pages/membership_application_confirmation.ts @@ -33,7 +33,7 @@ createVueApp( App, assetsPath: pageData.assetsPath, bucketClasses: bucketIdToCssClass( pageData.selectedBuckets ), isFullWidth: true, - usesContentCards: false, + usesContentCards: true, pageIdentifier: PAGE_IDENTIFIER, page: MembershipConfirmation, pageTitle: 'membership_application_confirmation_page_title', diff --git a/tests/data/salutations.ts b/tests/data/salutations.ts new file mode 100644 index 000000000..4f077166e --- /dev/null +++ b/tests/data/salutations.ts @@ -0,0 +1,26 @@ +import { Salutation } from '@src/view_models/Salutation'; + +export const salutations: Salutation[] = [ + { + label: 'Herr', + value: 'Herr', + display: 'Herr', + greetings: { + formal: 'Good day', + informal: 'Yo!', + lastNameInformal: 'My Herr!', + }, + }, + { + label: 'Frau', + value: 'Frau', + display: 'Frau', + greetings: { + formal: 'Good day', + informal: 'Yo!', + lastNameInformal: 'My Frau!', + }, + }, +]; + +export default salutations; diff --git a/tests/unit/components/pages/MembershipConfirmation.spec.ts b/tests/unit/components/pages/MembershipConfirmation.spec.ts new file mode 100644 index 000000000..69942d8f2 --- /dev/null +++ b/tests/unit/components/pages/MembershipConfirmation.spec.ts @@ -0,0 +1,129 @@ +import { mount } from '@vue/test-utils'; +import { MembershipApplication } from '@src/Domain/Membership/MembershipApplication'; +import { MembershipAddress } from '@src/Domain/Membership/MembershipAddress'; +import { MembershipApplicationConfirmationData } from '@src/Domain/Membership/MembershipApplicationConfirmationData'; +import salutations from '@test/data/salutations'; +import countries from '@test/data/countries'; +import MembershipConfirmation from '@src/components/pages/MembershipConfirmation.vue'; + +const privateAddress: MembershipAddress = { + applicantType: 'person', + city: 'Berlin', + countryCode: 'DE', + email: 'testperson@wikimedia.de', + fullName: 'Prof. Dr. Testy MacTest', + postalCode: '10963', + salutation: 'Herr', + streetAddress: 'Tempelhofer Ufer 26', + title: 'Prof. Dr.', +}; + +const companyAddress: MembershipAddress = { + applicantType: 'firma', + city: 'Company City', + countryCode: 'DE', + email: 'testcompany@wikimedia.de', + fullName: 'Test Company', + postalCode: '12345', + salutation: 'Firma', + streetAddress: 'Teststreet 123', + title: '', +}; + +const monthlyApplication: MembershipApplication = { + membershipFee: '15.00', + membershipType: 'sustaining', + paymentIntervalInMonths: 1, + paymentType: 'BEZ', + incentives: [], +}; + +const yearlyApplication: MembershipApplication = { + ...monthlyApplication, + membershipFee: '199.00', + paymentIntervalInMonths: 12, +}; + +describe( 'MembershipConfirmation.vue', () => { + const getWrapper = ( membershipApplication: MembershipApplication, address: MembershipAddress ) => { + const confirmationData: MembershipApplicationConfirmationData = { + piwik: { + membershipApplicationConfirmationGoalId: 123, + }, + membershipApplication, + address, + countries, + salutations, + }; + return mount( MembershipConfirmation, { + props: { + confirmationData, + countries, + salutations, + }, + global: { + mocks: { + $t: ( key: string, params?: Object ) => JSON.stringify( [ key, params ] ), + $n: ( amount: string ) => amount, + }, + }, + } ); + }; + + test( 'displays the correct membership fee', () => { + const wrapper = getWrapper( yearlyApplication, privateAddress ); + const summaryElement = wrapper.find( '.membership-confirmation-summary' ); + + expect( summaryElement.text() ).toContain( '199' ); + expect( summaryElement.text() ).toContain( 'donation_form_payment_interval_12' ); + expect( summaryElement.text() ).toContain( 'BEZ' ); + expect( summaryElement.text() ).toContain( 'sustaining' ); + } ); + + test( 'displays the calculated yearly membership fee', () => { + const wrapper = getWrapper( monthlyApplication, privateAddress ); + const summaryElement = wrapper.find( '.membership-confirmation-summary' ); + + expect( summaryElement.text() ).toContain( '15' ); + expect( summaryElement.text() ).toContain( '180' ); + expect( summaryElement.text() ).toContain( 'donation_form_payment_interval_1' ); + expect( summaryElement.text() ).toContain( 'donation_form_payment_interval_12' ); + } ); + + test( 'displays the correct address for a private person', () => { + const wrapper = getWrapper( yearlyApplication, privateAddress ); + const addressElement = wrapper.find( '.membership-confirmation-card:nth-child(2)' ); + + expect( addressElement.text() ).toContain( 'Prof. Dr. Testy MacTest' ); + expect( addressElement.text() ).toContain( 'Tempelhofer Ufer 26' ); + expect( addressElement.text() ).toContain( '10963 Berlin' ); + expect( addressElement.text() ).toContain( 'Deutschland' ); + expect( addressElement.text() ).toContain( 'testperson@wikimedia.de' ); + } ); + + test( 'displays the correct address for a company', () => { + const wrapper = getWrapper( yearlyApplication, companyAddress ); + const addressElement = wrapper.find( '.membership-confirmation-card:nth-child(2)' ); + + expect( addressElement.text() ).toContain( 'Test Company' ); + expect( addressElement.text() ).toContain( 'Teststreet 123' ); + expect( addressElement.text() ).toContain( '12345 Company City' ); + expect( addressElement.text() ).toContain( 'Deutschland' ); + expect( addressElement.text() ).toContain( 'testcompany@wikimedia.de' ); + } ); + + test( 'displays different text when membership has incentives', () => { + const wrapperWithoutIncentives = getWrapper( yearlyApplication, privateAddress ); + const wrapperWithIncentives = getWrapper( { ...yearlyApplication, incentives: [ 'incentive1', 'incentive2' ] }, privateAddress ); + + expect( wrapperWithoutIncentives.text() ).toContain( 'membership_confirmation_success_text' ); + expect( wrapperWithIncentives.text() ).toContain( 'membership_confirmation_success_text_incentive' ); + } ); + + test( 'displays additional text when payment is bank transfer', () => { + const wrapper = getWrapper( { ...yearlyApplication, paymentType: 'UEB' }, privateAddress ); + + expect( wrapper.text() ).toContain( 'membership_confirmation_success_text_bank_transfer' ); + } ); + +} ); diff --git a/tests/unit/components/pages/membership_confirmation/MembershipSummary.spec.ts b/tests/unit/components/pages/membership_confirmation/MembershipSummary.spec.ts index 77d008b24..e8cfdbac8 100644 --- a/tests/unit/components/pages/membership_confirmation/MembershipSummary.spec.ts +++ b/tests/unit/components/pages/membership_confirmation/MembershipSummary.spec.ts @@ -2,7 +2,7 @@ import { mount, VueWrapper } from '@vue/test-utils'; import MembershipSummary from '@src/components/shared/MembershipSummary.vue'; import { MembershipAddress } from '@src/Domain/Membership/MembershipAddress'; import { MembershipApplication } from '@src/Domain/Membership/MembershipApplication'; -import { Salutation } from '@src/view_models/Salutation'; +import salutations from '@test/data/salutations'; import countries from '@test/data/countries'; const privateAddress: MembershipAddress = { @@ -49,29 +49,6 @@ const yearlyApplication: MembershipApplication = { paymentIntervalInMonths: 12, }; -const salutations: Salutation[] = [ - { - label: 'Herr', - value: 'Herr', - display: 'Herr', - greetings: { - formal: 'Good day', - informal: 'Yo!', - lastNameInformal: 'My Herr!', - }, - }, - { - label: 'Frau', - value: 'Frau', - display: 'Frau', - greetings: { - formal: 'Good day', - informal: 'Yo!', - lastNameInformal: 'My Frau!', - }, - }, -]; - describe( 'MembershipSummary.vue', () => { const getWrapper = ( address: MembershipAddress, membershipApplication: MembershipApplication, addressIsInvalid: boolean = false ): VueWrapper => {