PageSourceSearch

https://app.cookiefirst.com/dist/2026-09-15/13-16-9680/inputs/Choo…-ChooseSiteSubscriptionPlan-test.8c3f336.js

js cookiefirst.com collected 2026-10-01 08:36:28 UTC 7,078 bytes, 2 lines download raw bytes

1/*! For license information please see ChooseSiteSubscriptionPlan-__tests__-ChooseSiteSubscriptionPlan-test.8c3f336.js.LICENSE.txt */
2"use strict";(self.webpackChunkcookiefirst_admin_panel=self.webpackChunkcookiefirst_admin_panel||[]).push([[6489],{55840:function(e,t,n){n.r(t);var o=n(10467),l=n(58168),a=n(54756),c=n.n(a),i=n(40253),d=n(96540),u=n(33274);jest.mock("../../../../Button",function(){return function(e){return d.createElement("button",{"data-testid":"choose-plan-button",type:e.type,disabled:e.disabled,onClick:e.onClick},e.children)}}),jest.mock("../../../../ChoosePlanModal",function(){return function(e){return e.isModalOpen?d.createElement("div",{"data-testid":"choose-plan-modal"},d.createElement("div",{"data-testid":"modal-title"},e.title),d.createElement("button",{"data-testid":"select-plan",onClick:function(){return e.onPlanChosen({uuid:"plan-123",name:"Basic",billing_period:"monthly"},{})}},"Select Plan"),d.createElement("button",{"data-testid":"close-modal",onClick:e.onClose},"Close")):null}}),jest.mock("../../../../../hooks/useTranslate",function(){return function(){return[function(e,t){return{"components:choose_site_plan_field.button_label":"Choose Subscription Plan","components:choose_site_plan_field.title":"Select Plan","components:choose_plan.billing_period.monthly":"Monthly","components:choose_plan.billing_period.yearly":"Yearly"}[e]||e}]}}),delete window.location,window.location={reload:jest.fn()},describe("ChooseSiteSubscriptionPlan",function(){var e={value:null,onChange:jest.fn(),disabled:!1,invalid:!1};beforeEach(function(){jest.clearAllMocks()}),it("should render button",function(){(0,i.XX)(d.createElement(u.default,e)),expect(i.nj.getByTestId("choose-plan-button")).toBeInTheDocument()}),it("should show default button label when no plan selected",function(){(0,i.XX)(d.createElement(u.default,e)),expect(i.nj.getByText("Choose Subscription Plan")).toBeInTheDocument()}),it("should show custom button label when provided",function(){(0,i.XX)(d.createElement(u.default,(0,l.A)({},e,{btnLabel:"Custom Label"}))),expect(i.nj.getByText("Custom Label")).toBeInTheDocument()}),it("should show plan name and billing period when plan selected",function(){(0,i.XX)(d.createElement(u.default,(0,l.A)({},e,{value:{uuid:"plan-123",name:"Basic",billing_period:"monthly"}}))),expect(i.nj.getByText("Basic (Monthly)")).toBeInTheDocument()}),it("should open modal when button clicked",function(){(0,i.XX)(d.createElement(u.default,e)),i.rC.click(i.nj.getByTestId("choose-plan-button")),expect(i.nj.getByTestId("choose-plan-modal")).toBeInTheDocument()}),it("should not open modal initially",function(){(0,i.XX)(d.createElement(u.default,e));var t=i.nj.queryByTestId("choose-plan-modal");expect(t).toBeDefined()}),it("should open modal on init when openModalOnInit is true",function(){(0,i.XX)(d.createElement(u.default,(0,l.A)({},e,{openModalOnInit:!0}))),expect(i.nj.getByTestId("choose-plan-modal")).toBeInTheDocument()}),it("should close modal when close button clicked",function(){(0,i.XX)(d.createElement(u.default,e)),i.rC.click(i.nj.getByTestId("choose-plan-button")),i.rC.click(i.nj.getByTestId("close-modal")),expect(i.nj.queryByTestId("choose-plan-modal")).not.toBeInTheDocument()}),it("should call onChange when plan selected",function(){var t=jest.fn();(0,i.XX)(d.createElement(u.default,(0,l.A)({},e,{onChange:t}))),i.rC.click(i.nj.getByTestId("choose-plan-button")),i.rC.click(i.nj.getByTestId("select-plan")),expect(t).toHaveBeenCalledWith({uuid:"plan-123",name:"Basic",billing_period:"monthly"},{})}),it("should close modal after plan selected",function(){(0,i.XX)(d.createElement(u.default,e)),i.rC.click(i.nj.getByTestId("choose-plan-button")),i.rC.click(i.nj.getByTestId("select-plan")),expect(i.nj.queryByTestId("choose-plan-modal")).not.toBeInTheDocument()}),it("should reload page after plan selected",function(){(0,i.XX)(d.createElement(u.default,e)),i.rC.click(i.nj.getByTestId("choose-plan-button")),i.rC.click(i.nj.getByTestId("select-plan")),expect(window.location.reload).toHaveBeenCalled()}),it("should not reload page when openModalOnInit is true",function(){(0,i.XX)(d.createElement(u.default,(0,l.A)({},e,{openModalOnInit:!0}))),i.rC.click(i.nj.getByTestId("select-plan")),expect(window.location.reload).not.toHaveBeenCalled()}),it("should disable button when disabled prop is true",function(){(0,i.XX)(d.createElement(u.default,(0,l.A)({},e,{disabled:!0}
2))),expect(i.nj.getByTestId("choose-plan-button")).toBeDisabled()}),it("should not disable button when disabled prop is false",function(){(0,i.XX)(d.createElement(u.default,(0,l.A)({},e,{disabled:!1}))),expect(i.nj.getByTestId("choose-plan-button")).not.toBeDisabled()}),it("should apply is-invalid class when invalid",function(){var t=(0,i.XX)(d.createElement(u.default,(0,l.A)({},e,{invalid:!0}))).container;expect(t.querySelector(".is-invalid")).toBeInTheDocument()}),it("should not apply is-invalid class when valid",function(){var t=(0,i.XX)(d.createElement(u.default,(0,l.A)({},e,{invalid:!1}))).container;expect(t.querySelector(".is-invalid")).not.toBeInTheDocument()}),it("should have type button",function(){(0,i.XX)(d.createElement(u.default,e)),expect(i.nj.getByTestId("choose-plan-button")).toHaveAttribute("type","button")}),it("should open modal when value changes to null",(0,o.A)(c().mark(function t(){return c().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return(0,(0,i.XX)(d.createElement(u.default,(0,l.A)({},e,{value:{uuid:"plan-123",name:"Basic"}}))).rerender)(d.createElement(u.default,(0,l.A)({},e,{value:null}))),t.next=1,(0,i.fm)(function(){expect(i.nj.getByTestId("choose-plan-modal")).toBeInTheDocument()});case 1:case"end":return t.stop()}},t)}))),it("should update button label when plan changes",function(){var t=(0,i.XX)(d.createElement(u.default,e)).rerender;expect(i.nj.getByTestId("choose-plan-button")).toHaveTextContent("Choose Subscription Plan"),t(d.createElement(u.default,(0,l.A)({},e,{value:{name:"Plus",billing_period:"yearly"}}))),expect(i.nj.getByTestId("choose-plan-button")).toBeInTheDocument()}),it("should pass title to modal",function(){(0,i.XX)(d.createElement(u.default,e)),i.rC.click(i.nj.getByTestId("choose-plan-button")),expect(i.nj.getByTestId("modal-title")).toHaveTextContent("Select Plan")}),it("should handle yearly billing period",function(){(0,i.XX)(d.createElement(u.default,(0,l.A)({},e,{value:{name:"Pro",billing_period:"yearly"}}))),expect(i.nj.getByText("Pro (Yearly)")).toBeInTheDocument()}),it("should apply form-control class",function(){var t=(0,i.XX)(d.createElement(u.default,e)).container;expect(t.querySelector(".form-control")).toBeInTheDocument()}),it("should apply input class",function(){var t=(0,i.XX)(d.createElement(u.default,e)).container;expect(t.querySelector(".input")).toBeInTheDocument()}),it("should pass through additional props to modal",function(){(0,i.XX)(d.createElement(u.default,(0,l.A)({},e,{customProp:"test-value"}))),i.rC.click(i.nj.getByTestId("choose-plan-button")),expect(i.nj.getByTestId("choose-plan-modal")).toBeInTheDocument()})})}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.