Ghost/ghost
Simon Backx 8f8ca481a6
Fixed configUtils and adapter cache issues in E2E tests (#16167)
no issue

There are a couple of issues with resetting the Ghost instance between
E2E test files:

These issues came to the surface because of new tests written in
https://github.com/TryGhost/Ghost/pull/16117

**1. configUtils.restore does not work correctly**
`config.reset()` is a callback based method. On top of that, it doesn't
really work reliably (https://github.com/indexzero/nconf/issues/93)

What kinda happens, is that you first call `config.reset` but
immediately after you correcty reset the config using the `config.set`
calls afterwards. But since `config.reset` is async, that reset will
happen after all those sets, and the end result is that it isn't reset
correctly.

This mainly caused issues in the new updated images tests, which were
updating the config `imageOptimization.contentImageSizes`, which is a
deeply nested config value. Maybe some references to objects are reused
in nconf that cause this issue?

Wrapping `config.reset()` in a promise does fix the issue.

**2. Adapters cache not reset between tests**
At the start of each test, we set `paths:contentPath` to a nice new
temporary directory. But if a previous test already requests a
localStorage adapter, that adapter would have been created and in the
constructor `paths:contentPath` would have been passed. That same
instance will be reused in the next test run. So it won't read the new
config again. To fix this, we need to reset the adapter instances
between E2E tests.

How was this visible? Test uploads were stored in the actual git
repository, and not in a temporary directory. When writing the new image
upload tests, this also resulted in unreliable test runs because some
image names were already taken (from previous test runs).

**3. Old 2E2 test Ghost server not stopped**
Sometimes we still need access to the frontend test server using
`getAgentsWithFrontend`. But that does start a new Ghost server which is
actually listening for HTTP traffic. This could result in a fatal error
in tests because the port is already in use. The issue is that old E2E
tests also start a HTTP server, but they don't stop the server. When you
used the old `startGhost` util, it would check if a server was already
running and stop it first. The new `getAgentsWithFrontend` now also has
the same functionality to fix that issue.
2023-01-30 14:06:20 +01:00
..
adapter-manager Fixed configUtils and adapter cache issues in E2E tests (#16167) 2023-01-30 14:06:20 +01:00
admin Added milestone emails alpha flag 2023-01-30 13:02:31 +00:00
api-framework Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
api-version-compatibility-service Limited integrations triggering version mismatch emails 2023-01-30 17:57:14 +08:00
audience-feedback Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
bootstrap-socket Added version information to log lines 2023-01-20 13:18:44 +01:00
constants Update dependency mocha to v10.2.0 2022-12-12 13:20:22 +00:00
core Fixed configUtils and adapter cache issues in E2E tests (#16167) 2023-01-30 14:06:20 +01:00
custom-theme-settings-service Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
data-generator Added WebMentions to data generator 2023-01-23 17:39:00 +00:00
domain-events Added version information to log lines 2023-01-20 13:18:44 +01:00
dynamic-routing-events Added dynamic-routing-events package 2023-01-23 16:33:41 +08:00
email-analytics-provider-mailgun Update dependency mocha to v10.2.0 2022-12-12 13:20:22 +00:00
email-analytics-service Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
email-content-generator Update dependency fs-extra to v11 2022-12-13 10:59:55 +07:00
email-events Added 100% test coverage for EmailEventStorage 2023-01-10 16:36:41 +01:00
email-service 🐛 Fixed not reactivating email analytics jobs 2023-01-26 17:35:45 +01:00
email-suppression-list Update dependency mocha to v10.2.0 2022-12-12 13:20:22 +00:00
express-dynamic-redirects Update dependency mocha to v10.2.0 2022-12-12 13:20:22 +00:00
extract-api-key Fixed full Admin test suite running during unit tests 2022-08-15 15:34:52 +02:00
html-to-plaintext Update dependency mocha to v10.2.0 2022-12-12 13:20:22 +00:00
i18n Update dependency i18next to v22.4.9 2023-01-19 17:58:16 +00:00
importer-revue Updated Koenig packages 2023-01-04 11:27:39 +01:00
job-manager Added version information to log lines 2023-01-20 13:18:44 +01:00
link-redirects Update dependency @types/express to v4.17.16 2023-01-25 11:28:02 +01:00
link-replacer Update dependency mocha to v10.2.0 2022-12-12 13:20:22 +00:00
link-tracking Lowered threshold for link-tracking coverage 2023-01-04 11:27:39 +01:00
magic-link Update dependency @types/nodemailer to v6.4.7 2023-01-03 18:46:57 +01:00
mailgun-client Improved handling large amounts of email events (#16189) 2023-01-26 16:06:15 +01:00
member-attribution Added outbound link tagging setting (#16146) 2023-01-20 13:41:36 +01:00
member-events Update dependency mocha to v10.2.0 2022-12-12 13:20:22 +00:00
members-api Added version information to log lines 2023-01-20 13:18:44 +01:00
members-csv Update dependency fs-extra to v11 2022-12-13 10:59:55 +07:00
members-events-service Added version information to log lines 2023-01-20 13:18:44 +01:00
members-importer Added version information to log lines 2023-01-20 13:18:44 +01:00
members-ssr Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
minifier Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
mw-api-version-mismatch Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
mw-cache-control Update dependency mocha to v10.2.0 2022-12-12 13:20:22 +00:00
mw-error-handler Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
mw-session-from-token Update dependency mocha to v10.2.0 2022-12-12 13:20:22 +00:00
mw-update-user-last-seen Update dependency mocha to v10.2.0 2022-12-12 13:20:22 +00:00
mw-vhost Update dependency mocha to v10.2.0 2022-12-12 13:20:22 +00:00
oembed-service Update metascraper to v5.33.5 2023-01-23 12:04:33 +00:00
offers Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
package-json Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
payments Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
portal Updated email tips copy 2023-01-26 13:12:03 -04:00
referrers Added new urls to known referrers list for source attribution 2023-01-20 18:13:05 +05:30
security Updated @tryghost dependencies (#16005) 2022-12-14 11:18:55 +07:00
session-service Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
settings-path-manager Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
staff-service Fixed the test 2023-01-30 12:45:28 +00:00
stats-service Update dependency knex to v2.4.2 2023-01-23 13:00:53 +01:00
stripe Added version information to log lines 2023-01-20 13:18:44 +01:00
tiers Bumped TryGhost-owned dependencies and lockfile 2023-01-02 20:55:22 +01:00
update-check-service Added version information to log lines 2023-01-20 13:18:44 +01:00
verification-trigger Improved email verification required checks (#16060) 2023-01-04 11:22:12 +01:00
version-notifications-data-service Limited integrations triggering version mismatch emails 2023-01-30 17:57:14 +08:00
webmentions completely blocked external requests in Webmentions tests (#16186) 2023-01-25 10:43:57 -06:00