Skip to content

Commit c88c69f

Browse files
committed
Add test for VAR - WMDE_FR_2025_Desktop_DE_13
Ticket:https://phabricator.wikimedia.org/T411259
1 parent 00f6675 commit c88c69f

File tree

1 file changed

+165
-0
lines changed

1 file changed

+165
-0
lines changed
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
import { beforeEach, describe, test, vi } from 'vitest';
2+
import { mount, VueWrapper } from '@vue/test-utils';
3+
import Banner from '@banners/desktop/WMDE_FR_2025_Desktop_DE_13/components/BannerVar.vue';
4+
import { BannerStates } from '@src/components/BannerConductor/StateMachine/BannerStates';
5+
import { newDynamicContent } from '@test/banners/dynamicCampaignContent';
6+
import { useOfFundsContent } from '@test/banners/useOfFundsContent';
7+
import { formItems } from '@test/banners/formItems';
8+
import { CurrencyEn } from '@src/utils/DynamicContent/formatters/CurrencyEn';
9+
import { desktopUseOfFundsFeatures } from '@test/features/UseOfFunds';
10+
import {
11+
bannerContentAnimatedTextFeatures,
12+
bannerContentDateAndTimeFeatures,
13+
bannerContentDisplaySwitchFeatures,
14+
bannerContentFeatures
15+
} from '@test/features/BannerContent';
16+
import { donationFormFeatures } from '@test/features/forms/MainDonation_UpgradeToYearlyButton';
17+
import { useFormModel } from '@src/components/composables/useFormModel';
18+
import { resetFormModel } from '@test/resetFormModel';
19+
import { DynamicContent } from '@src/utils/DynamicContent/DynamicContent';
20+
import { bannerAutoHideFeatures } from '@test/features/MainBanner';
21+
import { formActionSwitchFeatures } from '@test/features/form_action_switch/MainDonation_UpgradeToYearlyButton';
22+
import { alreadyDonatedLinkFeatures } from '@test/features/AlreadyDonatedLink';
23+
import { Tracker } from '@src/tracking/Tracker';
24+
import { TimerStub } from '@test/fixtures/TimerStub';
25+
import { Timer } from '@src/utils/Timer';
26+
import { fakeFormActions } from '@test/fixtures/FakeFormActions';
27+
import { softCloseFeatures } from '@test/features/SoftCloseDesktop';
28+
import { softCloseSubmitTrackingFeaturesDesktop } from '@test/features/SoftCloseSubmitTrackingDesktop';
29+
30+
const formModel = useFormModel();
31+
const translator = ( key: string ): string => key;
32+
let tracker: Tracker;
33+
34+
describe( 'BannerCtrl.vue', () => {
35+
36+
beforeEach( () => {
37+
resetFormModel( formModel );
38+
tracker = {
39+
trackEvent: vi.fn()
40+
};
41+
} );
42+
43+
const getWrapper = ( dynamicContent: DynamicContent = null, timer: Timer = null ): VueWrapper<any> => {
44+
return mount( Banner, {
45+
attachTo: document.body,
46+
props: {
47+
bannerState: BannerStates.Pending,
48+
useOfFundsContent,
49+
localCloseTracker: {
50+
getItem: () => '',
51+
setItem: () => {}
52+
}
53+
},
54+
global: {
55+
mocks: {
56+
$translate: translator
57+
},
58+
provide: {
59+
translator: { translate: translator },
60+
dynamicCampaignText: dynamicContent ?? newDynamicContent(),
61+
currentCampaignTimePercentage: 42,
62+
formActions: fakeFormActions,
63+
currencyFormatter: new CurrencyEn(),
64+
formItems,
65+
tracker,
66+
timer: timer ?? new TimerStub()
67+
}
68+
}
69+
} );
70+
};
71+
72+
describe( 'Main Banner', () => {
73+
test.each( [
74+
[ 'expectClosesBannerWhenWindowBecomesSmall' ]
75+
] )( '%s', async ( testName: string ) => {
76+
await bannerAutoHideFeatures[ testName ]( getWrapper );
77+
} );
78+
} );
79+
80+
describe( 'Content', () => {
81+
test.each( [
82+
[ 'expectSlideShowPlaysWhenBecomesVisible' ],
83+
[ 'expectSlideShowStopsOnFormInteraction' ]
84+
] )( '%s', async ( testName: string ) => {
85+
await bannerContentFeatures[ testName ]( getWrapper() );
86+
} );
87+
88+
test.each( [
89+
[ 'expectShowsSlideShowOnSmallSizes' ],
90+
[ 'expectShowsMessageOnLargeSizes' ]
91+
] )( '%s', async ( testName: string ) => {
92+
await bannerContentDisplaySwitchFeatures[ testName ]( getWrapper, 1300 );
93+
} );
94+
95+
test.each( [
96+
[ 'expectShowsAnimatedVisitorsVsDonorsSentenceInMessage' ],
97+
[ 'expectShowsAnimatedVisitorsVsDonorsSentenceInSlideShow' ]
98+
] )( '%s', async ( testName: string ) => {
99+
await bannerContentAnimatedTextFeatures[ testName ]( getWrapper );
100+
} );
101+
102+
test.each( [
103+
[ 'expectShowsLiveDateAndTimeInTitle' ]
104+
] )( '%s', async ( testName: string ) => {
105+
await bannerContentDateAndTimeFeatures[ testName ]( getWrapper );
106+
} );
107+
} );
108+
109+
describe( 'Donation Form Happy Paths', () => {
110+
test.each( [
111+
[ 'expectMainDonationFormSubmitsWhenSofortIsSelected' ],
112+
[ 'expectMainDonationFormSubmitsWhenYearlyIsSelected' ],
113+
[ 'expectMainDonationFormGoesToUpgrade' ],
114+
[ 'expectUpgradeToYearlyFormSubmitsUpgrade' ],
115+
[ 'expectUpgradeToYearlyFormSubmitsDontUpgrade' ]
116+
] )( '%s', async ( testName: string ) => {
117+
await donationFormFeatures[ testName ]( getWrapper() );
118+
} );
119+
120+
test.each( [
121+
[ 'expectMainDonationFormSubmitsWithAddressForDirectDebit' ],
122+
[ 'expectMainDonationFormSubmitsWithAddressForPayPal' ],
123+
[ 'expectUpgradeToYearlyFormSubmitsWithAddressForDirectDebit' ],
124+
[ 'expectUpgradeToYearlyFormSubmitsWithAddressForPayPal' ]
125+
] )( '%s', async ( testName: string ) => {
126+
await formActionSwitchFeatures[ testName ]( getWrapper() );
127+
} );
128+
} );
129+
130+
describe( 'Soft Close', () => {
131+
test.each( [
132+
[ 'expectDoesNotShowSoftClose' ]
133+
] )( '%s', async ( testName: string ) => {
134+
await softCloseFeatures[ testName ]( getWrapper );
135+
} );
136+
} );
137+
138+
describe( 'Track user choice on the previous soft-close banner', () => {
139+
test.each( [
140+
[ 'expectEmitsBannerSubmitOnReturnEvent' ],
141+
[ 'expectDoesNotEmitsBannerSubmitOnReturnEventWhenLocalStorageItemIsMissing' ]
142+
] )( '%s', async ( testName: string ) => {
143+
await softCloseSubmitTrackingFeaturesDesktop[ testName ]( getWrapper(), tracker );
144+
} );
145+
} );
146+
147+
describe( 'Already Donated', () => {
148+
test.each( [
149+
[ 'expectFiresMaybeLaterEventOnLinkClick' ]
150+
] )( '%s', async ( testName: string ) => {
151+
await alreadyDonatedLinkFeatures[ testName ]( getWrapper() );
152+
} );
153+
} );
154+
155+
describe( 'Use of Funds', () => {
156+
test.each( [
157+
[ 'expectShowsUseOfFunds' ],
158+
[ 'expectHidesUseOfFunds' ],
159+
[ 'expectEmitsModalOpenedEvent' ],
160+
[ 'expectEmitsModalClosedEvent' ]
161+
] )( '%s', async ( testName: string ) => {
162+
await desktopUseOfFundsFeatures[ testName ]( getWrapper() );
163+
} );
164+
} );
165+
} );

0 commit comments

Comments
 (0)