-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement VAR for C24_WMDE_Desktop_EN_03
- Use main donation form with transaction fees in VAR - Fix test name in C24_WPDE_Desktop_01 Ticket: https://phabricator.wikimedia.org/T378702
- Loading branch information
Showing
8 changed files
with
233 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { TrackingEventConverterFactory } from '@src/tracking/LegacyTrackerWPORG'; | ||
import { WMDELegacyBannerEvent } from '@src/tracking/WPORG/WMDELegacyBannerEvent'; | ||
import { FormStepShownEvent } from '@src/tracking/events/FormStepShownEvent'; | ||
import { mapFormStepShownEvent } from '@src/tracking/LegacyEventTracking/mapFormStepShownEvent'; | ||
import { CustomAmountChangedEvent } from '@src/tracking/events/CustomAmountChangedEvent'; | ||
import { CloseEvent } from '@src/tracking/events/CloseEvent'; | ||
import { mapCloseEvent } from '@src/tracking/LegacyEventTracking/mapCloseEvent'; | ||
import { NotShownEvent } from '@src/tracking/events/NotShownEvent'; | ||
import { mapNotShownEvent } from '@src/tracking/LegacyEventTracking/mapNotShownEvent'; | ||
import { BannerSubmitEvent } from '@src/tracking/events/BannerSubmitEvent'; | ||
import { WMDESizeIssueEvent } from '@src/tracking/WPORG/WMDEBannerSizeIssue'; | ||
import { createViewportInfo } from '@src/tracking/LegacyEventTracking/createViewportInfo'; | ||
import { FallbackBannerSubmitEvent } from '@src/tracking/events/FallbackBannerSubmitEvent'; | ||
import { ShownEvent } from '@src/tracking/events/ShownEvent'; | ||
import { mapShownEvent } from '@src/tracking/LegacyEventTracking/mapShownEvent'; | ||
import { CoverTransactionFeesEvent } from '@src/tracking/events/CoverTransactionFeesEvent'; | ||
|
||
export default new Map<string, TrackingEventConverterFactory>( [ | ||
[ ShownEvent.EVENT_NAME, mapShownEvent ], | ||
[ CloseEvent.EVENT_NAME, mapCloseEvent ], | ||
|
||
[ FormStepShownEvent.EVENT_NAME, mapFormStepShownEvent ], | ||
[ CustomAmountChangedEvent.EVENT_NAME, | ||
( e: CustomAmountChangedEvent ): WMDELegacyBannerEvent => | ||
new WMDELegacyBannerEvent( e.userChoice + '-amount', 1 ) | ||
], | ||
[ NotShownEvent.EVENT_NAME, mapNotShownEvent ], | ||
[ BannerSubmitEvent.EVENT_NAME, ( e: BannerSubmitEvent ): WMDESizeIssueEvent => { | ||
switch ( e.feature ) { | ||
case 'UpgradeToYearlyForm': | ||
return new WMDESizeIssueEvent( `submit-${e.userChoice}`, createViewportInfo(), 1 ); | ||
case 'CustomAmountForm': | ||
return new WMDESizeIssueEvent( `submit-different-amount`, createViewportInfo(), 1 ); | ||
default: | ||
return new WMDESizeIssueEvent( `submit`, createViewportInfo(), 1 ); | ||
} | ||
} ], | ||
[ FallbackBannerSubmitEvent.EVENT_NAME, ( e: FallbackBannerSubmitEvent ): WMDESizeIssueEvent => new WMDESizeIssueEvent( e.eventName, createViewportInfo(), 1 ) ], | ||
[ CoverTransactionFeesEvent.EVENT_NAME, ( e: CoverTransactionFeesEvent ): WMDELegacyBannerEvent => new WMDELegacyBannerEvent( e.userChoice + 'cover-transaction-fee', 1 ) ] | ||
] ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
154 changes: 154 additions & 0 deletions
154
test/banners/english/C24_WMDE_Desktop_EN_03/components/BannerVar.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
import { afterEach, beforeEach, describe, test, vi } from 'vitest'; | ||
import { mount, VueWrapper } from '@vue/test-utils'; | ||
import Banner from '@banners/english/C24_WMDE_Desktop_EN_03/components/BannerVar.vue'; | ||
import { BannerStates } from '@src/components/BannerConductor/StateMachine/BannerStates'; | ||
import { newDynamicContent } from '@test/banners/dynamicCampaignContent'; | ||
import { useOfFundsContent } from '@test/banners/useOfFundsContent'; | ||
import { formItems } from '@test/banners/formItems'; | ||
import { CurrencyEn } from '@src/utils/DynamicContent/formatters/CurrencyEn'; | ||
import { useOfFundsFeatures } from '@test/features/UseOfFunds'; | ||
import { | ||
bannerContentAnimatedTextFeatures, | ||
bannerContentDateAndTimeFeatures, | ||
bannerContentDisplaySwitchFeatures, | ||
bannerContentFeatures | ||
} from '@test/features/BannerContent'; | ||
import { TrackerStub } from '@test/fixtures/TrackerStub'; | ||
import { donationFormFeatures } from '@test/features/forms/MainDonation_UpgradeToYearlyButton'; | ||
import { useFormModel } from '@src/components/composables/useFormModel'; | ||
import { resetFormModel } from '@test/resetFormModel'; | ||
import { bannerMainFeatures } from '@test/features/MainBanner'; | ||
import { DynamicContent } from '@src/utils/DynamicContent/DynamicContent'; | ||
import { alreadyDonatedModalFeatures } from '@test/features/AlreadyDonatedModal'; | ||
import { softCloseFeatures } from '@test/features/SoftCloseDesktop'; | ||
import { donationFormTransactionFeeFeatures } from '@test/features/forms/MainDonation_TransactionFee'; | ||
|
||
const formModel = useFormModel(); | ||
const translator = ( key: string, context: any ): string => context ? `${key} -- ${Object.entries( context )}` : key; | ||
|
||
describe( 'BannerCtrl.vue', () => { | ||
|
||
beforeEach( () => { | ||
resetFormModel( formModel ); | ||
vi.useFakeTimers(); | ||
} ); | ||
|
||
afterEach( () => { | ||
vi.restoreAllMocks(); | ||
vi.useRealTimers(); | ||
} ); | ||
|
||
const getWrapper = ( dynamicContent: DynamicContent = null ): VueWrapper<any> => { | ||
return mount( Banner, { | ||
attachTo: document.body, | ||
props: { | ||
bannerState: BannerStates.Pending, | ||
useOfFundsContent, | ||
remainingImpressions: 10 | ||
}, | ||
global: { | ||
mocks: { | ||
$translate: translator | ||
}, | ||
provide: { | ||
translator: { translate: translator }, | ||
dynamicCampaignText: dynamicContent ?? newDynamicContent(), | ||
formActions: { donateWithAddressAction: 'https://example.com', donateWithoutAddressAction: 'https://example.com' }, | ||
currencyFormatter: new CurrencyEn(), | ||
formItems, | ||
tracker: new TrackerStub() | ||
} | ||
} | ||
} ); | ||
}; | ||
|
||
describe( 'Main Banner', () => { | ||
test.each( [ | ||
[ 'expectDoesNotEmitCloseEvent' ] | ||
] )( '%s', async ( testName: string ) => { | ||
await bannerMainFeatures[ testName ]( getWrapper() ); | ||
} ); | ||
} ); | ||
|
||
describe( 'Content', () => { | ||
test.each( [ | ||
[ 'expectSlideShowPlaysWhenBecomesVisible' ], | ||
[ 'expectSlideShowStopsOnFormInteraction' ] | ||
] )( '%s', async ( testName: string ) => { | ||
await bannerContentFeatures[ testName ]( getWrapper() ); | ||
} ); | ||
|
||
test.each( [ | ||
[ 'expectShowsSlideShowOnSmallSizes' ], | ||
[ 'expectShowsMessageOnLargeSizes' ] | ||
] )( '%s', async ( testName: string ) => { | ||
await bannerContentDisplaySwitchFeatures[ testName ]( getWrapper, 1300 ); | ||
} ); | ||
|
||
test.each( [ | ||
[ 'expectShowsAnimatedVisitorsVsDonorsSentenceInMessage' ], | ||
[ 'expectShowsAnimatedVisitorsVsDonorsSentenceInSlideShow' ] | ||
] )( '%s', async ( testName: string ) => { | ||
await bannerContentAnimatedTextFeatures[ testName ]( getWrapper ); | ||
} ); | ||
|
||
test.each( [ | ||
[ 'expectShowsLiveDateAndTimeInMessage' ], | ||
[ 'expectShowsLiveDateAndTimeInSlideshow' ] | ||
] )( '%s', async ( testName: string ) => { | ||
await bannerContentDateAndTimeFeatures[ testName ]( getWrapper ); | ||
} ); | ||
} ); | ||
|
||
describe( 'Donation Form Happy Paths', () => { | ||
test.each( [ | ||
[ 'expectMainDonationFormSubmitsWhenSofortIsSelected' ], | ||
[ 'expectMainDonationFormSubmitsWhenYearlyIsSelected' ], | ||
[ 'expectMainDonationFormGoesToUpgrade' ], | ||
[ 'expectUpgradeToYearlyFormSubmitsUpgrade' ], | ||
[ 'expectUpgradeToYearlyFormSubmitsDontUpgrade' ] | ||
] )( '%s', async ( testName: string ) => { | ||
await donationFormFeatures[ testName ]( getWrapper() ); | ||
} ); | ||
} ); | ||
|
||
describe( 'Soft Close', () => { | ||
test.each( [ | ||
[ 'expectShowsSoftClose' ], | ||
[ 'expectEmitsSoftCloseCloseEvent' ], | ||
[ 'expectEmitsSoftCloseMaybeLaterEvent' ], | ||
[ 'expectEmitsSoftCloseTimeOutEvent' ], | ||
[ 'expectEmitsBannerContentChangedOnSoftClose' ], | ||
[ 'expectDoesNotShowSoftCloseOnFinalBannerImpression' ] | ||
] )( '%s', async ( testName: string ) => { | ||
await softCloseFeatures[ testName ]( getWrapper() ); | ||
} ); | ||
} ); | ||
|
||
describe( 'Donation Form Transaction Fees', () => { | ||
test.each( [ | ||
[ 'expectMainDonationFormShowsTransactionFeeForPayPalAndCreditCard' ], | ||
[ 'expectMainDonationFormSetsSubmitValuesWithTransactionFee' ], | ||
[ 'expectUpsellFormHasTransactionFee' ] | ||
] )( '%s', async ( testName: string ) => { | ||
await donationFormTransactionFeeFeatures[ testName ]( getWrapper() ); | ||
} ); | ||
} ); | ||
|
||
describe( 'Use of Funds', () => { | ||
test.each( [ | ||
[ 'expectShowsUseOfFunds' ], | ||
[ 'expectHidesUseOfFunds' ] | ||
] )( '%s', async ( testName: string ) => { | ||
await useOfFundsFeatures[ testName ]( getWrapper() ); | ||
} ); | ||
} ); | ||
|
||
describe( 'Already Donated', () => { | ||
test.each( [ | ||
[ 'expectFiresMaybeLaterEventOnLinkClick' ] | ||
] )( '%s', async ( testName: string ) => { | ||
await alreadyDonatedModalFeatures[ testName ]( getWrapper() ); | ||
} ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters