@internetarchive/donation-form 0.5.8 → 0.5.9-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/braintree-manager/braintree-interfaces.d.ts +6 -0
- package/dist/src/braintree-manager/braintree-interfaces.js.map +1 -1
- package/dist/src/braintree-manager/braintree-manager.d.ts +4 -1
- package/dist/src/braintree-manager/braintree-manager.js +11 -0
- package/dist/src/braintree-manager/braintree-manager.js.map +1 -1
- package/dist/src/braintree-manager/payment-providers/credit-card/credit-card-interface.d.ts +6 -0
- package/dist/src/braintree-manager/payment-providers/credit-card/credit-card-interface.js.map +1 -1
- package/dist/src/braintree-manager/payment-providers/credit-card/credit-card.d.ts +12 -2
- package/dist/src/braintree-manager/payment-providers/credit-card/credit-card.js +60 -8
- package/dist/src/braintree-manager/payment-providers/credit-card/credit-card.js.map +1 -1
- package/dist/src/braintree-manager/payment-providers/credit-card/hosted-field-container.d.ts +18 -5
- package/dist/src/braintree-manager/payment-providers/credit-card/hosted-field-container.js +15 -0
- package/dist/src/braintree-manager/payment-providers/credit-card/hosted-field-container.js.map +1 -1
- package/dist/src/braintree-manager/payment-providers-interface.d.ts +4 -1
- package/dist/src/braintree-manager/payment-providers-interface.js.map +1 -1
- package/dist/src/braintree-manager/payment-providers.d.ts +4 -1
- package/dist/src/braintree-manager/payment-providers.js +13 -1
- package/dist/src/braintree-manager/payment-providers.js.map +1 -1
- package/dist/src/donation-form-controller.js +12 -0
- package/dist/src/donation-form-controller.js.map +1 -1
- package/dist/src/util/promisedSleep.d.ts +1 -0
- package/dist/src/util/promisedSleep.js +4 -0
- package/dist/src/util/promisedSleep.js.map +1 -0
- package/dist/test/mocks/mock-braintree-manager.d.ts +4 -1
- package/dist/test/mocks/mock-braintree-manager.js +5 -0
- package/dist/test/mocks/mock-braintree-manager.js.map +1 -1
- package/dist/test/mocks/mock-hosted-fields-container.d.ts +2 -0
- package/dist/test/mocks/mock-hosted-fields-container.js +6 -0
- package/dist/test/mocks/mock-hosted-fields-container.js.map +1 -1
- package/dist/test/mocks/payment-providers/individual-providers/mock-creditcard-handler.d.ts +4 -1
- package/dist/test/mocks/payment-providers/individual-providers/mock-creditcard-handler.js +5 -0
- package/dist/test/mocks/payment-providers/individual-providers/mock-creditcard-handler.js.map +1 -1
- package/dist/test/mocks/payment-providers/mock-payment-providers.d.ts +4 -1
- package/dist/test/mocks/payment-providers/mock-payment-providers.js +5 -0
- package/dist/test/mocks/payment-providers/mock-payment-providers.js.map +1 -1
- package/dist/test/tests/donation-form-controller.test.js +1 -1
- package/dist/test/tests/donation-form-controller.test.js.map +1 -1
- package/dist/test/tests/donation-form.test.js +1 -1
- package/dist/test/tests/donation-form.test.js.map +1 -1
- package/dist/test/tests/form-elements/payment-selector.test.js +1 -1
- package/dist/test/tests/form-elements/payment-selector.test.js.map +1 -1
- package/dist/test/tests/payment-providers/creditcard.test.js +101 -0
- package/dist/test/tests/payment-providers/creditcard.test.js.map +1 -1
- package/package.json +2 -1
- package/src/braintree-manager/braintree-interfaces.ts +11 -0
- package/src/braintree-manager/braintree-manager.ts +19 -0
- package/src/braintree-manager/payment-providers/credit-card/credit-card-interface.ts +10 -0
- package/src/braintree-manager/payment-providers/credit-card/credit-card.ts +79 -12
- package/src/braintree-manager/payment-providers/credit-card/hosted-field-container.ts +35 -8
- package/src/braintree-manager/payment-providers-interface.ts +12 -1
- package/src/braintree-manager/payment-providers.ts +22 -2
- package/src/donation-form-controller.ts +17 -3
- package/src/util/promisedSleep.ts +3 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"donation-form-controller.js","sourceRoot":"","sources":["../../src/donation-form-controller.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAkC,MAAM,KAAK,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,QAAQ,MAAM,aAAa,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ropertyValues, TemplateResult } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\n\nimport currency from 'currency.js';\nimport {\n LazyLoaderService,\n LazyLoaderServiceInterface,\n} from '@internetarchive/lazy-loader-service';\nimport { ModalManagerInterface } from '@internetarchive/modal-manager';\n\nimport { DonationForm } from './donation-form';\nimport { PaymentClients, PaymentClientsInterface } from './braintree-manager/payment-clients';\nimport { BraintreeManager } from './braintree-manager/braintree-manager';\nimport {\n BraintreeEndpointManagerInterface,\n BraintreeManagerInterface,\n HostingEnvironment,\n} from './braintree-manager/braintree-interfaces';\nimport {\n PaymentFlowHandlers,\n PaymentFlowHandlersInterface,\n} from './payment-flow-handlers/payment-flow-handlers';\n\nimport { RecaptchaManager, RecaptchaManagerInterface } from './recaptcha-manager/recaptcha-manager';\nimport { HostedFieldConfiguration } from './braintree-manager/payment-providers/credit-card/hosted-field-configuration';\nimport {\n HostedFieldContainerInterface,\n HostedFieldContainer,\n} from './braintree-manager/payment-providers/credit-card/hosted-field-container';\n\nimport './form-elements/badged-input';\nimport { ContactForm } from './form-elements/contact-form/contact-form';\nimport './form-elements/contact-form/contact-form';\n\nimport creditCardImg from '@internetarchive/icon-credit-card';\nimport calendarImg from '@internetarchive/icon-calendar';\nimport lockImg from '@internetarchive/icon-lock';\nimport { AnalyticsHandlerInterface } from './@types/analytics-handler';\nimport {\n EditDonationAmountSelectionLayout,\n EditDonationFrequencySelectionMode,\n} from '@internetarchive/donation-form-edit-donation';\n\nimport {\n DonationPaymentInfo,\n PaymentProvider,\n DonationType,\n defaultDonationAmounts,\n defaultSelectedDonationInfo,\n} from '@internetarchive/donation-form-data-models';\nimport { UpsellModalCTAMode } from './modals/upsell-modal-content';\n\n/**\n * The DonationFormController orchestrates several of the interactions between\n * the various pieces of the donation form like modals, braintree, paypal, and recaptcha\n *\n * @export\n * @class RadioPlayerController\n * @extends {LitElement}\n */\n@customElement('donation-form-controller')\nexport class DonationFormController extends LitElement {\n @property({ type: String }) environment?: HostingEnvironment;\n\n @property({ type: String }) braintreeAuthToken?: string;\n\n @property({ type: String }) recaptchaSiteKey?: string;\n\n @property({ type: String }) venmoProfileId?: string;\n\n @property({ type: String }) googlePayMerchantId?: string;\n\n @property({ type: String }) analyticsCategory = 'DonationForm';\n\n @property({ type: Array }) amountOptions: number[] = defaultDonationAmounts;\n\n @property({ type: Object }) donationInfo: DonationPaymentInfo = defaultSelectedDonationInfo;\n\n @property({ type: String }) amountSelectionLayout: EditDonationAmountSelectionLayout =\n EditDonationAmountSelectionLayout.MultiLine;\n\n @property({ type: String }) frequencySelectionMode: EditDonationFrequencySelectionMode =\n EditDonationFrequencySelectionMode.Button;\n\n @property({ type: String }) referrer?: string;\n\n @property({ type: String }) loggedInUser?: string;\n\n @property({ type: String }) origin?: string;\n\n @property({ type: Object }) endpointManager?: BraintreeEndpointManagerInterface;\n\n @property({ type: Object }) analyticsHandler?: AnalyticsHandlerInterface;\n\n @property({ type: Object }) modalManager?: ModalManagerInterface;\n\n @property({ type: Object }) recaptchaElement?: HTMLElement;\n\n @property({ type: Object }) braintreeManager?: BraintreeManagerInterface;\n\n @property({ type: Object }) recaptchaManager?: RecaptchaManagerInterface;\n\n @property({ type: Object }) paymentFlowHandlers?: PaymentFlowHandlersInterface;\n\n @property({ type: Object }) paymentClients?: PaymentClientsInterface;\n\n @property({ type: Object })\n lazyLoaderService: LazyLoaderServiceInterface = new LazyLoaderService();\n\n @query('donation-form') private donationForm!: DonationForm;\n\n @query('#braintree-creditcard') private braintreeNumberInput!: HTMLInputElement;\n\n @query('#braintree-cvv') private braintreeCVVInput!: HTMLInputElement;\n\n @query('#braintree-expiration') private braintreeExpirationDateInput!: HTMLInputElement;\n\n @query('#braintree-error-message') private braintreeErrorMessage!: HTMLDivElement;\n\n @query('contact-form') private contactForm?: ContactForm;\n\n /** @inheritdoc */\n updated(changedProperties: PropertyValues): void {\n if (changedProperties.has('referrer') && this.referrer) {\n this.braintreeManager?.setReferrer(this.referrer);\n }\n\n if (changedProperties.has('loggedInUser') && this.loggedInUser) {\n this.braintreeManager?.setLoggedInUser(this.loggedInUser);\n }\n\n if (changedProperties.has('origin') && this.origin) {\n this.braintreeManager?.setOrigin(this.origin);\n }\n\n if (\n changedProperties.has('paymentClients') ||\n changedProperties.has('braintreeAuthToken') ||\n changedProperties.has('endpointManager') ||\n changedProperties.has('environment')\n ) {\n this.setupBraintreeManager();\n this.setupRecaptchaManager();\n }\n\n if (changedProperties.has('recaptchaSiteKey')) {\n this.setupRecaptchaManager();\n }\n\n if (\n changedProperties.has('braintreeManager') ||\n changedProperties.has('recaptchaManager') ||\n changedProperties.has('modalManager') ||\n changedProperties.has('recaptchaElement')\n ) {\n this.setupPaymentFlowHandlers();\n }\n\n if (\n (changedProperties.has('environment') || changedProperties.has('lazyLoaderService')) &&\n this.environment\n ) {\n this.paymentClients = new PaymentClients(this.lazyLoaderService, this.environment);\n }\n }\n\n async showUpsellModalDev(options: {\n oneTimeAmount: number;\n ctaMode?: UpsellModalCTAMode;\n yesSelected?: (amount: number) => void;\n noSelected?: () => void;\n amountChanged?: (amount: number) => void;\n userClosedModalCallback?: () => void;\n }): Promise<void> {\n this.donationForm.showUpsellModalDev(options);\n }\n\n private setupBraintreeManager(): void {\n if (\n this.braintreeManager === undefined &&\n this.braintreeAuthToken &&\n this.endpointManager &&\n this.paymentClients &&\n this.environment\n ) {\n this.braintreeManager = new BraintreeManager({\n paymentClients: this.paymentClients,\n endpointManager: this.endpointManager,\n authorizationToken: this.braintreeAuthToken,\n venmoProfileId: this.venmoProfileId,\n googlePayMerchantId: this.googlePayMerchantId,\n hostedFieldConfig: this.hostedFieldConfig,\n hostingEnvironment: this.environment,\n referrer: this.referrer,\n loggedInUser: this.loggedInUser,\n origin: this.origin,\n });\n }\n }\n\n private recaptchaManagerSetup = false;\n\n private async setupRecaptchaManager(): Promise<void> {\n if (!this.recaptchaSiteKey || !this.paymentClients || this.recaptchaManagerSetup) {\n return;\n }\n this.recaptchaManagerSetup = true;\n const grecaptchaLibrary = await this.paymentClients.recaptchaLibrary.get();\n this.recaptchaManager = new RecaptchaManager({\n grecaptchaLibrary: grecaptchaLibrary,\n siteKey: this.recaptchaSiteKey,\n });\n }\n\n /** @inheritdoc */\n firstUpdated(): void {\n this.configureFromQueryParams();\n this.trackViewedEvent();\n }\n\n private configureFromQueryParams(): void {\n const urlParams = new URLSearchParams(window.location.search);\n\n let amountOptions = this.amountOptions;\n const amountOptionsParam = urlParams.get('dollarAmounts');\n if (amountOptionsParam) {\n const stripBrackets = amountOptionsParam.slice(1, -1);\n const splitValues = stripBrackets.split(',');\n const numberArray = splitValues\n .map(value => parseFloat(value))\n .filter(value => !isNaN(value));\n amountOptions = numberArray;\n }\n\n let coverFees = this.donationInfo.coverFees;\n const coverFeesParam = urlParams.get('coverFees');\n if (coverFeesParam) {\n coverFees = coverFeesParam === 'true';\n }\n\n let frequency = this.donationInfo.donationType;\n const frequencyParam = urlParams.get('contrib_type');\n if (frequencyParam === 'monthly') {\n frequency = DonationType.Monthly;\n }\n\n let amount = this.donationInfo.amount;\n const amountParam = urlParams.get('amt');\n if (amountParam) {\n const parsedAmount = currency(amountParam).value;\n if (parsedAmount > 0) {\n amount = parsedAmount;\n }\n }\n\n const amountLayoutParam = urlParams.get('amountLayout');\n if (amountLayoutParam) {\n const amountLayout = amountLayoutParam as EditDonationAmountSelectionLayout;\n if (Object.values(EditDonationAmountSelectionLayout).includes(amountLayout)) {\n this.amountSelectionLayout = amountLayout;\n }\n }\n\n const frequencyModeParam = urlParams.get('frequencyMode');\n if (frequencyModeParam) {\n const frequencyMode = frequencyModeParam as EditDonationFrequencySelectionMode;\n if (Object.values(EditDonationFrequencySelectionMode).includes(frequencyMode)) {\n this.frequencySelectionMode = frequencyMode;\n }\n }\n\n const donationInfo = new DonationPaymentInfo({\n donationType: frequency,\n amount: amount,\n coverFees: coverFees,\n });\n\n this.amountOptions = amountOptions;\n this.donationInfo = donationInfo;\n }\n\n private setupPaymentFlowHandlers(): void {\n // only set up once\n if (this.paymentFlowHandlers) {\n return;\n }\n\n // verify we have all of the dependencies\n if (\n !this.braintreeManager ||\n !this.recaptchaManager ||\n !this.modalManager ||\n !this.recaptchaElement\n ) {\n return;\n }\n\n this.paymentFlowHandlers = new PaymentFlowHandlers({\n braintreeManager: this.braintreeManager,\n modalManager: this.modalManager,\n recaptchaManager: this.recaptchaManager,\n });\n\n this.donationForm.braintreeManager = this.braintreeManager;\n this.donationForm.paymentFlowHandlers = this.paymentFlowHandlers;\n\n this.braintreeManager.startup();\n this.paymentFlowHandlers.startup();\n this.recaptchaManager.setup(this.recaptchaElement, 1, 'light', 'image');\n }\n\n private get hostedFieldConfig(): HostedFieldConfiguration {\n const hostedFieldStyle: Record<string, Record<string, string>> = {\n input: {\n 'font-size': '16px',\n 'font-family': '\"Helvetica Neue\", Helvetica, Arial, sans-serif',\n 'font-weight': '700',\n color: '#333',\n },\n ':focus': {\n color: '#333',\n },\n '.valid': {},\n '.invalid': {\n color: '#b00b00',\n },\n };\n\n const hostedFieldFieldOptions: braintree.HostedFieldFieldOptions = {\n number: {\n selector: '#braintree-creditcard',\n placeholder: 'Card number',\n },\n cvv: {\n selector: '#braintree-cvv',\n placeholder: 'CVC',\n },\n expirationDate: {\n selector: '#braintree-expiration',\n placeholder: 'MM / YY',\n },\n };\n\n const hostedFieldContainer: HostedFieldContainerInterface = new HostedFieldContainer({\n number: this.braintreeNumberInput,\n cvv: this.braintreeCVVInput,\n expirationDate: this.braintreeExpirationDateInput,\n errorContainer: this.braintreeErrorMessage,\n });\n\n const config: HostedFieldConfiguration = new HostedFieldConfiguration({\n hostedFieldStyle,\n hostedFieldFieldOptions,\n hostedFieldContainer,\n });\n\n return config;\n }\n\n /** @inheritdoc */\n render(): TemplateResult {\n return html`\n <div class=\"donation-form-controller-container\">\n <donation-form\n .environment=${this.environment}\n .braintreeManager=${this.braintreeManager}\n .contactForm=${this.contactForm}\n .amountOptions=${this.amountOptions}\n .donationInfo=${this.donationInfo}\n .amountSelectionLayout=${this.amountSelectionLayout}\n .frequencySelectionMode=${this.frequencySelectionMode}\n @donationInfoChanged=${this.donationInfoChanged}\n @paymentProviderSelected=${this.paymentProviderSelected}\n @paymentFlowStarted=${this.paymentFlowStarted}\n @paymentFlowCancelled=${this.paymentFlowCancelled}\n @paymentFlowError=${this.paymentFlowError}\n >\n <!--\n Why are these slots here?\n\n Due to the way Braintree, PayPal, and Recaptcha work, they cannot exist\n in the shadowDOM so must exist in the clearDOM and get passed\n in through a <slot>.\n\n Braintree / PayPal are working on a solution to this. See:\n - https://github.com/braintree/braintree-web-drop-in/issues/614#issuecomment-616796104\n - https://github.com/braintree/braintree-web-drop-in/issues/296#issuecomment-616749307\n - https://github.com/paypal/paypal-checkout-components/issues/353#issuecomment-595956216\n -->\n <div slot=\"braintree-hosted-fields\">\n <div id=\"braintree-error-message\"></div>\n <div class=\"braintree-row\">\n <badged-input .icon=${creditCardImg} ?required=${true} class=\"creditcard\">\n <div class=\"braintree-input\" id=\"braintree-creditcard\"></div>\n </badged-input>\n </div>\n <div class=\"braintree-row\">\n <badged-input .icon=${calendarImg} ?required=${true} class=\"expiration\">\n <div class=\"braintree-input\" id=\"braintree-expiration\"></div>\n </badged-input>\n <badged-input .icon=${lockImg} ?required=${true} class=\"cvv\">\n <div class=\"braintree-input\" id=\"braintree-cvv\"></div>\n </badged-input>\n </div>\n </div>\n\n <!--\n Form autocompletion does not work in the shadowDOM so\n we slot the contact form in from the lightDOM and pass\n in a reference to it in the <donation-form> tag above\n -->\n <div slot=\"contact-form\">\n <contact-form></contact-form>\n </div>\n\n <div slot=\"paypal-button\">\n <div id=\"paypal-button\"></div>\n </div>\n\n <slot name=\"recaptcha\" slot=\"recaptcha\"> </slot>\n </donation-form>\n </div>\n\n ${this.getStyles}\n `;\n }\n\n /** @inheritdoc */\n createRenderRoot(): this {\n // Render template without shadow DOM. Note that shadow DOM features like\n // encapsulated CSS and slots are unavailable.\n // We have to do this to accomodate the PayPal buttons and HostedFields,\n // which do not work in the shadow DOM\n return this;\n }\n\n private donationInfoChanged(): void {\n this.logEvent('DonationInfoChanged');\n }\n\n private trackViewedEvent(): void {\n this.logEvent('Viewed');\n }\n\n private paymentProviderSelected(e: CustomEvent): void {\n const paymentProvider = e.detail.paymentProvider as PaymentProvider;\n const previousPaymentProvider = e.detail.previousPaymentProvider;\n const providerNoSpaces = this.removeSpaces(paymentProvider);\n let eventName = `ProviderFirstSelected-${providerNoSpaces}`;\n let previousProviderInfo;\n if (previousPaymentProvider !== undefined) {\n eventName = `ProviderChangedTo-${providerNoSpaces}`;\n previousProviderInfo = `ProviderChangedFrom-${this.removeSpaces(previousPaymentProvider)}`;\n }\n this.logEvent(eventName, previousProviderInfo);\n }\n\n private paymentFlowStarted(e: CustomEvent): void {\n const selectedProvider = e.detail.paymentProvider as PaymentProvider;\n const providerNoSpaces = this.removeSpaces(selectedProvider);\n this.logEvent('PaymentFlowStarted', providerNoSpaces);\n }\n\n private paymentFlowCancelled(e: CustomEvent): void {\n const selectedProvider = e.detail.paymentProvider as PaymentProvider;\n const providerNoSpaces = this.removeSpaces(selectedProvider);\n this.logEvent('PaymentFlowCancelled', providerNoSpaces);\n }\n\n private paymentFlowError(e: CustomEvent): void {\n const selectedProvider = e.detail.paymentProvider as PaymentProvider;\n const providerNoSpaces = this.removeSpaces(selectedProvider);\n const error = e.detail.error;\n const detail = `${providerNoSpaces}-${error}`;\n this.logEvent('PaymentFlowError', detail);\n }\n\n private removeSpaces(original: string): string {\n return original.replace(/\\s+/g, '');\n }\n\n /**\n * Log an event\n *\n * @param {string} name Name of event\n * @param {string} label Event label, optional\n */\n private logEvent(name: string, label?: string): void {\n this.analyticsHandler?.send_event(this.analyticsCategory, name, label);\n }\n\n /**\n * This is not the normal LitElement styles block.\n *\n * This element uses the clear DOM instead of the shadow DOM, it can't use\n * the shadowRoot's isolated styling. This is a bit of a workaround to keep all of\n * the styling local by writing out our own <style> tag and just be careful about\n * the selectors since they will leak outside of this component.\n *\n * @readonly\n * @private\n * @type {TemplateResult}\n * @memberof IADonationFormController\n */\n private get getStyles(): TemplateResult {\n return html`\n <style>\n .donation-form-controller-container donation-form:focus {\n outline: none;\n }\n\n .donation-form-controller-container #paypal-button {\n opacity: 0.001;\n width: 5rem;\n height: 3rem;\n overflow: hidden;\n }\n\n .donation-form-controller-container .braintree-row {\n display: flex;\n margin-top: -1px;\n }\n\n .donation-form-controller-container badged-input {\n width: 100%;\n }\n\n .donation-form-controller-container badged-input.cvv {\n margin-left: -1px;\n }\n\n .donation-form-controller-container .braintree-input {\n width: 100%;\n height: 100%;\n }\n\n .donation-form-controller-container #braintree-error-message {\n color: red;\n font-size: 1.4rem;\n margin-bottom: 0.6rem;\n }\n </style>\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"donation-form-controller.js","sourceRoot":"","sources":["../../src/donation-form-controller.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAkC,MAAM,KAAK,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,EACL,iBAAiB,GAElB,MAAM,sCAAsC,CAAC;AAI9C,OAAO,EAAE,cAAc,EAA2B,MAAM,qCAAqC,CAAC;AAC9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAMzE,OAAO,EACL,mBAAmB,GAEpB,MAAM,+CAA+C,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAA6B,MAAM,uCAAuC,CAAC;AACpG,OAAO,EAAE,wBAAwB,EAAE,MAAM,8EAA8E,CAAC;AACxH,OAAO,EAEL,oBAAoB,GACrB,MAAM,0EAA0E,CAAC;AAElF,OAAO,8BAA8B,CAAC;AAEtC,OAAO,2CAA2C,CAAC;AAEnD,OAAO,aAAa,MAAM,mCAAmC,CAAC;AAC9D,OAAO,WAAW,MAAM,gCAAgC,CAAC;AACzD,OAA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ourcesContent":["import { LitElement, html, PropertyValues, TemplateResult } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\n\nimport currency from 'currency.js';\nimport {\n LazyLoaderService,\n LazyLoaderServiceInterface,\n} from '@internetarchive/lazy-loader-service';\nimport { ModalManagerInterface } from '@internetarchive/modal-manager';\n\nimport { DonationForm } from './donation-form';\nimport { PaymentClients, PaymentClientsInterface } from './braintree-manager/payment-clients';\nimport { BraintreeManager } from './braintree-manager/braintree-manager';\nimport {\n BraintreeEndpointManagerInterface,\n BraintreeManagerInterface,\n HostingEnvironment,\n} from './braintree-manager/braintree-interfaces';\nimport {\n PaymentFlowHandlers,\n PaymentFlowHandlersInterface,\n} from './payment-flow-handlers/payment-flow-handlers';\n\nimport { RecaptchaManager, RecaptchaManagerInterface } from './recaptcha-manager/recaptcha-manager';\nimport { HostedFieldConfiguration } from './braintree-manager/payment-providers/credit-card/hosted-field-configuration';\nimport {\n HostedFieldContainerInterface,\n HostedFieldContainer,\n} from './braintree-manager/payment-providers/credit-card/hosted-field-container';\n\nimport './form-elements/badged-input';\nimport { ContactForm } from './form-elements/contact-form/contact-form';\nimport './form-elements/contact-form/contact-form';\n\nimport creditCardImg from '@internetarchive/icon-credit-card';\nimport calendarImg from '@internetarchive/icon-calendar';\nimport lockImg from '@internetarchive/icon-lock';\nimport { AnalyticsHandlerInterface } from './@types/analytics-handler';\nimport {\n EditDonationAmountSelectionLayout,\n EditDonationFrequencySelectionMode,\n} from '@internetarchive/donation-form-edit-donation';\n\nimport {\n DonationPaymentInfo,\n PaymentProvider,\n DonationType,\n defaultDonationAmounts,\n defaultSelectedDonationInfo,\n} from '@internetarchive/donation-form-data-models';\nimport { UpsellModalCTAMode } from './modals/upsell-modal-content';\n\n/**\n * The DonationFormController orchestrates several of the interactions between\n * the various pieces of the donation form like modals, braintree, paypal, and recaptcha\n *\n * @export\n * @class RadioPlayerController\n * @extends {LitElement}\n */\n@customElement('donation-form-controller')\nexport class DonationFormController extends LitElement {\n @property({ type: String }) environment?: HostingEnvironment;\n\n @property({ type: String }) braintreeAuthToken?: string;\n\n @property({ type: String }) recaptchaSiteKey?: string;\n\n @property({ type: String }) venmoProfileId?: string;\n\n @property({ type: String }) googlePayMerchantId?: string;\n\n @property({ type: String }) analyticsCategory = 'DonationForm';\n\n @property({ type: Array }) amountOptions: number[] = defaultDonationAmounts;\n\n @property({ type: Object }) donationInfo: DonationPaymentInfo = defaultSelectedDonationInfo;\n\n @property({ type: String }) amountSelectionLayout: EditDonationAmountSelectionLayout =\n EditDonationAmountSelectionLayout.MultiLine;\n\n @property({ type: String }) frequencySelectionMode: EditDonationFrequencySelectionMode =\n EditDonationFrequencySelectionMode.Button;\n\n @property({ type: String }) referrer?: string;\n\n @property({ type: String }) loggedInUser?: string;\n\n @property({ type: String }) origin?: string;\n\n @property({ type: Object }) endpointManager?: BraintreeEndpointManagerInterface;\n\n @property({ type: Object }) analyticsHandler?: AnalyticsHandlerInterface;\n\n @property({ type: Object }) modalManager?: ModalManagerInterface;\n\n @property({ type: Object }) recaptchaElement?: HTMLElement;\n\n @property({ type: Object }) braintreeManager?: BraintreeManagerInterface;\n\n @property({ type: Object }) recaptchaManager?: RecaptchaManagerInterface;\n\n @property({ type: Object }) paymentFlowHandlers?: PaymentFlowHandlersInterface;\n\n @property({ type: Object }) paymentClients?: PaymentClientsInterface;\n\n @property({ type: Object })\n lazyLoaderService: LazyLoaderServiceInterface = new LazyLoaderService();\n\n @query('donation-form') private donationForm!: DonationForm;\n\n @query('#braintree-creditcard') private braintreeNumberInput!: HTMLDivElement;\n\n @query('#braintree-cvv') private braintreeCVVInput!: HTMLDivElement;\n\n @query('#braintree-expiration') private braintreeExpirationDateInput!: HTMLDivElement;\n\n @query('#braintree-error-message') private braintreeErrorMessage!: HTMLDivElement;\n\n @query('contact-form') private contactForm?: ContactForm;\n\n /** @inheritdoc */\n updated(changedProperties: PropertyValues): void {\n if (changedProperties.has('referrer') && this.referrer) {\n this.braintreeManager?.setReferrer(this.referrer);\n }\n\n if (changedProperties.has('loggedInUser') && this.loggedInUser) {\n this.braintreeManager?.setLoggedInUser(this.loggedInUser);\n }\n\n if (changedProperties.has('origin') && this.origin) {\n this.braintreeManager?.setOrigin(this.origin);\n }\n\n if (\n changedProperties.has('paymentClients') ||\n changedProperties.has('braintreeAuthToken') ||\n changedProperties.has('endpointManager') ||\n changedProperties.has('environment')\n ) {\n this.setupBraintreeManager();\n this.setupRecaptchaManager();\n }\n\n if (changedProperties.has('recaptchaSiteKey')) {\n this.setupRecaptchaManager();\n }\n\n if (\n changedProperties.has('braintreeManager') ||\n changedProperties.has('recaptchaManager') ||\n changedProperties.has('modalManager') ||\n changedProperties.has('recaptchaElement')\n ) {\n this.setupPaymentFlowHandlers();\n }\n\n if (\n (changedProperties.has('environment') || changedProperties.has('lazyLoaderService')) &&\n this.environment\n ) {\n this.paymentClients = new PaymentClients(this.lazyLoaderService, this.environment);\n }\n }\n\n async showUpsellModalDev(options: {\n oneTimeAmount: number;\n ctaMode?: UpsellModalCTAMode;\n yesSelected?: (amount: number) => void;\n noSelected?: () => void;\n amountChanged?: (amount: number) => void;\n userClosedModalCallback?: () => void;\n }): Promise<void> {\n this.donationForm.showUpsellModalDev(options);\n }\n\n private setupBraintreeManager(): void {\n if (\n this.braintreeManager === undefined &&\n this.braintreeAuthToken &&\n this.endpointManager &&\n this.paymentClients &&\n this.environment\n ) {\n this.braintreeManager = new BraintreeManager({\n paymentClients: this.paymentClients,\n endpointManager: this.endpointManager,\n authorizationToken: this.braintreeAuthToken,\n venmoProfileId: this.venmoProfileId,\n googlePayMerchantId: this.googlePayMerchantId,\n hostedFieldConfig: this.hostedFieldConfig,\n hostingEnvironment: this.environment,\n referrer: this.referrer,\n loggedInUser: this.loggedInUser,\n origin: this.origin,\n });\n\n this.braintreeManager.on('paymentProvidersHostedFieldsRetry', (retryNumber: number) => {\n const event = new CustomEvent('paymentProvidersHostedFieldsRetry', {\n detail: { retryNumber },\n });\n this.dispatchEvent(event);\n });\n\n this.braintreeManager.on('paymentProvidersHostedFieldsFailed', (error: unknown) => {\n const event = new CustomEvent('paymentProvidersHostedFieldsFailed', {\n detail: { error },\n });\n this.dispatchEvent(event);\n });\n }\n }\n\n private recaptchaManagerSetup = false;\n\n private async setupRecaptchaManager(): Promise<void> {\n if (!this.recaptchaSiteKey || !this.paymentClients || this.recaptchaManagerSetup) {\n return;\n }\n this.recaptchaManagerSetup = true;\n const grecaptchaLibrary = await this.paymentClients.recaptchaLibrary.get();\n this.recaptchaManager = new RecaptchaManager({\n grecaptchaLibrary: grecaptchaLibrary,\n siteKey: this.recaptchaSiteKey,\n });\n }\n\n /** @inheritdoc */\n firstUpdated(): void {\n this.configureFromQueryParams();\n this.trackViewedEvent();\n }\n\n private configureFromQueryParams(): void {\n const urlParams = new URLSearchParams(window.location.search);\n\n let amountOptions = this.amountOptions;\n const amountOptionsParam = urlParams.get('dollarAmounts');\n if (amountOptionsParam) {\n const stripBrackets = amountOptionsParam.slice(1, -1);\n const splitValues = stripBrackets.split(',');\n const numberArray = splitValues\n .map(value => parseFloat(value))\n .filter(value => !isNaN(value));\n amountOptions = numberArray;\n }\n\n let coverFees = this.donationInfo.coverFees;\n const coverFeesParam = urlParams.get('coverFees');\n if (coverFeesParam) {\n coverFees = coverFeesParam === 'true';\n }\n\n let frequency = this.donationInfo.donationType;\n const frequencyParam = urlParams.get('contrib_type');\n if (frequencyParam === 'monthly') {\n frequency = DonationType.Monthly;\n }\n\n let amount = this.donationInfo.amount;\n const amountParam = urlParams.get('amt');\n if (amountParam) {\n const parsedAmount = currency(amountParam).value;\n if (parsedAmount > 0) {\n amount = parsedAmount;\n }\n }\n\n const amountLayoutParam = urlParams.get('amountLayout');\n if (amountLayoutParam) {\n const amountLayout = amountLayoutParam as EditDonationAmountSelectionLayout;\n if (Object.values(EditDonationAmountSelectionLayout).includes(amountLayout)) {\n this.amountSelectionLayout = amountLayout;\n }\n }\n\n const frequencyModeParam = urlParams.get('frequencyMode');\n if (frequencyModeParam) {\n const frequencyMode = frequencyModeParam as EditDonationFrequencySelectionMode;\n if (Object.values(EditDonationFrequencySelectionMode).includes(frequencyMode)) {\n this.frequencySelectionMode = frequencyMode;\n }\n }\n\n const donationInfo = new DonationPaymentInfo({\n donationType: frequency,\n amount: amount,\n coverFees: coverFees,\n });\n\n this.amountOptions = amountOptions;\n this.donationInfo = donationInfo;\n }\n\n private setupPaymentFlowHandlers(): void {\n // only set up once\n if (this.paymentFlowHandlers) {\n return;\n }\n\n // verify we have all of the dependencies\n if (\n !this.braintreeManager ||\n !this.recaptchaManager ||\n !this.modalManager ||\n !this.recaptchaElement\n ) {\n return;\n }\n\n this.paymentFlowHandlers = new PaymentFlowHandlers({\n braintreeManager: this.braintreeManager,\n modalManager: this.modalManager,\n recaptchaManager: this.recaptchaManager,\n });\n\n this.donationForm.braintreeManager = this.braintreeManager;\n this.donationForm.paymentFlowHandlers = this.paymentFlowHandlers;\n\n this.braintreeManager.startup();\n this.paymentFlowHandlers.startup();\n this.recaptchaManager.setup(this.recaptchaElement, 1, 'light', 'image');\n }\n\n private get hostedFieldConfig(): HostedFieldConfiguration {\n const hostedFieldStyle: Record<string, Record<string, string>> = {\n input: {\n 'font-size': '16px',\n 'font-family': '\"Helvetica Neue\", Helvetica, Arial, sans-serif',\n 'font-weight': '700',\n color: '#333',\n },\n ':focus': {\n color: '#333',\n },\n '.valid': {},\n '.invalid': {\n color: '#b00b00',\n },\n };\n\n const hostedFieldFieldOptions: braintree.HostedFieldFieldOptions = {\n number: {\n selector: '#braintree-creditcard',\n placeholder: 'Card number',\n },\n cvv: {\n selector: '#braintree-cvv',\n placeholder: 'CVC',\n },\n expirationDate: {\n selector: '#braintree-expiration',\n placeholder: 'MM / YY',\n },\n };\n\n const hostedFieldContainer: HostedFieldContainerInterface = new HostedFieldContainer({\n number: this.braintreeNumberInput,\n cvv: this.braintreeCVVInput,\n expirationDate: this.braintreeExpirationDateInput,\n errorContainer: this.braintreeErrorMessage,\n });\n\n const config: HostedFieldConfiguration = new HostedFieldConfiguration({\n hostedFieldStyle,\n hostedFieldFieldOptions,\n hostedFieldContainer,\n });\n\n return config;\n }\n\n /** @inheritdoc */\n render(): TemplateResult {\n return html`\n <div class=\"donation-form-controller-container\">\n <donation-form\n .environment=${this.environment}\n .braintreeManager=${this.braintreeManager}\n .contactForm=${this.contactForm}\n .amountOptions=${this.amountOptions}\n .donationInfo=${this.donationInfo}\n .amountSelectionLayout=${this.amountSelectionLayout}\n .frequencySelectionMode=${this.frequencySelectionMode}\n @donationInfoChanged=${this.donationInfoChanged}\n @paymentProviderSelected=${this.paymentProviderSelected}\n @paymentFlowStarted=${this.paymentFlowStarted}\n @paymentFlowCancelled=${this.paymentFlowCancelled}\n @paymentFlowError=${this.paymentFlowError}\n >\n <!--\n Why are these slots here?\n\n Due to the way Braintree, PayPal, and Recaptcha work, they cannot exist\n in the shadowDOM so must exist in the clearDOM and get passed\n in through a <slot>.\n\n Braintree / PayPal are working on a solution to this. See:\n - https://github.com/braintree/braintree-web-drop-in/issues/614#issuecomment-616796104\n - https://github.com/braintree/braintree-web-drop-in/issues/296#issuecomment-616749307\n - https://github.com/paypal/paypal-checkout-components/issues/353#issuecomment-595956216\n -->\n <div slot=\"braintree-hosted-fields\">\n <div id=\"braintree-error-message\"></div>\n <div class=\"braintree-row\">\n <badged-input .icon=${creditCardImg} ?required=${true} class=\"creditcard\">\n <div class=\"braintree-input\" id=\"braintree-creditcard\"></div>\n </badged-input>\n </div>\n <div class=\"braintree-row\">\n <badged-input .icon=${calendarImg} ?required=${true} class=\"expiration\">\n <div class=\"braintree-input\" id=\"braintree-expiration\"></div>\n </badged-input>\n <badged-input .icon=${lockImg} ?required=${true} class=\"cvv\">\n <div class=\"braintree-input\" id=\"braintree-cvv\"></div>\n </badged-input>\n </div>\n </div>\n\n <!--\n Form autocompletion does not work in the shadowDOM so\n we slot the contact form in from the lightDOM and pass\n in a reference to it in the <donation-form> tag above\n -->\n <div slot=\"contact-form\">\n <contact-form></contact-form>\n </div>\n\n <div slot=\"paypal-button\">\n <div id=\"paypal-button\"></div>\n </div>\n\n <slot name=\"recaptcha\" slot=\"recaptcha\"> </slot>\n </donation-form>\n </div>\n\n ${this.getStyles}\n `;\n }\n\n /** @inheritdoc */\n createRenderRoot(): this {\n // Render template without shadow DOM. Note that shadow DOM features like\n // encapsulated CSS and slots are unavailable.\n // We have to do this to accomodate the PayPal buttons and HostedFields,\n // which do not work in the shadow DOM\n return this;\n }\n\n private donationInfoChanged(): void {\n this.logEvent('DonationInfoChanged');\n }\n\n private trackViewedEvent(): void {\n this.logEvent('Viewed');\n }\n\n private paymentProviderSelected(e: CustomEvent): void {\n const paymentProvider = e.detail.paymentProvider as PaymentProvider;\n const previousPaymentProvider = e.detail.previousPaymentProvider;\n const providerNoSpaces = this.removeSpaces(paymentProvider);\n let eventName = `ProviderFirstSelected-${providerNoSpaces}`;\n let previousProviderInfo;\n if (previousPaymentProvider !== undefined) {\n eventName = `ProviderChangedTo-${providerNoSpaces}`;\n previousProviderInfo = `ProviderChangedFrom-${this.removeSpaces(previousPaymentProvider)}`;\n }\n this.logEvent(eventName, previousProviderInfo);\n }\n\n private paymentFlowStarted(e: CustomEvent): void {\n const selectedProvider = e.detail.paymentProvider as PaymentProvider;\n const providerNoSpaces = this.removeSpaces(selectedProvider);\n this.logEvent('PaymentFlowStarted', providerNoSpaces);\n }\n\n private paymentFlowCancelled(e: CustomEvent): void {\n const selectedProvider = e.detail.paymentProvider as PaymentProvider;\n const providerNoSpaces = this.removeSpaces(selectedProvider);\n this.logEvent('PaymentFlowCancelled', providerNoSpaces);\n }\n\n private paymentFlowError(e: CustomEvent): void {\n const selectedProvider = e.detail.paymentProvider as PaymentProvider;\n const providerNoSpaces = this.removeSpaces(selectedProvider);\n const error = e.detail.error;\n const detail = `${providerNoSpaces}-${error}`;\n this.logEvent('PaymentFlowError', detail);\n }\n\n private removeSpaces(original: string): string {\n return original.replace(/\\s+/g, '');\n }\n\n /**\n * Log an event\n *\n * @param {string} name Name of event\n * @param {string} label Event label, optional\n */\n private logEvent(name: string, label?: string): void {\n this.analyticsHandler?.send_event(this.analyticsCategory, name, label);\n }\n\n /**\n * This is not the normal LitElement styles block.\n *\n * This element uses the clear DOM instead of the shadow DOM, it can't use\n * the shadowRoot's isolated styling. This is a bit of a workaround to keep all of\n * the styling local by writing out our own <style> tag and just be careful about\n * the selectors since they will leak outside of this component.\n *\n * @readonly\n * @private\n * @type {TemplateResult}\n * @memberof IADonationFormController\n */\n private get getStyles(): TemplateResult {\n return html`\n <style>\n .donation-form-controller-container donation-form:focus {\n outline: none;\n }\n\n .donation-form-controller-container #paypal-button {\n opacity: 0.001;\n width: 5rem;\n height: 3rem;\n overflow: hidden;\n }\n\n .donation-form-controller-container .braintree-row {\n display: flex;\n margin-top: -1px;\n }\n\n .donation-form-controller-container badged-input {\n width: 100%;\n }\n\n .donation-form-controller-container badged-input.cvv {\n margin-left: -1px;\n }\n\n .donation-form-controller-container .braintree-input {\n width: 100%;\n height: 100%;\n }\n\n .donation-form-controller-container #braintree-error-message {\n color: red;\n font-size: 1.4rem;\n margin-bottom: 0.6rem;\n }\n </style>\n `;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function promisedSleep(ms: number): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promisedSleep.js","sourceRoot":"","sources":["../../../src/util/promisedSleep.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,aAAa,CAAC,EAAU;IACtC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AACzD,CAAC","sourcesContent":["export function promisedSleep(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms));\n}\n"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { BraintreeManagerInterface } from '../../src/braintree-manager/braintree-interfaces';
|
|
1
|
+
import { BraintreeManagerEvents, BraintreeManagerInterface } from '../../src/braintree-manager/braintree-interfaces';
|
|
2
2
|
import { PromisedSingleton } from '@internetarchive/promised-singleton';
|
|
3
3
|
import { PaymentProvider, DonationPaymentInfo, BillingInfo, DonationResponse, CustomerInfo, SuccessResponse } from '@internetarchive/donation-form-data-models';
|
|
4
4
|
import { PaymentProvidersInterface } from '../../src/braintree-manager/payment-providers-interface';
|
|
5
|
+
import { Unsubscribe } from 'nanoevents';
|
|
5
6
|
export declare class MockBraintreeManager implements BraintreeManagerInterface {
|
|
6
7
|
donationSuccessfulOptions?: {
|
|
7
8
|
successResponse: SuccessResponse;
|
|
@@ -13,6 +14,8 @@ export declare class MockBraintreeManager implements BraintreeManagerInterface {
|
|
|
13
14
|
submitDonationError?: boolean;
|
|
14
15
|
submitDonationResponse?: 'success' | 'failure';
|
|
15
16
|
});
|
|
17
|
+
private emitter;
|
|
18
|
+
on<E extends keyof BraintreeManagerEvents>(event: E, callback: BraintreeManagerEvents[E]): Unsubscribe;
|
|
16
19
|
paymentProviders: PaymentProvidersInterface;
|
|
17
20
|
instance: PromisedSingleton<import("../../src/@types/braintree-web").Client>;
|
|
18
21
|
setReferrer(referrer: string): void;
|
|
@@ -4,11 +4,13 @@ import { DonationResponse, SuccessResponse, ErrorResponse, } from '@internetarch
|
|
|
4
4
|
import { MockPaymentProviders } from './payment-providers/mock-payment-providers';
|
|
5
5
|
import { mockSuccessResponse } from './models/mock-success-response';
|
|
6
6
|
import { MockBraintreeClient } from './payment-clients/mock-braintree-client';
|
|
7
|
+
import { createNanoEvents } from 'nanoevents';
|
|
7
8
|
export class MockBraintreeManager {
|
|
8
9
|
constructor(options) {
|
|
9
10
|
var _a, _b;
|
|
10
11
|
this.submitDonationError = false;
|
|
11
12
|
this.submitDonationResponse = 'success';
|
|
13
|
+
this.emitter = createNanoEvents();
|
|
12
14
|
this.paymentProviders = new MockPaymentProviders();
|
|
13
15
|
this.instance = new PromisedSingleton({
|
|
14
16
|
generator: () => new Promise(resolve => {
|
|
@@ -18,6 +20,9 @@ export class MockBraintreeManager {
|
|
|
18
20
|
this.submitDonationError = (_a = options === null || options === void 0 ? void 0 : options.submitDonationError) !== null && _a !== void 0 ? _a : false;
|
|
19
21
|
this.submitDonationResponse = (_b = options === null || options === void 0 ? void 0 : options.submitDonationResponse) !== null && _b !== void 0 ? _b : 'success';
|
|
20
22
|
}
|
|
23
|
+
on(event, callback) {
|
|
24
|
+
return this.emitter.on(event, callback);
|
|
25
|
+
}
|
|
21
26
|
setReferrer(referrer) { }
|
|
22
27
|
setLoggedInUser(loggedInUser) { }
|
|
23
28
|
setOrigin(origin) { }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-braintree-manager.js","sourceRoot":"","sources":["../../../test/mocks/mock-braintree-manager.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"mock-braintree-manager.js","sourceRoot":"","sources":["../../../test/mocks/mock-braintree-manager.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAIL,gBAAgB,EAEhB,eAAe,EACf,aAAa,GACd,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAE9E,OAAO,EAAE,gBAAgB,EAAe,MAAM,YAAY,CAAC;AAE3D,MAAM,OAAO,oBAAoB;IAS/B,YAAY,OAGX;;QANO,wBAAmB,GAAG,KAAK,CAAC;QAC5B,2BAAsB,GAA0B,SAAS,CAAC;QAU1D,YAAO,GAAG,gBAAgB,EAA0B,CAAC;QAS7D,qBAAgB,GAA8B,IAAI,oBAAoB,EAAE,CAAC;QAEzE,aAAQ,GAAG,IAAI,iBAAiB,CAAmB;YACjD,SAAS,EAAE,GAA8B,EAAE,CACzC,IA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L,OAAO,IAAI,gBAAgB,CAAC;oBAC1B,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,IAAI,aAAa,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;iBAC/C,CAAC,CAAC;aACJ;QACH,CAAC;KAAA;IAEK,oBAAoB,CAAC,OAG1B;;YACC,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC;gBACpC,OAAO,EAAE,IAAI;gBACb,KAAK,EAAE,mBAAmB;aAC3B,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC;QAClB,CAAC;KAAA;IAED,kBAAkB,CAAC,OAGlB;QACC,IAAI,CAAC,yBAAyB,GAAG,OAAO,CAAC;IAC3C,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/camelcase */\n/* eslint-disable @typescript-eslint/no-empty-function */\n/* eslint-disable @typescript-eslint/no-unused-vars */\nimport {\n BraintreeManagerEvents,\n BraintreeManagerInterface,\n} from '../../src/braintree-manager/braintree-interfaces';\nimport { PromisedSingleton } from '@internetarchive/promised-singleton';\nimport {\n PaymentProvider,\n DonationPaymentInfo,\n BillingInfo,\n DonationResponse,\n CustomerInfo,\n SuccessResponse,\n ErrorResponse,\n} from '@internetarchive/donation-form-data-models';\nimport { MockPaymentProviders } from './payment-providers/mock-payment-providers';\nimport { mockSuccessResponse } from './models/mock-success-response';\nimport { MockBraintreeClient } from './payment-clients/mock-braintree-client';\nimport { PaymentProvidersInterface } from '../../src/braintree-manager/payment-providers-interface';\nimport { createNanoEvents, Unsubscribe } from 'nanoevents';\n\nexport class MockBraintreeManager implements BraintreeManagerInterface {\n donationSuccessfulOptions?: {\n successResponse: SuccessResponse;\n upsellSuccessResponse?: SuccessResponse | undefined;\n };\n\n private submitDonationError = false;\n private submitDonationResponse: 'success' | 'failure' = 'success';\n\n constructor(options?: {\n submitDonationError?: boolean;\n submitDonationResponse?: 'success' | 'failure';\n }) {\n this.submitDonationError = options?.submitDonationError ?? false;\n this.submitDonationResponse = options?.submitDonationResponse ?? 'success';\n }\n\n private emitter = createNanoEvents<BraintreeManagerEvents>();\n\n on<E extends keyof BraintreeManagerEvents>(\n event: E,\n callback: BraintreeManagerEvents[E],\n ): Unsubscribe {\n return this.emitter.on(event, callback);\n }\n\n paymentProviders: PaymentProvidersInterface = new MockPaymentProviders();\n\n instance = new PromisedSingleton<braintree.Client>({\n generator: (): Promise<braintree.Client> =>\n new Promise(resolve => {\n resolve(new MockBraintreeClient());\n }),\n });\n\n setReferrer(referrer: string): void {}\n\n setLoggedInUser(loggedInUser: string): void {}\n\n setOrigin(origin: string): void {}\n\n startup(): void {}\n\n async submitDonation(options: {\n nonce: string;\n paymentProvider: PaymentProvider;\n donationInfo: DonationPaymentInfo;\n billingInfo: BillingInfo;\n customerInfo: CustomerInfo;\n upsellOnetimeTransactionId?: string | undefined;\n customerId?: string | undefined;\n recaptchaToken?: string | undefined;\n bin?: string | undefined;\n binName?: string | undefined;\n }): Promise<DonationResponse> {\n if (this.submitDonationError) {\n throw 'oh no';\n }\n\n if (this.submitDonationResponse === 'success') {\n const response = new SuccessResponse({\n paymentMethodNonce: options.nonce,\n paymentProvider: options.paymentProvider,\n amount: options.donationInfo.amount,\n donationType: options.donationInfo.donationType,\n transaction_id: 'foo',\n customer_id: 'bar',\n customer: options.customerInfo,\n billing: options.billingInfo,\n });\n\n return new DonationResponse({\n success: true,\n value: response,\n });\n } else {\n return new DonationResponse({\n success: false,\n value: new ErrorResponse({ message: 'error' }),\n });\n }\n }\n\n async submitUpsellDonation(options: {\n oneTimeDonationResponse: SuccessResponse;\n amount: number;\n }): Promise<DonationResponse> {\n const response = new DonationResponse({\n success: true,\n value: mockSuccessResponse,\n });\n return response;\n }\n\n donationSuccessful(options: {\n successResponse: SuccessResponse;\n upsellSuccessResponse?: SuccessResponse | undefined;\n }): void {\n this.donationSuccessfulOptions = options;\n }\n}\n"]}
|
|
@@ -4,6 +4,8 @@ export declare class MockHostedFieldContainer implements HostedFieldContainerInt
|
|
|
4
4
|
removeErrorsCalled: boolean;
|
|
5
5
|
showErrorMessageCalled: boolean;
|
|
6
6
|
hideErrorMessageCalled: boolean;
|
|
7
|
+
allHostedFieldsAreLoaded(): boolean;
|
|
8
|
+
resetHostedFields(): void;
|
|
7
9
|
fieldFor(field: HostedFieldName): HTMLInputElement;
|
|
8
10
|
markFieldErrors(fields: HostedFieldName[]): void;
|
|
9
11
|
removeFieldErrors(fields: HostedFieldName[]): void;
|
|
@@ -5,6 +5,12 @@ export class MockHostedFieldContainer {
|
|
|
5
5
|
this.showErrorMessageCalled = false;
|
|
6
6
|
this.hideErrorMessageCalled = false;
|
|
7
7
|
}
|
|
8
|
+
allHostedFieldsAreLoaded() {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
resetHostedFields() {
|
|
12
|
+
// noop
|
|
13
|
+
}
|
|
8
14
|
fieldFor(field) {
|
|
9
15
|
const input = document.createElement('input');
|
|
10
16
|
return input;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-hosted-fields-container.js","sourceRoot":"","sources":["../../../test/mocks/mock-hosted-fields-container.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,wBAAwB;IAArC;QACE,qBAAgB,GAAG,KAAK,CAAC;QACzB,uBAAkB,GAAG,KAAK,CAAC;QAC3B,2BAAsB,GAAG,KAAK,CAAC;QAC/B,2BAAsB,GAAG,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"mock-hosted-fields-container.js","sourceRoot":"","sources":["../../../test/mocks/mock-hosted-fields-container.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,wBAAwB;IAArC;QACE,qBAAgB,GAAG,KAAK,CAAC;QACzB,uBAAkB,GAAG,KAAK,CAAC;QAC3B,2BAAsB,GAAG,KAAK,CAAC;QAC/B,2BAAsB,GAAG,KAAK,CAAC;IA8BjC,CAAC;IA5BC,wBAAwB;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,iBAAiB;QACf,OAAO;IACT,CAAC;IAED,QAAQ,CAAC,KAAsB;QAC7B,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAqB,CAAC;QAClE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,eAAe,CAAC,MAAyB;QACvC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAC/B,CAAC;IAED,iBAAiB,CAAC,MAAyB;QACzC,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;IACjC,CAAC;IAED,gBAAgB,CAAC,OAA4B;QAC3C,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC;IACrC,CAAC;IAED,gBAAgB;QACd,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC;IACrC,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport {\n HostedFieldContainerInterface,\n HostedFieldName,\n} from '../../src/braintree-manager/payment-providers/credit-card/hosted-field-container';\n\nexport class MockHostedFieldContainer implements HostedFieldContainerInterface {\n markErrorsCalled = false;\n removeErrorsCalled = false;\n showErrorMessageCalled = false;\n hideErrorMessageCalled = false;\n\n allHostedFieldsAreLoaded(): boolean {\n return true;\n }\n\n resetHostedFields(): void {\n // noop\n }\n\n fieldFor(field: HostedFieldName): HTMLInputElement {\n const input = document.createElement('input') as HTMLInputElement;\n return input;\n }\n\n markFieldErrors(fields: HostedFieldName[]): void {\n this.markErrorsCalled = true;\n }\n\n removeFieldErrors(fields: HostedFieldName[]): void {\n this.removeErrorsCalled = true;\n }\n\n showErrorMessage(message?: string | undefined): void {\n this.showErrorMessageCalled = true;\n }\n\n hideErrorMessage(): void {\n this.hideErrorMessageCalled = true;\n }\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PromisedSingleton } from '@internetarchive/promised-singleton';
|
|
2
2
|
import { HostedFieldName } from '../../../../src/braintree-manager/payment-providers/credit-card/hosted-field-container';
|
|
3
|
-
import { CreditCardHandlerInterface } from '../../../../src/braintree-manager/payment-providers/credit-card/credit-card-interface';
|
|
3
|
+
import { CreditCardHandlerEvents, CreditCardHandlerInterface } from '../../../../src/braintree-manager/payment-providers/credit-card/credit-card-interface';
|
|
4
|
+
import { Unsubscribe } from 'nanoevents';
|
|
4
5
|
export declare class MockCreditCardHandler implements CreditCardHandlerInterface {
|
|
5
6
|
instance: PromisedSingleton<import("../../../../src/@types/braintree-web").HostedFields>;
|
|
6
7
|
tokenizeHostedFields(): Promise<braintree.HostedFieldsTokenizePayload | undefined>;
|
|
@@ -11,5 +12,7 @@ export declare class MockCreditCardHandler implements CreditCardHandlerInterface
|
|
|
11
12
|
constructor(options?: {
|
|
12
13
|
mockPayload: braintree.HostedFieldsTokenizePayload;
|
|
13
14
|
});
|
|
15
|
+
private emitter;
|
|
16
|
+
on<E extends keyof CreditCardHandlerEvents>(event: E, callback: CreditCardHandlerEvents[E]): Unsubscribe;
|
|
14
17
|
mockPayload: braintree.HostedFieldsTokenizePayload;
|
|
15
18
|
}
|
|
@@ -3,6 +3,7 @@ import { __awaiter } from "tslib";
|
|
|
3
3
|
import { PromisedSingleton } from '@internetarchive/promised-singleton';
|
|
4
4
|
import { MockHostedFieldsClient } from '../../payment-clients/mock-hostedfields-client';
|
|
5
5
|
import { mockHostedFieldTokenizePayload } from '../../payment-clients/mock-hostedfieldtokenizepayload';
|
|
6
|
+
import { createNanoEvents } from 'nanoevents';
|
|
6
7
|
export class MockCreditCardHandler {
|
|
7
8
|
constructor(options) {
|
|
8
9
|
var _a;
|
|
@@ -14,6 +15,7 @@ export class MockCreditCardHandler {
|
|
|
14
15
|
resolve(client);
|
|
15
16
|
}),
|
|
16
17
|
});
|
|
18
|
+
this.emitter = createNanoEvents();
|
|
17
19
|
this.mockPayload = (_a = options === null || options === void 0 ? void 0 : options.mockPayload) !== null && _a !== void 0 ? _a : mockHostedFieldTokenizePayload;
|
|
18
20
|
}
|
|
19
21
|
tokenizeHostedFields() {
|
|
@@ -33,5 +35,8 @@ export class MockCreditCardHandler {
|
|
|
33
35
|
hideErrorMessage() {
|
|
34
36
|
throw new Error('Method not implemented.');
|
|
35
37
|
}
|
|
38
|
+
on(event, callback) {
|
|
39
|
+
return this.emitter.on(event, callback);
|
|
40
|
+
}
|
|
36
41
|
}
|
|
37
42
|
//# sourceMappingURL=mock-creditcard-handler.js.map
|
package/dist/test/mocks/payment-providers/individual-providers/mock-creditcard-handler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-creditcard-handler.js","sourceRoot":"","sources":["../../../../../test/mocks/payment-providers/individual-providers/mock-creditcard-handler.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAExE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AACxF,OAAO,EAAE,8BAA8B,EAAE,MAAM,uDAAuD,CAAC;
|
|
1
|
+
{"version":3,"file":"mock-creditcard-handler.js","sourceRoot":"","sources":["../../../../../test/mocks/payment-providers/individual-providers/mock-creditcard-handler.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAExE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AACxF,OAAO,EAAE,8BAA8B,EAAE,MAAM,uDAAuD,CAAC;AAKvG,OAAO,EAAE,gBAAgB,EAAe,MAAM,YAAY,CAAC;AAE3D,MAAM,OAAO,qBAAqB;IA+BhC,YAAY,OAAgE;;QA9B5E,aAAQ,GAAG,IAAI,iBAAiB,CAAyB;YACvD,SAAS,EAAE,GAAoC,EAAE,CAC/C,IAAI,OAAO,CAAyB,OAAO,CAAC,EAAE;gBAC5C,MAAM,MAAM,GAAG,IAAI,sBAAsB,CAAC;oBACxC,8BAA8B,EAAE,IAAI,CAAC,WAAW;iBACjD,CAAC,CAAC;gBACH,OAAO,CAAC,MAAM,CAAC,CAAC;YAClB,CAAC,CAAC;SACL,CAAC,CAAC;QA0BK,YAAO,GAAG,gBAAgB,EAA2B,CAAC;QAH5D,IAAI,CAAC,WAAW,SAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,mCAAI,8BAA8B,CAAC;IAC5E,CAAC;IAtBK,oBAAoB;;YACxB,OAAO,IAAI,CAAC,WAAW,CAAC;QAC1B,CAAC;KAAA;IAED,eAAe,CAAC,MAAyB;QACvC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,iBAAiB,CAAC,MAAyB;QACzC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,gBAAgB,CAAC,OAA4B;QAC3C,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,gBAAgB;QACd,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAQD,EAAE,CACA,KAAQ,EACR,QAAoC;QAEpC,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC1C,CAAC;CAGF","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { PromisedSingleton } from '@internetarchive/promised-singleton';\nimport { HostedFieldName } from '../../../../src/braintree-manager/payment-providers/credit-card/hosted-field-container';\nimport { MockHostedFieldsClient } from '../../payment-clients/mock-hostedfields-client';\nimport { mockHostedFieldTokenizePayload } from '../../payment-clients/mock-hostedfieldtokenizepayload';\nimport {\n CreditCardHandlerEvents,\n CreditCardHandlerInterface,\n} from '../../../../src/braintree-manager/payment-providers/credit-card/credit-card-interface';\nimport { createNanoEvents, Unsubscribe } from 'nanoevents';\n\nexport class MockCreditCardHandler implements CreditCardHandlerInterface {\n instance = new PromisedSingleton<braintree.HostedFields>({\n generator: (): Promise<braintree.HostedFields> =>\n new Promise<braintree.HostedFields>(resolve => {\n const client = new MockHostedFieldsClient({\n mockHostedFieldTokenizePayload: this.mockPayload,\n });\n resolve(client);\n }),\n });\n\n async tokenizeHostedFields(): Promise<braintree.HostedFieldsTokenizePayload | undefined> {\n return this.mockPayload;\n }\n\n markFieldErrors(fields: HostedFieldName[]): void {\n throw new Error('Method not implemented.');\n }\n\n removeFieldErrors(fields: HostedFieldName[]): void {\n throw new Error('Method not implemented.');\n }\n\n showErrorMessage(message?: string | undefined): void {\n throw new Error('Method not implemented.');\n }\n\n hideErrorMessage(): void {\n throw new Error('Method not implemented.');\n }\n\n constructor(options?: { mockPayload: braintree.HostedFieldsTokenizePayload }) {\n this.mockPayload = options?.mockPayload ?? mockHostedFieldTokenizePayload;\n }\n\n private emitter = createNanoEvents<CreditCardHandlerEvents>();\n\n on<E extends keyof CreditCardHandlerEvents>(\n event: E,\n callback: CreditCardHandlerEvents[E],\n ): Unsubscribe {\n return this.emitter.on(event, callback);\n }\n\n mockPayload: braintree.HostedFieldsTokenizePayload;\n}\n"]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { PromisedSingleton } from '@internetarchive/promised-singleton';
|
|
2
|
-
import { PaymentProvidersInterface } from '../../../src/braintree-manager/payment-providers-interface';
|
|
2
|
+
import { PaymentProvidersEvents, PaymentProvidersInterface } from '../../../src/braintree-manager/payment-providers-interface';
|
|
3
3
|
import { CreditCardHandlerInterface } from '../../../src/braintree-manager/payment-providers/credit-card/credit-card-interface';
|
|
4
4
|
import { ApplePayHandlerInterface } from '../../../src/braintree-manager/payment-providers/apple-pay/apple-pay-interface';
|
|
5
5
|
import { PayPalHandlerInterface } from '../../../src/braintree-manager/payment-providers/paypal/paypal-interface';
|
|
6
6
|
import { GooglePayHandlerInterface } from '../../../src/braintree-manager/payment-providers/google-pay-interface';
|
|
7
7
|
import { VenmoHandlerInterface } from '../../../src/braintree-manager/payment-providers/venmo-interface';
|
|
8
|
+
import { Unsubscribe } from 'nanoevents';
|
|
8
9
|
export declare class MockPaymentProviders implements PaymentProvidersInterface {
|
|
9
10
|
creditCardHandler: PromisedSingleton<CreditCardHandlerInterface>;
|
|
10
11
|
applePayHandler: PromisedSingleton<ApplePayHandlerInterface>;
|
|
@@ -14,5 +15,7 @@ export declare class MockPaymentProviders implements PaymentProvidersInterface {
|
|
|
14
15
|
constructor(options?: {
|
|
15
16
|
mockHostedFieldTokenizePayload?: braintree.HostedFieldsTokenizePayload;
|
|
16
17
|
});
|
|
18
|
+
private emitter;
|
|
19
|
+
on<E extends keyof PaymentProvidersEvents>(event: E, callback: PaymentProvidersEvents[E]): Unsubscribe;
|
|
17
20
|
mockHostedFieldTokenizePayload: braintree.HostedFieldsTokenizePayload;
|
|
18
21
|
}
|
|
@@ -5,6 +5,7 @@ import { MockApplePayHandler } from './individual-providers/mock-applepay-handle
|
|
|
5
5
|
import { MockPayPalHandler } from './individual-providers/mock-paypal-handler';
|
|
6
6
|
import { MockGooglePayHandler } from './individual-providers/mock-googlepay-handler';
|
|
7
7
|
import { mockHostedFieldTokenizePayload } from '../payment-clients/mock-hostedfieldtokenizepayload';
|
|
8
|
+
import { createNanoEvents } from 'nanoevents';
|
|
8
9
|
export class MockPaymentProviders {
|
|
9
10
|
constructor(options) {
|
|
10
11
|
var _a;
|
|
@@ -35,7 +36,11 @@ export class MockPaymentProviders {
|
|
|
35
36
|
resolve(new MockVenmoHandler());
|
|
36
37
|
}),
|
|
37
38
|
});
|
|
39
|
+
this.emitter = createNanoEvents();
|
|
38
40
|
this.mockHostedFieldTokenizePayload = (_a = options === null || options === void 0 ? void 0 : options.mockHostedFieldTokenizePayload) !== null && _a !== void 0 ? _a : mockHostedFieldTokenizePayload;
|
|
39
41
|
}
|
|
42
|
+
on(event, callback) {
|
|
43
|
+
return this.emitter.on(event, callback);
|
|
44
|
+
}
|
|
40
45
|
}
|
|
41
46
|
//# sourceMappingURL=mock-payment-providers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-payment-providers.js","sourceRoot":"","sources":["../../../../test/mocks/payment-providers/mock-payment-providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAC;AACrF,OAAO,EAAE,8BAA8B,EAAE,MAAM,oDAAoD,CAAC;
|
|
1
|
+
{"version":3,"file":"mock-payment-providers.js","sourceRoot":"","sources":["../../../../test/mocks/payment-providers/mock-payment-providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAC;AACrF,OAAO,EAAE,8BAA8B,EAAE,MAAM,oDAAoD,CAAC;AAapG,OAAO,EAAE,gBAAgB,EAAe,MAAM,YAAY,CAAC;AAE3D,MAAM,OAAO,oBAAoB;IAwC/B,YAAY,OAEX;;QAzCD,sBAAiB,GAAG,IAAI,iBAAiB,CAA6B;YACpE,SAAS,EAAE,GAAwC,EAAE,CACnD,IAAI,OAAO,CAA6B,OAAO,CAAC,EAAE;gBAChD,OAAO,CACL,IAAI,qBAAqB,CAAC;oBACxB,WAAW,EAAE,IAAI,CAAC,8BAA8B;iBACjD,CAAC,CACH,CAAC;YACJ,CAAC,CAAC;SACL,CAAC,CAAC;QAEH,oBAAe,GAAG,IAAI,iBAAiB,CAA2B;YAChE,SAAS,EAAE,GAAsC,EAAE,CACjD,IAAI,OAAO,CAA2B,OAAO,CAAC,EAAE;gBAC9C,OAAO,CAAC,IAAI,mBAAmB,EAAE,CAAC,CAAC;YACrC,CAAC,CAAC;SACL,CAAC,CAAC;QAEH,kBAAa,GAAG,IAAI,iBAAiB,CAAyB;YAC5D,SAAS,EAAE,GAAoC,EAAE,CAC/C,IAAI,OAAO,CAAyB,OAAO,CAAC,EAAE;gBAC5C,OAAO,CAAC,IAAI,iBAAiB,EAAE,CAAC,CAAC;YACnC,CAAC,CAAC;SACL,CAAC,CAAC;QAEH,qBAAgB,GAAG,IAAI,iBAAiB,CAA4B;YAClE,SAAS,EAAE,GAAuC,EAAE,CAClD,IAAI,OAAO,CAA4B,OAAO,CAAC,EAAE;gBAC/C,OAAO,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC;YACtC,CAAC,CAAC;SACL,CAAC,CAAC;QAEH,iBAAY,GAAG,IAAI,iBAAiB,CAAwB;YAC1D,SAAS,EAAE,GAAmC,EAAE,CAC9C,IAAI,OAAO,CAAwB,OAAO,CAAC,EAAE;gBAC3C,OAAO,CAAC,IAAI,gBAAgB,EAAE,CAAC,CAAC;YAClC,CAAC,CAAC;SACL,CAAC,CAAC;QASK,YAAO,GAAG,gBAAgB,EAA0B,CAAC;QAJ3D,IAAI,CAAC,8BAA8B,SACjC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,8BAA8B,mCAAI,8BAA8B,CAAC;IAC9E,CAAC;IAID,EAAE,CACA,KAAQ,EACR,QAAmC;QAEnC,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC1C,CAAC;CAGF","sourcesContent":["import { PromisedSingleton } from '@internetarchive/promised-singleton';\nimport { MockVenmoHandler } from './individual-providers/mock-venmo-handler';\nimport { MockCreditCardHandler } from './individual-providers/mock-creditcard-handler';\nimport { MockApplePayHandler } from './individual-providers/mock-applepay-handler';\nimport { MockPayPalHandler } from './individual-providers/mock-paypal-handler';\nimport { MockGooglePayHandler } from './individual-providers/mock-googlepay-handler';\nimport { mockHostedFieldTokenizePayload } from '../payment-clients/mock-hostedfieldtokenizepayload';\nimport {\n PaymentProvidersEvents,\n PaymentProvidersInterface,\n} from '../../../src/braintree-manager/payment-providers-interface';\nimport {\n CreditCardHandlerEvents,\n CreditCardHandlerInterface,\n} from '../../../src/braintree-manager/payment-providers/credit-card/credit-card-interface';\nimport { ApplePayHandlerInterface } from '../../../src/braintree-manager/payment-providers/apple-pay/apple-pay-interface';\nimport { PayPalHandlerInterface } from '../../../src/braintree-manager/payment-providers/paypal/paypal-interface';\nimport { GooglePayHandlerInterface } from '../../../src/braintree-manager/payment-providers/google-pay-interface';\nimport { VenmoHandlerInterface } from '../../../src/braintree-manager/payment-providers/venmo-interface';\nimport { createNanoEvents, Unsubscribe } from 'nanoevents';\n\nexport class MockPaymentProviders implements PaymentProvidersInterface {\n creditCardHandler = new PromisedSingleton<CreditCardHandlerInterface>({\n generator: (): Promise<CreditCardHandlerInterface> =>\n new Promise<CreditCardHandlerInterface>(resolve => {\n resolve(\n new MockCreditCardHandler({\n mockPayload: this.mockHostedFieldTokenizePayload,\n }),\n );\n }),\n });\n\n applePayHandler = new PromisedSingleton<ApplePayHandlerInterface>({\n generator: (): Promise<ApplePayHandlerInterface> =>\n new Promise<ApplePayHandlerInterface>(resolve => {\n resolve(new MockApplePayHandler());\n }),\n });\n\n paypalHandler = new PromisedSingleton<PayPalHandlerInterface>({\n generator: (): Promise<PayPalHandlerInterface> =>\n new Promise<PayPalHandlerInterface>(resolve => {\n resolve(new MockPayPalHandler());\n }),\n });\n\n googlePayHandler = new PromisedSingleton<GooglePayHandlerInterface>({\n generator: (): Promise<GooglePayHandlerInterface> =>\n new Promise<GooglePayHandlerInterface>(resolve => {\n resolve(new MockGooglePayHandler());\n }),\n });\n\n venmoHandler = new PromisedSingleton<VenmoHandlerInterface>({\n generator: (): Promise<VenmoHandlerInterface> =>\n new Promise<VenmoHandlerInterface>(resolve => {\n resolve(new MockVenmoHandler());\n }),\n });\n\n constructor(options?: {\n mockHostedFieldTokenizePayload?: braintree.HostedFieldsTokenizePayload;\n }) {\n this.mockHostedFieldTokenizePayload =\n options?.mockHostedFieldTokenizePayload ?? mockHostedFieldTokenizePayload;\n }\n\n private emitter = createNanoEvents<PaymentProvidersEvents>();\n\n on<E extends keyof PaymentProvidersEvents>(\n event: E,\n callback: PaymentProvidersEvents[E],\n ): Unsubscribe {\n return this.emitter.on(event, callback);\n }\n\n mockHostedFieldTokenizePayload: braintree.HostedFieldsTokenizePayload;\n}\n"]}
|
|
@@ -7,7 +7,7 @@ import { HostingEnvironment } from '../../src/braintree-manager/braintree-interf
|
|
|
7
7
|
import { MockEndpointManager } from '../mocks/mock-endpoint-manager';
|
|
8
8
|
import { MockPaymentClients } from '../mocks/mock-payment-clients';
|
|
9
9
|
import { fillInContactForm } from '../helpers/fillInContactForm';
|
|
10
|
-
import { promisedSleep } from '
|
|
10
|
+
import { promisedSleep } from '../../src/util/promisedSleep';
|
|
11
11
|
import { MockModalManager } from '../mocks/mock-modal-manager';
|
|
12
12
|
import { MockAnalyticHandler } from '../mocks/mock-analytics-handler';
|
|
13
13
|
import { MockPaymentFlowHandlers } from '../mocks/flow-handlers/mock-payment-flow-handlers';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"donation-form-controller.test.js","sourceRoot":"","sources":["../../../test/tests/donation-form-controller.test.ts"],"names":[],"mappings":";AAAA,uDAAuD;AACvD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEnF,OAAO,oCAAoC,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAC9F,OAAO,EAAE,kBAAkB,EAAE,MAAM,kDAAkD,CAAC;A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C,mBAAmB,GAAG,YAAY,CAAC;QAChD,MAAM,cAAc,CAAC,YAAY,CAAC,CAAC;QACnC,MAAM,aAAa,CAAC,GAAG,CAAC,CAAC;QACzB,YAAY,CAAC,aAAa,CAAC,qBAAqB,EAAE,CAAC;QACnD,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAC9D,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAC/D,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { html, fixture, expect, elementUpdated, oneEvent } from '@open-wc/testing';\n\nimport '../../src/donation-form-controller';\nimport { DonationFormController } from '../../src/donation-form-controller';\nimport { MockGrecaptcha, MockGrecaptchaMode } from '../mocks/payment-clients/mock-grecaptcha';\nimport { HostingEnvironment } from '../../src/braintree-manager/braintree-interfaces';\nimport { MockEndpointManager } from '../mocks/mock-endpoint-manager';\nimport { MockPaymentClients } from '../mocks/mock-payment-clients';\nimport { ContactForm } from '../../src/form-elements/contact-form/contact-form';\nimport { fillInContactForm } from '../helpers/fillInContactForm';\nimport { promisedSleep } from '../helpers/promisedSleep';\nimport { MockModalManager } from '../mocks/mock-modal-manager';\nimport { MockHostedFieldsClient } from '../mocks/payment-clients/mock-hostedfields-client';\nimport { DonationForm } from '../../src/donation-form';\nimport { PaymentSelector } from '../../src/form-elements/payment-selector';\nimport { MockAnalyticHandler } from '../mocks/mock-analytics-handler';\nimport { DonationFormHeader } from '../../src/form-elements/header/donation-form-header';\nimport { DonationFormEditDonation } from '@internetarchive/donation-form-edit-donation';\nimport { MockPaymentFlowHandlers } from '../mocks/flow-handlers/mock-payment-flow-handlers';\n\ndescribe('Donation Form Controller', () => {\n beforeEach(() => {\n (window['grecaptcha' as any] as any) = new MockGrecaptcha(MockGrecaptchaMode.Success);\n });\n\n afterEach(() => {\n delete window['grecaptcha' as any];\n });\n\n it('has no shadowRoot', async () => {\n const el = (await fixture(html`\n <donation-form-controller></donation-form-controller>\n `)) as DonationFormController;\n\n expect(el.shadowRoot).to.equal(null);\n });\n\n it('can submit a donation', async () => {\n const mockAnalytics = new MockAnalyticHandler();\n const controller = (await fixture(html`\n <donation-form-controller .analyticsHandler=${mockAnalytics}> </donation-form-controller>\n `)) as DonationFormController;\n\n // configure the donation-form-controller\n const recaptchaElement = (await fixture(\n html`\n <div></div>\n `,\n )) as HTMLElement;\n const endpointManager = new MockEndpointManager();\n const paymentClients = new MockPaymentClients();\n const modalManager = new MockModalManager();\n controller.paymentClients = paymentClients;\n controller.modalManager = modalManager;\n controller.environment = HostingEnvironment.Development;\n controller.recaptchaElement = recaptchaElement;\n controller.endpointManager = endpointManager;\n controller.braintreeAuthToken = 'foo';\n controller.recaptchaSiteKey = 'bar';\n controller.venmoProfileId = 'baz';\n controller.referrer = 'test-referrer';\n controller.loggedInUser = 'test-user';\n\n // grab some internal elements to interact with\n const donationForm: DonationForm = controller.querySelector('donation-form') as DonationForm;\n const paymentSelector: PaymentSelector = donationForm?.shadowRoot?.querySelector(\n 'payment-selector',\n ) as PaymentSelector;\n const creditCardButton = paymentSelector?.shadowRoot?.querySelector('.credit-card-button');\n\n // click on the credit card button\n const ccClickEvent = new MouseEvent('click');\n creditCardButton?.dispatchEvent(ccClickEvent);\n\n // clicking on the credit card button will show the contact form so wait for it to be updated\n await elementUpdated(donationForm);\n await promisedSleep(100);\n const contactForm = document.querySelector('contact-form') as ContactForm;\n await fillInContactForm(contactForm);\n\n // verify the Donate button is still disabled\n const donateButton = donationForm?.shadowRoot?.querySelector(\n '#donate-button',\n ) as HTMLButtonElement;\n\n // simulates after the user has input all of the credit card fields\n const hostedFields = (await paymentClients.hostedFields.get()) as MockHostedFieldsClient;\n hostedFields.emitValidityChangedEvent(true);\n await promisedSleep(100);\n\n // verify that the donate button has become enabled and no request has been submitted\n expect(donateButton.disabled).to.equal(false);\n expect(endpointManager.requestSubmitted).to.equal(undefined);\n\n // click the donate button\n const donateClickEvent = new MouseEvent('click');\n donateButton?.dispatchEvent(donateClickEvent);\n await promisedSleep(100);\n\n expect(mockAnalytics.callAction).to.equal('PaymentFlowStarted');\n\n // verify that a payload has been requested to be submitted to the backend\n expect(endpointManager.requestSubmitted).to.not.equal(undefined);\n });\n\n it('sends Viewed analytics when it first updates', async () => {\n const mockAnalytics = new MockAnalyticHandler();\n const analyticsCategory = 'FooCategory';\n (await fixture(html`\n <donation-form-controller\n ?showCreditCardButtonText=${true}\n .analyticsCategory=${analyticsCategory}\n .analyticsHandler=${mockAnalytics}\n >\n </donation-form-controller>\n `)) as DonationFormController;\n\n expect(mockAnalytics.callCategory).to.equal(analyticsCategory);\n expect(mockAnalytics.callAction).to.equal('Viewed');\n });\n\n it('sends DonationInfoChanged analytics when donation info changes', async () => {\n const mockAnalytics = new MockAnalyticHandler();\n const analyticsCategory = 'FooCategory';\n const controller = (await fixture(html`\n <donation-form-controller\n ?showCreditCardButtonText=${true}\n .analyticsCategory=${analyticsCategory}\n .analyticsHandler=${mockAnalytics}\n >\n </donation-form-controller>\n `)) as DonationFormController;\n\n const donationForm: DonationForm = controller.querySelector('donation-form') as DonationForm;\n const donationHeader = donationForm.shadowRoot?.querySelector(\n 'donation-form-header',\n ) as DonationFormHeader;\n const editDonation = donationHeader?.shadowRoot?.querySelector(\n 'donation-form-edit-donation',\n ) as DonationFormEditDonation;\n const monthlyOption = editDonation?.shadowRoot?.querySelector('#donationType-monthly-option');\n const clickEvent = new MouseEvent('click');\n monthlyOption?.dispatchEvent(clickEvent);\n\n expect(mockAnalytics.callCategory).to.equal(analyticsCategory);\n expect(mockAnalytics.callAction).to.equal('DonationInfoChanged');\n });\n\n it('sends ProviderSelected analytics', async () => {\n const mockAnalytics = new MockAnalyticHandler();\n const analyticsCategory = 'FooCategory';\n const controller = (await fixture(html`\n <donation-form-controller\n ?showCreditCardButtonText=${true}\n .analyticsCategory=${analyticsCategory}\n .analyticsHandler=${mockAnalytics}\n >\n </donation-form-controller>\n `)) as DonationFormController;\n\n const donationForm: DonationForm = controller.querySelector('donation-form') as DonationForm;\n const paymentSelector = donationForm.shadowRoot?.querySelector(\n 'payment-selector',\n ) as PaymentSelector;\n\n // on the first payment provider chosen, the previousPaymentProvider is undefined\n const creditCardButton = paymentSelector.shadowRoot?.querySelector(\n '.credit-card-button',\n ) as HTMLButtonElement;\n setTimeout(() => {\n const ccClickEvent = new MouseEvent('click');\n creditCardButton.dispatchEvent(ccClickEvent);\n });\n await oneEvent(donationForm, 'paymentProviderSelected');\n expect(mockAnalytics.callAction).to.equal('ProviderFirstSelected-CreditCard');\n\n // on subsequent payment provider choices, the previousPaymentProvider is populated\n const venmoButton = paymentSelector.shadowRoot?.querySelector('.venmo') as HTMLButtonElement;\n setTimeout(() => {\n const venmoClickEvent = new MouseEvent('click');\n venmoButton.dispatchEvent(venmoClickEvent);\n });\n await oneEvent(donationForm, 'paymentProviderSelected');\n expect(mockAnalytics.callAction).to.equal('ProviderChangedTo-Venmo');\n });\n\n it('sends PaymentFlowCancelled analytics', async () => {\n const mockAnalytics = new MockAnalyticHandler();\n const analyticsCategory = 'FooCategory';\n const controller = (await fixture(html`\n <donation-form-controller\n ?showCreditCardButtonText=${true}\n .analyticsCategory=${analyticsCategory}\n .analyticsHandler=${mockAnalytics}\n >\n </donation-form-controller>\n `)) as DonationFormController;\n\n const donationForm: DonationForm = controller.querySelector('donation-form') as DonationForm;\n const flowHandlers = new MockPaymentFlowHandlers();\n donationForm.paymentFlowHandlers = flowHandlers;\n await elementUpdated(donationForm);\n await promisedSleep(250);\n flowHandlers.paypalHandler.emitPaymentCancelledEvent();\n expect(mockAnalytics.callAction).to.equal('PaymentFlowCancelled');\n expect(mockAnalytics.callLabel).to.equal('PayPal');\n });\n\n it('sends PaymentFlowError analytics', async () => {\n const mockAnalytics = new MockAnalyticHandler();\n const analyticsCategory = 'FooCategory';\n const controller = (await fixture(html`\n <donation-form-controller\n ?showCreditCardButtonText=${true}\n .analyticsCategory=${analyticsCategory}\n .analyticsHandler=${mockAnalytics}\n >\n </donation-form-controller>\n `)) as DonationFormController;\n\n const donationForm: DonationForm = controller.querySelector('donation-form') as DonationForm;\n const flowHandlers = new MockPaymentFlowHandlers();\n donationForm.paymentFlowHandlers = flowHandlers;\n await elementUpdated(donationForm);\n await promisedSleep(250);\n flowHandlers.paypalHandler.emitPaymentErrorEvent();\n expect(mockAnalytics.callAction).to.equal('PaymentFlowError');\n expect(mockAnalytics.callLabel).to.equal('PayPal-foo-error');\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"donation-form-controller.test.js","sourceRoot":"","sources":["../../../test/tests/donation-form-controller.test.ts"],"names":[],"mappings":";AAAA,uDAAuD;AACvD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEnF,OAAO,oCAAoC,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAC9F,OAAO,EAAE,kBAAkB,EAAE,MAAM,kDAAkD,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAI/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,mDAAmD,CAAC;AAE5F,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,UAAU,CAAC,GAAG,EAAE;QACb,MAAM,CAAC,YAAmB,C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vent } from '@open-wc/testing';\n\nimport '../../src/donation-form-controller';\nimport { DonationFormController } from '../../src/donation-form-controller';\nimport { MockGrecaptcha, MockGrecaptchaMode } from '../mocks/payment-clients/mock-grecaptcha';\nimport { HostingEnvironment } from '../../src/braintree-manager/braintree-interfaces';\nimport { MockEndpointManager } from '../mocks/mock-endpoint-manager';\nimport { MockPaymentClients } from '../mocks/mock-payment-clients';\nimport { ContactForm } from '../../src/form-elements/contact-form/contact-form';\nimport { fillInContactForm } from '../helpers/fillInContactForm';\nimport { promisedSleep } from '../../src/util/promisedSleep';\nimport { MockModalManager } from '../mocks/mock-modal-manager';\nimport { MockHostedFieldsClient } from '../mocks/payment-clients/mock-hostedfields-client';\nimport { DonationForm } from '../../src/donation-form';\nimport { PaymentSelector } from '../../src/form-elements/payment-selector';\nimport { MockAnalyticHandler } from '../mocks/mock-analytics-handler';\nimport { DonationFormHeader } from '../../src/form-elements/header/donation-form-header';\nimport { DonationFormEditDonation } from '@internetarchive/donation-form-edit-donation';\nimport { MockPaymentFlowHandlers } from '../mocks/flow-handlers/mock-payment-flow-handlers';\n\ndescribe('Donation Form Controller', () => {\n beforeEach(() => {\n (window['grecaptcha' as any] as any) = new MockGrecaptcha(MockGrecaptchaMode.Success);\n });\n\n afterEach(() => {\n delete window['grecaptcha' as any];\n });\n\n it('has no shadowRoot', async () => {\n const el = (await fixture(html`\n <donation-form-controller></donation-form-controller>\n `)) as DonationFormController;\n\n expect(el.shadowRoot).to.equal(null);\n });\n\n it('can submit a donation', async () => {\n const mockAnalytics = new MockAnalyticHandler();\n const controller = (await fixture(html`\n <donation-form-controller .analyticsHandler=${mockAnalytics}> </donation-form-controller>\n `)) as DonationFormController;\n\n // configure the donation-form-controller\n const recaptchaElement = (await fixture(\n html`\n <div></div>\n `,\n )) as HTMLElement;\n const endpointManager = new MockEndpointManager();\n const paymentClients = new MockPaymentClients();\n const modalManager = new MockModalManager();\n controller.paymentClients = paymentClients;\n controller.modalManager = modalManager;\n controller.environment = HostingEnvironment.Development;\n controller.recaptchaElement = recaptchaElement;\n controller.endpointManager = endpointManager;\n controller.braintreeAuthToken = 'foo';\n controller.recaptchaSiteKey = 'bar';\n controller.venmoProfileId = 'baz';\n controller.referrer = 'test-referrer';\n controller.loggedInUser = 'test-user';\n\n // grab some internal elements to interact with\n const donationForm: DonationForm = controller.querySelector('donation-form') as DonationForm;\n const paymentSelector: PaymentSelector = donationForm?.shadowRoot?.querySelector(\n 'payment-selector',\n ) as PaymentSelector;\n const creditCardButton = paymentSelector?.shadowRoot?.querySelector('.credit-card-button');\n\n // click on the credit card button\n const ccClickEvent = new MouseEvent('click');\n creditCardButton?.dispatchEvent(ccClickEvent);\n\n // clicking on the credit card button will show the contact form so wait for it to be updated\n await elementUpdated(donationForm);\n await promisedSleep(100);\n const contactForm = document.querySelector('contact-form') as ContactForm;\n await fillInContactForm(contactForm);\n\n // verify the Donate button is still disabled\n const donateButton = donationForm?.shadowRoot?.querySelector(\n '#donate-button',\n ) as HTMLButtonElement;\n\n // simulates after the user has input all of the credit card fields\n const hostedFields = (await paymentClients.hostedFields.get()) as MockHostedFieldsClient;\n hostedFields.emitValidityChangedEvent(true);\n await promisedSleep(100);\n\n // verify that the donate button has become enabled and no request has been submitted\n expect(donateButton.disabled).to.equal(false);\n expect(endpointManager.requestSubmitted).to.equal(undefined);\n\n // click the donate button\n const donateClickEvent = new MouseEvent('click');\n donateButton?.dispatchEvent(donateClickEvent);\n await promisedSleep(100);\n\n expect(mockAnalytics.callAction).to.equal('PaymentFlowStarted');\n\n // verify that a payload has been requested to be submitted to the backend\n expect(endpointManager.requestSubmitted).to.not.equal(undefined);\n });\n\n it('sends Viewed analytics when it first updates', async () => {\n const mockAnalytics = new MockAnalyticHandler();\n const analyticsCategory = 'FooCategory';\n (await fixture(html`\n <donation-form-controller\n ?showCreditCardButtonText=${true}\n .analyticsCategory=${analyticsCategory}\n .analyticsHandler=${mockAnalytics}\n >\n </donation-form-controller>\n `)) as DonationFormController;\n\n expect(mockAnalytics.callCategory).to.equal(analyticsCategory);\n expect(mockAnalytics.callAction).to.equal('Viewed');\n });\n\n it('sends DonationInfoChanged analytics when donation info changes', async () => {\n const mockAnalytics = new MockAnalyticHandler();\n const analyticsCategory = 'FooCategory';\n const controller = (await fixture(html`\n <donation-form-controller\n ?showCreditCardButtonText=${true}\n .analyticsCategory=${analyticsCategory}\n .analyticsHandler=${mockAnalytics}\n >\n </donation-form-controller>\n `)) as DonationFormController;\n\n const donationForm: DonationForm = controller.querySelector('donation-form') as DonationForm;\n const donationHeader = donationForm.shadowRoot?.querySelector(\n 'donation-form-header',\n ) as DonationFormHeader;\n const editDonation = donationHeader?.shadowRoot?.querySelector(\n 'donation-form-edit-donation',\n ) as DonationFormEditDonation;\n const monthlyOption = editDonation?.shadowRoot?.querySelector('#donationType-monthly-option');\n const clickEvent = new MouseEvent('click');\n monthlyOption?.dispatchEvent(clickEvent);\n\n expect(mockAnalytics.callCategory).to.equal(analyticsCategory);\n expect(mockAnalytics.callAction).to.equal('DonationInfoChanged');\n });\n\n it('sends ProviderSelected analytics', async () => {\n const mockAnalytics = new MockAnalyticHandler();\n const analyticsCategory = 'FooCategory';\n const controller = (await fixture(html`\n <donation-form-controller\n ?showCreditCardButtonText=${true}\n .analyticsCategory=${analyticsCategory}\n .analyticsHandler=${mockAnalytics}\n >\n </donation-form-controller>\n `)) as DonationFormController;\n\n const donationForm: DonationForm = controller.querySelector('donation-form') as DonationForm;\n const paymentSelector = donationForm.shadowRoot?.querySelector(\n 'payment-selector',\n ) as PaymentSelector;\n\n // on the first payment provider chosen, the previousPaymentProvider is undefined\n const creditCardButton = paymentSelector.shadowRoot?.querySelector(\n '.credit-card-button',\n ) as HTMLButtonElement;\n setTimeout(() => {\n const ccClickEvent = new MouseEvent('click');\n creditCardButton.dispatchEvent(ccClickEvent);\n });\n await oneEvent(donationForm, 'paymentProviderSelected');\n expect(mockAnalytics.callAction).to.equal('ProviderFirstSelected-CreditCard');\n\n // on subsequent payment provider choices, the previousPaymentProvider is populated\n const venmoButton = paymentSelector.shadowRoot?.querySelector('.venmo') as HTMLButtonElement;\n setTimeout(() => {\n const venmoClickEvent = new MouseEvent('click');\n venmoButton.dispatchEvent(venmoClickEvent);\n });\n await oneEvent(donationForm, 'paymentProviderSelected');\n expect(mockAnalytics.callAction).to.equal('ProviderChangedTo-Venmo');\n });\n\n it('sends PaymentFlowCancelled analytics', async () => {\n const mockAnalytics = new MockAnalyticHandler();\n const analyticsCategory = 'FooCategory';\n const controller = (await fixture(html`\n <donation-form-controller\n ?showCreditCardButtonText=${true}\n .analyticsCategory=${analyticsCategory}\n .analyticsHandler=${mockAnalytics}\n >\n </donation-form-controller>\n `)) as DonationFormController;\n\n const donationForm: DonationForm = controller.querySelector('donation-form') as DonationForm;\n const flowHandlers = new MockPaymentFlowHandlers();\n donationForm.paymentFlowHandlers = flowHandlers;\n await elementUpdated(donationForm);\n await promisedSleep(250);\n flowHandlers.paypalHandler.emitPaymentCancelledEvent();\n expect(mockAnalytics.callAction).to.equal('PaymentFlowCancelled');\n expect(mockAnalytics.callLabel).to.equal('PayPal');\n });\n\n it('sends PaymentFlowError analytics', async () => {\n const mockAnalytics = new MockAnalyticHandler();\n const analyticsCategory = 'FooCategory';\n const controller = (await fixture(html`\n <donation-form-controller\n ?showCreditCardButtonText=${true}\n .analyticsCategory=${analyticsCategory}\n .analyticsHandler=${mockAnalytics}\n >\n </donation-form-controller>\n `)) as DonationFormController;\n\n const donationForm: DonationForm = controller.querySelector('donation-form') as DonationForm;\n const flowHandlers = new MockPaymentFlowHandlers();\n donationForm.paymentFlowHandlers = flowHandlers;\n await elementUpdated(donationForm);\n await promisedSleep(250);\n flowHandlers.paypalHandler.emitPaymentErrorEvent();\n expect(mockAnalytics.callAction).to.equal('PaymentFlowError');\n expect(mockAnalytics.callLabel).to.equal('PayPal-foo-error');\n });\n});\n"]}
|
|
@@ -4,7 +4,7 @@ import '../../src/donation-form';
|
|
|
4
4
|
import { DonationType, DonationPaymentInfo, PaymentProvider, } from '@internetarchive/donation-form-data-models';
|
|
5
5
|
import { MockBraintreeManager } from '../mocks/mock-braintree-manager';
|
|
6
6
|
import { MockPaymentFlowHandlers } from '../mocks/flow-handlers/mock-payment-flow-handlers';
|
|
7
|
-
import { promisedSleep } from '
|
|
7
|
+
import { promisedSleep } from '../../src/util/promisedSleep';
|
|
8
8
|
import { MockDonationInfo } from '../mocks/mock-donation-info';
|
|
9
9
|
describe('Donation Form', () => {
|
|
10
10
|
describe('Configuration', () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"donation-form.test.js","sourceRoot":"","sources":["../../../test/tests/donation-form.test.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEnF,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,eAAe,GAChB,MAAM,4CAA4C,CAAC;AAEpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,mDAAmD,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;QAC7B,EAAE,CAAC,sBAAsB,EAAE,GAAS,EAAE;YACpC,MAAM,EAAE,GAAG,CAAC,MAAM,OAAO,CAAC,IAAI,CAAA;;OAE7B,CAAC,CAAiB,CAAC;YAEpB,MAAM,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YAChD,MAAM,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,S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AC,eAAe,CAAC,UAAU,CAAC,CAAC;IAC5F,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { html, fixture, expect, elementUpdated, oneEvent } from '@open-wc/testing';\n\nimport '../../src/donation-form';\nimport { DonationForm } from '../../src/donation-form';\nimport {\n DonationType,\n DonationPaymentInfo,\n PaymentProvider,\n} from '@internetarchive/donation-form-data-models';\nimport { PaymentSelector } from '../../src/form-elements/payment-selector';\nimport { MockBraintreeManager } from '../mocks/mock-braintree-manager';\nimport { MockPaymentFlowHandlers } from '../mocks/flow-handlers/mock-payment-flow-handlers';\nimport { promisedSleep } from '../helpers/promisedSleep';\nimport { MockDonationInfo } from '../mocks/mock-donation-info';\n\ndescribe('Donation Form', () => {\n describe('Configuration', () => {\n it('has no configuration', async () => {\n const el = (await fixture(html`\n <donation-form></donation-form>\n `)) as DonationForm;\n\n expect(el.braintreeManager).to.equal(undefined);\n expect(el.donationRequest).to.equal(undefined);\n });\n\n it('updates donationInfo when user changes donation info', async () => {\n const el = (await fixture(html`\n <donation-form .donationInfo=${new MockDonationInfo()}></donation-form>\n `)) as DonationForm;\n const donationHeader = el.shadowRoot?.querySelector('donation-form-header');\n const editDonation = donationHeader?.shadowRoot?.querySelector('donation-form-edit-donation');\n const monthlyOption = editDonation?.shadowRoot?.querySelector('#donationType-monthly-option');\n const clickEvent = new MouseEvent('click');\n monthlyOption?.dispatchEvent(clickEvent);\n await elementUpdated(el);\n expect(el.donationInfo?.donationType).to.equal(DonationType.Monthly);\n });\n });\n\n it('shows the contact form when Credit Card is selected', async () => {\n const el = (await fixture(html`\n <donation-form></donation-form>\n `)) as DonationForm;\n const contactFormSection = el.shadowRoot?.querySelector('.contact-form-section');\n const paymentSelector = el.shadowRoot?.querySelector('payment-selector') as PaymentSelector;\n const creditCardButton = paymentSelector.shadowRoot?.querySelector(\n '.credit-card-button',\n ) as HTMLButtonElement;\n expect(contactFormSection?.classList.contains('hidden')).to.be.true;\n const clickEvent = new MouseEvent('click');\n creditCardButton.dispatchEvent(clickEvent);\n await elementUpdated(el);\n expect(contactFormSection?.classList.contains('hidden')).to.be.false;\n });\n\n it('shows the contact form when Venmo is selected', async () => {\n const el = (await fixture(html`\n <donation-form></donation-form>\n `)) as DonationForm;\n const braintreeManager = new MockBraintreeManager();\n el.braintreeManager = braintreeManager;\n await elementUpdated(el);\n const contactFormSection = el.shadowRoot?.querySelector('.contact-form-section');\n const paymentSelector = el.shadowRoot?.querySelector('payment-selector') as PaymentSelector;\n const venmoButton = paymentSelector.shadowRoot?.querySelector('.venmo') as HTMLButtonElement;\n expect(contactFormSection?.classList.contains('hidden')).to.be.true;\n const clickEvent = new MouseEvent('click');\n venmoButton.dispatchEvent(clickEvent);\n await elementUpdated(el);\n expect(contactFormSection?.classList.contains('hidden')).to.be.false;\n });\n\n it('properly configures the flow handlers when they are set', async () => {\n const donationInfo = new DonationPaymentInfo({\n donationType: DonationType.Monthly,\n amount: 3.5,\n coverFees: false,\n });\n const el = (await fixture(html`\n <donation-form .donationInfo=${donationInfo}></donation-form>\n `)) as DonationForm;\n const flowHandlers = new MockPaymentFlowHandlers();\n el.paymentFlowHandlers = flowHandlers;\n await elementUpdated(el);\n await promisedSleep(250);\n expect(flowHandlers.paypalHandler.donationInfo).to.equal(donationInfo);\n });\n\n it('emits paymentProviderSelected when the selected provider changes', async () => {\n const el = (await fixture(html`\n <donation-form></donation-form>\n `)) as DonationForm;\n const braintreeManager = new MockBraintreeManager();\n el.braintreeManager = braintreeManager;\n await elementUpdated(el);\n const paymentSelector = el.shadowRoot?.querySelector('payment-selector') as PaymentSelector;\n const creditCardButton = paymentSelector.shadowRoot?.querySelector(\n '.credit-card-button',\n ) as HTMLButtonElement;\n\n // on the first payment provider chosen, the previousPaymentProvider is undefined\n setTimeout(() => {\n const ccClickEvent = new MouseEvent('click');\n creditCardButton.dispatchEvent(ccClickEvent);\n });\n const ccResponse = await oneEvent(el, 'paymentProviderSelected');\n expect(ccResponse).to.exist;\n expect(ccResponse.detail.paymentProvider).to.equal(PaymentProvider.CreditCard);\n expect(ccResponse.detail.previousPaymentProvider).to.equal(undefined);\n\n // on subsequent payment provider choices, the previousPaymentProvider is populated\n setTimeout(() => {\n const venmoButton = paymentSelector.shadowRoot?.querySelector('.venmo') as HTMLButtonElement;\n const venmoClickEvent = new MouseEvent('click');\n venmoButton.dispatchEvent(venmoClickEvent);\n });\n const venmoResponse = await oneEvent(el, 'paymentProviderSelected');\n expect(venmoResponse).to.exist;\n expect(venmoResponse.detail.paymentProvider).to.equal(PaymentProvider.Venmo);\n expect(venmoResponse.detail.previousPaymentProvider).to.equal(PaymentProvider.CreditCard);\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"donation-form.test.js","sourceRoot":"","sources":["../../../test/tests/donation-form.test.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEnF,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,eAAe,GAChB,MAAM,4CAA4C,CAAC;AAEpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,mDAAmD,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;QAC7B,EAAE,CAAC,sBAAsB,EAAE,GAAS,EAAE;YACpC,MAAM,EAAE,GAAG,CAAC,MAAM,OAAO,CAAC,IAAI,CAAA;;OAE7B,CAAC,CAAiB,CAAC;YAEpB,MAAM,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,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;QAC7E,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;IAC5F,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { html, fixture, expect, elementUpdated, oneEvent } from '@open-wc/testing';\n\nimport '../../src/donation-form';\nimport { DonationForm } from '../../src/donation-form';\nimport {\n DonationType,\n DonationPaymentInfo,\n PaymentProvider,\n} from '@internetarchive/donation-form-data-models';\nimport { PaymentSelector } from '../../src/form-elements/payment-selector';\nimport { MockBraintreeManager } from '../mocks/mock-braintree-manager';\nimport { MockPaymentFlowHandlers } from '../mocks/flow-handlers/mock-payment-flow-handlers';\nimport { promisedSleep } from '../../src/util/promisedSleep';\nimport { MockDonationInfo } from '../mocks/mock-donation-info';\n\ndescribe('Donation Form', () => {\n describe('Configuration', () => {\n it('has no configuration', async () => {\n const el = (await fixture(html`\n <donation-form></donation-form>\n `)) as DonationForm;\n\n expect(el.braintreeManager).to.equal(undefined);\n expect(el.donationRequest).to.equal(undefined);\n });\n\n it('updates donationInfo when user changes donation info', async () => {\n const el = (await fixture(html`\n <donation-form .donationInfo=${new MockDonationInfo()}></donation-form>\n `)) as DonationForm;\n const donationHeader = el.shadowRoot?.querySelector('donation-form-header');\n const editDonation = donationHeader?.shadowRoot?.querySelector('donation-form-edit-donation');\n const monthlyOption = editDonation?.shadowRoot?.querySelector('#donationType-monthly-option');\n const clickEvent = new MouseEvent('click');\n monthlyOption?.dispatchEvent(clickEvent);\n await elementUpdated(el);\n expect(el.donationInfo?.donationType).to.equal(DonationType.Monthly);\n });\n });\n\n it('shows the contact form when Credit Card is selected', async () => {\n const el = (await fixture(html`\n <donation-form></donation-form>\n `)) as DonationForm;\n const contactFormSection = el.shadowRoot?.querySelector('.contact-form-section');\n const paymentSelector = el.shadowRoot?.querySelector('payment-selector') as PaymentSelector;\n const creditCardButton = paymentSelector.shadowRoot?.querySelector(\n '.credit-card-button',\n ) as HTMLButtonElement;\n expect(contactFormSection?.classList.contains('hidden')).to.be.true;\n const clickEvent = new MouseEvent('click');\n creditCardButton.dispatchEvent(clickEvent);\n await elementUpdated(el);\n expect(contactFormSection?.classList.contains('hidden')).to.be.false;\n });\n\n it('shows the contact form when Venmo is selected', async () => {\n const el = (await fixture(html`\n <donation-form></donation-form>\n `)) as DonationForm;\n const braintreeManager = new MockBraintreeManager();\n el.braintreeManager = braintreeManager;\n await elementUpdated(el);\n const contactFormSection = el.shadowRoot?.querySelector('.contact-form-section');\n const paymentSelector = el.shadowRoot?.querySelector('payment-selector') as PaymentSelector;\n const venmoButton = paymentSelector.shadowRoot?.querySelector('.venmo') as HTMLButtonElement;\n expect(contactFormSection?.classList.contains('hidden')).to.be.true;\n const clickEvent = new MouseEvent('click');\n venmoButton.dispatchEvent(clickEvent);\n await elementUpdated(el);\n expect(contactFormSection?.classList.contains('hidden')).to.be.false;\n });\n\n it('properly configures the flow handlers when they are set', async () => {\n const donationInfo = new DonationPaymentInfo({\n donationType: DonationType.Monthly,\n amount: 3.5,\n coverFees: false,\n });\n const el = (await fixture(html`\n <donation-form .donationInfo=${donationInfo}></donation-form>\n `)) as DonationForm;\n const flowHandlers = new MockPaymentFlowHandlers();\n el.paymentFlowHandlers = flowHandlers;\n await elementUpdated(el);\n await promisedSleep(250);\n expect(flowHandlers.paypalHandler.donationInfo).to.equal(donationInfo);\n });\n\n it('emits paymentProviderSelected when the selected provider changes', async () => {\n const el = (await fixture(html`\n <donation-form></donation-form>\n `)) as DonationForm;\n const braintreeManager = new MockBraintreeManager();\n el.braintreeManager = braintreeManager;\n await elementUpdated(el);\n const paymentSelector = el.shadowRoot?.querySelector('payment-selector') as PaymentSelector;\n const creditCardButton = paymentSelector.shadowRoot?.querySelector(\n '.credit-card-button',\n ) as HTMLButtonElement;\n\n // on the first payment provider chosen, the previousPaymentProvider is undefined\n setTimeout(() => {\n const ccClickEvent = new MouseEvent('click');\n creditCardButton.dispatchEvent(ccClickEvent);\n });\n const ccResponse = await oneEvent(el, 'paymentProviderSelected');\n expect(ccResponse).to.exist;\n expect(ccResponse.detail.paymentProvider).to.equal(PaymentProvider.CreditCard);\n expect(ccResponse.detail.previousPaymentProvider).to.equal(undefined);\n\n // on subsequent payment provider choices, the previousPaymentProvider is populated\n setTimeout(() => {\n const venmoButton = paymentSelector.shadowRoot?.querySelector('.venmo') as HTMLButtonElement;\n const venmoClickEvent = new MouseEvent('click');\n venmoButton.dispatchEvent(venmoClickEvent);\n });\n const venmoResponse = await oneEvent(el, 'paymentProviderSelected');\n expect(venmoResponse).to.exist;\n expect(venmoResponse.detail.paymentProvider).to.equal(PaymentProvider.Venmo);\n expect(venmoResponse.detail.previousPaymentProvider).to.equal(PaymentProvider.CreditCard);\n });\n});\n"]}
|
|
@@ -2,7 +2,7 @@ import { __awaiter } from "tslib";
|
|
|
2
2
|
import { html, fixture, expect, elementUpdated, oneEvent } from '@open-wc/testing';
|
|
3
3
|
import '../../../src/form-elements/payment-selector';
|
|
4
4
|
import { MockPaymentProviders } from '../../mocks/payment-providers/mock-payment-providers';
|
|
5
|
-
import { promisedSleep } from '
|
|
5
|
+
import { promisedSleep } from '../../../src/util/promisedSleep';
|
|
6
6
|
describe('Payment Selector', () => {
|
|
7
7
|
it('shows Venmo if it is available', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
8
8
|
var _a;
|