Skip to content

Commit

Permalink
Merge pull request #549 from wmde/add-survey-tile
Browse files Browse the repository at this point in the history
Add survey tile
  • Loading branch information
Sperling-0 authored Jan 2, 2025
2 parents 7091c31 + 4a0fe8b commit bd67857
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ export interface MembershipApplicationConfirmationData {
membershipApplication: MembershipApplication;
address: MembershipAddress;
countries: Country[];
tracking?: string;
}
6 changes: 6 additions & 0 deletions src/components/pages/MembershipConfirmation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@
<p>{{ address.email }}</p>
</div>

<membership-survey
v-if="$t( 'membership_confirmation_survey_link') !== ''"
:tracking="confirmationData.tracking ?? ''"
/>

<MembershipConfirmationBannerNotifier/>
</div>
</template>

<script setup lang="ts">
import MembershipSurvey from '@src/components/pages/membership_confirmation/MembershipSurvey.vue';
import MembershipConfirmationBannerNotifier
from '@src/components/pages/membership_confirmation/MembershipConfirmationBannerNotifier.vue';
import { Salutation } from '@src/view_models/Salutation';
Expand Down
18 changes: 18 additions & 0 deletions src/components/pages/membership_confirmation/MembershipSurvey.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<template>
<div class="membership-confirmation-card membership-survey">
<h2 class="icon-title"><donor-icon/> {{ $t( 'membership_confirmation_survey_title' ) }}</h2>
<p>{{ $t( 'membership_confirmation_survey_content' ) }}</p>
<p><a target="_blank" :href="$t( 'membership_confirmation_survey_link', { tracking: tracking } )">{{ $t( 'membership_confirmation_survey_link_text' ) }}</a></p>
</div>
</template>

<script setup lang="ts">
import DonorIcon from '@src/components/shared/icons/DonorIcon.vue';
interface Props {
tracking: string;
}
defineProps<Props>();
</script>
31 changes: 29 additions & 2 deletions tests/unit/components/pages/MembershipConfirmation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ const yearlyApplication: MembershipApplication = {
};

describe( 'MembershipConfirmation.vue', () => {
const getWrapper = ( membershipApplication: MembershipApplication, address: MembershipAddress ) => {
const getWrapper = ( membershipApplication: MembershipApplication, address: MembershipAddress, translationMock?: ( key: string, params?: Object ) => string ) => {
const translateFn = translationMock === undefined ? ( key: string, params?: Object ) => JSON.stringify( [ key, params ] ) : translationMock;
const confirmationData: MembershipApplicationConfirmationData = {
piwik: {
membershipApplicationConfirmationGoalId: 123,
Expand All @@ -63,7 +64,7 @@ describe( 'MembershipConfirmation.vue', () => {
},
global: {
mocks: {
$t: ( key: string, params?: Object ) => JSON.stringify( [ key, params ] ),
$t: translateFn,
$n: ( amount: string ) => amount,
},
},
Expand Down Expand Up @@ -126,4 +127,30 @@ describe( 'MembershipConfirmation.vue', () => {
expect( wrapper.text() ).toContain( 'membership_confirmation_success_text_bank_transfer' );
} );

test( 'shows the survey tile if survey link language item is not empty', () => {
const translateMock = ( key: string ): string => {
if ( key === 'membership_confirmation_survey_link' ) {
return 'https://example.com/survey';
}

return key;
};
const wrapper = getWrapper( yearlyApplication, privateAddress, translateMock );

expect( wrapper.find( '.membership-survey' ).exists() ).toBeTruthy();
} );

test( 'hides the survey tile if survey link language item is blank', () => {
const translateMock = ( key: string ): string => {
if ( key === 'membership_confirmation_survey_link' ) {
return '';
}

return key;
};
const wrapper = getWrapper( yearlyApplication, privateAddress, translateMock );

expect( wrapper.find( '.membership-survey' ).exists() ).toBeFalsy();
} );

} );

0 comments on commit bd67857

Please sign in to comment.