From 7b3ba6163f5af0ad675f5bd61e171ba70b646c90 Mon Sep 17 00:00:00 2001 From: Gabriel Birke Date: Fri, 6 Dec 2024 15:33:41 +0100 Subject: [PATCH 1/4] Prepare campaign for C24_WMDE_Desktop_EN_06 Ticket: https://phabricator.wikimedia.org/T381396 --- .../C24_WMDE_Desktop_EN_06/banner_ctrl.ts | 71 ++++++++ .../C24_WMDE_Desktop_EN_06/banner_var.ts | 71 ++++++++ .../components/BannerCtrl.vue | 160 +++++++++++++++++ .../components/BannerVar.vue | 161 ++++++++++++++++++ .../components/FallbackBanner.vue | 106 ++++++++++++ .../components/MainBanner.vue | 50 ++++++ .../content/BannerSlides.vue | 51 ++++++ .../content/BannerText.vue | 44 +++++ .../content/FallbackSlides.vue | 27 +++ .../content/FallbackText.vue | 32 ++++ .../C24_WMDE_Desktop_EN_06/event_map.ts | 38 +++++ .../C24_WMDE_Desktop_EN_06/form_items.ts | 21 +++ .../C24_WMDE_Desktop_EN_06/messages.ts | 27 +++ .../C24_WMDE_Desktop_EN_06/messages_var.ts | 28 +++ .../C24_WMDE_Desktop_EN_06/styles/Banner.scss | 17 ++ .../styles/FallbackBanner.scss | 136 +++++++++++++++ .../styles/MainBanner.scss | 44 +++++ .../C24_WMDE_Desktop_EN_06/styles/styles.scss | 61 +++++++ .../styles/styles_var.scss | 61 +++++++ campaign_info.toml | 18 +- .../components/BannerCtrl.spec.ts | 141 +++++++++++++++ .../components/BannerVar.spec.ts | 142 +++++++++++++++ .../components/FallbackBanner.spec.ts | 64 +++++++ 23 files changed, 1562 insertions(+), 9 deletions(-) create mode 100644 banners/english/C24_WMDE_Desktop_EN_06/banner_ctrl.ts create mode 100644 banners/english/C24_WMDE_Desktop_EN_06/banner_var.ts create mode 100644 banners/english/C24_WMDE_Desktop_EN_06/components/BannerCtrl.vue create mode 100644 banners/english/C24_WMDE_Desktop_EN_06/components/BannerVar.vue create mode 100644 banners/english/C24_WMDE_Desktop_EN_06/components/FallbackBanner.vue create mode 100644 banners/english/C24_WMDE_Desktop_EN_06/components/MainBanner.vue create mode 100644 banners/english/C24_WMDE_Desktop_EN_06/content/BannerSlides.vue create mode 100644 banners/english/C24_WMDE_Desktop_EN_06/content/BannerText.vue create mode 100644 banners/english/C24_WMDE_Desktop_EN_06/content/FallbackSlides.vue create mode 100644 banners/english/C24_WMDE_Desktop_EN_06/content/FallbackText.vue create mode 100644 banners/english/C24_WMDE_Desktop_EN_06/event_map.ts create mode 100644 banners/english/C24_WMDE_Desktop_EN_06/form_items.ts create mode 100644 banners/english/C24_WMDE_Desktop_EN_06/messages.ts create mode 100644 banners/english/C24_WMDE_Desktop_EN_06/messages_var.ts create mode 100644 banners/english/C24_WMDE_Desktop_EN_06/styles/Banner.scss create mode 100644 banners/english/C24_WMDE_Desktop_EN_06/styles/FallbackBanner.scss create mode 100644 banners/english/C24_WMDE_Desktop_EN_06/styles/MainBanner.scss create mode 100644 banners/english/C24_WMDE_Desktop_EN_06/styles/styles.scss create mode 100644 banners/english/C24_WMDE_Desktop_EN_06/styles/styles_var.scss create mode 100644 test/banners/english/C24_WMDE_Desktop_EN_06/components/BannerCtrl.spec.ts create mode 100644 test/banners/english/C24_WMDE_Desktop_EN_06/components/BannerVar.spec.ts create mode 100644 test/banners/english/C24_WMDE_Desktop_EN_06/components/FallbackBanner.spec.ts diff --git a/banners/english/C24_WMDE_Desktop_EN_06/banner_ctrl.ts b/banners/english/C24_WMDE_Desktop_EN_06/banner_ctrl.ts new file mode 100644 index 000000000..5ac47a488 --- /dev/null +++ b/banners/english/C24_WMDE_Desktop_EN_06/banner_ctrl.ts @@ -0,0 +1,71 @@ +import { createVueApp } from '@src/createVueApp'; + +import './styles/styles.scss'; + +import BannerConductor from '@src/components/BannerConductor/FallbackBannerConductor.vue'; +import Banner from './components/BannerCtrl.vue'; +import FallbackBanner from './components/FallbackBanner.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 { LegacyTrackerWPORG } from '@src/tracking/LegacyTrackerWPORG'; +import { Locales } from '@src/domain/Locales'; +import messages from './messages'; +import { LocaleFactoryEn } from '@src/utils/LocaleFactory/LocaleFactoryEn'; +import { createFormItems } from './form_items'; +import { createFormActions } from '@src/createFormActions'; +import eventMappings from './event_map'; +import { createFallbackDonationURL } from '@src/createFallbackDonationURL'; +import { WindowTimer } from '@src/utils/Timer'; + +const localeFactory = new LocaleFactoryEn(); +const translator = new Translator( messages ); +const mediaWiki = new WindowMediaWiki(); +const page = new PageWPORG( mediaWiki, ( new SkinFactory( mediaWiki ) ).getSkin(), new WindowSizeIssueChecker( 400 ) ); +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(), + remainingImpressions: impressionCount.getRemainingImpressions( page.getMaxBannerImpressions( 'english' ) ), + donationLink: createFallbackDonationURL( page.getTracking(), impressionCount, { locale: Locales.EN } ) + }, + resizeHandler: new WindowResizeHandler(), + banner: Banner, + fallbackBanner: FallbackBanner, + minWidthForMainBanner: 800, + impressionCount +} ); + +app.use( TranslationPlugin, translator ); +app.use( DynamicTextPlugin, { + campaignParameters: page.getCampaignParameters(), + date: new Date(), + formatters: localeFactory.getFormatters(), + impressionCount, + translator +} ); + +const currencyFormatter = localeFactory.getCurrencyFormatter(); + +app.provide( 'currencyFormatter', currencyFormatter ); +app.provide( 'formItems', createFormItems( translator, currencyFormatter.euroAmount.bind( currencyFormatter ) ) ); +app.provide( 'formActions', createFormActions( page.getTracking(), impressionCount, { locale: Locales.EN } ) ); +app.provide( 'tracker', tracker ); +app.provide( 'timer', new WindowTimer() ); + +app.mount( page.getBannerContainer() ); diff --git a/banners/english/C24_WMDE_Desktop_EN_06/banner_var.ts b/banners/english/C24_WMDE_Desktop_EN_06/banner_var.ts new file mode 100644 index 000000000..9883c3e6d --- /dev/null +++ b/banners/english/C24_WMDE_Desktop_EN_06/banner_var.ts @@ -0,0 +1,71 @@ +import { createVueApp } from '@src/createVueApp'; + +import './styles/styles_var.scss'; + +import BannerConductor from '@src/components/BannerConductor/FallbackBannerConductor.vue'; +import Banner from './components/BannerVar.vue'; +import FallbackBanner from './components/FallbackBanner.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 { LegacyTrackerWPORG } from '@src/tracking/LegacyTrackerWPORG'; +import { Locales } from '@src/domain/Locales'; +import messages from './messages_var'; +import { LocaleFactoryEn } from '@src/utils/LocaleFactory/LocaleFactoryEn'; +import { createFormItems } from './form_items'; +import { createFormActions } from '@src/createFormActions'; +import eventMappings from './event_map'; +import { createFallbackDonationURL } from '@src/createFallbackDonationURL'; +import { WindowTimer } from '@src/utils/Timer'; + +const localeFactory = new LocaleFactoryEn(); +const translator = new Translator( messages ); +const mediaWiki = new WindowMediaWiki(); +const page = new PageWPORG( mediaWiki, ( new SkinFactory( mediaWiki ) ).getSkin(), new WindowSizeIssueChecker( 400 ) ); +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(), + remainingImpressions: impressionCount.getRemainingImpressions( page.getMaxBannerImpressions( 'english' ) ), + donationLink: createFallbackDonationURL( page.getTracking(), impressionCount, { locale: Locales.EN } ) + }, + resizeHandler: new WindowResizeHandler(), + banner: Banner, + fallbackBanner: FallbackBanner, + minWidthForMainBanner: 800, + impressionCount +} ); + +app.use( TranslationPlugin, translator ); +app.use( DynamicTextPlugin, { + campaignParameters: page.getCampaignParameters(), + date: new Date(), + formatters: localeFactory.getFormatters(), + impressionCount, + translator +} ); + +const currencyFormatter = localeFactory.getCurrencyFormatter(); + +app.provide( 'currencyFormatter', currencyFormatter ); +app.provide( 'formItems', createFormItems( translator, currencyFormatter.euroAmount.bind( currencyFormatter ) ) ); +app.provide( 'formActions', createFormActions( page.getTracking(), impressionCount, { locale: Locales.EN } ) ); +app.provide( 'tracker', tracker ); +app.provide( 'timer', new WindowTimer() ); + +app.mount( page.getBannerContainer() ); diff --git a/banners/english/C24_WMDE_Desktop_EN_06/components/BannerCtrl.vue b/banners/english/C24_WMDE_Desktop_EN_06/components/BannerCtrl.vue new file mode 100644 index 000000000..d5f616146 --- /dev/null +++ b/banners/english/C24_WMDE_Desktop_EN_06/components/BannerCtrl.vue @@ -0,0 +1,160 @@ + + + diff --git a/banners/english/C24_WMDE_Desktop_EN_06/components/BannerVar.vue b/banners/english/C24_WMDE_Desktop_EN_06/components/BannerVar.vue new file mode 100644 index 000000000..c9a62e3be --- /dev/null +++ b/banners/english/C24_WMDE_Desktop_EN_06/components/BannerVar.vue @@ -0,0 +1,161 @@ + + + diff --git a/banners/english/C24_WMDE_Desktop_EN_06/components/FallbackBanner.vue b/banners/english/C24_WMDE_Desktop_EN_06/components/FallbackBanner.vue new file mode 100644 index 000000000..75e469475 --- /dev/null +++ b/banners/english/C24_WMDE_Desktop_EN_06/components/FallbackBanner.vue @@ -0,0 +1,106 @@ + + + diff --git a/banners/english/C24_WMDE_Desktop_EN_06/components/MainBanner.vue b/banners/english/C24_WMDE_Desktop_EN_06/components/MainBanner.vue new file mode 100644 index 000000000..9f9ebe572 --- /dev/null +++ b/banners/english/C24_WMDE_Desktop_EN_06/components/MainBanner.vue @@ -0,0 +1,50 @@ + + + diff --git a/banners/english/C24_WMDE_Desktop_EN_06/content/BannerSlides.vue b/banners/english/C24_WMDE_Desktop_EN_06/content/BannerSlides.vue new file mode 100644 index 000000000..ac14de304 --- /dev/null +++ b/banners/english/C24_WMDE_Desktop_EN_06/content/BannerSlides.vue @@ -0,0 +1,51 @@ + + + diff --git a/banners/english/C24_WMDE_Desktop_EN_06/content/BannerText.vue b/banners/english/C24_WMDE_Desktop_EN_06/content/BannerText.vue new file mode 100644 index 000000000..7129d9b38 --- /dev/null +++ b/banners/english/C24_WMDE_Desktop_EN_06/content/BannerText.vue @@ -0,0 +1,44 @@ + + + diff --git a/banners/english/C24_WMDE_Desktop_EN_06/content/FallbackSlides.vue b/banners/english/C24_WMDE_Desktop_EN_06/content/FallbackSlides.vue new file mode 100644 index 000000000..a50a81082 --- /dev/null +++ b/banners/english/C24_WMDE_Desktop_EN_06/content/FallbackSlides.vue @@ -0,0 +1,27 @@ + + + diff --git a/banners/english/C24_WMDE_Desktop_EN_06/content/FallbackText.vue b/banners/english/C24_WMDE_Desktop_EN_06/content/FallbackText.vue new file mode 100644 index 000000000..60a58e80d --- /dev/null +++ b/banners/english/C24_WMDE_Desktop_EN_06/content/FallbackText.vue @@ -0,0 +1,32 @@ + + + diff --git a/banners/english/C24_WMDE_Desktop_EN_06/event_map.ts b/banners/english/C24_WMDE_Desktop_EN_06/event_map.ts new file mode 100644 index 000000000..612f999a8 --- /dev/null +++ b/banners/english/C24_WMDE_Desktop_EN_06/event_map.ts @@ -0,0 +1,38 @@ +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'; + +export default new Map( [ + [ 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 ) ] +] ); diff --git a/banners/english/C24_WMDE_Desktop_EN_06/form_items.ts b/banners/english/C24_WMDE_Desktop_EN_06/form_items.ts new file mode 100644 index 000000000..95a254ccb --- /dev/null +++ b/banners/english/C24_WMDE_Desktop_EN_06/form_items.ts @@ -0,0 +1,21 @@ +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.QUARTERLY, + Intervals.YEARLY + ) + .setAmounts( 5, 10, 20, 25, 50, 100 ) + .setPaymentMethods( + PaymentMethods.PAYPAL, + PaymentMethods.CREDIT_CARD + ).getItems(); +} diff --git a/banners/english/C24_WMDE_Desktop_EN_06/messages.ts b/banners/english/C24_WMDE_Desktop_EN_06/messages.ts new file mode 100644 index 000000000..24d57a42d --- /dev/null +++ b/banners/english/C24_WMDE_Desktop_EN_06/messages.ts @@ -0,0 +1,27 @@ +import CustomAmountFormEn from '@src/components/DonationForm/Forms/messages/CustomAmountForm.en'; +import DynamicCampaignTextEn from '@src/utils/DynamicContent/messages/DynamicCampaignText.en'; +import { TranslationMessages } from '@src/Translator'; +import UpgradeToYearlyEn from '@src/components/DonationForm/Forms/messages/UpgradeToYearly.en'; +import SoftCloseEn from '@src/components/SoftClose/messages/SoftClose.en'; +import AddressFormEn from '@src/components/DonationForm/Forms/messages/AddressForm.en'; +import FooterEn from '@src/components/Footer/messages/Footer.en'; +import MainDonationFormEn from '@src/components/DonationForm/Forms/messages/MainDonationForm.en'; +import AlreadyDonatedModalEn from '@src/components/AlreadyDonatedModal/translations/AlreadyDonatedModal.en'; +import FallbackBanner from '@src/components/FallbackBanner/messages/FallbackBanner.en'; + +const messages: TranslationMessages = { + ...CustomAmountFormEn, + ...DynamicCampaignTextEn, + ...UpgradeToYearlyEn, + ...SoftCloseEn, + ...AddressFormEn, + ...FooterEn, + ...MainDonationFormEn, + ...AlreadyDonatedModalEn, + ...FallbackBanner, + 'upgrade-to-yearly-copy': '

Every year we are dependent on the support of people like you. Yearly donations ' + + 'help sustainably and enable long term development.

' + + '

No risks attached, you can tell us to stop at any time.

' +}; + +export default messages; diff --git a/banners/english/C24_WMDE_Desktop_EN_06/messages_var.ts b/banners/english/C24_WMDE_Desktop_EN_06/messages_var.ts new file mode 100644 index 000000000..4b3e5c0e9 --- /dev/null +++ b/banners/english/C24_WMDE_Desktop_EN_06/messages_var.ts @@ -0,0 +1,28 @@ +import CustomAmountFormEn from '@src/components/DonationForm/Forms/messages/CustomAmountForm.en'; +import DynamicCampaignTextEn from '@src/utils/DynamicContent/messages/DynamicCampaignText.en'; +import { TranslationMessages } from '@src/Translator'; +import UpgradeToYearlyEn from '@src/components/DonationForm/Forms/messages/UpgradeToYearly.en'; +import SoftCloseEn from '@src/components/SoftClose/messages/SoftClose.en'; +import AddressFormEn from '@src/components/DonationForm/Forms/messages/AddressForm.en'; +import FooterEn from '@src/components/Footer/messages/Footer.en'; +import MainDonationFormEn from '@src/components/DonationForm/Forms/messages/MainDonationForm.en'; +import AlreadyDonatedModalEn from '@src/components/AlreadyDonatedModal/translations/AlreadyDonatedModal.en'; +import FallbackBanner from '@src/components/FallbackBanner/messages/FallbackBanner.en'; + +const messages: TranslationMessages = { + ...CustomAmountFormEn, + ...DynamicCampaignTextEn, + ...UpgradeToYearlyEn, + ...SoftCloseEn, + ...AddressFormEn, + ...FooterEn, + ...MainDonationFormEn, + ...AlreadyDonatedModalEn, + ...FallbackBanner, + 'upgrade-to-yearly-copy': '

Every year we are dependent on the support of people like you. Yearly donations ' + + 'help sustainably and enable long term development.

' + + '

No risks attached, you can tell us to stop at any time.

', + 'donation-receipt-checkbox-label': 'Please send me a tax deductible donation receipt to my postal address.' +}; + +export default messages; diff --git a/banners/english/C24_WMDE_Desktop_EN_06/styles/Banner.scss b/banners/english/C24_WMDE_Desktop_EN_06/styles/Banner.scss new file mode 100644 index 000000000..f88657686 --- /dev/null +++ b/banners/english/C24_WMDE_Desktop_EN_06/styles/Banner.scss @@ -0,0 +1,17 @@ +@use 'src/themes/Treedip/variables/fonts'; + +.wmde-banner { + &-wrapper { + font-size: 14px; + font-family: fonts.$ui; + box-shadow: var( --main-box-shadow ); + background-color: var( --main-background ); + color: var( --main-color ); + } + + &--closed { + .wmde-banner-wrapper { + display: none; + } + } +} diff --git a/banners/english/C24_WMDE_Desktop_EN_06/styles/FallbackBanner.scss b/banners/english/C24_WMDE_Desktop_EN_06/styles/FallbackBanner.scss new file mode 100644 index 000000000..2361a26cf --- /dev/null +++ b/banners/english/C24_WMDE_Desktop_EN_06/styles/FallbackBanner.scss @@ -0,0 +1,136 @@ +@use 'src/themes/Treedip/variables/globals'; +@use 'src/themes/Treedip/variables/fonts'; + +$breakpoint: 800px; + +.wmde-banner { + &-fallback { + width: 100%; + height: 150px; + display: flex; + flex-direction: column; + background: var( --fallback-background ); + box-shadow: var( --main-box-shadow ); + + @media ( min-width: $breakpoint ) { + height: auto; + min-height: 250px; + padding: 4px; + } + + &-small, + &-large { + display: flex; + flex-direction: column; + flex: 1 1 auto; + } + + &-small { + align-items: center; + border: 4px solid var( --fallback-border ); + border-radius: 4px; + padding: 8px; + + .wmde-banner-progress-bar { + height: 25px; + line-height: 25px; + } + + .wmde-banner-progress-bar-text, + .wmde-banner-progress-bar-fill-wrapper { + height: 25px; + } + + .wmde-banner-progress-bar-fill { + line-height: 20px; + } + + .wmde-banner-fallback-button { + margin: 0 0 8px; + } + + .wmde-banner-selection-input-text, + .wmde-banner-selection-input-input { + font-family: fonts.$content; + font-size: 14px; + font-weight: normal; + } + } + + &-large { + align-items: stretch; + } + + &-usage-link { + color: var( --fallback-uof-link ); + } + + &-message { + flex: 1 1 auto; + display: flex; + flex-direction: column; + background: var( --fallback-message-background ); + border: 4px solid var( --fallback-message-border ); + border-radius: 4px; + padding: 8px 0; + } + + &-bank-item { + display: block; + + &-label { + font-weight: bold; + } + } + + .wmde-banner-close { + height: 16px; + width: 16px; + top: 8px; + right: 8px; + margin: 0; + padding: 0; + + @media ( min-width: $breakpoint ) { + height: 30px; + width: 30px; + top: 12px; + right: 12px; + } + } + + .wmde-banner-slider-container { + padding: 0 0 8px; + } + + .wmde-banner-slide-content { + font-size: 14px; + p { + margin-bottom: 8px; + } + } + + .wmde-banner-slider-navigation-previous, + .wmde-banner-slider-navigation-next { + align-items: end; + } + + .wmde-banner-slider-pagination-dot { + cursor: default; + } + + .wmde-banner-message { + flex: 1 1 auto; + + p { + margin-bottom: 0; + } + } + } + + &--pending { + .wmde-banner-fallback { + box-shadow: none; + } + } +} diff --git a/banners/english/C24_WMDE_Desktop_EN_06/styles/MainBanner.scss b/banners/english/C24_WMDE_Desktop_EN_06/styles/MainBanner.scss new file mode 100644 index 000000000..518b8c959 --- /dev/null +++ b/banners/english/C24_WMDE_Desktop_EN_06/styles/MainBanner.scss @@ -0,0 +1,44 @@ +$banner-height: 357px !default; +$form-width: 300px !default; + +.wmde-banner { + &-main { + min-height: $banner-height; + display: flex; + flex-direction: column; + padding: 12px 24px 0; + } + + &-content { + display: flex; + flex-direction: row; + flex-grow: 1; + } + + &-message { + padding: 0 15px; + } + + &-column-left { + display: flex; + flex-direction: column; + justify-content: center; + flex: 1 1 auto; + margin-bottom: 0; + overflow-y: hidden; + margin-right: 30px; + padding: 0 0 10px; + background: var( --message-background ); + border: 5px solid var( --message-border ); + border-radius: 9px; + } + + &-column-right { + order: 2; + flex: 0 0 $form-width; + display: flex; + flex-direction: column; + width: $form-width; + padding: 10px 0; + } +} diff --git a/banners/english/C24_WMDE_Desktop_EN_06/styles/styles.scss b/banners/english/C24_WMDE_Desktop_EN_06/styles/styles.scss new file mode 100644 index 000000000..1e0e5a7f3 --- /dev/null +++ b/banners/english/C24_WMDE_Desktop_EN_06/styles/styles.scss @@ -0,0 +1,61 @@ +// This is the file where we import the theme-specific component styles +@use 'src/themes/Treedip/swatches/skin_vector-2022' with ( + $slider: true, + $select-group-bubble: true, + $select-group-image-label: true, + $upgrade-to-yearly: true, + $fallback-banner: true, + $progress-bar: true, + $soft-close: true, +); +@use 'src/themes/Treedip/variables/breakpoints'; +@use 'src/components/BannerConductor/banner-transition'; +@use 'Banner'; +@use 'MainBanner' with ( + $banner-height: 355px, + $form-width: 300px +); +@use 'src/themes/UseOfFunds/swatches/skin_vector-2022' as uof-vector-2022; +@use 'src/themes/UseOfFunds/UseOfFunds'; +@use 'src/themes/Treedip/defaults'; +@use 'src/themes/Treedip/ButtonClose/ButtonClose' with ( + $padding: 4px, + $top: 12px, + $right: 8px, + $margin: -4.5px +); +@use 'src/themes/Treedip/ProgressBar/ProgressBarAlternative' with ( + $progress-bar-margin: 0 15px +); +@use 'src/themes/Treedip/DonationForm/DonationForm'; +@use 'src/themes/Treedip/DonationForm/MultiStepDonation'; +@use 'src/themes/Treedip/DonationForm/BubbleForm/SelectGroupBubble'; +@use 'src/themes/Treedip/DonationForm/BubbleForm/SelectGroupRadioBubbles' with ( + $height: 34px, + $font-size: 14px +); +@use 'src/themes/Treedip/DonationForm/BubbleForm/SelectCustomAmountRadioBubble' with ( + $height: 34px, + $font-size: 14px +); +@use 'src/themes/Treedip/DonationForm/BubbleForm/SelectGroupBubbleImageLabel'; +@use 'src/themes/Treedip/DonationForm/SubComponents/SmsBox'; +@use 'src/themes/Treedip/DonationForm/Forms/MainDonationForm' with ( + $padding: 14px 0 0 +); +@use 'src/themes/Treedip/DonationForm/Forms/UpgradeToYearlyButtonForm' with ( + $font-size: 14px +); +@use 'src/themes/Treedip/Footer/FooterAlreadyDonated' with ( + $right-column-width: 300px +); +@use 'src/themes/Treedip/Footer/SelectionInput'; +@use 'src/themes/Treedip/Message/Message' with ( + $font-sizes: ( 1400px: 15px, 1600px: 16px, 1800px: 18px ) +); +@use 'src/themes/Treedip/Slider/KeenSlider'; +@use 'src/themes/Treedip/SoftClose/SoftClose'; +@use 'FallbackBanner'; +@use 'src/themes/Fijitiv/FallbackBanner/FallbackButton'; +@use 'src/themes/Fijitiv/FallbackBanner/LargeFooter'; +@use 'src/themes/Fijitiv/FallbackBanner/SmallFooter'; diff --git a/banners/english/C24_WMDE_Desktop_EN_06/styles/styles_var.scss b/banners/english/C24_WMDE_Desktop_EN_06/styles/styles_var.scss new file mode 100644 index 000000000..7a126e0a0 --- /dev/null +++ b/banners/english/C24_WMDE_Desktop_EN_06/styles/styles_var.scss @@ -0,0 +1,61 @@ +// This is the file where we import the theme-specific component styles +@use 'src/themes/Treedip/swatches/skin_vector-2022' with ( + $slider: true, + $select-group-bubble: true, + $select-group-image-label: true, + $upgrade-to-yearly: true, + $fallback-banner: true, + $progress-bar: true, + $soft-close: true, +); +@use 'src/themes/Treedip/variables/breakpoints'; +@use 'src/components/BannerConductor/banner-transition'; +@use 'Banner'; +@use 'MainBanner' with ( + $banner-height: 355px, + $form-width: 300px +); +@use 'src/themes/UseOfFunds/swatches/skin_vector-2022' as uof-vector-2022; +@use 'src/themes/UseOfFunds/UseOfFunds'; +@use 'src/themes/Treedip/defaults'; +@use 'src/themes/Treedip/ButtonClose/ButtonClose' with ( + $padding: 4px, + $top: 12px, + $right: 8px, + $margin: -4.5px +); +@use 'src/themes/Treedip/ProgressBar/ProgressBarAlternative' with ( + $progress-bar-margin: 0 15px +); +@use 'src/themes/Treedip/DonationForm/DonationForm'; +@use 'src/themes/Treedip/DonationForm/MultiStepDonation'; +@use 'src/themes/Treedip/DonationForm/BubbleForm/SelectGroupBubble'; +@use 'src/themes/Treedip/DonationForm/BubbleForm/SelectGroupRadioBubbles' with ( + $height: 34px, + $font-size: 14px +); +@use 'src/themes/Treedip/DonationForm/BubbleForm/SelectCustomAmountRadioBubble' with ( + $height: 34px, + $font-size: 14px +); +@use 'src/themes/Treedip/DonationForm/BubbleForm/SelectGroupBubbleImageLabel'; +@use 'src/themes/Treedip/DonationForm/SubComponents/SmsBox'; +@use 'src/themes/Treedip/DonationForm/Forms/MainDonationFormDonationReceipt' with ( + $padding: 14px 0 0 +); +@use 'src/themes/Treedip/DonationForm/Forms/UpgradeToYearlyButtonForm' with ( + $font-size: 14px +); +@use 'src/themes/Treedip/Footer/FooterAlreadyDonated' with ( + $right-column-width: 300px +); +@use 'src/themes/Treedip/Footer/SelectionInput'; +@use 'src/themes/Treedip/Message/Message' with ( + $font-sizes: ( 1400px: 15px, 1600px: 16px, 1800px: 18px ) +); +@use 'src/themes/Treedip/Slider/KeenSlider'; +@use 'src/themes/Treedip/SoftClose/SoftClose'; +@use 'FallbackBanner'; +@use 'src/themes/Fijitiv/FallbackBanner/FallbackButton'; +@use 'src/themes/Fijitiv/FallbackBanner/LargeFooter'; +@use 'src/themes/Fijitiv/FallbackBanner/SmallFooter'; diff --git a/campaign_info.toml b/campaign_info.toml index fe8063f62..26930e350 100644 --- a/campaign_info.toml +++ b/campaign_info.toml @@ -139,9 +139,9 @@ tracking = "wpde-mob01-241028-var" [english] name = "English Desktop" icon = "desktop" -campaign = "C24_WMDE_Desktop_EN_05" -description = "Based on CTRL desktop EN 04" -campaign_tracking = "en05-ba-241126" +campaign = "C24_WMDE_Desktop_EN_06" +description = "Based on CTRL desktop EN 05" +campaign_tracking = "en06-ba-241209" preview_link = "/wiki/Main_Page?devbanner={{banner}}&banner=B22_WMDE_local_prototype" preview_link_darkmode = "/wiki/Main_Page?devbanner={{banner}}&banner=B22_WMDE_local_prototype&vectornightmode=1" preview_url = 'https://en.wikipedia.org/wiki/Main_Page?banner={{banner}}&devMode' @@ -149,14 +149,14 @@ wrapper_template = "wikipedia_org" use_of_funds_source = "MediaWiki:WMDE_Fundraising/UseOfFunds_2024_EN" [english.banners.ctrl] -filename = "./banners/english/C24_WMDE_Desktop_EN_05/banner_ctrl.ts" -pagename = "B24_WMDE_Desktop_EN_05_ctrl" -tracking = "org-en05-241126-ctrl" +filename = "./banners/english/C24_WMDE_Desktop_EN_06/banner_ctrl.ts" +pagename = "B24_WMDE_Desktop_EN_06_ctrl" +tracking = "org-en06-241209-ctrl" [english.banners.var] -filename = "./banners/english/C24_WMDE_Desktop_EN_05/banner_var.ts" -pagename = "B24_WMDE_Desktop_EN_05_var" -tracking = "org-en05-241126-var" +filename = "./banners/english/C24_WMDE_Desktop_EN_06/banner_var.ts" +pagename = "B24_WMDE_Desktop_EN_06_var" +tracking = "org-en06-241209-var" [english.test_matrix] platform = ["edge", "firefox_win10", "chrome_win10", "safari", "firefox_macos", "chrome_macos", "firefox_linux", "chrome_linux"] diff --git a/test/banners/english/C24_WMDE_Desktop_EN_06/components/BannerCtrl.spec.ts b/test/banners/english/C24_WMDE_Desktop_EN_06/components/BannerCtrl.spec.ts new file mode 100644 index 000000000..37fea86fa --- /dev/null +++ b/test/banners/english/C24_WMDE_Desktop_EN_06/components/BannerCtrl.spec.ts @@ -0,0 +1,141 @@ +import { beforeEach, describe, test } from 'vitest'; +import { mount, VueWrapper } from '@vue/test-utils'; +import Banner from '@banners/english/C24_WMDE_Desktop_EN_06/components/BannerCtrl.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 { bannerAutoHideFeatures, 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 { Timer } from '@src/utils/Timer'; +import { TimerStub } from '@test/fixtures/TimerStub'; + +const formModel = useFormModel(); +const translator = ( key: string ): string => key; + +describe( 'BannerCtrl.vue', () => { + + beforeEach( () => { + resetFormModel( formModel ); + } ); + + const getWrapper = ( dynamicContent: DynamicContent = null, timer: Timer = null ): VueWrapper => { + 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(), + timer: timer ?? new TimerStub() + } + } + } ); + }; + + describe( 'Main Banner', () => { + test.each( [ + [ 'expectDoesNotEmitCloseEvent' ] + ] )( '%s', async ( testName: string ) => { + await bannerMainFeatures[ testName ]( getWrapper() ); + } ); + + test.each( [ + [ 'expectClosesBannerWhenWindowBecomesSmall' ] + ] )( '%s', async ( testName: string ) => { + await bannerAutoHideFeatures[ 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( '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() ); + } ); + } ); +} ); diff --git a/test/banners/english/C24_WMDE_Desktop_EN_06/components/BannerVar.spec.ts b/test/banners/english/C24_WMDE_Desktop_EN_06/components/BannerVar.spec.ts new file mode 100644 index 000000000..a3a49d6fa --- /dev/null +++ b/test/banners/english/C24_WMDE_Desktop_EN_06/components/BannerVar.spec.ts @@ -0,0 +1,142 @@ +import { beforeEach, describe, test } from 'vitest'; +import { mount, VueWrapper } from '@vue/test-utils'; +import Banner from '@banners/english/C24_WMDE_Desktop_EN_06/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/MainDonationDonationReceipt_UpgradeToYearlyButton'; +import { useFormModel } from '@src/components/composables/useFormModel'; +import { resetFormModel } from '@test/resetFormModel'; +import { bannerAutoHideFeatures, 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 { Timer } from '@src/utils/Timer'; +import { TimerStub } from '@test/fixtures/TimerStub'; + +const formModel = useFormModel(); +const translator = ( key: string ): string => key; + +describe( 'BannerVar.vue', () => { + + beforeEach( () => { + resetFormModel( formModel ); + } ); + + const getWrapper = ( dynamicContent: DynamicContent = null, timer: Timer = null ): VueWrapper => { + 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(), + timer: timer ?? new TimerStub() + } + } + } ); + }; + + describe( 'Main Banner', () => { + test.each( [ + [ 'expectDoesNotEmitCloseEvent' ] + ] )( '%s', async ( testName: string ) => { + await bannerMainFeatures[ testName ]( getWrapper() ); + } ); + + test.each( [ + [ 'expectClosesBannerWhenWindowBecomesSmall' ] + ] )( '%s', async ( testName: string ) => { + await bannerAutoHideFeatures[ 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' ], + [ 'expectMainDonationFormShowsDonationReceiptCheckbox' ] + ] )( '%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( '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() ); + } ); + } ); +} ); diff --git a/test/banners/english/C24_WMDE_Desktop_EN_06/components/FallbackBanner.spec.ts b/test/banners/english/C24_WMDE_Desktop_EN_06/components/FallbackBanner.spec.ts new file mode 100644 index 000000000..9c9f301be --- /dev/null +++ b/test/banners/english/C24_WMDE_Desktop_EN_06/components/FallbackBanner.spec.ts @@ -0,0 +1,64 @@ +import { describe, test } from 'vitest'; +import { mount, VueWrapper } from '@vue/test-utils'; +import FallbackBanner from '@banners/english/C24_WMDE_Desktop_EN_06/components/FallbackBanner.vue'; +import { BannerStates } from '@src/components/BannerConductor/StateMachine/BannerStates'; +import { useOfFundsContent } from '@test/banners/useOfFundsContent'; +import { newDynamicContent } from '@test/banners/dynamicCampaignContent'; +import { DynamicContent } from '@src/utils/DynamicContent/DynamicContent'; +import { Tracker } from '@src/tracking/Tracker'; +import { TrackerStub } from '@test/fixtures/TrackerStub'; +import { dynamicContentFeatures, fallbackBannerFeatures, submitFeatures } from '@test/features/FallbackBanner'; +import { TimerStub } from '@test/fixtures/TimerStub'; +import { Timer } from '@src/utils/Timer'; + +const translator = ( key: string ): string => key; + +describe( 'FallbackBanner.vue', () => { + const getWrapperAtWidth = ( width: number, dynamicContent: DynamicContent = null, tracker: Tracker = null, timer: Timer = null ): VueWrapper => { + Object.defineProperty( window, 'innerWidth', { writable: true, configurable: true, value: width } ); + return mount( FallbackBanner, { + props: { + bannerState: BannerStates.Pending, + useOfFundsContent, + donationLink: 'https://spenden.wikimedia.de' + }, + global: { + mocks: { + $translate: translator + }, + provide: { + translator: { translate: translator }, + dynamicCampaignText: dynamicContent ?? newDynamicContent(), + tracker: tracker ?? new TrackerStub(), + timer: timer ?? new TimerStub() + } + } + } ); + }; + + test.each( [ + [ 'showsTheSmallBanner' ], + [ 'showsTheLargeBanner' ], + [ 'emitsTheBannerCloseEvent' ], + [ 'playsTheSlideshowWhenBecomesVisible' ], + [ 'showsUseOfFundsFromSmallBanner' ], + [ 'hidesUseOfFundsFromSmallBanner' ], + [ 'showsUseOfFundsFromLargeBanner' ], + [ 'hidesUseOfFundsFromLargeBanner' ] + ] )( '%s', async ( testName: string ) => { + await fallbackBannerFeatures[ testName ]( getWrapperAtWidth ); + } ); + + test.each( [ + [ 'showsLiveTimeInLargeBanner' ] + ] )( '%s', async ( testName: string ) => { + await dynamicContentFeatures[ testName ]( getWrapperAtWidth ); + } ); + + test.each( [ + [ 'submitsFromLargeBanner' ], + [ 'submitsFromSmallBanner' ] + ] )( '%s', async ( testName: string ) => { + await submitFeatures[ testName ]( getWrapperAtWidth ); + } ); +} ); From 9246b0913bd1e154fa2a22bac395d08dc5aaf609 Mon Sep 17 00:00:00 2001 From: Gabriel Birke Date: Fri, 6 Dec 2024 16:15:18 +0100 Subject: [PATCH 2/4] Prepare CTRL for C24_WMDE_Desktop_EN_06 - Add `modalOpened` and `modalClosed` events to use of funds. - Reset VAR files Ticket: https://phabricator.wikimedia.org/T381396 --- .../C24_WMDE_Desktop_EN_06/banner_var.ts | 2 +- .../components/BannerCtrl.vue | 22 +++++++--- .../components/BannerVar.vue | 41 +++++++++++-------- .../C24_WMDE_Desktop_EN_06/messages_var.ts | 28 ------------- .../styles/styles_var.scss | 2 +- .../components/BannerVar.spec.ts | 5 +-- 6 files changed, 45 insertions(+), 55 deletions(-) delete mode 100644 banners/english/C24_WMDE_Desktop_EN_06/messages_var.ts diff --git a/banners/english/C24_WMDE_Desktop_EN_06/banner_var.ts b/banners/english/C24_WMDE_Desktop_EN_06/banner_var.ts index 9883c3e6d..a43bf7aaa 100644 --- a/banners/english/C24_WMDE_Desktop_EN_06/banner_var.ts +++ b/banners/english/C24_WMDE_Desktop_EN_06/banner_var.ts @@ -17,7 +17,7 @@ import DynamicTextPlugin from '@src/DynamicTextPlugin'; import { LocalImpressionCount } from '@src/utils/LocalImpressionCount'; import { LegacyTrackerWPORG } from '@src/tracking/LegacyTrackerWPORG'; import { Locales } from '@src/domain/Locales'; -import messages from './messages_var'; +import messages from './messages'; import { LocaleFactoryEn } from '@src/utils/LocaleFactory/LocaleFactoryEn'; import { createFormItems } from './form_items'; import { createFormActions } from '@src/createFormActions'; diff --git a/banners/english/C24_WMDE_Desktop_EN_06/components/BannerCtrl.vue b/banners/english/C24_WMDE_Desktop_EN_06/components/BannerCtrl.vue index d5f616146..32ae64f83 100644 --- a/banners/english/C24_WMDE_Desktop_EN_06/components/BannerCtrl.vue +++ b/banners/english/C24_WMDE_Desktop_EN_06/components/BannerCtrl.vue @@ -56,7 +56,7 @@ @@ -70,10 +70,10 @@ @time-out-close="() => onClose( 'SoftClose', CloseChoices.TimeOut )" /> - @@ -74,10 +70,10 @@ @time-out-close="() => onClose( 'SoftClose', CloseChoices.TimeOut )" /> -