Commit Graph

15563 Commits

Author SHA1 Message Date
Hannah Wolfe
3bd8e01495 Pinned coverage to current levels to prevent drops
- Updating our config to have `--check-coverage` enforces that the coverage meets a certain level.
- The default is 95 I believe, but our coverage is lower.
- I've set the levels to our current levels, so any drop below these numbers will cause the build to fail.
- I've also set the reporters to be text, html and cobertura so we always have a mini report, the full HTML files to navigate and cobertura for CI
- Cleaned up CI so we don't use the cov:unit command as we're now using codecov
- This also means we can remove the cov:unit command which was weird to use because it uses the last test run, which can be confusing
2022-02-24 09:56:06 +00:00
Renovate Bot
6d648487fc
Update dependency luxon to v2.3.1 2022-02-23 20:51:21 +00: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
Renovate Bot
3c3ead8648
Update dependency fs-extra to v10.0.1 2022-02-22 19:57:01 +00: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
Renovate Bot
af1d1abd1d Update dependency @tryghost/logging to v2.0.4 2022-02-22 12:24:23 +01:00
Renovate Bot
688c353030 Update dependency @tryghost/nodemailer to v0.3.13 2022-02-22 12:20:40 +01:00
Renovate Bot
a0d248d18e Update dependency @tryghost/debug to v0.1.13 2022-02-22 12:20:27 +01:00
Renovate Bot
0ca6318f20 Update dependency @tryghost/errors to v1.2.3 2022-02-22 12:20:16 +01:00
Renovate Bot
d88770cc32 Update dependency @tryghost/tpl to v0.1.12 2022-02-22 12:19:20 +01:00
Renovate Bot
0e7eb4acd9 Update dependency @tryghost/version to v0.1.11 2022-02-22 12:17:30 +01:00
Thibaut Patel
e7751fa279 Backfilled the members last_seen_at column
refs https://github.com/TryGhost/Team/issues/1305

- Skipped sqlite3 compatibility due to the lack of join support in update
- Uses a raw migration to improve performance
2022-02-22 12:16:36 +01:00
Kevin Ansfield
00195b5bc4 Merged v4.36.3 into main 2022-02-22 10:28:55 +00:00
Daniel Lockyer
8b8144a3b8 v4.36.3 2022-02-22 10:25:09 +00:00
Daniel Lockyer
7a9c80a771 Updated Admin to v4.36.3 2022-02-22 10:25:09 +00: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
Renovate Bot
63762afc49
Update dependency express-jwt to v6.1.1 2022-02-21 17:23:30 +00:00
Djordje Vlaisavljevic
2c5643623d Added the "selectablePortalLinks" feature flag
refs https://github.com/TryGhost/Team/issues/1096
2022-02-21 16:46:15 +01:00
Renovate Bot
b19bb35aca Update dependency mocha to v9.2.1 2022-02-21 12:53:22 +00: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
Kevin Ansfield
2f7456790e Added membersLastSeenFilter labs flag
refs https://github.com/TryGhost/Team/issues/1307

- flag for gating `members.last_seen_at` API property and associated filtering in Admin
2022-02-21 11:48:23 +00:00
Daniel Lockyer
ddaa4ee5e1 Removed unnecessary checks during initial DB init
refs https://github.com/TryGhost/Toolbox/issues/202

- during DB init, we have to create all the tables
- right now we loop over all tables and call the `createTable` command
  - this command checks if the table exists and if not, creates the table
  - this works fine but it means we query the database for every table
  - in MySQL, we query the information_schema table, which we've seen
    issues with before because it doesn't have indexes
- the smarter thing to do here is to get all the tables that already exist,
  remove them from the list, and just straight up create them without
  further checks
- this entire thing should be protected by the migration lock so we
  shouldn't encounter issues from multiple processes initializing the DB
  and tables existing after the initial check
- this commit also removes the check from `createTable` because this isn't
  really needed. We should be using the migration utils, which do
  check for existing tables. I've added a note to the function and
  audited anywhere we still call the function
- this commit removes (- 49 tables + 1 initial check) 48 queries from
  the initial DB init
2022-02-21 08:44:40 +01: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
Daniel Lockyer
0ccbfea8fc v4.36.2 2022-02-18 16:00:29 +00:00
Daniel Lockyer
2e9d15d115 Updated Admin to v4.36.2 2022-02-18 16:00:29 +00:00
Thibaut Patel
a5a44f3448 Added more members e2e test snapshots
no issue
2022-02-18 16:48:55 +01:00
Renovate Bot
34fbed10bd Update dependency @tryghost/validator to v0.1.13 2022-02-18 14:33:31 +01:00
Renovate Bot
72fe844396 Update dependency @tryghost/nodemailer to v0.3.12 2022-02-18 14:28:29 +01:00
Renovate Bot
0a84bae1b8 Update dependency @tryghost/errors to v1.2.2 2022-02-18 14:13:57 +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
Daniel Lockyer
3ad871b21e
Added handler for unhandled rejections
refs https://github.com/TryGhost/Toolbox/issues/163

- as of Node 15, unhandled rejections will exit the process so if
  Ghost is running on Node 15+ and encounters one, it will kill Ghost
- if Sentry is enabled, it will add a handler for the event that will
  send it to Sentry but the logging is sent to stdout/stderr, which means
  we lose it in Ghost logs
- this commit adds a process handler for the `unhandledRejection` event
  which will log the reason to Ghost logs and prevent Ghost from
  exiting
2022-02-18 10:35:36 +01:00
Naz
32884fa412 🐛 Fixed StripeAPI disconnection
refs https://github.com/TryGhost/Toolbox/issues/214

- After calling `DELETE /settings/stripe/connect/` Admin API endpoint, stripe did not fully disconnect causing other Member API endpoints to behave as if Stripe was still configured
2022-02-18 16:30:50 +07:00
Renovate Bot
c8105ea08f Update dependency @tryghost/html-to-mobiledoc to v1.8.5 2022-02-18 09:23:55 +01:00
Renovate Bot
39ab0baa82 Update dependency @tryghost/magic-link to v1.0.19 2022-02-18 09:21:38 +01:00