Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added e2e tests for post.published.edited webhook #15642

Merged
merged 1 commit into from Oct 24, 2022

Conversation

kritikash18
Copy link
Contributor

Added e2e tests for post.published.edited webhook

Refs #15537

@kritikash18
Copy link
Contributor Author

Hi @naz, I seem to be running into an odd issue with this one.

When I run single test suite with command:
yarn test:single test/e2e-webhooks/posts.test.js

Everything works fine and I get this result:

7 passing (4s)
✨  Done in 6.11s.

But when I run all test suites using this command:
yarn test:all

I get this result:

post.* events
       post.published.edited event is triggered:
     "response.body" does not match snapshot.

Snapshot name: `post.* events post.published.edited event is triggered 2: [body] 1`

- Expected properties  - 7
+ Received value       + 7

@@ -13,13 +13,13 @@
              },
            ],
            "updated_at": StringMatching /\\d\{4\}-\\d\{2\}-\\d\{2\}T\\d\{2\}:\\d\{2\}:\\d\{2\}\\\.000Z/,
          },
        ],
-       "comment_id": StringMatching /\[a-f0-9\]\{24\}/,
-       "created_at": StringMatching /\\d\{4\}-\\d\{2\}-\\d\{2\}T\\d\{2\}:\\d\{2\}:\\d\{2\}\\\.000Z/,
-       "id": StringMatching /\[a-f0-9\]\{24\}/,
+       "comment_id": "634d776ee8a14c09c4c36ef5",
+       "created_at": "2022-10-17T15:40:30.000Z",
+       "id": "634d776ee8a14c09c4c36ef5",
        "primary_author": Object {
          "created_at": StringMatching /\\d\{4\}-\\d\{2\}-\\d\{2\}T\\d\{2\}:\\d\{2\}:\\d\{2\}\\\.000Z/,
          "last_seen": StringMatching /\\d\{4\}-\\d\{2\}-\\d\{2\}T\\d\{2\}:\\d\{2\}:\\d\{2\}\\\.000Z/,
          "roles": Array [
            Object {
@@ -28,11 +28,11 @@
              "updated_at": StringMatching /\\d\{4\}-\\d\{2\}-\\d\{2\}T\\d\{2\}:\\d\{2\}:\\d\{2\}\\\.000Z/,
            },
          ],
          "updated_at": StringMatching /\\d\{4\}-\\d\{2\}-\\d\{2\}T\\d\{2\}:\\d\{2\}:\\d\{2\}\\\.000Z/,
        },
-       "published_at": StringMatching /\\d\{4\}-\\d\{2\}-\\d\{2\}T\\d\{2\}:\\d\{2\}:\\d\{2\}\\\.000Z/,
+       "published_at": "2022-10-17T15:40:30.000Z",
        "tiers": Array [
          Object {
            "created_at": StringMatching /\\d\{4\}-\\d\{2\}-\\d\{2\}T\\d\{2\}:\\d\{2\}:\\d\{2\}\\\.000Z/,
            "id": StringMatching /\[a-f0-9\]\{24\}/,
            "updated_at": StringMatching /\\d\{4\}-\\d\{2\}-\\d\{2\}T\\d\{2\}:\\d\{2\}:\\d\{2\}\\\.000Z/,
@@ -41,13 +41,13 @@
            "created_at": StringMatching /\\d\{4\}-\\d\{2\}-\\d\{2\}T\\d\{2\}:\\d\{2\}:\\d\{2\}\\\.000Z/,
            "id": StringMatching /\[a-f0-9\]\{24\}/,
            "updated_at": StringMatching /\\d\{4\}-\\d\{2\}-\\d\{2\}T\\d\{2\}:\\d\{2\}:\\d\{2\}\\\.000Z/,
          },
        ],
-       "updated_at": StringMatching /\\d\{4\}-\\d\{2\}-\\d\{2\}T\\d\{2\}:\\d\{2\}:\\d\{2\}\\\.000Z/,
-       "url": StringMatching /http:\\/\\/127\.0\.0\.1:2369\\/\\w\+\\//,
-       "uuid": StringMatching /\[a-f0-9\]\{8\}-\[a-f0-9\]\{4\}-\[a-f0-9\]\{4\}-\[a-f0-9\]\{4\}-\[a-f0-9\]\{12\}/,
+       "updated_at": "2022-10-17T15:40:30.000Z",
+       "url": "http://127.0.0.1:2369/testing-post-published-edited-webhook/",
+       "uuid": "08c2b1d7-3cd1-4b1f-a15a-016c137029cc",
      },
      "previous": Object {
        "tiers": Array [

Any pointers on what could I be missing?

@codecov
Copy link

codecov bot commented Oct 17, 2022

Codecov Report

Base: 52.92% // Head: 52.91% // Decreases project coverage by -0.00% ⚠️

Coverage data is based on head (58e6153) compared to base (48b033f).
Patch has no changes to coverable lines.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15642      +/-   ##
==========================================
- Coverage   52.92%   52.91%   -0.01%     
==========================================
  Files        1465     1465              
  Lines       95683    95683              
  Branches    10739    10739              
==========================================
- Hits        50639    50631       -8     
- Misses      43800    43808       +8     
  Partials     1244     1244              
Impacted Files Coverage Δ
ghost/admin/app/helpers/gh-price-amount.js 44.44% <0.00%> (-22.23%) ⬇️
ghost/admin/app/components/gh-file-uploader.js 82.94% <0.00%> (-3.11%) ⬇️
ghost/admin/app/components/gh-site-iframe.js 43.18% <0.00%> (-2.28%) ⬇️
ghost/admin/app/controllers/offer.js 41.57% <0.00%> (-0.53%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@naz
Copy link
Member

naz commented Oct 18, 2022

Hey-hey @kritikash18 👋 Could this possibly be a problem with matching the "author" propery like the discussed here? 🤔

@halldorbjarni
Copy link
Contributor

Hey @kritikash18, I was curious if this was the same issue that I ran into. It turns out the routing issue is present here but it's actually the reason your single test suite run works.

yarn test:single test/e2e-webhooks/posts.test.js generates a post['current']['url'] = 'http://127.0.0.1:2369/404/' due to the routing bug mentioned above and sends it to the webhook. Luckily this still matches the regex for anyLocalURL perfectly.

However, yarn test:all generates the correct post['current']['url'] = http://127.0.0.1:2369/testing-post-published-edited-webhook/' but here the regex anyLocalURL doesn't match since it doesn't support dashes. To add it you can edit the anyLocalUrl matcher at Ghost/ghost/core/test/utils/e2e-framework.js to be something like stringMatching(/http:\/\/127.0.0.1:2369\/\[w-]+\//),. Other url allowed symbols could be added as well for completeness.

What I'm mostly curious about is why this matching error is not singled out in the output and instead the jest diff points at all the matchers as a potential problem. Any idea here @naz? I'm not sure if it's a jest bug or a bug in how Ghost directly invokes some internal jest packages.

@naz
Copy link
Member

naz commented Oct 19, 2022

Oh hey @halldorbjarni 👋 Thanks for joining the discussion!

matching error is not singled out in the output

I've came across this issue few times now and I think it's worth the investigation and a separate issue in the test framework. It's super hard to figure out which parts did not match with the current output 💯

@halldorbjarni
Copy link
Contributor

I've came across this issue few times now and I think it's worth the investigation and a separate issue in the test framework.

@naz I agree. It reproduces on a minimal example. I've opened a bug on jest. Let's get this fixed!

@kritikash18
Copy link
Contributor Author

Updated the local URL to support - and it worked. Thanks for the pointers @naz and @halldorbjarni !

@naz naz self-assigned this Oct 24, 2022
@@ -384,7 +384,7 @@ module.exports = {
// @NOTE: hack here! it's due to https://github.com/TryGhost/Toolbox/issues/341
// this matcher should be removed once the issue is solved - routing is redesigned
// An ideal solution would be removal of this matcher altogether.
anyLocalURL: stringMatching(/http:\/\/127.0.0.1:2369\/\w+\//),
anyLocalURL: stringMatching(/http:\/\/127.0.0.1:2369\/[A-Za-z0-9_-]+\//),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohhh! nice catch here 🎣

Copy link
Member

@naz naz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to land in the main 👍 Thanks for great work @kritikash18!

@ErisDS ErisDS changed the title Added e2e tests for post.published.edited webhook Added e2e tests for post.published.edited webhook Oct 24, 2022
@ErisDS ErisDS merged commit 26d0499 into TryGhost:main Oct 24, 2022
@ErisDS
Copy link
Member

ErisDS commented Oct 24, 2022

@kritikash18 merged and labelled 🎉 Thanks so much for your continued contributions, please keep them coming 🙏

CarolBarno added a commit to CarolBarno/Ghost that referenced this pull request Oct 24, 2022
* Added Tier price and currency data to products table (TryGhost#15366)

refs https://github.com/TryGhost/Team/issues/1765

In order to better handle deleted objects in Stripe we want to decouple
Members from Stripe.

These changes allow us to have the Tier concept completely independent
of the Stripe tables, such that the Stripe data can be generated as/when
it's needed - which will help to protect against missing data.

* 🐛 Removed redirects from search engine indexing (TryGhost#15617)

refs https://github.com/TryGhost/Team/issues/2072

Google is indexing our redirects and storign the redirected content
against the redirect URL in search results. This seems to be caused by
us using a 302 redirect rather than 301. We don't want to switch to a
301 however, so that we can support the ability to update redirects in
the future.

* Stored price and currency data on Tiers when creating & editing

refs https://github.com/TryGhost/Team/issues/2029

This will allow us to start decoupling the Stripe side of things once we've got
the core data stored. We've also add some integrity checks on the incoming
monthly_price and yearly_price to ensure they are the same currency.

* Fixed up more like this and newsletter clicks table at narrower viewports

no issue

* Updated engagement bar metrics so when no link it doesn't hover

no issue

* Added the feedback buttons in the emails (TryGhost#15619)

closes TryGhost/Team#2046
closes TryGhost/Team#2045
- Added feedback buttons markup.
- Added feedback links generation.

* v5.19.0

* Fix newsletter links (TryGhost#15621)

Added a button for editing links in newsletters after sending to the
Post analytics page

Co-authored-by: Rishabh <zrishabhgarg@gmail.com>

* Added ability to handle feedback links from emails (TryGhost#15622)

* Updated test snapshot after bumping Portal (TryGhost#15623)

* Bumped portal package.json to latest version

refs TryGhost@d381ff8

- portal was bumped to 2.15 but the version in package json didn't get auto-updated

* Fixed optional syntax style for jsdoc

refs https://jsdoc.app/tags-param.html#optional-parameters-and-default-values

- using an equals sign in the type definition is part of the Google
  Closure syntax but we use the JSDoc syntax in all other places, and
  tsc detects the different syntax
- this commit standardizes the syntax ahead of enforcing a certain style
  down the line

* Bumped `kg-lexical-html-renderer` version
no issue

- Bumped from 0.0.8 to 0.0.9

* Fixed unnecessary requests with loading comment counts

refs https://github.com/TryGhost/Team/issues/2082

- if a site has comments enabled but doesn't use the `comments_count`
  helper, the comments-count.min.js will still be loaded and it'll send
  a POST request to Ghost with an empty array of post IDs to fetch
- this is unnecessary and we should avoid this extra request for pages
  that don't need to show comment counts
- this commit prevents the comment-counts JS from sending the request if
  there are no post IDs to fetch

* Fixed unnecessary requests with loading comment counts

refs https://github.com/TryGhost/Team/issues/2082

- if a site has comments enabled but doesn't use the `comments_count`
  helper, the comments-count.min.js will still be loaded and it'll send
  a POST request to Ghost with an empty array of post IDs to fetch
- this is unnecessary and we should avoid this extra request for pages
  that don't need to show comment counts
- this commit prevents the comment-counts JS from sending the request if
  there are no post IDs to fetch

* Added handling for unsuccessful comments API requests

refs https://github.com/TryGhost/Team/issues/2082

- in the event the API doesn't return a 200 OK, we shouldn't be
  processing the response from it, as we can end up doing weird things
  if, for example, an error object is returned

* Added handling for unsuccessful comments API requests

refs https://github.com/TryGhost/Team/issues/2082

- in the event the API doesn't return a 200 OK, we shouldn't be
  processing the response from it, as we can end up doing weird things
  if, for example, an error object is returned

* Fixed loading animation for Safari

no refs.

- the size of the loading animation in Safari wasn't set correctly and didn't always start automatically

* Added imageUpload function to Lexical Editor (TryGhost#15634)

no issue

- A basic image upload function for testing the image card of the new Lexical Koenig Editor.

* Update dependency util to v0.12.5

* Update dependency mocha to v10.1.0

* 🐛 Fixed 404 collection links for new tags

closes TryGhost#15608
closes https://github.com/TryGhost/Toolbox/issues/437
refs bookshelf/bookshelf#2111
refs knex/knex#1641

- When new tag was attached to the post the tag collection link returned 404 - instead of a collection with one post
- The root cause of the issue and it's flaky behavior (sometimes the collection link was returning correctly) was a race condition between event propagation in routing for "tag.attached" event and the post+tag+relations transaction completion
- The race condition was happening as the bookshelf-transaction-events plugin was emitting the 'committed' event BEFORE the transaction was committed!

* v5.19.1

* Added conversions count and separate analytics page (TryGhost#15637)

fixes https://github.com/TryGhost/Team/issues/2084

- When audience feedback is enabled, we use a single 'conversions' count instead of having separate ones for signups and paid conversions.
- The analytics component is separated so we can change it without breaking the existing page.

* Fixed PromiseObject related errors thrown from members activity list (TryGhost#15641)

no issue

- the `memberRecord` getter on the members activity controller was
returning the direct result of `store.findRecord()` which in reality is
a `PromiseObject` that is a type of proxy. Although templates handle
this OK, any JS code using the object needs to know that it's not a
typical type of object and has to use `.get()` for all property access
to avoid errors
- switched `memberRecord` from a getter to a resource so we have more
control over the returned object and loading lifecycle
- added a `MemberFetcher` resource class that awaits the result of the
store find and only then sets the value meaning we always have a fully
resolved model object
- being a resource the fetch will only occur when the `member` id
property changes, unlike the getter which performed the fetch every time
it was accessed

* Added feedback events to activity feed (TryGhost#15639)

fixes https://github.com/TryGhost/Team/issues/2051
fixes https://github.com/TryGhost/Team/issues/2052

* Added support for supplying the foreign key constraint name

- this allows us to choose the foreign key constraint name when the
  auto-generated one would be too long

* Allowed `constraintName` in schema column spec

refs TryGhost@0ba3d6d

- this is used to indicate the name of the foreign key constraint and so
  we should let it through the schema checks

* Fixed various code nits with schema command utils

- de-duped the exports at the bottom if they export the same name as the
  function
- added types to all functions, or fixed existing ones
- renamed `table` to `tableBuilder` to represent it better
- these should help with code readability and autocomplete in editors

* Dropped nullable status on `subscriptions.tier_id`

fixes https://github.com/TryGhost/Team/issues/2102

- this column was added with `nullable: true` but it should never be
  nullable, so we should drop the nullable status whilst it's easy to

* Improved jsdoc for permission migration utils

- this helps with readability and editor autocomplete

* 🐛 Fixed large mailgun recipient data (TryGhost#15638)

fixes https://github.com/TryGhost/Team/issues/2096

When generating the recipient data for emails, the email clicks
implementation is resulting in a recipient variable being added called
replacement_xxx once for each link containing the same UUID.

This generates a lot of unnecessary data overhead for emails, and it
turns out that mailgun has a 25MB message limit. We wouldn't have come
close if we only included the uuid once.

* v5.19.2

* Added design for success and error states for editing newsletter links

refs https://github.com/TryGhost/Team/issues/2095
refs https://github.com/TryGhost/Team/issues/2098

- Added success state design for editing links in newsletters
- Added error state for invalid URL when editing links in newsletters

* Fixed broken `ember-svg-jar` asset viewer

no issue

- downgraded to `2.3.4` because `2.4.0` is missing the asset viewer assets, see evoactivity/ember-svg-jar#233

* Update dependency ember-template-lint to v4.16.0

* Added post_id filter and total to activity feed API (TryGhost#15650)

fixes https://github.com/TryGhost/Team/issues/2091
fixes https://github.com/TryGhost/Team/issues/2089

- Added new fixtures to make testing easier for the activity feed
- Improved E2E test coverage of activity feed with separate test file
- Added data.post_id filter to enable filtering by events related to a
given post
- Fixed return types in JSDoc of test agents (TypeScript interprets
these as `typeof Agent` if we don't add `InstanceType<Agent>`)
- Added total pagination metadata to activity feed API (to allow a basic
type of pagination using filters)

* 🐛 Fixed alpha feature visible in new newsletters

no issue

* Added test to check if feedback buttons are hidden if alpha flag is disabled

* v5.19.3

* Update dependency ember-template-lint to v4.16.1

* Refactored Tiers logic into separate package

refs https://github.com/TryGhost/Team/issues/2078

This pulls the current Tiers logic into its own package, the persistence part of
the work has not been done yet, that will be handled in core, so all bookshelf
model specific stuff is kept together.

* Supported payment URL in Portal

refs https://github.com/TryGhost/Team/issues/2078

As part of decoupling Stripe from the members feature, we are going to be using
payment URLs rather than Stripe sepcific session ids and publick keys.

This prepares Portal to work with the new system, whilst retainign the existing
functionality

* Made edit link button always visible

refs https://github.com/TryGhost/Team/issues/2067

* Added newsletter links editing explanation text

refs https://github.com/TryGhost/Team/issues/2067

* Fixed overflow for newsletter links

refs https://github.com/TryGhost/Team/issues/2067

* Updated JSDoc and fixed typos

* Fixed typo

* Fixed typo

* Increased test coverage

refs https://github.com/TryGhost/Toolbox/issues/430

- The bonus of using the module exports file is that it also gets included in the test coverage statistics ^_^

* Added test coverage for 'subscribed' transform

refs https://github.com/TryGhost/Toolbox/issues/430

- Not having any extra logic in the mapper will allow to have a generalized "mapping" concept for CSV input serialization
- This is groundwork for stricter header value filtering on the parsing stage

* Added JSDoc to members csv parser

refs https://github.com/TryGhost/Toolbox/issues/430

- Typings make developer's life nicer

* Removed hidden row mapping in csv parser

refs https://github.com/TryGhost/Toolbox/issues/430
refs TryGhost#14882

- Having an explicit mappings passed into the members CSV parser makes it easier to control and understand the transforms for package clients
- Eventually the parser will receive a strict map with the fields it should parse - skipping all unknown & unmapped fields

* Extracted MembersCSVImporter to a builder method

refs https://github.com/TryGhost/Toolbox/issues/430
refs TryGhost#14882

- The MembersCSVImporter constructor is way to complex and needs refactoring. This complexity makes initialization in tests too bulky and makes tests hard to read.
- Having a builder method is a stopgap solution to avoid going into MembersCSVImporter refactoring too deep.

* Added future investigation note

refs https://github.com/TryGhost/Toolbox/issues/430

- This is a strange hardcoded value that seems like some legacy leftover concept we could do without or improve

* Removed unused concept of "status" in importer job

refs https://github.com/TryGhost/Toolbox/issues/430

- The job "status" is never anything different than "pending" and never leaves the module itself. It's an outdated concept that only takes up lines of code!

* Removed cleaned up use of "Job" object

refs https://github.com/TryGhost/Toolbox/issues/430

- Importer code was filled with an unnecessarily complex "job" object that was passed around. It had an "id" property, which confusingly was a path to a file at all times.
- Simplified the logic significantly by keeping and passing around the path to a "prepared" members CSV.

* Added basic test coverage for perform method

refs https://github.com/TryGhost/Toolbox/issues/430

- "perform()" is what gets executed by the import job for both immediate import and "inline job" import. Testing it on granular level will allow to change it with more confidence when introducing strict field mapping rules

* Moved header mapping configuration to importer

refs https://github.com/TryGhost/Toolbox/issues/430

- To be able to introduce strict mapping rules (exclude unknown fields) we need to control the CSV header mapping on the importer level. This change moves the configuration up from CSV parser to the importer
- Also adds tests covering correct inserts for specially treated "subscribed_to_emails" field

* Cleaned up test case names

* Cleaned up csv parse test suite

refs https://github.com/TryGhost/Toolbox/issues/430

- Removed unnecessary "readCSV" leftover code.

* Added strict header mapping parsing

refs https://github.com/TryGhost/Toolbox/issues/430

- Previously the CSV parser had "map whatever you can and pass on unknown properties further" approach to CSV parsing. This logic has led to unwanted fields leaking through CSV imports - messy, dangerous.
- The strict mapping rules act as a "validator" to the user input, only passing through the fields we expect explicitly - safer clean cut solution with no unintended side-effects.

* Migrated CSV parser tests to 'assert'

no issue

- Using native 'assert' module in unit tests is a preferred practice. Should is outdated and is phased out of codebase.

* Removed unused error message

no issue

- The job-related code was ripped out form the importer and this message was just an overlooked leftover

* Made running the import outside of job on test env

- Allows to write tests for the importer easier when there is a "subscription" or a "product" present

* Added strict field mapping to member CSV importer

closes https://github.com/TryGhost/Toolbox/issues/430

- The members importer used to  import all fields present in the uploaded CSV if the headers match, even if they're not mapped in the UI. This behavior has lead to have misleading consequences and "hidden" features. For example, if the field was present but intentionally left as "Not imported" in the UI the field would still get imported.
- Having a strict list of supported import fields also allows for manageable long-term maintenance of the CSV Import API and detect/communicate changes when they happen.
- The list of the current default field mapping is:

    email: 'email',
    name: 'name',
    note: 'note',
    subscribed_to_emails: 'subscribed',
    created_at: 'created_at',
    complimentary_plan: 'complimentary_plan',
    stripe_customer_id: 'stripe_customer_id',
    labels: 'labels',
    products: 'products'

* Fixed broken CSV importer tests

refs TryGhost@90768e9

- With introduction of strict field mapping the regression test testing for "imports of not mapped fields" failed.

* Added tabs component (TryGhost#15652)

closes TryGhost/Team#2086

* Updated feedback buttons url (TryGhost#15655)

closes TryGhost/Team#2080
- If the post was published and emailed the link leads the user to the
post.
- If the post was just emailed the link leads the user to the home page.

* Remove Grunt from `yarn setup` in Ghost core

no issue

* Added design for edited state of newsletter links

refs https://github.com/TryGhost/Team/issues/2111

- Added indicator that the link in a newsletter has been edited after sending

* Wired newsletter link success/error states

refs https://github.com/TryGhost/Team/issues/2116

- wires handling of success and error messages on editing a newsletter link
- has the update api commented out temporarily to mock the changes

* Added sentiment ordering and include for posts (TryGhost#15657)

fixes https://github.com/TryGhost/Team/issues/2090

- This changes how sentiment is exposed in the API. Now it is exposed as a `sentiment` relation, directly on the model (no longer in counts). Internally we still use `count.sentiment`.
- Content API users (and themes) can include the 'sentiment' relation and order by sentiment.
- Updated Admin to use sentiment instead of count.sentiment

* Fixed period filter not appearing on smaller screens on dashboard

no ref

* Added edited state for newsletter links

refs https://github.com/TryGhost/Team/issues/2111

- shows edited in UI next to edited newsletter links in post analytics

* Handled no empty sources for attribution table

- fixes an edge case where if a site has no unavailable sources in a particular period, it broke the table view as the `Others` data doesn't get fetched

* Fixed up the more like this event icons as they were too large

refs https://github.com/TryGhost/Team/issues/2106

* Update dependency mocha to v10.1.0

* Fixed permissions for links endpoint (TryGhost#15656)

refs TryGhost@5fcf509

- links browse endpoint had permissions switched off unintentionally and was also missing the necessary permissions in fixtures.
- enables permissions for browse endpoint and adds migration insert permissions in DB

* Update dependency ember-svg-jar to v2.4.1

* Update peter-evans/create-or-update-comment digest to 7305482

* Added permissions for link edit endpoints (TryGhost#15664)

refs https://github.com/TryGhost/Team/issues/2104

- adds edit permissions for links endpoints to fixtures
- new `bulkEdit` endpoint will use the permissions and allow fixing newsletter links via Admin

* Added `ghost_subscription_id` column to `members_stripe_customers_subscriptions`

refs https://github.com/TryGhost/Team/issues/2034

- this table will be used to link Stripe subscriptions to Ghost
  subscriptions via a foreign key that we add at a later point
- this also includes `constraintName` as the auto-generated one would be
  too long for MySQL 8

* Refactored TiersAPI to use core slug generation

refs https://github.com/TryGhost/Team/issues/2078

This removes the burden from the Tier object, and allows us to reuse
the existing slug generation implementation we have in our bookshelf
models.

* Fixed visibility property on Tiers

refs https://github.com/TryGhost/Team/issues/2078

This property should be settable to either 'public' or 'none'

* Updated Tier to use camelCase property names

refs https://github.com/TryGhost/Team/issues/2078

Having to map between snake_case and camelCase was becoming confusing, so this
updates the Tier object to exclusively use camelCase, and the snake_case for the
API can be handled by the serializer/mapper or at the controller level.

* Updated Tier welcomePageURL to be a string rather than URL

refs https://github.com/TryGhost/Team/issues/2078

We allow passing in relative URLs for the welcome page, so we need to accept a
string for this property.

* Fixed trialDays validation to default to 0

refs https://github.com/TryGhost/Team/issues/2078

This retains current functionality

* Added error messages for monthly & yearly price validation

refs https://github.com/TryGhost/Team/issues/2078

These were missing, and will be refactored into the correct
tpl(messages.prop) format

* Fixed edit method to accept a string

refs https://github.com/TryGhost/Team/issues/2078

This fixes a bug with the edit method where we passed a raw string
rather than ObjectID

* Fixed add method for TiersAPI

refs https://github.com/TryGhost/Team/issues/2078

The check for creating free Tiers needs to be explicit, rather than implicit
because the type is optional, we only want to error if it is explicitly passed
as "free", not if it is missing as "paid".

* Removed garbage test

no issue

- This test does nothing but occupy the disc space

* Moved the resources to the new style

refs https://github.com/TryGhost/Team/issues/2117

* Added 'getDefaultProduct' convenience method to product repo

refs https://github.com/TryGhost/Team/issues/1869

- There are multiple places in the codebase fetching "default product". The code is slightly divergent in each one of them and has been a source of bugs (like the one referenced). Having the logic captured in one place will allow reducing the code duplication, making code less bug prone, and making testing the modules dependent on the "setDefaultProduct" method easier

* Fixed comped tier assignment

closes https://github.com/TryGhost/Team/issues/1869

- When there were "archived" tiers in the system the importer incorrectly fetched them instead of only taking "active" ones into account. The "getDefaultProduct" on product repository does exactly that.
- Additionally, reusing the "getDefaultProduct" makes testing the importer slightly less complex.

* Reused getDefaultProduct where possible

refs TryGhost@82ed104
refs https://github.com/TryGhost/Team/issues/1869

- getDefaultProduct has unified logic across different places (see refed commit). It is recommended to use instead of writing custom queries prone to mistakes.
- Also added more readable name to the possible error message thrown by setComplimentarySubscription

* Added button for saving changes made to the link

refs https://github.com/TryGhost/Team/issues/2125

* Added support for Tier events

refs https://github.com/TryGhost/Team/issues/2078

These events are all required for other parts of the Ghost system to stay in
sync. The events on each Tier object will be dispatched by the TierRepository
once they've been persisted.

TierCreatedEvent - generate Stripe Products & Prices
TierNameChangeEvent - update Stripe Products
TierPriceChangeEvent - update Stripe Products & Prices
TierArchivedEvent - update the Portal settings for visible tiers
                  - disable Stripe Products & Prices
TierActivatedEvent - enable Stripe Products & Prices

* Exported Tier events from tiers package

These are required to be exported so that external code can subscribe to the
events.

* Made default and editing states the same height

refs https://github.com/TryGhost/Team/issues/2067

* Added support for filtering email events by post_id (TryGhost#15666)

refs https://github.com/TryGhost/Team/issues/2093

* Moving the post analytics layout closer to new design

- Newsletter clicks module has new header and box
- Source attribution module has new header and box
- Resources have new headers inside the box
- New split layout if there are two modules side-by-side

refs https://github.com/TryGhost/Team/issues/2119

* Added endpoint for fixing newsletter links

refs https://github.com/TryGhost/Team/issues/2104

- adds new bulk edit endpoint for links, updates all matching link with the current redirect url and update to new url

* Added reset for link click count on edit

refs https://github.com/TryGhost/Team/issues/2104

When a newsletter link is edited, we reset its click count to 0 to show only the clicks on newly edited links. This is done by only counting the member click events for a link which are greater than its last updated at, so that all previous click events are not counted for the link, but are included in the total count of all links on the page.

* Wired link update api on Admin

refs https://github.com/TryGhost/Team/issues/2116

- wires link update API on post analytics UI page to save edited links for a newsletter
- all links matching the edited link are updated by the API in the backend

* Added edited property to links api

refs https://github.com/TryGhost/Team/issues/2104

- adds a boolean `edited` property to links api that denotes if the link has been edited

* Updated success state for link update on Admin

refs https://github.com/TryGhost/Team/issues/2116

- removes extra redundant success state handling

* Fixed first and last child padding in edit mode

refs https://github.com/TryGhost/Team/issues/2067

* Added missing dependencies for link tracking

* Improved responsiveness

refs https://github.com/TryGhost/Team/issues/2067

* Deemphasized edited state

refs https://github.com/TryGhost/Team/issues/2127

* Fixed missing padding in post analytics header

refs https://github.com/TryGhost/Team/issues/2127

* Fixed unrelated elements sharing the same CSS class

refs https://github.com/TryGhost/Team/issues/2127

* Vertically aligned icons

refs https://github.com/TryGhost/Team/issues/2127

* Fixed explanation text not showing when there's no pagination

refs https://github.com/TryGhost/Team/issues/2127

* Added retry button in error state

refs https://github.com/TryGhost/Team/issues/2127

* Fixed jumping of links on edit in analytics

refs https://github.com/TryGhost/Team/issues/2116

- editing a link caused it to jump in the list as its count is reset to 0
- this forces the order of links same after edit, the new order is only visible on refresh or navigating away and coming back

* Added filtered events tables to the analytics page (TryGhost#15669)

closes TryGhost/Team#2087

* Updated edited state font weight for better contrast

refs https://github.com/TryGhost/Team/issues/2127

* Removed unnecessary padding

refs https://github.com/TryGhost/Team/issues/2127

* Updated save button handling for links

refs https://github.com/TryGhost/Team/issues/2116

* Fixed row hover effects in dark mode

refs https://github.com/TryGhost/Team/issues/2127

* Changed explainer text color and icon to deemphasize it

refs https://github.com/TryGhost/Team/issues/2127

* Refined link edit flow on Admin

refs https://github.com/TryGhost/Team/issues/2116

* Fixed cached redirects for edited newsletter links

refs https://github.com/TryGhost/Team/issues/2135

The email link redirects on Pro are cached as 302 redirects in Varnish, so we're missing further clicks after the first one for each member, until the cache is invalidated. This change invalidates cache on link edits to ensure that we correctly redirect members to updated link everytime

* Fixed lint

* Improved URL syncing between Admin and Explore (TryGhost#15640)

no issue

Improve the route communication between Ghost Admin and Ghost Explore to
reflect route changes in the URL and correctly navigate to Explore sub
routes

* Improved readability of unparse test

refs https://github.com/TryGhost/Team/issues/1076

- The column parameter has default behavior attached to it, so it is best to have it mentioned and used in an explicit way.

* Migrated unparse test suite to assert

refs https://github.com/TryGhost/Team/issues/1076

- The 'should' assertion library is deprecated. Native 'assert' is the recommended lib to use
- Migrating this bit of code allows to remove the should's "utils" folder. Less code, yey!

* Removed test "utils" folder

refs https://github.com/TryGhost/Team/issues/1076

- The members-csv package does not use "should" for assertions anymore, so the accompanying "utils" lib can go away now

* Added  100% unit test coverage to unparse

refs https://github.com/TryGhost/Team/issues/1076

- 100% is the golden standard. Easy to keep it this way once there

* Changed members export to contain tiers

refs https://github.com/TryGhost/Team/issues/1076

- The "products" is a legacy term for what is now "tiers" since multiple tiers feature introduction in https://github.com/TryGhost/Ghost/releases/tag/v4.39.0
- Note, the "tiers" is a field meant for informational purposes and cannot be imported back into Ghost site.

* Fixed date format for link bulk edit

refs https://github.com/TryGhost/Team/issues/2104

- updates date format for `updated_at` to use the right DB date format

* Refined link edit cancellation on analytics page

refs https://github.com/TryGhost/Team/issues/2116

- ignores blur events when link is edited via keypress

* Added e2e tests for `post.edited` webhook (TryGhost#15625)

refs: TryGhost#15537

- snapshot test created to add confidence to webhook stability and increase overall test coverage.

* Added e2e tests for `member.edited` webhook (TryGhost#15620)

refs: TryGhost#15537

- snapshot test created to add confidence to webhook stability and increase overall test coverage.

* Added e2e tests for `page.edited` webhook (TryGhost#15627)

refs: TryGhost#15537

- snapshot test created to add confidence to webhook stability and increase overall test coverage.

* Updated explainer text design

refs https://github.com/TryGhost/Team/issues/2127

* Added e2e test for `post.unpublished` webhook (TryGhost#15628)

refs: TryGhost#15537

- snapshot test created to add confidence to webhook stability and increase overall test coverage.

* Fixed test snapshots

refs TryGhost@5b28393

* Quick tweak to max height when there are columns side-by-side

refs https://github.com/TryGhost/Team/issues/2118

* Added e2e tests for `page.unpublished` webhook (TryGhost#15613)

refs: TryGhost#15537

- snapshot test created to add confidence to webhook stability and increase overall test coverage.

* Updated webhook test snapshots

refs: TryGhost@717a27c
refs: TryGhost@6380b82

- The snapshots just needed updating

* Better matching the pagination styles across modules for post analytics

- Careful of flags, having different paginations depending on those
- Little stylistic adjustment to how pagination is shown on engagement bar
- Quite a few feature flag checks to make sure the right style is showing

refs https://github.com/TryGhost/Team/issues/2136

* Added importer for custom theme settings (TryGhost#15596)

closes: TryGhost#15542

- custom theme settings were not reinstated on import
- importing custom theme settings for the current active theme requires the theme be re-activated

* Moved the newsletter settings option for audience feedback based on feedback

refs https://github.com/TryGhost/Team/issues/2124

* ✨ Allowed fixing newsletter links (TryGhost#15672)

refs https://github.com/TryGhost/Team/issues/2116

- allows site owners to edit a link in a post that has already been sent out, fixing any typos or other mistakes
- resets click counter for the edited link back to 0 so site owners can see the clicks on new link, doesn't change the overall click count

* v5.20.0

* Changing the metric to positive feedback rather than more like this

refs https://github.com/TryGhost/Team/issues/2138

* Making avatar initials smaller in the engagement bar

refs https://github.com/TryGhost/Team/issues/2139

* Added new members filters and refactored filters (TryGhost#15667)

fixes https://github.com/TryGhost/Team/issues/2112

- Removed a bit of duplicate code across templates and components that was used to handle filters
- Updated filter objects to contain information about the filter
- Added resource filters that are able to select a single resource, which can be used in columns
- Filters can now define columns by themselves. Not all columns already make use of this functionality, but we can move those over later (cleanup: https://github.com/TryGhost/Team/issues/2133)
- The filter definitions became quite long. We should move them to separate files in the future: https://github.com/TryGhost/Team/issues/2134
- Filters can now have custom NQL parsing
- Improved support for parsing recursive or grouped NQL queries
- Added support for filtering members by feedback

* Improved post activity feed table

no issue

- Fixed counter at the bottom
- Fixed forward > backward not working

* Add in dummy rows and empty states to the engagement bar

refs https://github.com/TryGhost/Team/issues/2130

* Removed bluebird from fixture-manager.js (TryGhost#15629)

refs: TryGhost#14882

- Removing bluebird specific methods in favour of the Ghost sequence method so we can remove the bluebird dependency

Co-authored-by: Hannah Wolfe <github.erisds@gmail.com>

* Added pie chart for activity feed (TryGhost#15673)

closes TryGhost/Team#2088
- Added pie chart to feedback event
- Added `negative_feedback` field to response from BE

* Removed bluebird from `fixture-utils.js` (TryGhost#15626)

refs: TryGhost#14882

- Opted to use the in-house `sequence` function when refactoring Bluebird's `Promise.each` to avoid deadlock issues (see TryGhost@734ef66). 
-It's hard to know without tonnes of context if any `Promise.each` are safe to refactor to `Promise.all`.

* 🐛 Fixed redirect to signin modal not shown when logged out (TryGhost#15522)

fixes:  TryGhost#15291

- An attempt to improve re-authenticate modal toggle - show re-authenticate modal every time user save (ctrl/cmd + s)
- An attempt to fix redirection when user re-login on different tab. Prevent redirection to sign-in page since the user already logged in on another tab.
- Re-enable `editor` test on `authentication-test.js`

* 🐛 Fixed missing unsaved changes modal for member newsletters (TryGhost#15564)

closes: TryGhost#15507

- manually handle relationship changes detection labels and newsletters
- add `dirtyAttributes` controller property - return newsletters and labels dirty attributes status

* Lock file maintenance

* Update dependency eslint to v8.26.0

* Update dependency ember-auto-import to v2.4.3

* Update dependency inquirer to v8.2.5

* Update dependency concurrently to v7.5.0

* Update dependency @babel/plugin-proposal-decorators to v7.19.6

* Update dependency ember-svg-jar to v2.4.2

* Updated @TryGhost dependencies (TryGhost#15631)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Update dependency html-validate to v7.7.0

* Released Portal v2.16.0

* Fixed default feedback enabled when flag is disabled (TryGhost#15660)

fixes https://github.com/TryGhost/Team/issues/2114
fixes https://github.com/TryGhost/Team/issues/2115

When a new newsletter is created, the frontend will send feedback_enabled to true. We'll catch this in the backend and don't allow setting feedback_enabled to true when audience_feedback flag is disabled. This is also handled for editing newsletters.

To fix this in existing sites, I added a migration that disables feedback for all sites (since this is an alpha feature). Once we'll release the feature later, it will be disabled for existing newsletters, just like expected.

* Added email sent events (TryGhost#15682)

fixes https://github.com/TryGhost/Team/issues/2137

For the analytics page, we need the sent events to show up immediately
after sending an email. Otherwise we need to wait for emails to be
marked as received (which takes too long) before being able to show them
on the analytics page.

This adds the email_sent_event, which is hidden by default everywhere
and used on the analytics page.

* Added dark mode styles to the post analytics table

no issue

* Rearranged the markup so the empty state shows ok without pie chart

refs https://github.com/orgs/TryGhost/projects/60

* Restricted members importer to ignore "products" column

refs https://github.com/TryGhost/Team/issues/1076
refs TryGhost@70229e4#diff-b67ecda91b5bd79c598e5c5a9ec2ccf28dbfab6a924b21352273865e07cd7ceaR57

- The "products" column has not been doing any logic anything since at least 5.20.0 (see refed commit). The concept of columns in the export file was mostly there for analytical/data filtering reasons - so the user could analyze their exports. CSV was never a good suite for relational data that "products" (or now tiers) represent
- The "tiers" column will still be present in the exported CSV file, but there is not going to be any logic attached to it.
- The only columns that can effect the "tiers" state of the member are: "complimentary_plan" (assign default tier to the member) and "stripe_customer_id" (pulls in subscription/tier data from Stripe)

* Cleaned up leftover "product" variable naming

refs https://github.com/TryGhost/Team/issues/1076

- "product" in the context of members has been deprecated since introduction of "tiers"

* Improved the error modals for audience feedback and newsletter unsubscribe

- Main goal to improve modal when audience feedback fails
- Felt right to also improve the newsletter unsubscribe issue, too
- Makes this more pleasing to read and look at, nothing fancy

refs https://github.com/TryGhost/Team/issues/2081

* Released Portal v2.17.0

* Released Portal v2.18.0

* Update the portal version number

no issue

* Fixed snapshot tests

refs TryGhost@30ecaef

* Added e2e tests for `post.unscheduled` webhook (TryGhost#15675)

refs: TryGhost#15537

- snapshot test created to add confidence to webhook stability and increase overall test coverage.

* Added e2e tests for `post.published.edited` webhook (TryGhost#15642)

refs: TryGhost#15537

- snapshot test created to add confidence to webhook stability and increase overall test coverage.

Co-authored-by: Kritika Sharma <kritikasharma@Kritikas-MacBook-Pro-2.local>

* Renamed the member links to be something simpler on Post Analytics page

refs https://github.com/TryGhost/Team/issues/2147

* Updated webhook test snapshots

refs: TryGhost@26d0499
refs: TryGhost@8c2f832

- snapshots fell behind between the two referenced commits, and needed updating

Co-authored-by: Fabien 'egg' O'Carroll <fabien@allou.is>
Co-authored-by: James Morris <moreofmorris@users.noreply.github.com>
Co-authored-by: Elena Baidakova <lena.baydakova@gmail.com>
Co-authored-by: Ghost CI <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Djordje Vlaisavljevic <dzvlais@gmail.com>
Co-authored-by: Rishabh <zrishabhgarg@gmail.com>
Co-authored-by: Daniel Lockyer <hi@daniellockyer.com>
Co-authored-by: Ronald Langeveld <hi@ronaldlangeveld.com>
Co-authored-by: Peter Zimon <peter.zimon@gmail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Naz <hi@nazavo.com>
Co-authored-by: Simon Backx <simon@ghost.org>
Co-authored-by: Kevin Ansfield <kevin@ghost.org>
Co-authored-by: Kevin Ansfield <kevin@lookingsideways.co.uk>
Co-authored-by: Sam Lord <hello@samlord.me>
Co-authored-by: Rishabh Garg <rish@ghost.org>
Co-authored-by: Aileen Booker <AileenCGN@gmail.com>
Co-authored-by: Shubhadeep Das <dshubhadeep@gmail.com>
Co-authored-by: illiteratewriter <manukoshyabraham@gmail.com>
Co-authored-by: Shashank Gupta <shaz4194@gmail.com>
Co-authored-by: Samprit JC <sampritchaurasiya07@gmail.com>
Co-authored-by: Halldor Thorhallsson <halldorbjarni@gmail.com>
Co-authored-by: Hannah Wolfe <github.erisds@gmail.com>
Co-authored-by: Hakim Razalan <hakim.razalan@gmail.com>
Co-authored-by: Dominik Picheta <dominikpicheta@googlemail.com>
Co-authored-by: Kritika Sharma <kritikash18@gmail.com>
Co-authored-by: Kritika Sharma <kritikasharma@Kritikas-MacBook-Pro-2.local>
@ErisDS ErisDS mentioned this pull request Nov 2, 2022
29 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants