Commit Graph

1358 Commits

Author SHA1 Message Date
Thibaut Patel
7a55e1a60a
Added the newsletter_id query string to the post edit API route (#14449)
refs https://github.com/TryGhost/Team/issues/1502

- Support the `newsletter_id` only when sending a newsletter
- Default to the default newsletter when `newsletter_id` isn't specified
- Ignore the `newsletter_id` parameter when passed in the post body
2022-04-13 15:27:43 +02:00
Thibaut Patel
ffc57301f6
Fixed the newsletters api permissions (#14458)
refs https://github.com/TryGhost/Team/issues/1504

- The permissions were missing in the fixture file
- This caused some Ghost installs to not have the right permissions
- This is fixed by adding the missing permissions to the fixture file and creating a migration to resolve the missing permissions
2022-04-13 12:02:06 +02:00
Naz
4c2bcba5f0 Added example test case for a 404 vs 406
closes https://github.com/TryGhost/Toolbox/issues/291

- When a legit Resource 404 is returned by the API we want to make sure it's not shadowed by a 406. That would be confusing, eh?
2022-04-13 12:53:49 +08:00
Rishabh
9f7bb5b65b Updated snapshot members test
refs e6f96d4711
2022-04-12 21:07:47 +05:30
Rishabh Garg
e6f96d4711
Added filtering for members api on newsletter subscriptions (#14460)
refs https://github.com/TryGhost/Team/issues/1484

While sending a post to a specific newsletter, we'll need to get list/count of members eligible to receive the post. This change enables members admin API to filter list of members on specific newsletter by their slug.
2022-04-12 21:01:49 +05:30
Rishabh Garg
95670eed52
Handled default newsletter fixtures setup (#14459)
closes https://github.com/TryGhost/Team/issues/1491

With multiple newsletters feature, a site should always have at-least one newsletter by default. Also, as with the default product, the default newsletter also needs to be renamed to the site title during the setup flow.

- adds default newsletter to main and test fixtures
- updates setup flow to rename newsletter name and sender name to site title
- updates model to extend default value for fields
- updates test
2022-04-12 19:44:21 +05:30
Fabien 'egg' O'Carroll
baf9c1b61b
Updated MRR events & stored current subscription MRR
refs https://github.com/TryGhost/Team/issues/1456
refs https://github.com/TryGhost/Team/issues/1454
refs https://github.com/TryGhost/Team/issues/1302
refs https://github.com/TryGhost/Team/issues/1453

This includes changes to store MRR on subscriptions, as well as to store
events for both cancellation and expiration of subscriptions. Cancellation
events will cause a change in MRR when the `dashboardV5` flag is enabled.

Co-authored-by: Simon Backx <simon@ghost.org>
2022-04-12 12:22:26 +01:00
Naz
3381dae1e6 Added missing snapshots
refs eee8f364de

- Part of the snapshot file was not commited with a referenced commit
- Also while at it, had another look at naming used and have cleared up couple places
2022-04-12 17:03:23 +08:00
Simon Backx
2db746e559
Added mrr column to subscriptions (#14448)
refs https://github.com/TryGhost/Team/issues/1457

We want to save the MRR with a subscription to simplify the calculation of the total MRR once, in 5.0, we also take 'forever' offers into account into the MRR (so we can just SUM the MRR of all subscriptions).

- Sets the MRR to 0 for now.
- Separate commit will fill in all the values in a data migration, but this needs to get merged first because we need this new column in order to update the members-api package (so we already save the MRR before doing the data migration).
- Updated `test/e2e-api/admin/legacy-members.test.js` with improved body assertions.
2022-04-12 11:02:18 +02:00
Rishabh Garg
cb76b738ce
Fixed newsletter schema column validation (#14456)
refs https://github.com/TryGhost/Team/issues/1500

- newsletter schema columns were using incorrect syntax for `isIn` validations
- adds schema test to make sure schema `isIn` validations are in correct format
2022-04-11 15:05:02 +05:30
Hannah Wolfe
95faf54e73
Moved route-settings tests to their own folder
- the route settings code was factored out into its own service, but the tests were not moved
- this moves them so it's clearer what tests are for what service
2022-04-08 16:53:11 +01:00
Thibaut Patel
1ba72edce6
Added the emails-newsletters relation (#14434)
refs https://github.com/TryGhost/Team/issues/1497

- This enables us to keep track of which newsletter an email was sent to even if the related post is deleted.
- Adds the `newsletter_id` property to the email API
2022-04-08 16:16:23 +02:00
Rishabh Garg
b0df387deb
Cleaned up newsletter schema migrations (#14441)
refs https://github.com/TryGhost/Team/issues/1500

The newsletter table schema has bunch of changes to go through for new and existing columns, this consolidates the schema changes into a single re-create table migration that drops and adds the newsletter table with correct schema. The table re-create migration needs to run before any of the tables using newsletter as foreign key. The changes include -

- new columns for design related fields
- new slug column for filtering
- unique constraint to `name` column
- remove `default` column (noops the existing default column migration)
- `sender_reply_to` has a default of newsletter and a validation of ['newsletter', 'support']
- updated default values for `subscribe_on_signup` and  `recipient_filter`
2022-04-08 19:06:30 +05:30
Fabien 'egg' O'Carroll
7ff0247e8d
Added subscription_id to MRR events (#14445)
* Added subscription_id to MRR events

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

As part of 5.0 we want to have cancelled evetns affect MRR. We are going
to backfill and begin populating cancelled events _before_ 5.0 however,
adding a migration to set the MRR deltas as part of 5.0

This migration will need to associate the cancelled events with a
subscription, so we are adding the subscription_id now. This will allow
us to guarantee that all cancelled events will have a subscription_id.

The column is missing a NOT NULL and REFERENCES constraint because
we have not populated the missing values. These will be added in the future
once we have populated the column for all rows
2022-04-08 14:04:40 +01:00
Fabien 'egg' O'Carroll
022c8c8e69
Added support for 'FOR UPDATE' lock (#14433)
refs https://github.com/TryGhost/Team/issues/1248

This is the underlying cause of the problems we've seen whilst handling
Stripe webhooks. A transaction ensures that the operations are atomic,
but not that they can run concurrently.

If you have some code which does this, concurrently:
1. Starts a transaction
2. Reads a value
3. Changes the values
4. Ends the transaction

Without applying the `FOR UPDATE` lock - you will have both sequenes
read the same value at step 2.

With the `FOR UPDATE` lock - one of the sequences will hang at step 2,
waiting for the other transaction to end, at which point it will resume
and read the _changed_ value.

Because the `edit` method explicitly does a read followed by a write, we
have also add the `FOR UPDATE` lock to this by default, to avoid any race
conditions. This does however require that `edit` is called within a
transaction. An issue here https://github.com/TryGhost/Team/issues/1503
considers running in a transaction by default.
2022-04-08 12:52:33 +01:00
Naz
eee8f364de Added test coverage for Content APIs versioning support
refs https://github.com/TryGhost/Toolbox/issues/280

- Some additional coverage showcasing the versioning support is universal across APIs
2022-04-08 17:30:10 +08:00
Naz
313ab2a13f Moved version test to shared folder
refs https://github.com/TryGhost/Toolbox/issues/280

- The Accept-Version/Content-Version header handling  is shared between all APIs and should not structurally belong to any of the admin/content/members folders
2022-04-08 17:28:46 +08:00
Naz
4959dd83b8 Added 406 errors when Accept-Version header is missmatched
refs https://github.com/TryGhost/Toolbox/issues/280

- This change covers two use cases:
  -  The accept-version > current version + the request cannot be served: ERROR CASE 1
    - The accept-version < current version + the request cannot be served: ERROR CASE 2
- Along with 406 status there's additional information about the probable cause and action to be taken by the Ghost site owner or an integration talking to the Ghost API.
- These errors is designed to allow introducing breaking API changes gradually and have meaningful information when the requests cannot be server any longer
2022-04-08 20:41:54 +12:00
Naz
76aa2479f8 Added 'content-version' header response
refs https://github.com/TryGhost/Toolbox/issues/280

- In response to 'Accept-Version' header in the request headers, Ghost will always respond with a content-version header indicating the version of the Ghost install that is responding. This should signal to the client the content version that is bein g served
- This is a bare bones implementation and more logic with edge cases where `content-version` is served with a  version value of "best format API could respond with" will be added later.
2022-04-08 20:41:54 +12:00
Simon Backx
132726fe20
Added MRR stats service and endpoint (#14427)
refs https://github.com/TryGhost/Team/issues/1470

Instead of counting the MRR by resolving all the deltas from the past until now, we should start with the current calculated MRR and resolve it until the first event. That would give a more accurate recent MRR (in exchange for a less accurate MRR for older data) and allows us to limit the amount of returned days in the future.

- Includes MRR stats service that can fetch the current MRR per currency
- The service can return a history of the MRR for every day and currency
- New admin API endpoint /stats/mrr that returns the MRR history
- Includes tests for these new service and endpoint
2022-04-08 09:18:04 +02:00
Fabien 'egg' O'Carroll
6507a0b88e
Added type column to members_paid_subscription_events (#14432)
refs https://github.com/TryGhost/Team/issues/1302

This column allows us to store multiple events types in the table, which
can be differentiated by their `type`
2022-04-07 11:29:14 +01:00
Thibaut Patel
88877312b5
Removed the default column from the newsletters table (#14428)
refs https://github.com/TryGhost/Team/issues/1474

- The `default` concept will be replaced by the first newsletter based on the `sort_order`
- This removes the `default` value from the newsletter API
- This simplifies the design to make the api and datastructure more maintainable
2022-04-07 11:50:20 +02:00
Thibaut Patel
2bfd8f8b7e
Added the post-newsletter relation (#14411)
refs https://github.com/TryGhost/Team/issues/1471

- This is a many-to-one relation so that many posts can be linked to a specific newsletter
- The `newsletters` table had to come first in the schema file so that it's initialized before the `posts` table (because of the foreign key)
- Updated the model to make sure the new field doesn't leak in the API for now
- This migration isn't using the `createAddColumnMigration` util because of a performance issue. In MySQL, adding/dropping a column without `algorithm=copy` uses the INPLACE algorithm which was too slow on big posts tables (~3 minutes for 10k posts). Switching to the COPY algorithm fixed the issue (~3 seconds for 10k posts).
- SQLite isn't using the codepath where we run a raw SQL query because `knex` is doing multiple queries to add/remove a column
2022-04-07 10:26:37 +02:00
Rishabh Garg
90e7887007
Added default newsletter subscription for new members (#14431)
refs https://github.com/TryGhost/Team/issues/1469

Currently, all new members get auto subscribed to the default newsletter. This change adds same behavior with multiple newsletters by auto subscribing all available newsletters on site for new members(If flag is enabled). 
Note: In future, this will also take into consideration the `subscribe_on_signup` flag for a newsletter to filter which newsletters should a member be auto-subscribed.

- adds newsletters service for working with newsletter data
- bumps `@tryghost/members-api` package which handles default subscription
- adds new test fixture/data for newsletters
2022-04-07 08:30:00 +05:30
Simon Backx
1957b5b789
Removed pagination from members stats endpoint and added extra day to output (#14429) 2022-04-06 17:10:47 +02:00
Hannah Wolfe
0581314796
Fixed location of url service unit tests
- The url service was moved from frontend to server some time ago but the tests were forgotten
- This is only being done now because in 5.0 major changes are happening and it'll be annoying if the
  files move on that branch
2022-04-06 13:05:41 +01:00
Simon Backx
abb3ee48e4
Extended tests for member events (#14333)
refs https://github.com/TryGhost/Team/issues/1372

- Added tests for Stripe webhooks that cancel a subscription (paid and complimentary)
- Tests for manually adding a complimentary member, and removing it again (the 'new' way)
- Added tests for creating new members (paid, complimentary)
- Includes tests for the `stripe_customer_id` property when creating new members (this is broken, fixed by https://github.com/TryGhost/Members/pull/378#issuecomment-1070835800)
- Deduplicated some nock code for Stripe
- Improved event assertions and interference between multiple tests in the giant members test file (by asserting only for the affected member id instead of all events).
2022-04-06 10:40:16 +02:00
Hannah Wolfe
08479f3816
Moved routing helpers to rendering service
- The helpers folder was full of things used for rendering pages
- It belongs as its own service so that we can see what it really does
2022-04-05 20:12:20 +01:00
Hannah Wolfe
c902d91c81
Renamed rendering service to handlebars
- This fits more closely, as this service is to so with rendering helpers and small parts
- Whereas we want to use "rendering" for things concerned with rendering pages
2022-04-05 20:10:33 +01:00
Rishabh
cc7c51e140 Handled newsletter data for member api
refs https://github.com/TryGhost/Team/issues/1469

- Added newsletter data handling to member BREAD service
- Allowed updating newsletter data for a member
2022-04-05 22:23:39 +05:30
Rishabh
a1417e86b7 Added relation between newsletters and members
refs https://github.com/TryGhost/Team/issues/1469

- updates member model to add relation to newsletter via pivot table
- updates member api serializer to include newsletter data
- updates tests
2022-04-05 22:23:39 +05:30
Hannah Wolfe
e9d6f61029
Moved checks into frontend data service
refs: https://github.com/TryGhost/Ghost/commit/11867ab43

- These checks live in the wrong place. They are mostly a frontend thing
- The only server place they were used was slack and that was fixed in 11867ab43
- Moving these to the frontend they fit neatly into the frontend data service
2022-04-05 15:23:00 +01:00
Hannah Wolfe
11867ab43a
Replaced schema.isPost in slack service /w custom fn
- This is the only piece of server code that relies on the schema.checks, the rest are all frontend
- IMO this code should actually check for the post properties that the slack message needs
- OR it should switch based on the event type
- either way there's no need to have a shared util for this simple use case
- especially becaue it's confusing the use case for it and creating cross-coupling between server and frontend
2022-04-05 14:24:42 +01:00
Hannah Wolfe
4ee2fcd869
Moved frontend data helpers into their own service
- Some of the helpers inside the routing service would be better suited to their own service
- These two helpers fetchData and entryLookup talk to the API to get data & so make a decent start for a data service
- The data service would be the single point of contact with the API for the frontend
- Doing this now cos I'm moving some files around ahead of deleting things for 5.0
2022-04-05 13:38:42 +01:00
Rishabh Garg
ee0a6910ce
Added table to store multiple newsletters for member (#14408)
refs https://github.com/TryGhost/Team/issues/1469

With multiple newsletters, members will now be able to subscribe to one or more newsletters on the site. Previously, the subscription to default newsletter for a member was controlled via a single boolean `subscribed` column on the member table.
This change allows mapping multiple newsletters to a member via new pivot table that stores relation between a member and newsletter.

- adds new `members_newsletters` pivot table
- update tests
2022-04-04 18:11:36 +05:30
Hannah Wolfe
c222d1f64e
Added expectEmptyBody assertions to e2e framework
- Updated express-test to latest version with new expectEmptyBody assertion
- Updated all the tests that used matchBodySnapshot for an empty body to use expectEmptyBody instead
- Updated all the snapshots that were affected manually, and verified running the tests works as expected
2022-03-31 18:56:05 +01:00
Simon Backx
759e362a30 Fixed snakeCase in stats member count endpoint
refs 31c1d4f513

Still had the camel case 🙈
2022-03-31 17:09:28 +02:00
Simon Backx
31c1d4f513 Renamed stats endpoint to /stats/member-count and added totals metadata
refs https://ghost.slack.com/archives/C02G9E68C/p1648737467414789?thread_ts=1648644801.253699&cid=C02G9E68C

- Anything in the API should use snakeCase
- Reduce amount of nesting in endpoint name
- Added totals metadata
2022-03-31 17:05:08 +02:00
Thibaut Patel
fdb0e3d44d Added the newsletter API permissions
refs https://github.com/TryGhost/Team/issues/1463

- Allow admins to perform all newsletter operations
- We can adjust and be more permissive in the future if needed
- Added the tests back as permissions are configured correctly now
2022-03-31 16:08:23 +02:00
Simon Backx
ae54352a29
Created new stats service and stats API to get member count history (#14391)
refs TryGhost/Team#1458
refs TryGhost/Team#1459
refs TryGhost/Team#1372

- Added a new stats service, which is divided into several categories. Currently only the 'members' category for member related stats.
- When there are missing or corrupt members status events in the DB, the totals returned by the old member stats endpoint (`/members/stats/count`) were wrong. This is fixed in the new service by counting in reverse order and starting with the actual totals.
- New Stats API, with the new `/stats/members/count-history` endpoint.
- This new endpoint also returns the paid deltas -> dashboard 5.0 will show subscribed and canceled paid members for each day
- Includes tests for the new stats service and endpoint
2022-03-31 16:01:11 +02:00
Thibaut Patel
9e4401d9f6 Added the newsletters endpoint
refs https://github.com/TryGhost/Team/issues/1463

- This enables listing, creating and editing newsletters
- The tests are commented out as the permissions will be added in a follow-up commit
2022-03-31 15:19:58 +02:00
Hannah Wolfe
130ffb4d63
Updated snippets e2e tests to use new framework
- Snippets are are one of the most recently implemented full e2e features
- https://github.com/TryGhost/Ghost/commit/13f653a12 updated the serialier pattern
- This updates the tests so _everything_ is shiny and new
2022-03-29 15:51:46 +01:00
Hannah Wolfe
f7ad32e76b
Removed unnecessary snippets serializer
refs: https://github.com/TryGhost/Toolbox/issues/245

- The default behaviour of a serializer is to call a mapper for each object
- Instead of all the boilerplate code we had in the snippets serializer, all we need is a single mapper function
- Added tests for the mapper function as well
2022-03-29 15:51:45 +01:00
Thibaut Patel
f096e29922 Added the newsletters table
refs https://github.com/TryGhost/Team/issues/1433

- The `default` property stores whether a newsletter is set as default by the admin
- The `status` property stores whether a newsletter is archived or not
- The `recipient_filter` property is only storing whether a newsletter is "paid-only" or not for now, although it can be expanded to more specific filters in the future
- The `subscribe_on_signup` property stores whether a new member should be automatically signed up to the newsletter
- The `sort_order` property enables displaying the newsletter list in an order chosen by the admins
2022-03-29 15:23:26 +02:00
Hannah Wolfe
22b6f1af99 Improved behaviour of default and all handlers
refs: https://github.com/TryGhost/Toolbox/issues/245

- .all methods are fallback serializers not to be run as well as a custom serializer
- The default serializer is also a fallback
- The "All" file with before and after are global hooks that _always_ get run as well as other serializers
- There's a lot of room for further improvement here especially with naming but this logic makes more sense
  for the usecases AND doesn't affect v2 & v3 etc. We can do another pass after 5.0
2022-03-29 13:44:21 +01:00
Hannah Wolfe
9f3b6f1818
Added missing e2e emails API browse & retry tests
refs: https://github.com/TryGhost/Team/issues/1446

- changed Emails API tests to use the new e2e test framework
- Added missing tests for browse and retry endpoints
2022-03-28 17:32:58 +01:00
Hannah Wolfe
ccef6dc44e
Added event mocking to e2e framework
- Allows mocking lib/common/events - stubs event.emit
- Means we can check that events fired, but their sideeffects won't happen, useful for things like bulk email
- I also reorganised the mock manager file to group related functions together
2022-03-28 17:32:57 +01:00
Hannah Wolfe
15da07f324
Added missing e2e mail API retry test
refs: https://github.com/TryGhost/Team/issues/1446

- changed mail API  tests to use the new e2e test framework
- added the missing retry test - which has the wrong response format :(

mail
2022-03-28 17:32:57 +01:00
Daniel Lockyer
32e2d15880
Split apart DB init queries in tests
refs https://github.com/TryGhost/Toolbox/issues/213

- `better-sqlite3` doesn't like multiple queries in the same statement
  so we can make the change here to split them up ahead of the switch
2022-03-28 16:17:17 +01:00
Hannah Wolfe
a31069d49d
Removed unnecessary use of rewire
refs: https://github.com/TryGhost/Ghost/commit/e68cb8b31

- I found that some of the places we use rewire are totally unnecessary
- Rewire seems to mess with coverage sometimes
- It's also a code smell in general so I've ripped it out where possible
2022-03-24 19:32:06 +00:00
Hannah Wolfe
45de9b0efc
Fixed filename casing in canary API
refs: 0ef5a5c97a

- As per the previous commit, our mixed filename casing inadvertently resulted in a bug
- The casing in the codebase is meant to be kebab-case always, so fixing this everywhere that's relevant to the API whilst there's a good reason
2022-03-24 17:25:53 +00:00
Hannah Wolfe
0ef5a5c97a
Fixed members connect endpoint returning JSON
refs: https://github.com/TryGhost/Toolbox/issues/245
refs: https://github.com/TryGhost/Team/issues/1360

- As a result of my changes in https://github.com/TryGhost/Ghost/commit/3bd4d098 the members connect endpoint had started returning JSON
- This is because the members connect endpoint relied on the old default behaviour of the serializer being to return no response, whereas now it does our default JSON response format
- I had written a tool to iterate over all endpoints and ensure that they all had explicit serializers before changing the default behaviour, but it missed this endpoint due to the snake case naming
- I have double checked and this was the only missed endpoint, the only other one was member_signin_urls.permissions but that was not a true endpoint and was removed in https://github.com/TryGhost/Ghost/commit/202696382
- Note: the snapshot file for this test was generated from running the test against https://github.com/TryGhost/Ghost/commit/e6b92aed9 - one commit before I added the new default behaviour.
  - Without the new serializer this test fails on main
  - With the new serialzier, this test passes again, showing the response format has gone back to what we expect
2022-03-24 17:09:23 +00:00
Hannah Wolfe
6976a3a9f2
Added labels test for empty browse response
- Added a simple test to prove the response is in the correct format when there is no results
2022-03-24 12:52:47 +00:00
Simon Backx
a7566c8503
Added e2e tests for offers API (#14335)
refs https://github.com/TryGhost/Team/issues/1429

Includes tests for all endpoints of the offers API
2022-03-24 13:41:48 +01:00
Naz
7d03194e55 Added detection of "ghost-api" use in theme config
refs https://github.com/TryGhost/Toolbox/issues/241

- The `engines.ghost-api` property has been deprecated and the support for it will be dropped in Ghost v5 due to versionless nature of the Content API.
- When uploading a new theme or activating existing one that uses ghost-api in it's config a warning will be shown to the user
2022-03-24 15:27:40 +13:00
Hannah Wolfe
9db1694647 Removed unnecessary tags serializer
refs: https://github.com/TryGhost/Toolbox/issues/245

- we don't need this serializer because the default serializer will call the tags mapper
- for now I've changed, rather than removed the tag serializer test as this shows default works the same!
2022-03-23 13:23:23 +00:00
Hannah Wolfe
396dd5f7f9 Removed unnecessary labels mapper & serializer
refs: https://github.com/TryGhost/Toolbox/issues/245

- There's no need for a mapper or serializer as labels uses the default behaviour
- Added a full suite of tests, consolidating from regression and using the new framework to prove nothing is broken
2022-03-23 13:23:23 +00:00
Hannah Wolfe
e68cb8b314
Improved settings cache unit tests
- settings cache was appearing as untested because we use rewire!
- rewire was totally unnecessary in this case, so I removed it
- updated to 100% test coverage whilst there, including removing one unreachable branch
- commented some undesirable behaviour I found whilst trying to reach all branches
- I don't want to change the behaviour to return false correctly without having a reason beyond improving coverage
2022-03-23 11:37:52 +00:00
Hannah Wolfe
3bd4d0989a Added default serializer + handling
refs: https://github.com/TryGhost/Toolbox/issues/245

- Added a serializer called default to the canary API
  - Ideally, this would be part of the shared framework, but this would change v2/v3 and we're about to get rid of them
  - Therefore, we change just canary for now, and we can refactor again later.
- Added wiring to handler that uses the default serializer, if there is a default, and isn't an explicit serializer for the endpoint
- Removed the invites serializer, so that one endpoint now uses the default

Note: previous commits have added explicit serializers to every endpoint, this is the first step towards paring
that back so that we have less serializers overall, not more!
2022-03-22 13:52:32 +00:00
Hannah Wolfe
3919d31838 Added serializer for missing settings endpoints
refs: https://github.com/TryGhost/Toolbox/issues/245

- Upload, updateMembersEmail, validateMembersEmailUpdate & disconnectStripeConnectIntegration were all missing serializers
- Upload is an as-is response, same as download
- updateMembersEmail, validateMembersEmailUpdate & disconnectStripeConnectIntegration are all passthroughs with no response
- With the upcoming refactor we want to have all the serializers defined explicitly
- This will allow us to change the default behaviour
- Updated the file based tests to prove the body doesn't change
- Tests were added to cover updateMembersEmail, validateMembersEmailUpdate & disconnectStripeConnectIntegration in 68c1bc0285
2022-03-22 13:52:32 +00:00
Hannah Wolfe
7e6a7cb98c Added serializer for email_preview.sendTestEmail
refs: https://github.com/TryGhost/Toolbox/issues/245

- sendTestEmail was missing a serializer because it's deliberately a passthrough
- With the upcoming refactor we want to have all the serializers defined explicitly
- This will allow us to change the default behaviour
- Updated the tests to prove the body doesn't change
2022-03-22 13:52:32 +00:00
Hannah Wolfe
84500be0e2 Added serializer for themes.destroy
refs: https://github.com/TryGhost/Toolbox/issues/245

- The destroy endpoint was missing a serializer
- Instead of adding one, I've refactored to use an all method that's a passthrough
- Updated the tests to use the same pattern as others to make it clearer this is tested
2022-03-22 13:52:32 +00:00
Hannah Wolfe
ac3f18b251 Added serializer for snippets.destroy
refs: https://github.com/TryGhost/Toolbox/issues/245

- The destroy endpoint was missing a serializer
- As this serializer uses the same createSerializer pattern as members, I've copied the passthrough from members into here
- This ensures the behaviour will stay the same when the default behaviour changes
- Updated the tests to prove the body doesn't change
2022-03-22 13:52:32 +00:00
Hannah Wolfe
c89a01b031 Added serializer for integrations.destroy
refs: https://github.com/TryGhost/Toolbox/issues/245

- The destroy endpoint was missing a serializer
- Instead of adding one, we've refactored to use the standard structure for this serializer
- Updated the tests to prove the body doesn't change
2022-03-22 13:52:32 +00:00
Hannah Wolfe
7433378e6a Added serializer for redirects.upload
refs:  https://github.com/TryGhost/Toolbox/issues/245

- There was only a serializer in place for redirects.download.
- Upload was falling through, which means nothing happens by default atm
- We want to change this default, so I'm making sure all our routes have serializers declared and tests
- Updated the tests and checked the behaviour was the same before and after:
  - We can't use our new framework here yet because it doesn't support uploads or downloads
  - Instead, just add simple matching for the body of the responses
2022-03-22 13:52:32 +00:00
Naz
3c9531452c Reverted "Added detection of "ghost-api" use in theme config"
This reverts commit 4c19f38c74.
2022-03-22 16:18:17 +08:00
Naz
4c19f38c74 Added detection of "ghost-api" use in theme config
refs https://github.com/TryGhost/Toolbox/issues/241

- The `engines.ghost-api` property has been deprecated and the support for it will be dropped in Ghost v5 due to versionless nature of the Content API.
- When uploading a new theme or activating existing one that uses ghost-api in it's config a warning will be shown to the user
2022-03-22 14:05:34 +08:00
Simon Backx
028cf7becc Added dashboardV5 feature flag 2022-03-21 16:56:34 +01:00
Thibaut Patel
6e9bc81d6d Fixed the tests from the previous commit
refs 2324b29b2a

- Updated the settings snapshot
2022-03-21 16:28:26 +01:00
Hannah Wolfe
3784d79682
Added fixture path utility to e2e-framework
- Always want to be able to safely get a fixture path without needing the path util
- Means tests can be moved around more easily
2022-03-21 11:14:54 +00:00
Hannah Wolfe
5f378ca3f6
Removed unused snapshot files
- the tests that used these files have been moved to test/e2e-api
2022-03-19 16:48:59 +00:00
Hannah Wolfe
68c1bc0285 Added missing settings endpoint tests
- Added a test for each of the 3 missing endpoints
- This is so that we can be sure future refactors won't break these endpoints
2022-03-19 16:06:07 +00:00
Hannah Wolfe
c66eeb5879 Updated settings to use new test framework
- split out the two tests that use files, as the new framework doesn't support this yet
- convert the 3 existing tests for the settings endpoint to use the new framework
- introduced a new pattern of using a function to generate a matching array, so that we can do extra stuff
- in this case, just one of the items needed a matcher for the value, which results in slightly weird code
- wrapping in a function gives us somewhere to do this and leave a comment
2022-03-19 16:06:07 +00:00
Hannah Wolfe
c11187d770 Updated members tests to use defined matcher
- some tests were inconsistently using copy-pasted matchers
- instead, we should define them once and use them everywere
- this keeps the tests easy to read and maintain
2022-03-19 16:06:07 +00:00
Kevin Ansfield
95c919852b
Fixed missing product name in API response when editing creating/editing subscriptions (#14339)
refs https://github.com/TryGhost/Team/issues/1141

- switched to the same member fetch method as used in `GET /member/:id/` so there's consistent data available when rendering the API responses
2022-03-18 16:06:38 +00:00
Hannah Wolfe
2cf7e00493 Added tests for session API
- this API has never had proper tests!
- using the new framework this was pretty easy :)
2022-03-18 13:13:16 +00:00
Hannah Wolfe
911ce5f92d Cleaned up db-utils and added jsdocs
- Attempted to make it clearer what the db utils do and what each one is for
- Clearly marked the old clearData & initData as deprecated, we don't want to mix db and url service resets
2022-03-17 17:33:11 +00:00
Hannah Wolfe
11a792f7df Wrapped test teardown in a fallback
- The fast truncateAll method can fail
- If it does, use knex-migrate to do a safe reset of the DB instead
- This is being done to try to make test runs more reliable in the face of database errors
2022-03-17 17:33:11 +00:00
Hannah Wolfe
b90e367563 Fixed error handling on db truncate in tests
- if the database does not exist, ignore the error
   - tables that don't exist don't need truncating
   - instead wait until the next thing calls init, that will cause a fresh db to be created in the correct state
- inside of reset, if the truncate fails then do a full reset instead
2022-03-17 17:33:11 +00:00
Hannah Wolfe
83ad79308b Updated tests to use DatabaseInfo
- some code in tests were still using various unreliable methods to determine the database in use
- DatabaseInfo is the correct method to check if the db is mysql or sqlite
- Exposed DatabaseInfo via our test db-utils to make this easier
2022-03-17 17:33:11 +00:00
Matt Hanley
340f64c2df Updated test snapshot for tiers e2e tests
- 18b59d2c01 renamed a test which invalidated the old snapshot
- the new snapshot wasn't committed
2022-03-17 14:03:12 +00:00
Kevin Ansfield
0cc147ae2d 🐛 Fixed member "last seen at" data not being returned in the API
refs c4470ff732

- labs flag was removed under the false assumption it was a client-side only flag but the `last_seen_at` property in API responses was also gated meaning the member details screen showed "Not seen yet" and the members list did not show the last seen date of all members when filtering
2022-03-17 10:58:07 +00:00
Fabien 'egg' O'Carroll
9ff8d7f910
🐛 Fixed post access in the get helper (#14282)
refs https://github.com/TryGhost/Team/issues/1367

Because we are passing through a different member object as the context
in the get helper, the content gating was not working correctly, as the
member was missing a status property, this adds the property which fixes
content gating.

- Added extra tests for get helper {{access}} property
- Added extra test for {{access}} property in next_post helper
- In the future we might want to update the tests so they test the whole request -> HBS context flow. Currently the has context is still stubbed manually.
2022-03-17 11:14:29 +01:00
Hannah Wolfe
2cc2d114f4
Revert "Added global setup to reset DB before test run"
This reverts commit d50fb7c922.
2022-03-16 21:10:49 +00:00
Hannah Wolfe
d50fb7c922
Added global setup to reset DB before test run
- We've been seeing weird errors with tables not existing when running tests locally
- This appears to happen after an error causes the tests to abort
- This change includes two fixes:
1. we triggers a full DB reset just before the entire test suite runs
 - this is done by wrapping the override file for tests that use a db, and supplying a mochaGlobalSetup hook
2. catch errors when attempting to do a fast truncation-based reset & init, and do a full reset & init instead

- These two changes should ensure the DB is always in the state we expect when running a new test suite
2022-03-16 20:56:17 +00:00
Rishabh Garg
18b59d2c01
Removed archived tiers from content api (#14329)
closes https://github.com/TryGhost/Team/issues/1426

When fetching tiers using the content API, we incorrectly returned all tiers including archived ones unless the active:true filter is passed. Correct behaviour is to always hide archived tiers, so this filter should not be required.

- forces `active:true` filter for tiers content api browse
- updates test to check for archived test removal in tiers content api
2022-03-16 22:02:42 +05:30
Hannah Wolfe
1a6a283a50
Fixed bad setup call in settings integration test
- the setup() function returns a function that's expected to be called as a mocha hook
- wrapping this in a function means it doesn't get called properly
- therefore the db setup was never being called for this test
2022-03-16 14:03:02 +00:00
Hannah Wolfe
4dd2ebc78b
Fixed local-only e2e test failure
fixes: https://github.com/TryGhost/Team/issues/1424

- This moves the require of the members service after Ghost has been booted normally.
- This gives the tests time to properly setup temporary folders before the paths get used.
- In turn this prevents issues in the legacy-members tests, which were affected by the Member Service being called too early in this test.
2022-03-16 12:53:58 +00:00
Hannah Wolfe
70d15e077b
Refactored mapper into individual files (#14328)
refs: https://github.com/TryGhost/Toolbox/issues/245

- Ghost's API framework has a mixed up concept of what a serializer is. Mappers are true serializers! What we call serializers are little more than a small formatting step.
- This PR splits mappers into individual files and uses the endpoint's docname as the mapper name. This will help us to automate the calling of a mapper for an endpoint later.
- This is one tiny step in reworking the framework to need less code to make it work, and to have clearer concepts for how to do things.
2022-03-16 12:44:11 +00:00
Rishabh Garg
f9aa18a534
Enabled Admin integration for tiers and offers API (#14325)
As multiple tiers is now GA, we want to allow devs to be able to work with Tiers and offers via content/Admin API. This change -

- updates fixtures to add permissions to admin integration role for new sites
- adds migration to update existing sites to have correct permissions for role
- whitelists add/edit/read/browse on tiers and offers API for integrations
2022-03-16 16:46:26 +05:30
Naz
cbba5471a2 Renamed versioned API URL variable
refs https://github.com/TryGhost/Toolbox/issues/169

- Improved code readability, otherwise it could be confusing what the default API URL means
2022-03-14 21:22:54 +13:00
Naz
1dd47c4191 Added test coverage proving token back compatibility
refs https://github.com/TryGhost/Toolbox/issues/169

- There was not much clarity around how the tokens created for the versioned API audience would behave when non-versioned API is introduced. The tests added here illustrate the tokens being forward compabible (created for versioned -> verified at non-versioned API) and not backwards combatible (created for non-versioned -> verified at versioned)
2022-03-14 21:22:54 +13:00
Naz
7becf0a2b2 Aliased canary endpoints to point to non-versioned URLs
refs https://github.com/TryGhost/Toolbox/issues/169

- Before releasing Ghost v5 we would like to move all canary-related URLs to a non-versioned format, which will become a default in v5.
- 'canary' is by definition unstable, so breaking any unprepared client explicitly using the canary is expected
- Removed the aliased /content/ and /admin/ apps from app.js because with updated configuration they become duplicates of 'canary' endpoints
2022-03-14 21:22:54 +13:00
Thibaut Patel
4ce9a5a167 Added the MemberCancelEvent model
refs https://github.com/TryGhost/Team/issues/1302

- This event stores the members' subscription cancelations.
2022-03-11 21:50:06 +01:00
Thibaut Patel
49d393c88f Added the product name to member subscriptions
refs https://github.com/TryGhost/Team/issues/1141 da6a43bfcf

- Adds the `member.subscriptions.price.product.name` property to the member read endpoint
2022-03-11 17:36:47 +01:00
Rishabh Garg
45cadcbe99
Bumped multiple tiers to GA (#14311)
refs https://github.com/TryGhost/Team/issues/1267

Multiple tiers is coming out of beta -

- allows site owners to create multiple tiers
- allows setting individual welcome page for each tier
- allows setting visibility for individual tiers for portal and themes
2022-03-11 20:15:44 +05:30
Simon Backx
42ac8c41e4
🐛 Fixed uppercase file extensions ignored in content import (#14268)
refs https://github.com/TryGhost/Team/issues/1363

- When uploading a zip of images in Settings > Labs > [Import], it will skip images that have an uppercase extension, citing an 'unsupported file type' error.
- Cause: Glob ignored those files when matching extensions in ImportManager
- Fix: Added nocase option where needed
- Extended tests to also test the processZip method of ImportManager with getFilesFromZip
- Added isValidZip for zip with uppercase image
- Cleaned up JSDoc in ImportManager, and replaced some older JS syntax

Fixed zipContainsMultipleDataFormats error never thrown:

When a zip combines two data formats, no error was thrown.

- The promise error was only returned in an _.each loop, but never thrown
- Previously when combining multiple data types in a zip file, no error got thrown
- Added a test for this error
- Also added a test for noContentToImport error

Other errors and fixes:

- Added missing length in getBaseDirectory check
- getContentTypes fixed (returned duplicate values). Type error came up after adding all JSDocs
- updated tests to match real types from JSDoc and pass type validations
- Rewrote some methods in the async await syntax
- Added tests for ImportManager clean up
2022-03-11 09:17:58 +01:00
Matt Hanley
7172db74b0
💡 Updated fixtures to make it easier to get started (#14299)
- Our old fixtures were designed as a guide to getting started to Ghost, but they got in the way
- The old fixtures now live as part of ghost.org/resources - a living guide to starting with Ghost
- These new fixtures mean the site is ready to go as soon as it's setup

Co-authored-by: Hannah Wolfe <github.erisds@gmail.com>
2022-03-10 17:41:46 +00:00
Daniel Lockyer
f2c074ac59 Fixed error when editing user with empty roles data
- we send the roles data array in when we're changing the role of the
  user
- if we send an empty array, we don't want to edit the user's role
- the code _thought_ that's what it was doing, but we only check the
  falsiness of the array, which is truthy for `[]`
- it also needs to check the length of the array
- this commit includes a test which would fail with a 500 error without
  the fix
2022-03-10 17:29:30 +00:00
Simon Backx
da9de95b74
🐛 Fixed duplicate tags created when slugs contain spaces (#14277)
refs https://github.com/TryGhost/Team/issues/1284

When you create a new post with a tag slug that contains spaces, those spaces will get replaced by dashes. But instead of reusing an existing tag, a new tag is always created.

- New tag slugs are cleaned up before matching with existing tags in the Post model onSaving method
- Cleaned up multiple loops in onSaving of Post model
- Cleaned up syntax when cleaning up tag slug
- Added tests for slugs with spaces
- Added test for too long tag slug causing duplication
2022-03-10 13:07:00 +01:00
Fabien "egg" O'Carroll
8229f8030e Fixed new sites using "Default Product" Tier name
https://github.com/TryGhost/Team/issues/1289

Since we added the free Tier fixture, this was attempting to fix the
free Tier, rather than the default one.
2022-03-10 11:35:03 +00:00
Fabien "egg" O'Carroll
f655ed3970 Added disableStripe method to mock manager
Some tests need to run without Stripe connected/enabled, which is the
default at the moment. This method will disconnect stripe for the
lifecycle of the API agent.
2022-03-10 11:35:03 +00:00
Simon Backx
9ad45ee5be
Added tests for creating product benefits without name (#14217)
refs https://github.com/TryGhost/Team/issues/1188

The products API did return a 500 error when you tried to store product benefits with an empty name. This should throw a 422 Validation Error instead. This change includes some tests for this error. The error itself has been solved by updating the bookshelf-relations dependency earlier.

- Added test when creating a new product with an empty benefit name
- Added test when updating an existing product with new benefits, with an empty name
- Added a test that creates a tier with benefits
2022-03-10 10:10:35 +01:00
Naz
16e0736379 Removed Roon related importer code
no issue

- The support for the misformated roon imports was temporary anyway, based on the comments in code. It's also unecessary to keep around any code related to Roon as it's been _ages_ since anybody needed this kind of migration
2022-03-10 16:29:54 +08:00
Daniel Lockyer
8a7c7f08e9 Enabled fetching .ico dimension size via probe-image-size
refs https://github.com/nodeca/probe-image-size/blob/master/CHANGELOG.md#600---2020-11-04

- `probe-image-size` v6 now supports `.ico` files so we can
  allow probing of dimensions via this library rather than falling back
  to downloading the entire image via `image-size`
- also updates a test because .ico files no longer use the internal
  request lib, which simplifies things a little bit
2022-03-09 20:27:38 +00:00
Hannah Wolfe
833035d7be
Improved coverage of api serializer
- Have ensured we have 100% coverage of core/server/api/shared/serializers/handle.js
- This meant I had to swap around two validation clauses as one was unreachable
- I have done this as I want to make some changes in this area of the codebase, and want to ensure we have tests
  and a clear understanding of what this code does before I change it
2022-03-09 20:02:15 +00:00
Kevin Ansfield
51e04c75ad
Added "contains" operator support to ?filter= query params (#14286)
refs https://github.com/TryGhost/Team/issues/1408

- switched from `@nexes/nql` to `@tryghost/nql` and bumped `@tryghost/bookshelf-plugins` to get access to the latest NQL version across the app
- adds "contains" operator support
  - `:~'string'` - contains
  - `:-~'string'` - does not contain
  - `:~^'string'` - starts with
  - `:-~^'string'` - does not start with
  - `:~$'string'` - ends with
  - `:-~$'string'` - does not end with
- enables `'` escaping in strings, eg `'O\'Nolan'`
2022-03-09 13:02:17 +00:00
Rishabh Garg
9794945549
Updated tests for custom welcome page redirects (#14288)
Welcome pages are now moved as a property of individual tiers instead of global property on settings. Since we removed the alpha flag for new welcome page behavior, tests had to be updated to test the flow against new behavior.
2022-03-09 17:49:25 +05:30
Naz
da9f018c70 🐛 Fixed theme activation with capitalized names
closes https://github.com/TryGhost/Team/issues/1420
refs da0dee548c
refs https://github.com/TryGhost/Toolbox/issues/169

- After introducing non-versioned API urls the "isAPI" regex failed to pass the test as it was expecting a `canary/vX` in the API URL. This caused "uncapitalization" to stop working for API requests.
- Regex visualizer for quick reference: https://jex.im/regulex/#!flags=&re=%5E(.*%5C%2Fghost%5C%2Fapi(%5C%2F(v%5B%5Cd.%5D%2B%7Ccanary))%3F%5C%2F.*%3F%5C%2F)
2022-03-09 20:07:04 +13:00
Rishabh Garg
e6c9dadec2
Fixed tiers test with correct visibility (#14280)
refs https://github.com/TryGhost/Team/issues/1387
2022-03-08 18:00:30 +05:30
Rishabh
7c43191ca7 Fixed members endpoint not ignoring unknown includes
refs https://github.com/TryGhost/Team/issues/1415

Members browse endpoint was missing allowedIncludes validation, causing unknown includes to throw 500 on API request.
2022-03-08 16:59:51 +05:30
Rishabh
90ef822259 Updated test fixtures for tiers with new visibility property
refs https://github.com/TryGhost/Team/issues/1387

Test fixtures were missed while updating new visibility property for tiers.
2022-03-08 14:49:13 +05:30
Fabien 'egg' O'Carroll
fa1165de6a
Support tier visibility editing Allowed Tiers Admin API to set visibility
refs https://github.com/TryGhost/Team/issues/1387

This will allow us to move from the portal_products and portal_plans
settings to using the visibility property on tiers to determine whether
or not a tier should be visible in Portal.

This also fixes a bug with the Tiers Admin API read method permissions.
2022-03-07 14:46:42 +00:00
Daniel Lockyer
1a3aa69c68 Re-throw error when attempting to create webhooks
- we catch error arising from creating webhooks and check for specific codes
- if our error does not match one of those codes, we don't propagate the
  error up
- this becomes a problem if saving a webhook fails for some other reason
  because upstream code assumes we return an error or model
- this commit re-throws the error and adds a test that would have caught
  this
2022-03-07 13:54:00 +00:00
Rishabh
b03862d08a Updated content cta helper to use new tiers helper
refs https://github.com/TryGhost/Team/issues/1004

Replaces {{products}} helper usage with updated {{tiers}} helper. Default output for {{tiers}} helper is the same as {{products}} helper.
2022-03-04 18:22:59 +05:30
Rishabh
665c30f255 Added new {{tiers}} theme helper
refs https://github.com/TryGhost/Team/issues/1004

- adds new `{{tiers}}` helper behind `multipleProducts` flag
- `{{tiers}}` outputs a string with list of tiers that have access to specific post when used in a post context in theme
- outputs empty string when used out of a post context and without access to `visibility` property
- uses tiers attached to post column for data
2022-03-04 18:22:59 +05:30
Rishabh
eac732f620 Added tiers data for posts with non tiers visibility
refs https://github.com/TryGhost/Team/issues/1004

The `tiers` column for a post/page only contained data if its visibility is set to `tiers`, otherwise its empty. This is because originally the purpose of `tiers` column on `post` was to capture specific tiers with access to post.
The best way to ensure a consistent behavior for `tiers` column data on post is to update it to always contain list of all `tiers` that have access to post, and not just when the visibility is `tiers`. This means the value is set to all tiers when visibility is one of public|members, and only paid tiers when visibility is `paid`.  This change also allows on frontend to get all relevant `tiers` information for a post locally within post context instead of relying on additional information from outside.

This change -

- updates the output serializer for post/page to add all desired tiers manually in case of visibility is not `tiers`
- updates tests
2022-03-04 18:22:59 +05:30
Matt Hanley
c6617459a5
Switched products.visible for products.visibility (#14264)
- We have an existing pattern for using `visibility: public` instead of `visible: true|false`
- We no-op the existing migration and roll forward so that we don't have to manually revert db changes
2022-03-04 11:07:38 +00:00
Simon Backx
f389bab6ab
🐛 {{access}} property incorrect when using get/next-post/prev-post helpers (#14256)
refs https://github.com/TryGhost/Team/issues/1367

- The {{access}} property of a post always returned false for non-public content
- Added the member context to the get, next-post and prev-post helpers
- The get, next-post and prev-post helpers didn't add the member context to the internal API calls
- Added the members context to these calls
- Added tests that check if the member context is passed to the API calls
- Transformed next_post helper tests to async await syntax
- Transformed prev_post helper tests to async await syntax
2022-03-03 16:18:05 +01:00
Simon Backx
e97abeceb5
Added >, <, >=, and <= operators to match helper (#14215)
refs https://github.com/TryGhost/Team/issues/1386

- The current match handler supports normal (in)equality operators, but no numeric comparisons (<, >, <=, >=)
- A use case for these new operators is to show the latest post in a separate way from other posts

Includes unit tests to check the new behaviour.
Run via `yarn test test/unit/frontend/helpers/match.test.js`
2022-03-03 15:43:47 +01:00
Fabien "egg" O'Carroll
1b96ce2794 Added /tiers endpoint to Content API
refs https://github.com/TryGhost/Team/issues/1313

When adding the tiers endpoint the Content API was missed, this is
needed so that themes can access Tiers via the `{{#get}}` helper.
2022-03-03 15:15:43 +02:00
Fabien "egg" O'Carroll
c00b398abf Added visible property to Tiers API
refs https://github.com/TryGhost/Team/issues/1387

This is also added to the Products API so that the Admin can use it
without having to switch to the new Tiers API.
2022-03-03 15:15:43 +02:00
Naz
da0dee548c Added alias for non-versioned API endpoints
refs https://github.com/TryGhost/Toolbox/issues/169

- Before next major version release we need to prepare for removal of API versioning.
- This change allows unversioned API requests to work under following endpoints:
- /ghost/api/admin
- /ghost/api/content
- This change should allow further preparation of the API clients (SDKs, Integrations, etc.) to non-versioned APIs in Ghost instances in ^5.0.0
- Changed default e2e test targets to non-versioned API. It's a trial, to have working examples. In the future all tests should switch to use only non-versioned endpoints.
2022-03-03 20:21:22 +13:00
Naz
cd1183c9d8 Added JWT authentication for non-versioned API
refs https://github.com/TryGhost/Toolbox/issues/169

- As Ghost prepares to drop API versioning in future major release it the authentication mechanism should take into account non-versioned token audience support. The audience for non-versioned api requests would be limited to "admin" rather than "canary/admin"
2022-03-03 20:21:22 +13:00
Naz
6b730cf201 Fixed use of anyDate matcher
refs c5f8853ad9

- The change in referenced commit was introduced by mistake
2022-03-03 12:06:40 +07:00
Thibaut Patel
c5f8853ad9
Ignore casper install on setup (#14218)
refs https://github.com/TryGhost/Team/issues/1362

- Casper is already installed, so the installation from github always fail.
- There is no need to display an error message in that case.

Added regression tests for blog setup with the default theme:
- Check whether there are no notifications after completing the setup
- Also test the setup with the default theme
2022-03-02 18:22:20 +01:00
Thibaut Patel
527ef79955 Added the last_seen_at update on member page view
refs https://github.com/TryGhost/Team/issues/1306

- This adds a `MemberPageViewEvent` event when a page is viewed by a member (post/page/tag/author/...)
- Integrates the `LastSeenAtUpdater` service that listens to the `MemberPageViewEvent` events to update `member.last_seen_at`
- Follows the latest testing recommendation (end to end test + testing for side-effects)
2022-03-02 13:58:26 +01:00
Fabien 'egg' O'Carroll
db202fb162
Added visible column to products table (#14221)
refs https://github.com/TryGhost/Team/issues/1387

We are moving away from the portal_products setting to instead store
each tiers visiblity on the tier itself. This column will be used for
that data.

Both of the default Tiers should be visible, but newly created tiers
should not be.
2022-03-01 18:11:59 +02:00
Naz
b3bf19e9e3 Renamed e2e framework date matchers
refs f48892028d
refs 33da584161

- There was another mather added recently: anyDateWithTimezoneOffset. The naming of date-related matchers was getting long and confusing. Renamed existing date matcher to better reflect what they do and they types of matches they are responsible for, following renames have been done:
- anyShortDate  -> anyISODate
- anyDate  -> anyISODateTime
- anyDateWithTimezoneOffset  -> anyISODateTimeWithTZ
2022-03-01 18:17:13 +07:00
Naz
b9e26c836b 🐛 Fixed missing index page from pages sitemaps
closes https://github.com/TryGhost/Ghost/issues/14180
refs 597ec51afb

- The index page `/` was missing from sitemaps.xml. It was a regression instoruced with a referenced commit.
2022-02-28 22:23:11 +07:00
Thibaut Patel
e262b09180 Enabled the last_seen_at flag in the legacy member tests
refs https://github.com/TryGhost/Team/issues/1393

- Added the `last_seen_at` property back in the api answers. The property was removed in ebab652919 without updating the member legacy snapshots
2022-02-24 17:41:38 +01:00
Aileen Nowak
92d9029500 Added accentColor and description parameters to /authentication/setup route
refs https://github.com/TryGhost/Team/issues/1382

- Added two possible new setup values: `accentColor` and `description` to define the brand colour and site description on initial setup
- Updated tests to reflect those changes
- Only the params when passed and fall back to default site description
2022-02-24 12:36:57 -04:00
Thibaut Patel
ebab652919 Moved the last_seen_at api property behind a flag
refs https://github.com/TryGhost/Team/issues/1393

- Prevents any issue from reaching all Ghost users
2022-02-24 17:28:07 +01:00
Fabien 'egg' O'Carroll
694721cbea
Added /tiers API to Admin API (#14200)
refs https://github.com/TryGhost/Team/issues/1313

Rather than removing the /products API we're adding a /tiers API as
a first step towards renaming "products" to "tiers". The initial idea was
to alias the URL's but out API framework doesn't easily allow for this so
we've duplicated it instead.
2022-02-23 17:00:18 +02:00
Naz
33da584161 Converted pages e2e test to use test-framework
refs https://github.com/TryGhost/Toolbox/issues/215

- The conversion should serve as a reference test. Eventually the aim is to have all tests converted to use "utils/e2e-framework"  instead of previously used plethora of utils and whatnot
2022-02-24 00:47:09 +13:00
Naz
d6d064be71 Converted posts e2e test to use test-framework
refs https://github.com/TryGhost/Toolbox/issues/215

- The conversion should serve as a reference test. Eventually the aim is to have all tests converted to use "utils/e2e-framework"  instead of previously used plethora of utils and whatnot
2022-02-24 00:47:09 +13:00
Naz
1309a8144f Converted settings e2e test to use test-framework
refs https://github.com/TryGhost/Toolbox/issues/215

- The conversion should serve as a reference test. It was also a massive LoC drop when converting, felt almost criminal not to do it!
2022-02-24 00:47:09 +13:00
Naz
9f0545b133 Added anyDateWithTimezoneOffset matcher to e2e framework
refs https://github.com/TryGhost/Toolbox/issues/215
refs https://github.com/TryGhost/Ghost/issues/10065

- The dates in Content API are returned with UTC offset which does not play ball with existing "anyDate" matcher. Created a new matcher to underline the difference in date formatting between Content and Admin APIs
2022-02-23 17:11:00 +07:00
Naz
fa373e0956 Added ContentAPITestAgent
refs https://github.com/TryGhost/Toolbox/issues/215

- The ContentAPI needs it's own test agent, so we can write e2e tests.
- The main method mostly to be used by the test suites is "authenticate" - it add necessary authentication keys to the request. The agent is not authenticated by default because there are suites that need to test the "non authenticated" requests. Also, there's a need to have the default API key inserted from fixtures level before authenticating (it's not strictly necessary because the key is not dynamic, but I think coupling this point would be a bad move)
2022-02-23 17:08:56 +07:00
Thibaut Patel
664dfbeae8 Added the last_seen_at field to the member API answers
refs https://github.com/TryGhost/Team/issues/1389
2022-02-22 19:45:55 +01:00
Daniel Lockyer
fb7e6e8276
Added note about installing the E2E browsers
refs https://github.com/TryGhost/Toolbox/issues/207

- we need to suggest to install the supported browsers so Playwright can run tests
  against them
2022-02-22 10:20:40 +01:00
Naz
4757158054 Removed leftover @tryghost/jest-snapshot usage
refs fd0a3e80ae
refs https://github.com/TryGhost/Toolbox/issues/215

- This changes got lost and should have landed with referenced commit
2022-02-22 10:33:42 +07:00
Naz
fd0a3e80ae Removed @tryghost/jest-snapshot dependency
refs https://github.com/TryGhost/Toolbox/issues/215

- Ghost tests had difficulty running sometimes when the versions for jest-snapshot package did not match in Ghost and @tryghost/express-test
- This is the error that was showing up: `IncorrectUsageError: Unable to run snapshot tests, current test was not configured`
- The reason why snapshot tests were misconfigured was multiple instances of SnapshotManager, which broke the singleton pattern
- Having jest-snapshot embeded within express-test makes sure the versions stay the same across the clients
- The version bump also introduces passing "queryParams" parameter into the Agent constructor - enables configuring query parameters that would appear in each agent's request. Example usecase - Content API authentication parameter "key" would be nice to "remember" and add to every request URL
2022-02-22 09:41:58 +07:00
Hannah Wolfe
5bf12939e4
Updated eslint-plugin-ghost & fixed resulting failures
- I recently added a bunch of strict rules to our eslint plugin around returns: ca9af37866
- These mostly are issues that occur whilst writing code, that you spot and fix as you're developing, but they're annoying to notice/find and eslint can be used to flag them quickly
- There are of course, edge cases where you don't need to return from array fns, but this rule also suggests better patterns might be available
- For our excert helper and new assertEvent helper, I've updated the code to use simpler patterns that are easier to read, so as to avoid the warnings
- For our old API I've simply disabled the rule as we're about to delete this code
2022-02-21 12:30:12 +00:00
Naz
8c311419c6 Cleaned up JSDocs referencing TestAgent
refs https://github.com/TryGhost/Toolbox/issues/214

- Previous docs were out of date
2022-02-21 20:06:20 +13:00
Naz
027d6a84a8 Fixed disconnected Stripe test
refs https://github.com/TryGhost/Toolbox/issues/214

- Disconnected Stripe state is now a special case after the defaul test configuration was changed to have fake Stripe keys included mimicing configured Stripe
- The disconnected state is now achieved through an API call instead of mocking internal services from the test level. This seems like a cleaner approach, although still a bit cumbersome
2022-02-21 20:06:20 +13:00
Naz
3a974f6e4e Added default values for Stripe config in tests
refs https://github.com/TryGhost/Toolbox/issues/214

- These variables need to be present in the configuration during the Ghost's boot time initialization, which caused a need to remember to mock settings cache before agent initialization.
- By moving the values into default settings config it removes the need to do any work during test environment setup. Yey!
- We should put default values in to test-specific settings-defaults.json In similar situations. Specifically, when we find a need to mock settings cache to be able to start Ghost instance in a certain state
2022-02-21 20:06:20 +13:00
Naz
8f17c1683d Added test-specific default-settings.json configuration
refs https://github.com/TryGhost/Toolbox/issues/214

- Having this config for test environment allows to pre-populate default settings values in the settings table
- Right now the default-settings.json is an exact copy of the original "/data/schema/default-settings/default-settings.json". Having a starter file as an exact copy, allows to track the differences between environments as they are introduced easier
2022-02-21 20:06:20 +13:00
Naz
4700b14d93 Made default settings file location configurable
refs https://github.com/TryGhost/Toolbox/issues/214

- The values configuration for the settings table need to become configurable to be able to run our test environment with a pre-defined set of configurations (e.g Stripe-related values).
- This change makes it possible to define the default settings file location (currently a JSON)
- A new key is now exposed through the "paths.defaultSettings" key in settings, which can be overloaded for the needs of the environment
2022-02-21 20:06:20 +13:00
Naz
7f0bf62ec9 Renamed defaultSettings to defaultRouteSettings
refs https://github.com/TryGhost/Toolbox/issues/214

- The `defaultSettings` path name in the config (one pointing to routes yaml file) creates confusion with the `defaultSettings` which populate defaults for  in the database settings table.
- Furthermore, the name collision creates a problem when trying to make database default settings dynamic - being able to load them from configurable file path.
- Rename makes "routing" explicit to avoid ambiguity and free up the name for the database defaults
- The value seems to be safe to be renamed as all keys used in `overrides.json` are taking priority - the name "defaultRouteSettings" hasn't surfaced at any point in the git history
2022-02-21 20:06:20 +13:00
Naz
178e7db066 Extracted TestAgent class for test utils
refs https://github.com/TryGhost/Toolbox/issues/214

- The constructor logic was duplicated across test agents, so made sence to extract the logic into a common class
2022-02-21 11:19:07 +07:00
Naz
4b5852fab1 Extracted separate member agent test util
refs https://github.com/TryGhost/Toolbox/issues/214

- TestAgent was used to initialize both Admin & Member API agents, which is somewhat confusing because Member API does not have the same "loginAs" functionality like Admin API does
- Having distinct agents for each API makes the class API cleaner with possibility to extract common functionality even further
2022-02-21 11:04:47 +07:00
Fabien 'egg' O'Carroll
9c5c41b927
🐛 Fixed welcome pages not working for "subscribe" links (#14176)
- Fixed test fixtures so that members with subscriptions also have products/tiers
- Fixed test fixtures so that default&free tiers can be updated for tests
- Added tests for the signin functionality and welcome page redirects
- Extended `setupStripe` to setup other Members settings - this needs some more
  thought around how we proceed
2022-02-20 16:02:42 +02:00
Thibaut Patel
c09a81aabe Added some event assertions to the members e2e tests
refs https://github.com/TryGhost/Team/issues/1355

- Uses the models to query the database for testing the event presence.
- Prototyped an util to help with event assertion and correct error messages and lower lines of codes.
- Given there are side-effects between tests (adding or removing members), the event count depends on the previous tests, this isn't optimal.
2022-02-18 18:20:45 +01:00
Thibaut Patel
a5a44f3448 Added more members e2e test snapshots
no issue
2022-02-18 16:48:55 +01:00
Hannah Wolfe
a064067154
Fixed logic error in labs mock
- the previous logic only allowed one flag to be mocked at a time because it kept recalling sinon.stub
- now it's possible to mock multiple flags with different settings as we always just add to the same stub
2022-02-18 10:13:30 +00:00
Naz
f48892028d Fixed failing snapshot match in members
no issue

- The test was failing because the match for a the data has changed, which was returned in a short format YYYY-MM-DD.
- Added a new matcher for short date format -anyShortDate. Can be used for match dynamic dates in short format
2022-02-18 11:30:14 +07:00
Naz
d54c1efefb Fixed typos 2022-02-18 11:27:22 +07:00
Thibaut Patel
06a4dd7456 Fixed the snapshot for members e2e tests
no issue

- A partial version was generated and committed, this is restoring all snapshots
2022-02-17 18:44:51 +01:00
Thibaut Patel
d4d6842bcc Fixed the members e2e test
no issue

- Added a missing `'content-length': anyString` as it's not returning a stable value
- Removed snapshots that aren't relevant anymore
2022-02-17 15:56:16 +01:00
Thibaut Patel
b10ea7c714 Removed the duplicated members regression tests
no issue
2022-02-17 15:44:48 +01:00
Thibaut Patel
c47ea0a17a Re-ordered the members tests
no issue

- They are now grouped by themes to make it easier to work on them
2022-02-17 15:44:48 +01:00
Thibaut Patel
7d66ba8bb1 Merged regression e2e members tests into api e2e tests
no issue

- no need for `sinon.restore()` in `afterEach` because it's already in `mockManager.restore()`.
- Removed test 884f837bd7/test/regression/api/admin/members.test.js (L196) as it's a duplicate of 884f837bd7/test/e2e-api/admin/members.test.js (L276)
2022-02-17 15:44:48 +01:00
Naz
80f0ba4abf Improved WEBHOOK_SECRET initialization in tests
refs https://github.com/TryGhost/Toolbox/issues/214

- Having to fill out `process.env` variables in tests is a frustrating developer experience. Test environment should be configured with smart defaults, so the developer writing test cases would modify variables like this only is special test cases.
2022-02-17 20:26:30 +07:00
Fabien 'egg' O'Carroll
daa39bf4fe
🐛 Fixed error handling webhooks for unknown member (#14155)
https://github.com/TryGhost/Team/issues/1374

When we receive a web hook to update payment details for a customer
which is not associated with a Member, instead of proceeding and erroring
we now return early and respond to Stripe with a 200. A test has been 
added to ensure this
2022-02-17 14:51:40 +02:00
Daniel Lockyer
1a0362f3db Added demo E2E browser test
refs https://github.com/TryGhost/Toolbox/issues/207

- we want to start writing some E2E tests that involve automated
  pointing and clicking around the frontend of Ghost to test that
  members of Ghost sites can still do what we expect
- we've decided to look in to Playwright for this - it looks __really__
  nice
- this is a VERY basic first test - it'll check for a 200 on the
  homepage of whatever we provide as the TEST_URL env variable, or
  default to a (manually-run) Ghost instance on port 2368
- also adds a `yarn test:browser` command to run the tests using the
  Playwright CLI, and a sample GitHub Action workflow which we can
  manually run with a site URL
- there's a lot more to add here in terms of test framework but this
  gets us started
2022-02-17 12:16:58 +01:00
Naz
884f837bd7 Improved webhooks e2e test bootstrap speed
refs https://github.com/TryGhost/Toolbox/issues/214

- Calling `getMembersAPIAgent` and `getAdminAPIAgent` separately was booting Ghost twice, which caused a significant performance degradation.
- Additionally, having two calls was slightly ugly and having once utility function that delivers multiple agents at once feels like  more readable syntax
2022-02-17 15:31:57 +07:00
Daniel Lockyer
55204bf725 Fixed admin views path mocking override in tests
- for some reason, this test seems to be failing now we've pulled it out
  of the general CI
- it makes sense when the repo is clean, because the html files don't
  exist, but I don't understand how they were working before... 🤔
- anyway, we should be overriding the path to the test fixtures admin
  view files here
- this fixes the unit tests
2022-02-16 19:22:20 +01:00
Hannah Wolfe
6a2755893e
Added new matcher for location strings
- Often in our API we want to check that the location string looks roughly right for a resource
- At the moment we're matching any String, this upgrades the check to look for resource URLs
2022-02-16 13:48:56 +00:00
Thibaut Patel
bed0115ddd
Added an e2e test for creating a member subscription
refs https://github.com/TryGhost/Team/issues/1355

- Used nock to mock the Stripe API.
- Re-used the price fixture for the Stripe API mocks.
2022-02-16 14:23:59 +01:00
Thibaut Patel
43960b7de6 Removed a side effect in member tests
- Removed stubs after each tests
- Removed assignments to `_configured` as they lead to side effects is the stripe service is configured beforehands
2022-02-16 14:02:13 +01:00
Fabien 'egg' O'Carroll
8547ea05e0
Added test for checkout.session.completed (#14149)
refs https://github.com/TryGhost/Team/issues/1338

Testing the most basic signup flow for new paid members should give us a
good base to write other stripe webhook based tests.
2022-02-16 13:34:33 +02:00
Fabien 'egg' O'Carroll
dc78d273c3
Added stripe test assertions (#14150)
We've split the tests into two describes, one for when Stripe is enabled
and one without, because we setup Stripe in the before method.

We use nock to mock the Stripe server and assert that there is no call
to delete the subscription.
2022-02-15 21:00:06 +02:00
Hannah Wolfe
d4ed00831e
Updated fixture Casper@v4.7.2 & corrected README
- I noticed our test fixture theme was still throwing errors during tests because it had partials that are no longer in use
- Updated the docs on how to update Casper to include ensuring Casper was on a valid version AND removing Casper before
  copying it across
- Performed the exact steps in the README
- This ensures that the Casper version we use in our tests is not throwing tonnes of errors and is up to date
2022-02-15 15:42:14 +00:00
Fabien 'egg' O'Carroll
133a41c256
Added scaffolding for testing Members with Stripe (#14142)
refs https://github.com/TryGhost/Team/issues/1338

This adds some initial scaffolding to make it easier to test Members with Stripe
 - `mockStripe` method to disable the network, so we can use nock to intercept
Stripe API calls
- `setupStripe` method to be called _before_ getting an agent so that Stripe is 
configured
- `getMembersAPIAgent` to get an agent for the Members frontend API
2022-02-15 15:08:58 +02:00
Naz
09bf5804ad Fixed e2e-framework to correctly compare headers
refs https://github.com/TryGhost/Toolbox/issues/209
refs https://github.com/TryGhost/Toolbox/issues/210

- Fixed request header processing by the e2e-framework where it failed to lowercase incoming header keys. This bug made it harder to test code paths which involve header checking, e.g. following code: `req.headers['stripe-signature']` would not get a correct value if the header was specified as Stripe-Signature
- Additional output to the status code assertions was added - this allows to have more context when an invalid response code comes back in a test.
2022-02-15 18:38:45 +07:00
Thibaut Patel
db6537fede Moved members importer tests to its own test file
no issue

- The members importer api tests don't use the e2e framework, so it's better to move them in their own file as we did for the e2e regression tests.
- Fixed a content-disposition header issue
2022-02-15 11:16:43 +01:00
Thibaut Patel
e59ee38d21 Updated the authentication test
no issue

- Mocked the github url with nock to avoid network usage during regression testing
- Added logging when the theme install fails during setup
2022-02-14 18:22:53 +01:00
Thibaut Patel
8dcf92d047 Disabled a failing test
refs 531ec579a2

- This test broke the build in commit 531ec579a2
- For some reason when running just the test file, it passes. When running the full e2e-api test suite, it fails.
- I'm commenting it to unblock the broken build and move on to other tests
2022-02-14 17:11:12 +01:00
Thibaut Patel
531ec579a2 Added missing tests from previous commit
refs 3288e5bf33

- These tests do not use the new e2e framework given it doesn't support file attachments yet
2022-02-14 14:43:34 +01:00
Thibaut Patel
3288e5bf33 Added e2e tests for members (with multipleProducts enabled)
refs https://github.com/TryGhost/Team/issues/1353 https://github.com/TryGhost/Team/issues/1356 https://github.com/TryGhost/Team/issues/1355

- Uses the new e2e test framework (snapshots)
- Part of the tests couldn't be converted as they use file attachments (unsupported by the new e2e test framework at the moment)
2022-02-14 14:14:03 +01:00
Hannah Wolfe
0ab2f36c22
Added settingsCache handling to e2e-framework
refs: https://github.com/Ghost/Ghost/commit/b5ee17b25

- When moving the site tests into e2e-api they broke because they were getting the changed settings value from the settings test
- The solution is to ensure the settingsCache is reset between tests, which is what this commit does
- This commit also renames the shutdown method to reset, because this is not a permanent operation
- It also renames the resetDb method to resetData, because the concept is we want the internal data to be reset, not just the DB
2022-02-11 16:24:24 +00:00
Hannah Wolfe
b5ee17b25f
Moved site.test.js from regression to e2e-api
- We're in the process of rolling out a new e2e-framework, and getting rid of the regression tests
- We'll eventually merge all the tests together and into using the same framework
2022-02-11 16:24:00 +00:00
Thibaut Patel
de94190ad5 Renamed members API tests to legacy
refs https://github.com/TryGhost/Team/issues/1353

- Doing a renaming-only commit to avoid merge conflicts while I work on the new members.test.js test file
- The new `members.test.js` file will set the `multipleProducts` flag to true
2022-02-11 15:02:08 +01:00
Fabien "egg" O'Carroll
126fc8cb81 Fixed e2e-framework not waiting for Ghost to start
no-issue

Because we were returning the call to `boot`, rather than awaiting it,
it meant that once a test was provided with an API Agent the Ghost
application hadn't necessarily started. This was noticed whilst working
on the Members API which requires the frontend to be loaded.

When the frontend is loaded we must also wait for the url service to
have finished initialising, so that we do not run into 503 maintenance
errors when hitting the frontend.
2022-02-11 15:56:09 +02:00
Fabien "egg" O'Carroll
af66ab02c8 Added getMembersAPIAgent to e2e-framework
no-issue

The Members API is served on a different endpoint to the Admin API, and
also requires that the frontend is booted. This agent is to be used when
testing the Members API, e.g. Stripe webhooks or Members config.
2022-02-11 15:56:09 +02:00
Hannah Wolfe
e30498ca2c
Enabled jsdoc in tests + fixed issue in e2e framework
- Enabled jsdoc type checking in tests
- Fixed a minor issue I just committed to the e2e framework
2022-02-11 12:48:02 +00:00
Hannah Wolfe
00e4a8cad4
Add option to include member in the adminAPIAgent
- The admin API test agent doesn't boot the Ghost frontend, which is where members routes are currently located
- This means we can't test members properly as we don't have access to webhooks etc
- This change adds a members option to getAdminAPIAgent(), which in turn enables the frontend
- We do it this way so that we can easily change the implementation later, e.g. if we have the option to boot members directly
2022-02-11 12:37:00 +00:00
Hannah Wolfe
9375a1701a
Revert "Fixed theme storage getting confused between tests"
This reverts commit 3e7039c47d.
2022-02-11 11:09:21 +00:00
Hannah Wolfe
3e7039c47d
Fixed theme storage getting confused between tests
- When starting ghost for e2e tests we create a content folder in the os tmp dir
- This means that the folder can change between suites as ghost is started and restarted
- For the most part this is fine, but theme storage caches the path to config (which makes sense, it's not meant to change whilst Ghost is in-memory)
- This is a quick-n-dirty fix that just makes it possible to update that path in the tests, so we know it's in sync
- Ideally we'd not cache the path, use a function to fetch it etc, or fully reset the theme storage layer, but this is the fix I have working today
     and so it's going in to unblock things for now
2022-02-11 10:37:37 +00:00
Hannah Wolfe
dabf143cae
Fixed Ghost boot errors being masked
- This was a total derp on my side, wanted to change the error message, not remove the error
2022-02-11 10:21:45 +00:00
Rishabh
56a8d21263 Added unit tests for content gating post access
refs https://github.com/TryGhost/Team/issues/1343
refs 3ccd3601b3
2022-02-11 14:26:04 +05:30
Hannah Wolfe
c80e68b93a
Updated all members tests to use mockManager
- This part of the framework can be used in isolation
- Using mockManager everywhere makes it more visible how to use it
- Aside: fixed .getAdminAPIAgent not needing a URL in site tests whilst cleaning up
2022-02-10 12:21:05 +00:00
Hannah Wolfe
83aa35241a
Added mockLabsDisabled to e2e framework
- Can now easily mock labs flags as enabled or disabled using mockManager
- Updated some bits of code that directly mocked labs
- Aside: improved error thrown when things go wrong booting Ghost
2022-02-10 12:10:31 +00:00
Thibaut Patel
26c6238c3b Released to GA the theme parameter in the /authentication/setup route
refs daeb06e835

- This is an additive change, and the parameter is optional so it's better to ship it right away (testing was hard as it's a chicken and an egg problem to have a feature flag in the setup route).
2022-02-10 12:21:28 +01:00
Hannah Wolfe
c885dac30a
Removed chai + misc auth test cleanup
refs: https://github.com/TryGhost/Toolbox/issues/158

- We only use chai in a handful of places now, and it seems totally unnecessary
- Use assert instead
- Made other minor changes with a view to this being a reference aka "perfect" test suite
2022-02-09 21:14:31 +00:00
Hannah Wolfe
da44ccaf11
Removed querystring dep from members tests
refs: https://github.com/TryGhost/Toolbox/issues/158

- if we had to combine a large list of params then this would make sense
- we could/should also add a .query() method to our agent
- however, I don't think this is worthwhile/necessary for just 2 params right now :)
2022-02-09 21:14:17 +00:00
Hannah Wolfe
527cb01680 Updated members tests to use snapshot testing
refs: https://github.com/TryGhost/Toolbox/issues/158

- This is a reference suite - it shows how snapshot testing can be used on a larger suite
2022-02-09 20:15:58 +00:00
Thibaut Patel
479df36a48 Added the last_seen_at column to members
refs https://github.com/TryGhost/Team/issues/1304

- This migration adds a column to store when a members was last seen
- The utils.js e2e test file was refactored according to the commit 06dd9bac59
2022-02-09 11:57:45 +01:00
Fabien 'egg' O'Carroll
88786f768b
Added validation for Tier prices
refs https://github.com/TryGhost/Team/issues/1319
refs https://github.com/TryGhost/Team/issues/521

This updates the members-api to explicitly validate Tier prices rather
than deferring to Stripe and using whichever errors they throw.
2022-02-09 11:04:58 +02:00