Ghost/test/utils
Simon Backx 6b3a657f88
Renamed newsletter_id and email_recipient_filter options (#14798)
refs https://github.com/TryGhost/Team/issues/1596

- Renamed `newsletter_id` to `newsletter` option, the `newsletter` option expects a slug instead of an id
- Renamed `email_recipient_filter` to `email_segment` option
- Default `email_segment` to `all`. Ignored if no newsletter is set
- `email_segment` is ignored if no newsletter is set
- When reverting a post to a draft, both `newsletter` and `email_segment` are reset to their default values (null, all)
- Removed legacy mapping from old email_recipient_filter values 'paid' and 'free' (already a migration in place)
- Dropped legacy throwing errors when email_recipient_filter is paid or free in transformEmailRecipientFilter
- Reorganized transformEmailRecipientFilter parameters for the now required newsletter parameter
- Fixed an issue where the newsletter filter wasn't working because it wasn't in permittedoptions
- Fixed an issue where you could send to an archived newsletter
- Added an extra protection when scheduling to an active, and later archiving the newsletter
- Dropped support for `send_email_when_published` in API
- When importing posts we currently don't have a system in place to set the newsletter_id to map the `send_email_when_published` behaviour. Since this was already the case, I won't include a fix in this PR.
- Stripped `email_recipient_filter`/`email_segment` from Content API (https://ghost.slack.com/archives/C02G9E68C/p1652363211841359?thread_ts=1650623650.233229&cid=C02G9E68C)
- Updated `admin-api-schema` to 3.2.0, which includes the new email_segment property
- Contains a temporary fix for https://github.com/TryGhost/Team/issues/1626, where the `.related('newsletter').fetch` call fails when the newsletter relation is already loaded, because of the overridden `formatOnWrite` method.

Since the `email_recipient_filter` is no longer used without a newsletter, the `none` value is no longer used. A migration transforms all those values to `all`. This should be safe, because we only send an email now when newsletter_id is not null (scheduled posts should already have a newsletter_id, even if at the time of scheduling they didn't add the newsletter_id option, because at that time, we defaulted to the default newsletter).

Admin changes to make this work: https://github.com/TryGhost/Admin/pull/2380
2022-05-16 10:18:04 +02:00
..
fixtures Renamed newsletter_id and email_recipient_filter options (#14798) 2022-05-16 10:18:04 +02:00
mocks Colocated mock-express style utilities 2021-10-20 13:18:35 +01:00
admin-api-test-agent.js Extracted TestAgent class for test utils 2022-02-21 11:19:07 +07:00
admin-utils.js Improved dev tooling (#13118) 2021-07-05 20:02:22 +01:00
api.js Fixed handing test suite 2021-12-09 13:52:02 +04:00
assertions.js Updated var declarations to const/let and no lists 2020-04-29 16:51:13 +01:00
configUtils.js Fixed "no-shadow" eslint warning in tests 2020-10-19 17:45:26 +13:00
content-api-test-agent.js Added ContentAPITestAgent 2022-02-23 17:08:56 +07:00
db-utils.js Cleaned newsletter e2e tests, improved framework 2022-05-06 12:15:12 +01:00
e2e-framework-mock-manager.js Fixed mockLabs disabling all other flags (#14621) 2022-04-28 10:55:20 +02:00
e2e-framework.js Renamed settings index.js to settings-service.js 2022-05-10 20:55:31 +01:00
e2e-utils.js Renamed settings index.js to settings-service.js 2022-05-10 20:55:31 +01:00
fixture-utils.js Renamed settings index.js to settings-service.js 2022-05-10 20:55:31 +01:00
index.js Removed support for single "author" shorthand in fixtures 2022-05-09 20:43:19 +08:00
members-api-test-agent.js Extracted TestAgent class for test utils 2022-02-21 11:19:07 +07:00
overrides.js Revert "Added global setup to reset DB before test run" 2022-03-16 21:10:49 +00:00
redirects.js Split test utilities out into separate files 2021-02-16 20:17:04 +00:00
test-agent.js Removed @tryghost/jest-snapshot dependency 2022-02-22 09:41:58 +07:00
url-service-utils.js Removed unused parameter from isFinished method 2021-11-24 05:32:20 +13:00
urlUtils.js Update dependency @tryghost/url-utils to v3 (#14705) 2022-05-05 16:10:18 +01:00