From 4b646d40ea072a98d3d5c2eb6dd7ab44c4a2ddca Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Fri, 18 Feb 2022 22:36:01 +0000 Subject: [PATCH] Added non-Stripe members setting screen acceptance tests refs https://github.com/TryGhost/Team/issues/1358 - added acceptance tests for members settings screen - subscription access management - default post access management - free tier management - fixed `enableLabsFlag()` test helper overwriting existing flag settings when enabling another one - updated API mocks and fixtures - matched product fixtures to default tiers-enabled products - updated product API mocks to include benefit handling --- ghost/admin/.lint-todo | 5 + .../admin/app/components/gh-benefit-item.hbs | 11 +- .../visibility-segment-select.hbs | 3 +- .../admin/app/components/gh-product-card.hbs | 46 +-- ghost/admin/app/components/gh-product-card.js | 1 - ghost/admin/app/components/gh-url-input.hbs | 1 + ghost/admin/app/components/modal-product.hbs | 55 ++-- .../settings/members-default-post-access.hbs | 6 +- .../settings/members-default-post-access.js | 2 +- .../settings/members-subscription-access.hbs | 4 +- .../app/templates/settings/membership.hbs | 11 +- ghost/admin/mirage/config/products.js | 23 +- ghost/admin/mirage/factories/product.js | 25 ++ ghost/admin/mirage/fixtures/products.js | 45 +-- ghost/admin/mirage/fixtures/settings.js | 30 ++ ghost/admin/mirage/models/product-benefit.js | 5 + ghost/admin/mirage/models/product.js | 5 +- .../mirage/serializers/product-benefit.js | 3 + ghost/admin/mirage/serializers/product.js | 22 ++ ghost/admin/tests/acceptance/offers-test.js | 5 +- .../acceptance/settings/membership-test.js | 283 ++++++++++++++++++ ghost/admin/tests/helpers/labs-flag.js | 3 +- 22 files changed, 505 insertions(+), 89 deletions(-) create mode 100644 ghost/admin/mirage/factories/product.js create mode 100644 ghost/admin/mirage/models/product-benefit.js create mode 100644 ghost/admin/mirage/serializers/product-benefit.js create mode 100644 ghost/admin/mirage/serializers/product.js create mode 100644 ghost/admin/tests/acceptance/settings/membership-test.js diff --git a/ghost/admin/.lint-todo b/ghost/admin/.lint-todo index bd2304536f..ddf9ec7544 100644 --- a/ghost/admin/.lint-todo +++ b/ghost/admin/.lint-todo @@ -1831,3 +1831,8 @@ remove|ember-template-lint|no-action|7|12|7|12|fada170dae44678cba8240b4ae3233c63 remove|ember-template-lint|no-action|17|12|17|12|b75d66d02a33b108a64bb94d494fa194434c82f9|1644364800000|1646956800000|1649545200000|lib/koenig-editor/addon/components/koenig-toolbar.hbs remove|ember-template-lint|no-action|28|16|28|16|e5e787868d089ae3141666004a914deff774b489|1644364800000|1646956800000|1649545200000|lib/koenig-editor/addon/components/koenig-toolbar.hbs remove|ember-template-lint|no-action|70|12|70|12|03d2eaf613eae8cb3ea3c821ba63544c730364c8|1644364800000|1646956800000|1649545200000|lib/koenig-editor/addon/components/koenig-toolbar.hbs +remove|ember-template-lint|no-duplicate-landmark-elements|126|24|126|24|a19c12d5f0d5fa9b890943214b862502d9f2dcee|1643760000000|1646352000000|1648940400000|app/components/modal-product.hbs +remove|ember-template-lint|no-nested-landmark|126|24|126|24|a19c12d5f0d5fa9b890943214b862502d9f2dcee|1643760000000|1646352000000|1648940400000|app/components/modal-product.hbs +remove|ember-template-lint|no-duplicate-attributes|9|4|9|4|6b5f76f812df2b84f2ed9ee5a557ca1bf98710df|1643760000000|1646352000000|1648940400000|app/components/gh-post-settings-menu/visibility-segment-select.hbs +add|ember-template-lint|no-duplicate-landmark-elements|131|24|131|24|9eb7d301f1f50334e793aafab8f6b9e8905125ab|1645142400000|1647734400000|1650322800000|app/components/modal-product.hbs +add|ember-template-lint|no-nested-landmark|131|24|131|24|9eb7d301f1f50334e793aafab8f6b9e8905125ab|1645142400000|1647734400000|1650322800000|app/components/modal-product.hbs diff --git a/ghost/admin/app/components/gh-benefit-item.hbs b/ghost/admin/app/components/gh-benefit-item.hbs index 96262e5bb5..64b6300c16 100644 --- a/ghost/admin/app/components/gh-benefit-item.hbs +++ b/ghost/admin/app/components/gh-benefit-item.hbs @@ -21,19 +21,22 @@ @input={{action "updateLabel" value="target.value"}} @keyPress={{action "clearLabelErrors"}} @stopEnterKeyDownPropagation={{true}} - @focus-out={{action "updateLabel" this.name}} data-test-input="name" /> + @focus-out={{action "updateLabel" this.name}} + data-test-input="benefit-label" /> + + @property="name" + data-test-error="benefit-label" /> {{#if this.benefitItem.isNew}} - {{else}} - {{/if}} diff --git a/ghost/admin/app/components/gh-post-settings-menu/visibility-segment-select.hbs b/ghost/admin/app/components/gh-post-settings-menu/visibility-segment-select.hbs index fa69faa1ae..1f238b14f3 100644 --- a/ghost/admin/app/components/gh-post-settings-menu/visibility-segment-select.hbs +++ b/ghost/admin/app/components/gh-post-settings-menu/visibility-segment-select.hbs @@ -6,12 +6,11 @@ @allowCreation={{false}} @renderInPlace={{this.renderInPlace}} @onChange={{this.setSegment}} - @disabled={{@disabled}} @class="select-members" @placeholder="Select a tier" as |option| > - {{option.name}} + {{option.name}} +
-

- {{this.product.name}} +

+ {{@product.name}}

-

- {{#if this.product.description.length}} - {{this.product.description}} +

+ {{#if @product.description.length}} + {{@product.description}} {{else}} No description added for this tier. {{/if}}

-
-

Benefits ({{if this.product.benefits.length this.product.benefits.length "0"}})

- {{#if this.product.benefits.length}} +
+

Benefits ({{or @product.benefits.length "0"}})

+ {{#if @product.benefits.length}}
    - {{#each this.product.benefits as |benefit|}} + {{#each @product.benefits as |benefit|}}
  • {{svg-jar "check"}} {{benefit.name}}
  • {{/each}}
@@ -23,10 +23,10 @@

No benefits added for this tier.

{{/if}}
- {{#if (eq this.product.type "free" )}} + {{#if (eq @product.type "free" )}}
-
+
{{currency-symbol this.productCurrency}} 0 @@ -35,31 +35,31 @@
{{/if}} - {{#if (eq this.product.type "paid" )}} + {{#if (eq @product.type "paid" )}}
-
+
{{currency-symbol this.productCurrency}} - {{gh-price-amount this.product.monthlyPrice.amount}} + {{gh-price-amount @product.monthlyPrice.amount}}
Monthly
-
+
{{currency-symbol this.productCurrency}} - {{gh-price-amount this.product.yearlyPrice.amount}} + {{gh-price-amount @product.yearlyPrice.amount}}
Yearly
{{/if}} - {{#if (eq this.product.type "paid" )}} + {{#if (eq @product.type "paid" )}}
  • -
  • {{#if this.showArchiveOption}}
  • @@ -92,7 +92,7 @@
    {{else}}
    - -
    -