From 8828197ecfb8db54d88719c5393079aaa0d7bd4d Mon Sep 17 00:00:00 2001 From: Sperling-0 Date: Fri, 8 Nov 2024 19:14:50 +0100 Subject: [PATCH 1/3] Prepere campaign for C24_WMDE_Mobile_DE_08 Ticket: https://phabricator.wikimedia.org/T379292 --- .../C24_WMDE_Mobile_DE_08/MinimisedTracker.ts | 27 ++ .../C24_WMDE_Mobile_DE_08/banner_ctrl.ts | 71 +++++ .../C24_WMDE_Mobile_DE_08/banner_var.ts | 71 +++++ .../components/BannerCtrl.vue | 224 +++++++++++++++ .../components/BannerVar.vue | 258 ++++++++++++++++++ .../components/FullPageBanner.vue | 43 +++ .../components/MiniBanner.vue | 37 +++ .../components/MiniBannerVar.vue | 46 ++++ .../components/MinimisedBanner.vue | 32 +++ .../content/BannerSlides.vue | 75 +++++ .../content/BannerText.vue | 52 ++++ .../mobile/C24_WMDE_Mobile_DE_08/event_map.ts | 33 +++ .../C24_WMDE_Mobile_DE_08/event_map_var.ts | 36 +++ .../C24_WMDE_Mobile_DE_08/form_items.ts | 23 ++ .../mobile/C24_WMDE_Mobile_DE_08/messages.ts | 30 ++ .../C24_WMDE_Mobile_DE_08/styles/Banner.scss | 56 ++++ .../styles/BannerVar.scss | 108 ++++++++ .../styles/FullPageBanner.scss | 99 +++++++ .../styles/MiniBanner.scss | 157 +++++++++++ .../styles/MiniBannerVar.scss | 196 +++++++++++++ .../styles/MinimisedBanner.scss | 96 +++++++ .../C24_WMDE_Mobile_DE_08/styles/styles.scss | 29 ++ .../styles/styles_var.scss | 30 ++ campaign_info.toml | 18 +- .../components/BannerCtrl.spec.ts | 181 ++++++++++++ .../components/BannerVar.spec.ts | 192 +++++++++++++ 26 files changed, 2211 insertions(+), 9 deletions(-) create mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/MinimisedTracker.ts create mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/banner_ctrl.ts create mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/banner_var.ts create mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/components/BannerCtrl.vue create mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/components/BannerVar.vue create mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/components/FullPageBanner.vue create mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/components/MiniBanner.vue create mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/components/MiniBannerVar.vue create mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/components/MinimisedBanner.vue create mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/content/BannerSlides.vue create mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/content/BannerText.vue create mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/event_map.ts create mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/event_map_var.ts create mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/form_items.ts create mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/messages.ts create mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/styles/Banner.scss create mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/styles/BannerVar.scss create mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/styles/FullPageBanner.scss create mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/styles/MiniBanner.scss create mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/styles/MiniBannerVar.scss create mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/styles/MinimisedBanner.scss create mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/styles/styles.scss create mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/styles/styles_var.scss create mode 100644 test/banners/mobile/C24_WMDE_Mobile_DE_08/components/BannerCtrl.spec.ts create mode 100644 test/banners/mobile/C24_WMDE_Mobile_DE_08/components/BannerVar.spec.ts diff --git a/banners/mobile/C24_WMDE_Mobile_DE_08/MinimisedTracker.ts b/banners/mobile/C24_WMDE_Mobile_DE_08/MinimisedTracker.ts new file mode 100644 index 000000000..2e207100e --- /dev/null +++ b/banners/mobile/C24_WMDE_Mobile_DE_08/MinimisedTracker.ts @@ -0,0 +1,27 @@ +import hasLocalStorage from '@src/utils/hasLocalStorage'; + +/** + * This feature is to track the minimised state and load the banner + * minimised on page change. It was removed from the ticket, but + * I'm leaving it here in case it gets re-added while I'm away. + */ +export interface MinimisedTracker { + setMinimised( minimised: boolean ): void; + isMinimised(): boolean; +} + +export class LocalStorageMinimisedTracker implements MinimisedTracker { + public setMinimised( minimised: boolean ): void { + if ( !hasLocalStorage() ) { + return; + } + window.localStorage.setItem( 'fundraising.minimised', minimised ? 'true' : 'false' ); + } + + public isMinimised(): boolean { + if ( !hasLocalStorage() ) { + return false; + } + return window.localStorage.getItem( 'fundraising.minimised' ) === 'true'; + } +} diff --git a/banners/mobile/C24_WMDE_Mobile_DE_08/banner_ctrl.ts b/banners/mobile/C24_WMDE_Mobile_DE_08/banner_ctrl.ts new file mode 100644 index 000000000..8c0342a68 --- /dev/null +++ b/banners/mobile/C24_WMDE_Mobile_DE_08/banner_ctrl.ts @@ -0,0 +1,71 @@ +import { createVueApp } from '@src/createVueApp'; + +import './styles/styles.scss'; + +import BannerConductor from '@src/components/BannerConductor/BannerConductor.vue'; +import Banner from './components/BannerCtrl.vue'; +import { UrlRuntimeEnvironment } from '@src/utils/RuntimeEnvironment'; +import { WindowResizeHandler } from '@src/utils/ResizeHandler'; +import PageWPORG from '@src/page/PageWPORG'; +import { WindowMediaWiki } from '@src/page/MediaWiki/WindowMediaWiki'; +import { SkinFactory } from '@src/page/skin/SkinFactory'; +import { WindowSizeIssueChecker } from '@src/utils/SizeIssueChecker/WindowSizeIssueChecker'; +import TranslationPlugin from '@src/TranslationPlugin'; +import { Translator } from '@src/Translator'; +import DynamicTextPlugin from '@src/DynamicTextPlugin'; +import { LocalImpressionCount } from '@src/utils/LocalImpressionCount'; +import { WindowPageScroller } from '@src/utils/PageScroller/WindowPageScroller'; +import { LegacyTrackerWPORG } from '@src/tracking/LegacyTrackerWPORG'; +import eventMappings from './event_map'; + +// Locale-specific imports +import messages from './messages'; +import { LocaleFactoryDe } from '@src/utils/LocaleFactory/LocaleFactoryDe'; + +// Channel specific form setup +import { createFormItems } from './form_items'; +import { createFormActions } from '@src/createFormActions'; +import { LocalStorageCloseTracker } from '@src/utils/LocalCloseTracker'; + +const localeFactory = new LocaleFactoryDe(); +const translator = new Translator( messages ); +const mediaWiki = new WindowMediaWiki(); +const page = new PageWPORG( mediaWiki, ( new SkinFactory( mediaWiki ) ).getSkin(), new WindowSizeIssueChecker() ); +const runtimeEnvironment = new UrlRuntimeEnvironment( window.location ); +const impressionCount = new LocalImpressionCount( page.getTracking().keyword, runtimeEnvironment ); +const tracker = new LegacyTrackerWPORG( mediaWiki, page.getTracking().keyword, eventMappings, runtimeEnvironment ); + +const app = createVueApp( BannerConductor, { + page, + bannerConfig: { + delay: runtimeEnvironment.getBannerDelay( 7500 ), + transitionDuration: 1000 + }, + bannerProps: { + useOfFundsContent: localeFactory.getUseOfFundsLoader().getContent(), + pageScroller: new WindowPageScroller(), + remainingImpressions: impressionCount.getRemainingImpressions( page.getMaxBannerImpressions( 'mobile' ) ), + localCloseTracker: new LocalStorageCloseTracker() + }, + resizeHandler: new WindowResizeHandler(), + banner: Banner, + impressionCount +} ); + +app.use( TranslationPlugin, translator ); +app.use( DynamicTextPlugin, { + campaignParameters: page.getCampaignParameters(), + date: new Date(), + formatters: localeFactory.getFormatters(), + impressionCount, + translator, + urgencyMessageDaysLeft: 45 +} ); +const currencyFormatter = localeFactory.getCurrencyFormatter(); + +app.provide( 'currencyFormatter', currencyFormatter ); +app.provide( 'formItems', createFormItems( translator, currencyFormatter.euroAmount.bind( currencyFormatter ) ) ); +app.provide( 'formActions', createFormActions( page.getTracking(), impressionCount, { afo: '1', ap: '0' } ) ); +app.provide( 'tracker', tracker ); + +app.mount( page.getBannerContainer() ); diff --git a/banners/mobile/C24_WMDE_Mobile_DE_08/banner_var.ts b/banners/mobile/C24_WMDE_Mobile_DE_08/banner_var.ts new file mode 100644 index 000000000..d4ca56a54 --- /dev/null +++ b/banners/mobile/C24_WMDE_Mobile_DE_08/banner_var.ts @@ -0,0 +1,71 @@ +import { createVueApp } from '@src/createVueApp'; + +import './styles/styles_var.scss'; + +import BannerConductor from '@src/components/BannerConductor/BannerConductor.vue'; +import Banner from './components/BannerVar.vue'; +import { UrlRuntimeEnvironment } from '@src/utils/RuntimeEnvironment'; +import { WindowResizeHandler } from '@src/utils/ResizeHandler'; +import PageWPORG from '@src/page/PageWPORG'; +import { WindowMediaWiki } from '@src/page/MediaWiki/WindowMediaWiki'; +import { SkinFactory } from '@src/page/skin/SkinFactory'; +import { WindowSizeIssueChecker } from '@src/utils/SizeIssueChecker/WindowSizeIssueChecker'; +import TranslationPlugin from '@src/TranslationPlugin'; +import { Translator } from '@src/Translator'; +import DynamicTextPlugin from '@src/DynamicTextPlugin'; +import { LocalImpressionCount } from '@src/utils/LocalImpressionCount'; +import { WindowPageScroller } from '@src/utils/PageScroller/WindowPageScroller'; +import { LegacyTrackerWPORG } from '@src/tracking/LegacyTrackerWPORG'; +import eventMappings from './event_map_var'; + +// Locale-specific imports +import messages from './messages'; +import { LocaleFactoryDe } from '@src/utils/LocaleFactory/LocaleFactoryDe'; + +// Channel specific form setup +import { createFormItems } from './form_items'; +import { createFormActions } from '@src/createFormActions'; +import { LocalStorageCloseTracker } from '@src/utils/LocalCloseTracker'; + +const localeFactory = new LocaleFactoryDe(); +const translator = new Translator( messages ); +const mediaWiki = new WindowMediaWiki(); +const page = new PageWPORG( mediaWiki, ( new SkinFactory( mediaWiki ) ).getSkin(), new WindowSizeIssueChecker() ); +const runtimeEnvironment = new UrlRuntimeEnvironment( window.location ); +const impressionCount = new LocalImpressionCount( page.getTracking().keyword, runtimeEnvironment ); +const tracker = new LegacyTrackerWPORG( mediaWiki, page.getTracking().keyword, eventMappings, runtimeEnvironment ); + +const app = createVueApp( BannerConductor, { + page, + bannerConfig: { + delay: runtimeEnvironment.getBannerDelay( 7500 ), + transitionDuration: 1000 + }, + bannerProps: { + useOfFundsContent: localeFactory.getUseOfFundsLoader().getContent(), + pageScroller: new WindowPageScroller(), + remainingImpressions: impressionCount.getRemainingImpressions( page.getMaxBannerImpressions( 'mobile' ) ), + localCloseTracker: new LocalStorageCloseTracker() + }, + resizeHandler: new WindowResizeHandler(), + banner: Banner, + impressionCount +} ); + +app.use( TranslationPlugin, translator ); +app.use( DynamicTextPlugin, { + campaignParameters: page.getCampaignParameters(), + date: new Date(), + formatters: localeFactory.getFormatters(), + impressionCount, + translator, + urgencyMessageDaysLeft: 45 +} ); +const currencyFormatter = localeFactory.getCurrencyFormatter(); + +app.provide( 'currencyFormatter', currencyFormatter ); +app.provide( 'formItems', createFormItems( translator, currencyFormatter.euroAmount.bind( currencyFormatter ) ) ); +app.provide( 'formActions', createFormActions( page.getTracking(), impressionCount, { afo: '1', ap: '0' } ) ); +app.provide( 'tracker', tracker ); + +app.mount( page.getBannerContainer() ); diff --git a/banners/mobile/C24_WMDE_Mobile_DE_08/components/BannerCtrl.vue b/banners/mobile/C24_WMDE_Mobile_DE_08/components/BannerCtrl.vue new file mode 100644 index 000000000..1191153ce --- /dev/null +++ b/banners/mobile/C24_WMDE_Mobile_DE_08/components/BannerCtrl.vue @@ -0,0 +1,224 @@ + + + diff --git a/banners/mobile/C24_WMDE_Mobile_DE_08/components/BannerVar.vue b/banners/mobile/C24_WMDE_Mobile_DE_08/components/BannerVar.vue new file mode 100644 index 000000000..0d3485523 --- /dev/null +++ b/banners/mobile/C24_WMDE_Mobile_DE_08/components/BannerVar.vue @@ -0,0 +1,258 @@ + + + diff --git a/banners/mobile/C24_WMDE_Mobile_DE_08/components/FullPageBanner.vue b/banners/mobile/C24_WMDE_Mobile_DE_08/components/FullPageBanner.vue new file mode 100644 index 000000000..d75bb5b68 --- /dev/null +++ b/banners/mobile/C24_WMDE_Mobile_DE_08/components/FullPageBanner.vue @@ -0,0 +1,43 @@ + + + diff --git a/banners/mobile/C24_WMDE_Mobile_DE_08/components/MiniBanner.vue b/banners/mobile/C24_WMDE_Mobile_DE_08/components/MiniBanner.vue new file mode 100644 index 000000000..b8d3ea00a --- /dev/null +++ b/banners/mobile/C24_WMDE_Mobile_DE_08/components/MiniBanner.vue @@ -0,0 +1,37 @@ + + + diff --git a/banners/mobile/C24_WMDE_Mobile_DE_08/components/MiniBannerVar.vue b/banners/mobile/C24_WMDE_Mobile_DE_08/components/MiniBannerVar.vue new file mode 100644 index 000000000..836e5697a --- /dev/null +++ b/banners/mobile/C24_WMDE_Mobile_DE_08/components/MiniBannerVar.vue @@ -0,0 +1,46 @@ + + + diff --git a/banners/mobile/C24_WMDE_Mobile_DE_08/components/MinimisedBanner.vue b/banners/mobile/C24_WMDE_Mobile_DE_08/components/MinimisedBanner.vue new file mode 100644 index 000000000..7678ce7c6 --- /dev/null +++ b/banners/mobile/C24_WMDE_Mobile_DE_08/components/MinimisedBanner.vue @@ -0,0 +1,32 @@ + + + diff --git a/banners/mobile/C24_WMDE_Mobile_DE_08/content/BannerSlides.vue b/banners/mobile/C24_WMDE_Mobile_DE_08/content/BannerSlides.vue new file mode 100644 index 000000000..d15aac265 --- /dev/null +++ b/banners/mobile/C24_WMDE_Mobile_DE_08/content/BannerSlides.vue @@ -0,0 +1,75 @@ + + + diff --git a/banners/mobile/C24_WMDE_Mobile_DE_08/content/BannerText.vue b/banners/mobile/C24_WMDE_Mobile_DE_08/content/BannerText.vue new file mode 100644 index 000000000..99e10fa75 --- /dev/null +++ b/banners/mobile/C24_WMDE_Mobile_DE_08/content/BannerText.vue @@ -0,0 +1,52 @@ + + + diff --git a/banners/mobile/C24_WMDE_Mobile_DE_08/event_map.ts b/banners/mobile/C24_WMDE_Mobile_DE_08/event_map.ts new file mode 100644 index 000000000..d7a00a5dd --- /dev/null +++ b/banners/mobile/C24_WMDE_Mobile_DE_08/event_map.ts @@ -0,0 +1,33 @@ +import { TrackingEventConverterFactory } from '@src/tracking/LegacyTrackerWPORG'; +import { WMDELegacyBannerEvent } from '@src/tracking/WPORG/WMDELegacyBannerEvent'; +import { MobileMiniBannerExpandedEvent } from '@src/tracking/events/MobileMiniBannerExpandedEvent'; +import { FormStepShownEvent } from '@src/tracking/events/FormStepShownEvent'; +import { mapFormStepShownEvent } from '@src/tracking/LegacyEventTracking/mapFormStepShownEvent'; +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 { BannerSubmitOnReturnEvent } from '@src/tracking/events/BannerSubmitOnReturnEvent'; + +export default new Map( [ + [ CloseEvent.EVENT_NAME, mapCloseEvent ], + [ MobileMiniBannerExpandedEvent.EVENT_NAME, + ( e: MobileMiniBannerExpandedEvent ): WMDELegacyBannerEvent => new WMDELegacyBannerEvent( e.eventName + ( e.userChoice !== '' ? `-${e.userChoice}` : '' ), 1 ) ], + [ FormStepShownEvent.EVENT_NAME, mapFormStepShownEvent ], + [ NotShownEvent.EVENT_NAME, mapNotShownEvent ], + + [ BannerSubmitEvent.EVENT_NAME, ( e: BannerSubmitEvent ): WMDESizeIssueEvent => { + switch ( e.feature ) { + case 'MiniBanner': + case 'UpgradeToYearlyForm': + return new WMDESizeIssueEvent( `submit-${e.userChoice}`, createViewportInfo(), 1 ); + default: + return new WMDESizeIssueEvent( `submit`, createViewportInfo(), 1 ); + } + } ], + [ BannerSubmitOnReturnEvent.EVENT_NAME, + ( e: BannerSubmitOnReturnEvent ): WMDELegacyBannerEvent => new WMDELegacyBannerEvent( e.eventName + ( e.userChoice !== '' ? `-${e.userChoice}` : '' ), 1 ) ] +] ); diff --git a/banners/mobile/C24_WMDE_Mobile_DE_08/event_map_var.ts b/banners/mobile/C24_WMDE_Mobile_DE_08/event_map_var.ts new file mode 100644 index 000000000..eb3a36efe --- /dev/null +++ b/banners/mobile/C24_WMDE_Mobile_DE_08/event_map_var.ts @@ -0,0 +1,36 @@ +import { TrackingEventConverterFactory } from '@src/tracking/LegacyTrackerWPORG'; +import { WMDELegacyBannerEvent } from '@src/tracking/WPORG/WMDELegacyBannerEvent'; +import { MobileMiniBannerExpandedEvent } from '@src/tracking/events/MobileMiniBannerExpandedEvent'; +import { FormStepShownEvent } from '@src/tracking/events/FormStepShownEvent'; +import { mapFormStepShownEvent } from '@src/tracking/LegacyEventTracking/mapFormStepShownEvent'; +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 { BannerSubmitOnReturnEvent } from '@src/tracking/events/BannerSubmitOnReturnEvent'; +import { MinimisedEvent } from '@src/tracking/events/MinimisedEvent'; + +export default new Map( [ + [ CloseEvent.EVENT_NAME, mapCloseEvent ], + [ MobileMiniBannerExpandedEvent.EVENT_NAME, + ( e: MobileMiniBannerExpandedEvent ): WMDELegacyBannerEvent => new WMDELegacyBannerEvent( e.eventName + ( e.userChoice !== '' ? `-${e.userChoice}` : '' ), 1 ) ], + [ FormStepShownEvent.EVENT_NAME, mapFormStepShownEvent ], + [ NotShownEvent.EVENT_NAME, mapNotShownEvent ], + + [ BannerSubmitEvent.EVENT_NAME, ( e: BannerSubmitEvent ): WMDESizeIssueEvent => { + switch ( e.feature ) { + case 'MiniBanner': + case 'UpgradeToYearlyForm': + return new WMDESizeIssueEvent( `submit-${e.userChoice}`, createViewportInfo(), 1 ); + default: + return new WMDESizeIssueEvent( `submit`, createViewportInfo(), 1 ); + } + } ], + [ BannerSubmitOnReturnEvent.EVENT_NAME, + ( e: BannerSubmitOnReturnEvent ): WMDELegacyBannerEvent => new WMDELegacyBannerEvent( e.eventName + ( e.userChoice !== '' ? `-${e.userChoice}` : '' ), 1 ) ], + [ MinimisedEvent.EVENT_NAME, + ( e: MinimisedEvent ): WMDELegacyBannerEvent => new WMDELegacyBannerEvent( e.eventName + `-${ e.feature }-${ e.userChoice }`, 1 ) ] +] ); diff --git a/banners/mobile/C24_WMDE_Mobile_DE_08/form_items.ts b/banners/mobile/C24_WMDE_Mobile_DE_08/form_items.ts new file mode 100644 index 000000000..53c204d06 --- /dev/null +++ b/banners/mobile/C24_WMDE_Mobile_DE_08/form_items.ts @@ -0,0 +1,23 @@ +import FormItemsBuilder from '@src/utils/FormItemsBuilder/FormItemsBuilder'; +import { Translator } from '@src/Translator'; +import { DonationFormItems } from '@src/utils/FormItemsBuilder/DonationFormItems'; +import { Intervals } from '@src/utils/FormItemsBuilder/fields/Intervals'; +import { PaymentMethods } from '@src/utils/FormItemsBuilder/fields/PaymentMethods'; +import { NumberFormatter } from '@src/utils/DynamicContent/formatters/NumberFormatter'; + +export function createFormItems( translations: Translator, amountFormatter: NumberFormatter ): DonationFormItems { + return new FormItemsBuilder( translations, amountFormatter ) + .setIntervals( + Intervals.ONCE, + Intervals.MONTHLY, + Intervals.YEARLY + ) + .setAmounts( 10, 15, 25, 50, 100 ) + .setPaymentMethods( + PaymentMethods.PAYPAL, + PaymentMethods.DIRECT_DEBIT, + PaymentMethods.BANK_TRANSFER, + PaymentMethods.CREDIT_CARD, + PaymentMethods.SOFORT + ).getItems(); +} diff --git a/banners/mobile/C24_WMDE_Mobile_DE_08/messages.ts b/banners/mobile/C24_WMDE_Mobile_DE_08/messages.ts new file mode 100644 index 000000000..930f9b38f --- /dev/null +++ b/banners/mobile/C24_WMDE_Mobile_DE_08/messages.ts @@ -0,0 +1,30 @@ +import DynamicCampaignTextDe from '@src/utils/DynamicContent/messages/DynamicCampaignText.de'; +import { TranslationMessages } from '@src/Translator'; +import UpgradeToYearlyDe from '@src/components/DonationForm/Forms/messages/UpgradeToYearly.de'; +import FooterDe from '@src/components/Footer/messages/Footer.de'; +import MainDonationFormDe from '@src/components/DonationForm/Forms/messages/MainDonationForm.de'; +import SoftCloseDe from '@src/components/SoftClose/messages/SoftClose.de'; + +const messages: TranslationMessages = { + ...DynamicCampaignTextDe, + ...FooterDe, + ...MainDonationFormDe, + ...UpgradeToYearlyDe, + ...SoftCloseDe, + + // custom messages here + 'use-of-funds-link': 'Was Ihre Spende bewirkt', + 'payment-bank-transfer': 'Überweisung', + 'payment-sofort': 'Sofort', + 'upgrade-to-yearly-copy': '

Jedes Jahr sind wir auf Menschen wie Sie angewiesen. Jährliche Spenden helfen uns' + + ' besonders und ermöglichen langfristige Weiterentwicklungen.

' + + '

Sie gehen kein Risiko ein: Jederzeit formlos zu sofort kündbar.

', + 'upgrade-to-yearly-no': 'Nein, ich spende einmalig {{amount}}', + 'upgrade-to-yearly-yes': 'Ja, ich spende {{amount}} jährlich', + 'campaign-day-only-n-days': 'Heute sind es nur noch {{days}} Tage bis zum Ende unserer Spendenkampagne.', + 'soft-close-prompt': 'Wikipedia später unterstützen?', + 'soft-close-button-already-donated': 'Habe schon gespendet', + 'amount-total': '' +}; + +export default messages; diff --git a/banners/mobile/C24_WMDE_Mobile_DE_08/styles/Banner.scss b/banners/mobile/C24_WMDE_Mobile_DE_08/styles/Banner.scss new file mode 100644 index 000000000..ef5ca15ed --- /dev/null +++ b/banners/mobile/C24_WMDE_Mobile_DE_08/styles/Banner.scss @@ -0,0 +1,56 @@ +@use 'src/themes/Mikings/variables/globals'; +@use 'src/themes/Mikings/variables/fonts'; + +@keyframes hide-mini { + 0% { + opacity: 1; + } + 99% { + opacity: 0; + } + 100% { + display: none; + } +} + +.wmde-banner { + + &-full { + visibility: hidden; + opacity: 0; + transform: scale( 1.1 ); + transition: opacity 500ms globals.$banner-easing, transform 500ms globals.$banner-easing; + } + + &-wrapper { + font-size: 16px; + font-family: fonts.$ui; + box-shadow: 0 3px 0.6em rgba( 60 60 60 / 40% ); + background-color: var( --main-background ); + color: var( --main-color ); + + &--full-page { + .wmde-banner-mini { + animation: hide-mini 500ms; + } + .wmde-banner-full { + visibility: visible; + opacity: 1; + transform: scale( 1 ); + } + } + + &--soft-closing { + .wmde-banner-mini { + display: none; + } + } + } + + &--closed, + &--not-shown { + .wmde-banner-wrapper { + display: none; + } + } +} diff --git a/banners/mobile/C24_WMDE_Mobile_DE_08/styles/BannerVar.scss b/banners/mobile/C24_WMDE_Mobile_DE_08/styles/BannerVar.scss new file mode 100644 index 000000000..28fd32cb1 --- /dev/null +++ b/banners/mobile/C24_WMDE_Mobile_DE_08/styles/BannerVar.scss @@ -0,0 +1,108 @@ +@use 'src/themes/Mikings/variables/globals'; +@use 'src/themes/Mikings/variables/fonts'; + +$transition-easing: cubic-bezier( 0.555, 0.155, 0.14, 0.945 ) !default; + +@keyframes hide-mini { + 0% { + opacity: 1; + } + 99% { + opacity: 0; + } + 100% { + display: none; + } +} + +/** + * This is for adding a padding to the Minerva navigation that we show the minimise/maximise tab over + */ +body.wmde-show-banner { + .header-container.header-chrome { + padding-top: 16px; + transition: padding-top $transition-easing var( --wmde-banner-transition-duration ); + } + + .minerva-header { + border-top: 0; + } + + .wmde-banner-mini-inner, + .wmde-banner-minimised-inner { + box-shadow: var( --mini-box-shadow ); + } + + .wmde-banner-mini-minimise, + .wmde-banner-minimised-maximise { + height: 0; + } +} + +.wmde-banner { + + &-full { + visibility: hidden; + opacity: 0; + transform: scale( 1.1 ); + transition: opacity 500ms globals.$banner-easing, transform 500ms globals.$banner-easing; + } + + &-wrapper { + font-size: 16px; + font-family: fonts.$ui; + color: var( --main-color ); + + &--mini { + .wmde-banner-minimised { + display: none; + } + } + + &--minimised { + .wmde-banner-mini { + display: none; + } + } + + &--full-page { + &.wmde-banner-opened-from-mini { + .wmde-banner-mini { + animation: hide-mini 500ms; + } + .wmde-banner-minimised { + display: none; + } + } + &.wmde-banner-opened-from-minimised { + .wmde-banner-mini { + display: none; + } + .wmde-banner-minimised { + animation: hide-mini 500ms; + } + } + .wmde-banner-full { + visibility: visible; + opacity: 1; + transform: scale( 1 ); + } + } + + &--soft-closing { + .wmde-banner-minimised { + display: none; + } + .wmde-banner-mini { + display: none; + } + } + } + + &--closed, + &--not-shown { + .wmde-banner-wrapper { + display: none; + } + } +} diff --git a/banners/mobile/C24_WMDE_Mobile_DE_08/styles/FullPageBanner.scss b/banners/mobile/C24_WMDE_Mobile_DE_08/styles/FullPageBanner.scss new file mode 100644 index 000000000..266b1a19f --- /dev/null +++ b/banners/mobile/C24_WMDE_Mobile_DE_08/styles/FullPageBanner.scss @@ -0,0 +1,99 @@ +@use '@src/themes/Mikings/variables/globals'; +@use '@src/themes/Mikings/variables/breakpoints'; + +.wmde-banner { + &-full { + border: 2px solid var( --full-border ); + background: var( --full-background ); + position: fixed; + top: 0; + z-index: 1000; + height: 100vh; + width: 100vw; + + &-content { + overflow-y: auto; + height: 100%; + width: 100%; + } + + p { + padding-bottom: 16px; + } + + &-close { + position: absolute; + top: 16px; + right: 16px; + height: 35px; + width: 35px; + padding: 5px; + background: var( --full-background ); + z-index: 99; + border: none; + border-radius: 50%; + + &:hover { + cursor: pointer; + } + + .close-button { + text-decoration: underline; + } + } + + &-info { + padding: 16px; + } + + &-call-to-action { + position: relative; + color: var( --full-cta-color ); + background: var( --full-cta-background ); + font-weight: bold; + height: 31px; + line-height: 31px; + text-align: center; + + &-optional-text { + display: none; + + @include breakpoints.tablet-portrait-up { + display: inline; + } + } + + &::after { + content: ''; + position: absolute; + bottom: -4px; + left: 50%; + margin-left: -4px; + width: 0; + height: 0; + border-style: solid; + border-width: 5px 4px 0; + border-color: var( --full-cta-background ) transparent transparent transparent; + } + } + + .banner-text-title { + margin-right: 30px; + } + + &-small-print { + text-align: center; + font-size: 12px; + margin-bottom: 16px; + + a { + color: var( --full-smallprint-color ); + + &:hover, + &:focus { + text-decoration: underline; + } + } + } + } +} diff --git a/banners/mobile/C24_WMDE_Mobile_DE_08/styles/MiniBanner.scss b/banners/mobile/C24_WMDE_Mobile_DE_08/styles/MiniBanner.scss new file mode 100644 index 000000000..2bd2f4059 --- /dev/null +++ b/banners/mobile/C24_WMDE_Mobile_DE_08/styles/MiniBanner.scss @@ -0,0 +1,157 @@ +@use '@src/themes/Mikings/variables/globals'; + +$height: 288px !default; + +.wmde-banner { + &-mini { + display: flex; + flex-direction: column; + min-height: $height; + padding: 16px 0; + position: relative; + border: 2px solid var( --mini-border ); + background: var( --mini-background ); + + &-close { + position: absolute; + height: 36px; + width: 36px; + top: 11px; + right: 16px; + text-align: center; + background: var( --mini-close-background ); + padding: 10px; + z-index: 2; + + &-button { + border: none; + margin-top: auto; + float: right; + height: 16px; + line-height: 16px; + width: 16px; + background: var( --mini-close-background ); + z-index: 2; + + svg { + height: 16px; + width: 16px; + } + + &:hover { + cursor: pointer; + } + } + } + + &-headline { + height: 25px; + text-align: center; + margin: 0 16px 16px; + + &-background { + position: relative; + text-align: left; + + @media ( min-width: 400px ) { + text-align: center; + } + + /* single line above container */ + &::before { + content: ''; + display: block; + background: var( --mini-headline-line ); + width: 100%; + height: 1px; + position: absolute; + top: 50%; + z-index: 1; + } + } + + &-content { + position: relative; + display: inline-block; + font-weight: bold; + font-size: 14px; + line-height: 25px; + color: var( --mini-headline-color ); + background: var( --mini-headline-background ); + padding: 0 5px; + z-index: 2; + white-space: nowrap; + + @media ( min-width: 330px ) { + font-size: 16px; + } + + @media ( min-width: 360px ) { + font-size: 18px; + } + } + } + + &-slideshow { + display: flex; + flex-direction: column; + flex: 1 1 auto; + } + + &-button-group { + display: flex; + justify-content: center; + } + + &-button, + &-button-preselect { + width: 50%; + height: 40px; + border: none; + border-radius: 20px; + font-weight: bold; + color: var( --mini-button-color ); + margin: 0 16px; + font-size: 14px; + white-space: nowrap; + + @media ( min-width: 370px ) { + font-size: 16px; + } + } + + &-button { + background: var( --mini-button-background ); + + &:hover, + &:focus { + background: var( --mini-button-background-hover ); + } + } + + &-button-preselect { + background: var( --mini-button-alt-background ); + + &:hover, + &:focus { + background: var( --mini-button-alt-background-hover ); + } + } + + .smallprint-mini { + text-align: center; + font-size: 11px; + margin-top: 12px; + margin-bottom: -5px; + + a { + color: var( --mini-smallprint-color ); + + &:hover, + &:focus { + text-decoration: underline; + } + } + } + } +} diff --git a/banners/mobile/C24_WMDE_Mobile_DE_08/styles/MiniBannerVar.scss b/banners/mobile/C24_WMDE_Mobile_DE_08/styles/MiniBannerVar.scss new file mode 100644 index 000000000..f1f797885 --- /dev/null +++ b/banners/mobile/C24_WMDE_Mobile_DE_08/styles/MiniBannerVar.scss @@ -0,0 +1,196 @@ +@use '@src/themes/Mikings/variables/globals'; + +$height: 288px !default; +$transition-easing: cubic-bezier( 0.555, 0.155, 0.14, 0.945 ) !default; + +.wmde-banner { + + &-mini { + display: flex; + flex-direction: column; + min-height: $height; + + &-inner { + flex: 1 0 auto; + display: flex; + flex-direction: column; + padding: 16px 0 18px; + position: relative; + border: 2px solid var( --mini-border ); + background: var( --mini-background ); + height: auto; + box-shadow: none; + } + + &-minimise { + height: 16px; + display: flex; + justify-content: center; + transition: height $transition-easing var( --wmde-banner-transition-duration ); + + &-tab { + height: 16px; + border: 2px solid var( --mini-border ); + border-top: none; + border-radius: 0 0 3px 3px; + box-shadow: var( --mini-box-shadow ); + } + + &-button { + border: none; + border-radius: 2px; + background: var( --mini-background ); + color: var( --minimise-color ); + position: relative; + height: 32px; + top: -18px; + cursor: pointer; + font-size: 14px; + font-weight: bold; + width: 175px; + } + } + + &-close { + position: absolute; + height: 36px; + width: 36px; + top: 11px; + right: 16px; + text-align: center; + background: var( --mini-close-background ); + padding: 10px; + z-index: 2; + + &-button { + border: none; + margin-top: auto; + float: right; + height: 16px; + line-height: 16px; + width: 16px; + background: var( --mini-close-background ); + z-index: 2; + + svg { + height: 16px; + width: 16px; + } + + &:hover { + cursor: pointer; + } + } + } + + &-headline { + height: 25px; + text-align: center; + margin: 0 16px 16px; + + &-background { + position: relative; + text-align: left; + + @media ( min-width: 400px ) { + text-align: center; + } + + /* single line above container */ + &::before { + content: ''; + display: block; + background: var( --mini-headline-line ); + width: 100%; + height: 1px; + position: absolute; + top: 50%; + z-index: 1; + } + } + + &-content { + position: relative; + display: inline-block; + font-weight: bold; + font-size: 14px; + line-height: 25px; + color: var( --mini-headline-color ); + background: var( --mini-headline-background ); + padding: 0 5px; + z-index: 2; + white-space: nowrap; + + @media ( min-width: 330px ) { + font-size: 16px; + } + + @media ( min-width: 360px ) { + font-size: 18px; + } + } + } + + &-slideshow { + display: flex; + flex-direction: column; + flex: 1 1 auto; + } + + &-button-group { + display: flex; + justify-content: center; + } + + &-button, + &-button-preselect { + width: 50%; + height: 40px; + border: none; + border-radius: 20px; + font-weight: bold; + color: var( --mini-button-color ); + margin: 0 16px; + font-size: 14px; + white-space: nowrap; + + @media ( min-width: 370px ) { + font-size: 16px; + } + } + + &-button { + background: var( --mini-button-background ); + + &:hover, + &:focus { + background: var( --mini-button-background-hover ); + } + } + + &-button-preselect { + background: var( --mini-button-alt-background ); + + &:hover, + &:focus { + background: var( --mini-button-alt-background-hover ); + } + } + + .smallprint-mini { + text-align: center; + font-size: 11px; + margin-top: 12px; + margin-bottom: -5px; + + a { + color: var( --mini-smallprint-color ); + + &:hover, + &:focus { + text-decoration: underline; + } + } + } + } +} diff --git a/banners/mobile/C24_WMDE_Mobile_DE_08/styles/MinimisedBanner.scss b/banners/mobile/C24_WMDE_Mobile_DE_08/styles/MinimisedBanner.scss new file mode 100644 index 000000000..71c9abf8d --- /dev/null +++ b/banners/mobile/C24_WMDE_Mobile_DE_08/styles/MinimisedBanner.scss @@ -0,0 +1,96 @@ +$transition-easing: cubic-bezier( 0.555, 0.155, 0.14, 0.945 ) !default; + +.wmde-banner { + &-minimised { + + height: 82px; + + &-inner { + flex: 1 0 auto; + display: flex; + flex-direction: column; + padding: 16px 0 18px; + position: relative; + border: 2px solid var( --mini-border ); + background: var( --mini-background ); + height: auto; + box-shadow: none; + } + + &-headline, + &-content { + padding: 0 16px; + margin-right: 26px; + } + + &-headline { + font-weight: bold; + } + + &-highlighted-text { + background: var( --minimise-text-highlight-background ); + font-weight: bold; + } + + &-close { + position: absolute; + height: 36px; + width: 36px; + top: 2px; + right: 6px; + text-align: center; + background: var( --mini-close-background ); + padding: 10px; + z-index: 2; + + &-button { + border: none; + margin-top: auto; + float: right; + height: 16px; + line-height: 16px; + width: 16px; + background: var( --mini-close-background ); + z-index: 2; + + svg { + height: 16px; + width: 16px; + } + + &:hover { + cursor: pointer; + } + } + } + + &-maximise { + height: 16px; + display: flex; + justify-content: center; + transition: height $transition-easing var( --wmde-banner-transition-duration ); + + &-tab { + height: 16px; + border: 2px solid var( --mini-border ); + border-top: none; + border-radius: 0 0 3px 3px; + box-shadow: var( --mini-box-shadow ); + } + + &-button { + border: none; + border-radius: 2px; + background: var( --mini-background ); + color: var( --minimise-color ); + position: relative; + height: 32px; + top: -18px; + cursor: pointer; + font-size: 14px; + font-weight: bold; + width: 175px; + } + } + } +} diff --git a/banners/mobile/C24_WMDE_Mobile_DE_08/styles/styles.scss b/banners/mobile/C24_WMDE_Mobile_DE_08/styles/styles.scss new file mode 100644 index 000000000..5b391ba5c --- /dev/null +++ b/banners/mobile/C24_WMDE_Mobile_DE_08/styles/styles.scss @@ -0,0 +1,29 @@ +@use 'src/themes/Mikings/swatches/skin_default' with ( + $upgrade-to-yearly-button-form: true, + $progress-bar: true, + $soft-close: true, + $thank-you-box: true +); +@use 'src/components/BannerConductor/banner-transition'; +@use 'src/themes/UseOfFunds/swatches/skin_default' as uof-default; +@use 'src/themes/UseOfFunds/UseOfFunds'; +@use 'src/themes/Mikings/defaults'; +@use './Banner'; +@use './MiniBanner' with ( + $height: 336px +); +@use './FullPageBanner'; +@use 'src/themes/Mikings/Footer/Footer'; +@use 'src/themes/Mikings/ThankYouBox/ThankYouBox'; +@use 'src/themes/Mikings/Footer/SelectionInput'; +@use 'src/themes/Mikings/DonationForm/MultiStepDonation'; +@use 'src/themes/Mikings/DonationForm/Forms/UpgradeToYearlyButtonForm'; +@use 'src/themes/Mikings/DonationForm/SubComponents/SelectGroup'; +@use 'src/themes/Mikings/DonationForm/SubComponents/SelectCustomAmount'; +@use 'src/themes/Mikings/DonationForm/SubComponents/SmsBox'; +@use 'src/themes/Mikings/Slider/Slider' with ( + $pagination-padding: 10px, + $pagination-height: 40px +); +@use 'src/themes/Mikings/SoftClose/SoftClose'; +@use 'src/themes/Mikings/ProgressBar/ProgressBar'; diff --git a/banners/mobile/C24_WMDE_Mobile_DE_08/styles/styles_var.scss b/banners/mobile/C24_WMDE_Mobile_DE_08/styles/styles_var.scss new file mode 100644 index 000000000..4b1977063 --- /dev/null +++ b/banners/mobile/C24_WMDE_Mobile_DE_08/styles/styles_var.scss @@ -0,0 +1,30 @@ +@use 'src/themes/Mikings/swatches/skin_default' with ( + $upgrade-to-yearly-button-form: true, + $progress-bar: true, + $soft-close: true, + $thank-you-box: true +); +@use 'src/components/BannerConductor/banner-transition'; +@use 'src/themes/UseOfFunds/swatches/skin_default' as uof-default; +@use 'src/themes/UseOfFunds/UseOfFunds'; +@use 'src/themes/Mikings/defaults'; +@use './BannerVar'; +@use './MiniBannerVar' with ( + $height: 336px +); +@use './FullPageBanner'; +@use './MinimisedBanner'; +@use 'src/themes/Mikings/Footer/Footer'; +@use 'src/themes/Mikings/ThankYouBox/ThankYouBox'; +@use 'src/themes/Mikings/Footer/SelectionInput'; +@use 'src/themes/Mikings/DonationForm/MultiStepDonation'; +@use 'src/themes/Mikings/DonationForm/Forms/UpgradeToYearlyButtonForm'; +@use 'src/themes/Mikings/DonationForm/SubComponents/SelectGroup'; +@use 'src/themes/Mikings/DonationForm/SubComponents/SelectCustomAmount'; +@use 'src/themes/Mikings/DonationForm/SubComponents/SmsBox'; +@use 'src/themes/Mikings/Slider/Slider' with ( + $pagination-padding: 10px, + $pagination-height: 40px +); +@use 'src/themes/Mikings/SoftClose/SoftClose'; +@use 'src/themes/Mikings/ProgressBar/ProgressBar'; diff --git a/campaign_info.toml b/campaign_info.toml index eb69072dd..2fd91a97c 100644 --- a/campaign_info.toml +++ b/campaign_info.toml @@ -34,9 +34,9 @@ resolution = ["800x600", "1024x768", "1280x960", "1600x1200", "1920x1200", "2560 [mobile] name = "Mobile" icon = "mobile" -campaign = "C24_WMDE_Mobile_DE_07" -description = "Based on VAR of C24_WMDE_Mobile_DE_06, VAR has a minimisable mini banner." -campaign_tracking = "mob-de-07-ba-241105" +campaign = "C24_WMDE_Mobile_DE_08" +description = "Based on CTRL of C24_WMDE_Mobile_DE_07, VAR has different copy." +campaign_tracking = "mob-de-08-ba-241112" preview_link = "/mobile/wiki/Wikipedia:Hauptseite?devbanner={{banner}}&banner=B22_WMDE_local_prototype&useskin=minerva" preview_link_darkmode = "/mobile/wiki/Wikipedia:Hauptseite?devbanner={{banner}}&banner=B22_WMDE_local_prototype&useskin=minerva&minervanightmode=1" preview_url = 'https://de.m.wikipedia.org/wiki/Wikipedia:Hauptseite?banner={{banner}}&useskin=minerva&devMode' @@ -45,14 +45,14 @@ use_of_funds_source = "MediaWiki:WMDE_Fundraising/UseOfFunds_2024_DE" # Banners of the campaign, key after "banners" can be anything [mobile.banners.ctrl] -filename = "./banners/mobile/C24_WMDE_Mobile_DE_07/banner_ctrl.ts" -pagename = "B24_WMDE_Mobile_DE_07_ctrl" -tracking = "org-mob07-241105-ctrl" +filename = "./banners/mobile/C24_WMDE_Mobile_DE_08/banner_ctrl.ts" +pagename = "B24_WMDE_Mobile_DE_08_ctrl" +tracking = "org-mob08-241112-ctrl" [mobile.banners.var] -filename = "./banners/mobile/C24_WMDE_Mobile_DE_07/banner_var.ts" -pagename = "B24_WMDE_Mobile_DE_07_var" -tracking = "org-mob07-241105-var" +filename = "./banners/mobile/C24_WMDE_Mobile_DE_08/banner_var.ts" +pagename = "B24_WMDE_Mobile_DE_08_var" +tracking = "org-mob08-241112-var" [mobile.test_matrix] device = [ 'samsung_s10', 'iphone_xs_max', 'iphone_5s', 'iphone_se', "iphone_8", "iphone_12_mini", "iphone_7_plus", "iphone_11_pro_max"] diff --git a/test/banners/mobile/C24_WMDE_Mobile_DE_08/components/BannerCtrl.spec.ts b/test/banners/mobile/C24_WMDE_Mobile_DE_08/components/BannerCtrl.spec.ts new file mode 100644 index 000000000..cf255b86d --- /dev/null +++ b/test/banners/mobile/C24_WMDE_Mobile_DE_08/components/BannerCtrl.spec.ts @@ -0,0 +1,181 @@ +import { afterEach, beforeEach, describe, test, vi } from 'vitest'; +import { mount, VueWrapper } from '@vue/test-utils'; +import Banner from '@banners/mobile/C24_WMDE_Mobile_DE_08/components/BannerCtrl.vue'; +import { BannerStates } from '@src/components/BannerConductor/StateMachine/BannerStates'; +import { PageScroller } from '@src/utils/PageScroller/PageScroller'; +import { useOfFundsContent } from '@test/banners/useOfFundsContent'; +import { newDynamicContent } from '@test/banners/dynamicCampaignContent'; +import { CurrencyEn } from '@src/utils/DynamicContent/formatters/CurrencyEn'; +import { formItems } from '@test/banners/formItems'; +import { softCloseFeatures } from '@test/features/SoftCloseMobile'; +import { useOfFundsFeatures, useOfFundsScrollFeatures } from '@test/features/UseOfFunds'; +import { miniBannerFeatures } from '@test/features/MiniBanner'; +import { donationFormFeatures } from '@test/features/forms/MainDonation_UpgradeToYearlyButton'; +import { useFormModel } from '@src/components/composables/useFormModel'; +import { resetFormModel } from '@test/resetFormModel'; +import { DynamicContent } from '@src/utils/DynamicContent/DynamicContent'; +import { fullPageBannerFeatures } from '@test/features/FullPageBanner'; +import { formActionSwitchFeatures } from '@test/features/form_action_switch/MainDonation_UpgradeToYearlyButton'; +import { Tracker } from '@src/tracking/Tracker'; +import { bannerContentAnimatedTextFeatures, bannerContentDateAndTimeFeatures } from '@test/features/BannerContent'; +import { softCloseSubmitTrackingFeatures } from '@test/features/SoftCloseSubmitTracking'; + +let pageScroller: PageScroller; +let tracker: Tracker; +const formModel = useFormModel(); +const translator = ( key: string ): string => key; +describe( 'BannerCtrl.vue', () => { + + let wrapper: VueWrapper; + beforeEach( () => { + resetFormModel( formModel ); + vi.useFakeTimers(); + + pageScroller = { + scrollIntoView: vi.fn(), + scrollToTop: vi.fn() + }; + + tracker = { + trackEvent: vi.fn() + }; + } ); + + const getWrapper = ( dynamicContent: DynamicContent = null ): VueWrapper => { + // attachTo the document body to fix an issue with Vue Test Utils where + // clicking a submit button in a form does not fire the submit event + wrapper = mount( Banner, { + attachTo: document.body, + props: { + bannerState: BannerStates.Pending, + useOfFundsContent, + pageScroller, + remainingImpressions: 10, + localCloseTracker: { + getItem: () => '', + setItem: () => {} + } + }, + global: { + mocks: { + $translate: translator + }, + provide: { + translator: { translate: translator }, + dynamicCampaignText: dynamicContent ?? newDynamicContent(), + formActions: { donateWithAddressAction: 'https://example.com/with-address', donateAnonymouslyAction: 'https://example.com/without-address' }, + currencyFormatter: new CurrencyEn(), + formItems, + tracker + } + } + } ); + + return wrapper; + }; + + afterEach( () => { + wrapper.unmount(); + vi.restoreAllMocks(); + vi.useRealTimers(); + } ); + + describe( 'Content', () => { + test.each( [ + [ 'expectShowsAnimatedVisitorsVsDonorsSentenceInMessage' ], + [ 'expectShowsAnimatedVisitorsVsDonorsSentenceInSlideShow' ], + [ 'expectHidesAnimatedVisitorsVsDonorsSentenceInMessage' ], + [ 'expectHidesAnimatedVisitorsVsDonorsSentenceInSlideShow' ] + ] )( '%s', async ( testName: string ) => { + await bannerContentAnimatedTextFeatures[ testName ]( getWrapper ); + } ); + + test.each( [ + [ 'expectShowsLiveDateAndTimeInMiniBanner' ], + [ 'expectShowsLiveDateAndTimeInFullPageBanner' ] + ] )( '%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() ); + } ); + + test.each( [ + [ 'expectMainDonationFormSubmitsWithAddressForDirectDebit' ], + [ 'expectUpgradeToYearlyFormSubmitsWithAddressForDirectDebit' ] + ] )( '%s', async ( testName: string ) => { + await formActionSwitchFeatures[ testName ]( getWrapper() ); + } ); + } ); + + describe( 'Soft Close', () => { + test.each( [ + [ 'expectShowsSoftCloseOnMiniBannerClose' ], + [ 'expectDoesNotShowSoftCloseOnFullBannerClose' ], + [ 'expectEmitsSoftCloseCloseEvent' ], + [ 'expectEmitsSoftCloseMaybeLaterEvent' ], + [ 'expectEmitsSoftCloseAlreadyDonatedEvent' ], + [ 'expectEmitsSoftCloseTimeOutEvent' ], + [ 'expectEmitsBannerContentChangedOnSoftClose' ], + [ 'expectDoesNotShowSoftCloseOnFinalBannerImpression' ] + ] )( '%s', async ( testName: string ) => { + await softCloseFeatures[ testName ]( getWrapper() ); + } ); + } ); + + describe( 'Soft Close Submit Tracking', () => { + test.each( [ + [ 'expectStoresMaybeLateCloseChoice' ], + [ 'expectStoresCloseCloseChoice' ], + [ 'expectStoresAlreadyDonatedCloseChoice' ], + [ 'expectEmitsBannerSubmitOnReturnEvent' ], + [ 'expectDoesNotEmitsBannerSubmitOnReturnEventWhenLocalStorageItemIsMissing' ] + ] )( '%s', async ( testName: string ) => { + await softCloseSubmitTrackingFeatures[ testName ]( getWrapper(), tracker ); + } ); + } ); + + describe( 'Use of Funds', () => { + test.each( [ + [ 'expectShowsUseOfFunds' ], + [ 'expectHidesUseOfFunds' ] + ] )( '%s', async ( testName: string ) => { + await useOfFundsFeatures[ testName ]( getWrapper() ); + } ); + + test.each( [ + [ 'expectScrollsToFormWhenCallToActionIsClicked' ], + [ 'expectScrollsToLinkWhenCloseIsClicked' ] + ] )( '%s', async ( testName: string ) => { + await useOfFundsScrollFeatures[ testName ]( getWrapper(), pageScroller ); + } ); + } ); + + describe( 'Mini Banner', () => { + test.each( [ + [ 'expectSlideShowPlaysWhenMiniBannerBecomesVisible' ], + [ 'expectSlideShowStopsWhenFullBannerBecomesVisible' ], + [ 'expectShowsFullPageWhenCallToActionIsClicked' ], + [ 'expectEmitsBannerContentChangedEventWhenCallToActionIsClicked' ] + ] )( '%s', async ( testName: string ) => { + await miniBannerFeatures[ testName ]( getWrapper() ); + } ); + } ); + + describe( 'Full Page Banner', () => { + test.each( [ + [ 'expectEmitsCloseEvent' ] + ] )( '%s', async ( testName: string ) => { + await fullPageBannerFeatures[ testName ]( getWrapper() ); + } ); + } ); +} ); diff --git a/test/banners/mobile/C24_WMDE_Mobile_DE_08/components/BannerVar.spec.ts b/test/banners/mobile/C24_WMDE_Mobile_DE_08/components/BannerVar.spec.ts new file mode 100644 index 000000000..e3f0884e9 --- /dev/null +++ b/test/banners/mobile/C24_WMDE_Mobile_DE_08/components/BannerVar.spec.ts @@ -0,0 +1,192 @@ +import { afterEach, beforeEach, describe, test, vi } from 'vitest'; +import { mount, VueWrapper } from '@vue/test-utils'; +import Banner from '@banners/mobile/C24_WMDE_Mobile_DE_08/components/BannerVar.vue'; +import { BannerStates } from '@src/components/BannerConductor/StateMachine/BannerStates'; +import { PageScroller } from '@src/utils/PageScroller/PageScroller'; +import { useOfFundsContent } from '@test/banners/useOfFundsContent'; +import { newDynamicContent } from '@test/banners/dynamicCampaignContent'; +import { CurrencyEn } from '@src/utils/DynamicContent/formatters/CurrencyEn'; +import { formItems } from '@test/banners/formItems'; +import { softCloseFeatures } from '@test/features/SoftCloseMobile'; +import { useOfFundsFeatures, useOfFundsScrollFeatures } from '@test/features/UseOfFunds'; +import { miniBannerFeatures } from '@test/features/MiniBanner'; +import { donationFormFeatures } from '@test/features/forms/MainDonation_UpgradeToYearlyButton'; +import { useFormModel } from '@src/components/composables/useFormModel'; +import { resetFormModel } from '@test/resetFormModel'; +import { DynamicContent } from '@src/utils/DynamicContent/DynamicContent'; +import { fullPageBannerFeatures } from '@test/features/FullPageBanner'; +import { formActionSwitchFeatures } from '@test/features/form_action_switch/MainDonation_UpgradeToYearlyButton'; +import { Tracker } from '@src/tracking/Tracker'; +import { bannerContentAnimatedTextFeatures, bannerContentDateAndTimeFeatures } from '@test/features/BannerContent'; +import { softCloseSubmitTrackingFeatures } from '@test/features/SoftCloseSubmitTracking'; +import { minimisedBannerFeatures } from '@test/features/MinimisedBanner'; + +let pageScroller: PageScroller; +let tracker: Tracker; +const formModel = useFormModel(); +const translator = ( key: string ): string => key; +describe( 'BannerVar.vue', () => { + + let wrapper: VueWrapper; + beforeEach( () => { + resetFormModel( formModel ); + vi.useFakeTimers(); + + pageScroller = { + scrollIntoView: vi.fn(), + scrollToTop: vi.fn() + }; + + tracker = { + trackEvent: vi.fn() + }; + } ); + + const getWrapper = ( dynamicContent: DynamicContent = null ): VueWrapper => { + // attachTo the document body to fix an issue with Vue Test Utils where + // clicking a submit button in a form does not fire the submit event + wrapper = mount( Banner, { + attachTo: document.body, + props: { + bannerState: BannerStates.Pending, + useOfFundsContent, + pageScroller, + remainingImpressions: 10, + localCloseTracker: { + getItem: () => '', + setItem: () => {} + } + }, + global: { + mocks: { + $translate: translator + }, + provide: { + translator: { translate: translator }, + dynamicCampaignText: dynamicContent ?? newDynamicContent(), + formActions: { donateWithAddressAction: 'https://example.com/with-address', donateAnonymouslyAction: 'https://example.com/without-address' }, + currencyFormatter: new CurrencyEn(), + formItems, + tracker + } + } + } ); + + return wrapper; + }; + + afterEach( () => { + wrapper.unmount(); + vi.restoreAllMocks(); + vi.useRealTimers(); + } ); + + describe( 'Content', () => { + test.each( [ + [ 'expectShowsAnimatedVisitorsVsDonorsSentenceInMessage' ], + [ 'expectShowsAnimatedVisitorsVsDonorsSentenceInSlideShow' ], + [ 'expectHidesAnimatedVisitorsVsDonorsSentenceInMessage' ], + [ 'expectHidesAnimatedVisitorsVsDonorsSentenceInSlideShow' ] + ] )( '%s', async ( testName: string ) => { + await bannerContentAnimatedTextFeatures[ testName ]( getWrapper ); + } ); + + test.each( [ + [ 'expectShowsLiveDateAndTimeInMiniBanner' ] + // [ 'expectShowsLiveDateAndTimeInFullPageBanner' ] + ] )( '%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() ); + } ); + + test.each( [ + [ 'expectMainDonationFormSubmitsWithAddressForDirectDebit' ], + [ 'expectUpgradeToYearlyFormSubmitsWithAddressForDirectDebit' ] + ] )( '%s', async ( testName: string ) => { + await formActionSwitchFeatures[ testName ]( getWrapper() ); + } ); + } ); + + describe( 'Soft Close', () => { + test.each( [ + [ 'expectShowsSoftCloseOnMiniBannerClose' ], + [ 'expectDoesNotShowSoftCloseOnFullBannerClose' ], + [ 'expectEmitsSoftCloseCloseEvent' ], + [ 'expectEmitsSoftCloseMaybeLaterEvent' ], + [ 'expectEmitsSoftCloseAlreadyDonatedEvent' ], + [ 'expectEmitsSoftCloseTimeOutEvent' ], + [ 'expectEmitsBannerContentChangedOnSoftClose' ], + [ 'expectDoesNotShowSoftCloseOnFinalBannerImpression' ] + ] )( '%s', async ( testName: string ) => { + await softCloseFeatures[ testName ]( getWrapper() ); + } ); + } ); + + describe( 'Soft Close Submit Tracking', () => { + test.each( [ + [ 'expectStoresMaybeLateCloseChoice' ], + [ 'expectStoresCloseCloseChoice' ], + [ 'expectStoresAlreadyDonatedCloseChoice' ], + [ 'expectEmitsBannerSubmitOnReturnEvent' ], + [ 'expectDoesNotEmitsBannerSubmitOnReturnEventWhenLocalStorageItemIsMissing' ] + ] )( '%s', async ( testName: string ) => { + await softCloseSubmitTrackingFeatures[ testName ]( getWrapper(), tracker ); + } ); + } ); + + describe( 'Use of Funds', () => { + test.each( [ + [ 'expectShowsUseOfFunds' ], + [ 'expectHidesUseOfFunds' ] + ] )( '%s', async ( testName: string ) => { + await useOfFundsFeatures[ testName ]( getWrapper() ); + } ); + + test.each( [ + [ 'expectScrollsToFormWhenCallToActionIsClicked' ], + [ 'expectScrollsToLinkWhenCloseIsClicked' ] + ] )( '%s', async ( testName: string ) => { + await useOfFundsScrollFeatures[ testName ]( getWrapper(), pageScroller ); + } ); + } ); + + describe( 'Mini Banner', () => { + test.each( [ + [ 'expectSlideShowPlaysWhenMiniBannerBecomesVisible' ], + // [ 'expectSlideShowStopsWhenFullBannerBecomesVisible' ], + [ 'expectShowsFullPageWhenCallToActionIsClicked' ], + [ 'expectEmitsBannerContentChangedEventWhenCallToActionIsClicked' ] + ] )( '%s', async ( testName: string ) => { + await miniBannerFeatures[ testName ]( getWrapper() ); + } ); + } ); + + describe( 'Minimised Banner', () => { + test.each( [ + [ 'expectMinimisesAndMaximises' ], + [ 'expectOpensFullPageFromMiniBanner' ], + [ 'expectTracksMinimiseAndMaximise' ] + ] )( '%s', async ( testName: string ) => { + await minimisedBannerFeatures[ testName ]( getWrapper(), tracker ); + } ); + } ); + + describe( 'Full Page Banner', () => { + test.each( [ + [ 'expectEmitsCloseEvent' ] + ] )( '%s', async ( testName: string ) => { + await fullPageBannerFeatures[ testName ]( getWrapper() ); + } ); + } ); +} ); From 3e03a725167cb08fa3f5b37e4989bef06e295725 Mon Sep 17 00:00:00 2001 From: Sperling-0 Date: Fri, 8 Nov 2024 20:07:54 +0100 Subject: [PATCH 2/3] Prepare CTRL for C24_WMDE_Mobile_DE_08 - It is reduced in height to match last year's banners (e. g. B23_WMDE_Mobile_DE_11_ctrl) - It uses slightly changed copy Ticket: https://phabricator.wikimedia.org/T379292 --- .../C24_WMDE_Mobile_DE_08/banner_var.ts | 4 +- .../components/BannerVar.vue | 38 +--- .../components/MiniBannerVar.vue | 51 ++--- .../content/BannerSlides.vue | 2 +- .../content/BannerText.vue | 14 +- .../C24_WMDE_Mobile_DE_08/event_map_var.ts | 36 ---- .../styles/BannerVar.scss | 108 ---------- .../styles/MiniBannerVar.scss | 196 ------------------ .../C24_WMDE_Mobile_DE_08/styles/styles.scss | 2 +- .../styles/styles_var.scss | 30 --- .../components/BannerVar.spec.ts | 17 +- 11 files changed, 36 insertions(+), 462 deletions(-) delete mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/event_map_var.ts delete mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/styles/BannerVar.scss delete mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/styles/MiniBannerVar.scss delete mode 100644 banners/mobile/C24_WMDE_Mobile_DE_08/styles/styles_var.scss diff --git a/banners/mobile/C24_WMDE_Mobile_DE_08/banner_var.ts b/banners/mobile/C24_WMDE_Mobile_DE_08/banner_var.ts index d4ca56a54..6772668fc 100644 --- a/banners/mobile/C24_WMDE_Mobile_DE_08/banner_var.ts +++ b/banners/mobile/C24_WMDE_Mobile_DE_08/banner_var.ts @@ -1,6 +1,6 @@ import { createVueApp } from '@src/createVueApp'; -import './styles/styles_var.scss'; +import './styles/styles.scss'; import BannerConductor from '@src/components/BannerConductor/BannerConductor.vue'; import Banner from './components/BannerVar.vue'; @@ -16,7 +16,7 @@ import DynamicTextPlugin from '@src/DynamicTextPlugin'; import { LocalImpressionCount } from '@src/utils/LocalImpressionCount'; import { WindowPageScroller } from '@src/utils/PageScroller/WindowPageScroller'; import { LegacyTrackerWPORG } from '@src/tracking/LegacyTrackerWPORG'; -import eventMappings from './event_map_var'; +import eventMappings from './event_map'; // Locale-specific imports import messages from './messages'; diff --git a/banners/mobile/C24_WMDE_Mobile_DE_08/components/BannerVar.vue b/banners/mobile/C24_WMDE_Mobile_DE_08/components/BannerVar.vue index 0d3485523..1191153ce 100644 --- a/banners/mobile/C24_WMDE_Mobile_DE_08/components/BannerVar.vue +++ b/banners/mobile/C24_WMDE_Mobile_DE_08/components/BannerVar.vue @@ -1,11 +1,9 @@