Commit Graph

1050 Commits

Author SHA1 Message Date
Naz
868ae96100 Removed copy-pasta code form TestAgent
refs https://github.com/TryGhost/Toolbox/issues/158

- To make the development quicker the copy-paste code was left in the codebase but gave immediate smell. Removed it to stop bothering me every time I look at the related code :)
2021-12-13 13:13:17 +04:00
Naz
42cd78e05e Added coverage for route settings class
refs 3150c87935

- Adds basic coverage for a bug that was fixed in referenced commit.
Next time it should be easier to add more tests to the suite as there's
already an example starter to work your way from.
2021-12-13 12:21:47 +04:00
Naz
f4ad3b23ba Removed need for 'Origin' header in test suites
refs https://github.com/TryGhost/Toolbox/issues/129

- The "Origin" header is require in Admin API requests so it makes sense to bake it into a default request made by most tests. Reduces unnecesary fluf around test request setup and removes a "config" dependency in each tests suite using the "e2e framework"
2021-12-10 11:05:37 +04:00
Naz
5a150cc3b6 Removed duplicate snapshot initialization code
refs https://github.com/TryGhost/Toolbox/issues/158

- Allows for much smaller amount of code to configure a test to work with chai-jest-snapshots. They now work automatically for all regression tests and could be enabled for other suites by adding the "--require=./test/utils/snapshots.js" parameter in respective test:* package script
- Regenerated snapshot for authentication test as the naming structure
changed a little with the snapshot metadata being taken on a higher
level in the test (uses the suite name instead of a specific describe it
used to be called from)
2021-12-10 06:37:31 +13:00
Naz
ea872101a0 Fixed linting error
refs 309e14b8c9
2021-12-09 15:18:15 +04:00
Naz
309e14b8c9 Moved email stubbing logic into e2e-framework utils
refs https://github.com/TryGhost/Toolbox/issues/158

- Moving common mocking/stubbing/spying logic into an outside utils module allows test suites to keep agnostic towards which framework powers mocking etc. Should also substitute email service stubbing used in multiple places
- Bonus, got rid of should dependency, which is deprecated
2021-12-09 15:10:13 +04:00
Naz
af8387d1f4 Fixed handing test suite
no issue

- The response from the server might not always contain an array with errors (for example when there's a generic 503 error). This changes prevents tests from hanging and adds at least some relevant output
2021-12-09 13:52:02 +04:00
Naz
307e4c2643 Removed unused test utils
refs https://github.com/TryGhost/Toolbox/issues/129

- These have been substituted by e2e-framework module
2021-12-09 22:20:54 +13:00
Naz
eb35c64f19 Added content folder initialization to e2e-framework
refs https://github.com/TryGhost/Toolbox/issues/129

- Adds content folder creation based on fixtures for e2e tests using the e2e framework
- Mostly a copy-paste for now from existing e2e utils with some simplifications, so we can "complicate things" later only if needed
2021-12-09 22:20:54 +13:00
Naz
4fa9f07d66 Cleaned up Authentication API test suite
refs https://github.com/TryGhost/Toolbox/issues/129

- Rejigged the tests to use consistant async/await syntax. Looks so much more readable now!
2021-12-09 22:20:54 +13:00
Naz
59b0c0bb4d Integrated chai-jest-snapshot into authentication suite
refs https://github.com/TryGhost/Toolbox/issues/129

- This is an example of how the converted test suite syntax could look like when using jest snapshots.
- The tradeoff is not that visible just yet as these tests were mostly checking few fields, but when the whole range of admin API tests is convered we'll be able to get rid of the "checkResponse" utiliti methods along with all the supporting luggage!
2021-12-09 22:20:54 +13:00
Naz
3dfab7d682 Integrated chai-jest-snapshot
refs https://github.com/TryGhost/Toolbox/issues/129

- Minimal version of chai-jest-snapshot with property matcher support. It runs off the forked version of https://github.com/suchipi/chai-jest-snapshot
2021-12-09 22:20:54 +13:00
Naz
743b7a16e0 Refactored authentication and site tests to use e2e-framework
refs https://github.com/TryGhost/Toolbox/issues/129

- Provides an example of how to use the e2e framework.
2021-12-09 22:20:54 +13:00
Naz
2ae0d8ef32 Added e2e framework
refs 24505db918

- The code is heavily borrowed from the referenced commit by @ErisDS. It starts a fresh abstraction layer for all e2e tests to use, provides simle interface for request agent initialization and state management (read the e2e-framework top file description for more)
- Main methods the framework exposes are:
  - getAgent - to initialize request agent with a fresh Ghost instance
  - initFixtures - to initializer a fresh db state
  - resetDb - cleans up the db state if there were state manipulations during the test suite run (POST, PUT requests or non-default fixtures)
2021-12-09 22:20:54 +13:00
Naz
6762e2a60d Started a greenfield e2e test framework
refs https://github.com/TryGhost/Toolbox/issues/129

- Having a fresh module should allow building new testing utility concepts from the ground up without being tied by the mystery baggage of the legacy localUtils/testUtils
- The outline of the concepts the framework will be handling is in the commont on the top of the e2e-framework file
2021-12-09 22:20:54 +13:00
Naz
a18fa18ff3 Fixed authentication test suites
refs https://github.com/TryGhost/Toolbox/issues/152

- This refactor fixes the rest of authentication test suite and outlines the state setup steps that are absolutely needed for tests that rely on any db state. It's still counterintuitive why the fixture initialization has to be called and in that specific order, so next will be refactoring in this area to simplify the initi code
2021-12-09 22:20:54 +13:00
Naz
25d75f69db Made options parameter in agetnt utils explicit
refs https://github.com/TryGhost/Toolbox/issues/152

- Passing around plain options object tends to become quite unreadable long term. While these new utils are being shaped up it's still easy to change interface and introduce new parameters with time as needed.
2021-12-09 22:20:54 +13:00
Naz
05a4fbfd2a Refactored request initialization with supertest
refs https://github.com/TryGhost/Toolbox/issues/152
refs 5bea089dfe
refs 16ad5f73c4

- The refactor is heavily inspired by the referenced commit from @ErisDS
- This refactor is meant to serve as a template for further refactors and unification of the abstraction over "request". Should allow us to be more agnostic towards the library that's powering the request thing. For example, mock-express style of request handling could substitute or get substututed easily if all tests are behind similar "get(Authenticated)Agent" interface
2021-12-09 22:20:54 +13:00
Naz
b7231875a0 Refactored authentication test suite to serverless boot
refs https://github.com/TryGhost/Toolbox/issues/152

- This is a continuation of an experiment to switch over to serverless boot in regression tests. Just a proofe of concept that authentication scenarios would also work and the expectations don't collapse unexpectedly.
- Nothing too crazy so far, easy and straight forward substitution of the config "url" with an express app passed to the supertest agent
2021-12-09 22:20:54 +13:00
Naz
4a1bee0a01 Reworked site regression test suite to serverless boot
refs https://github.com/TryGhost/Toolbox/issues/152

- Being able to set up test suites without blocking a port opens a door to new ways to run tests - for example this has been one of the blockers for running mocha tests in parallel
- Additional benefit is lighter statrup, which reducec the test execution time slightly. Doesn't seem like much but these things stack up!
2021-12-09 22:20:54 +13:00
Daniel Lockyer
2d090b8b2a Revert "Remove unnecessary references to ghostVersion"
This reverts commit 443ee369d2.
2021-12-08 14:28:41 +00:00
Sam Lord
443ee369d2
Remove unnecessary references to ghostVersion
refs: https://github.com/TryGhost/Toolbox/issues/146
GhostVersion was passed in here but not used at all. This just removes those unnecessary usages.
2021-12-07 13:48:22 +00:00
Daniel Lockyer
4673bd05fc
Destroyed connection before restoring DB file
no issue

- we've seen some instances of SQLite saying "database disk image is malformed"
- I think this happens because we copy the file whilst we are still connected to
  the old DB
- this commit destroys the connection before copying the clean file to the live
  DB file
2021-12-07 08:23:51 +00:00
Naz
9c0752896c Fixed error wording in fixture-utils
refs 404b2023e5
refs https://github.com/TryGhost/Toolbox/issues/129

- The previous error message wasn't helpful at all . Now we can tell "what?" fixture was looked-up and then go from there to find out why it is missing
2021-12-07 11:12:10 +04:00
Daniel Lockyer
a3cc66be50 Copied DB for faster SQLite tests
refs https://github.com/TryGhost/Toolbox/issues/136

- we nuke and reinitialize the DB many times between tests
- this forms a good portion of the time taken and we shouldn't be spending
  so much time on just resetting the DB back to a known state
- this commit switches out the knex-migrator reset + init calls for SQLite to
  a function which keeps a clean copy of the DB and copies the file back
  when we "reset"
- for MySQL, existing functionality is kept
- this massively speeds up tests because it saves ~700ms+ for every reset
- whilst this change seems to work, it's just the start so there's a
  lot more refactoring needed. this change is currently gated to CI until
  it's deemed safe/sane enough to run on local machines without blowing
  up
2021-12-06 15:22:44 +00:00
Hannah Wolfe
40fee069c9
Moved locale testing out of casper fixture (#13850)
refs: https://github.com/TryGhost/Toolbox/issues/137#issuecomment-986829141

- Moving the weird customisation of Casper out of the test fixture
- Created a standalone theme for testing locales instead
- This should make it easier for us to update our Casper fixture
2021-12-06 15:11:54 +00:00
Naz
3c19a8f014 Cleaned up mock-express tests from unnecessary inits
refs https://github.com/TryGhost/Toolbox/issues/152

- Have skimmed through the test suites in hopes to find some quick performance wins to bring the runtime speed closer to the one in "main". Haven't been successful to identify major wins, cleaned up a couple of small bits.
- We'll have to live with a tradeoff between maintainability/unified boot VS cost of mainitaining a fake boot process. Imo extra couple seconds of runtime is worth it.
2021-12-06 21:28:53 +13:00
Naz
a58e9bb61c Added default options to regression test utils
refs https://github.com/TryGhost/Toolbox/issues/152

- Allows to override boot options form regression test level - needed in some cases for vhost tests
2021-12-06 21:28:53 +13:00
Naz
9dc096cb15 Fixed api vs frontend test suites
refs 3c7a8dead4

- The tests needed adjustments with the native boot mechanism.
- The number of returned posts changed in the test resutls because duing native boot we also insert fixtures which add to the number of initial posts
- The vhost regression suite is still failing and I had no strength to figure out why. The redirect it fails with makes no sense, the clue here is that the test doesn't fail when running in isolation, so probably has to do with some leftover overrides from the previous test cases.
2021-12-06 21:28:53 +13:00
Naz
9e53f36c42 Fixed regression test suite stubs
refs 3c7a8dead4

- The boot process has been using an asyc method to load the routes file, which is the case now for these tests since the switch to raw boot method instead of mimicking it manually
2021-12-06 21:28:53 +13:00
Naz
51a4a65eec Enabled frontend-only boot for mock-express tests
refs 3c7a8dead4

- Simplifies the state initialization code significantly and reuses native boot mechanism instead of mimicking it (it was a headache to maintain with all the internal services moving around)
2021-12-06 21:28:53 +13:00
Daniel Lockyer
f2ba9d3aac
Fixed notify library tests
refs ec28478435

- the method signature changed in
  9fa8800b9d
  and the usage wasn't updated in Ghost
- this commit updates the tests to reflect this internal change
2021-12-06 08:20:39 +00:00
Thibaut Patel
faff6ad669 Fixed the tests from the previous commit
refs 77c0364efd
2021-12-02 10:48:46 +01:00
Thibaut Patel
77c0364efd 🐛 Fixed malformed URLs crashing the url helper
refs https://github.com/TryGhost/Team/issues/960

- Character like "%%" or "%80" would crash our current url escaping behavior. We consider they aren't valid URLs as the percentages haven't been properly escaped.
2021-12-02 10:34:24 +01:00
Fabien egg O'Carroll
6b99f0382f Fixed tests for members importer
refs https://github.com/TryGhost/Team/issues/1202

This was incorrectly setting the subscribed value to false due to the
bug referenced
2021-12-01 17:41:07 +02:00
Thibaut Patel
e17446456e Fixed a test failing due to a .DS_Store file
no refs

- When a `.DS_Store` file was present, the code wasn't ignoring the `README.md` anymore. I've fixed it with a for+while nested loops.
2021-12-01 15:58:09 +01:00
Thibaut Patel
a1421c2380 🐛 Fixes oembed bookmark with whitespaces
refs https://github.com/TryGhost/Team/issues/1200

- The leading/trailing whitespaces are trimmed by `new URL()` but are considered invalid in metascraper. Trimming solves this edge case.
2021-12-01 15:58:09 +01:00
Naz
57de4aca71 Fixed mock-express test setup
refs https://github.com/TryGhost/Toolbox/issues/152

- The tests would fail without these initializations when run in isolation
2021-12-01 18:56:29 +04:00
Fabien egg O'Carroll
3407df7c1c Fixed stubbing of labs data
no-issue

Labs data is read from the labs service not the settings cache, so we
should be stubbing this to ensure that the tests run correctly.
2021-12-01 16:11:27 +02:00
Sam Lord
2887e416da
Switch to @tryghost/errors from ignition errors package (#13807)
refs: TryGhost/Toolbox#147

* Replaces all references to isIgnitionError with isGhostError
* Switches use of GhostError to InternalServerError - as GhostError is no longer public
There are places where InternalServerError is not the valid error, and new errors should be added to the @tryghost/errors package to ensure that we can use semantically correct errors in those cases.
2021-12-01 10:22:01 +00:00
Kevin Ansfield
8cb748c580 Changed tenor config API key name
refs https://github.com/TryGhost/Team/issues/1237#issuecomment-981770688

- API key names for external services now follow a standard pattern
  - top-level key of the service name
  - public/private and read/write perms inside the name, eg. `publicReadOnlyApiKey`
- updated test to match expected API key name
2021-11-30 11:27:28 +00:00
Naz
2540be63c1 Removed v2/v3 regression tests for non-stable endpoints
closes https://github.com/TryGhost/Toolbox/issues/148

- These regression tests introduce very little additional value in exchange for an expensive time to run them. Because we mostly care about stable support for the latest stable API version, the older API version test for "internal" API can go away
- In case there are bugs found we do care about in the v2/v3 APIs we can always revert some of these tests.
2021-11-30 13:31:49 +04:00
Naz
6aee35ec3d Fixed typos
no issue
2021-11-30 20:54:18 +13:00
Naz
2ed1d5c2cc Removed unnecessary resetGenerators call
no issue

- This extra call doesn't seem to be necessary during a fresh boot. It only adds noise in code!
2021-11-30 20:54:18 +13:00
Naz
21219fff2f Removed unused sinon referece
https://github.com/TryGhost/Toolbox/issues/140

- There is no need for sinon usage in this test suite
2021-11-30 20:14:51 +13:00
Naz
6e395291fe Moved custom routes test to e2e frontend suite
https://github.com/TryGhost/Toolbox/issues/140

- This test was bloating the regression/site suite and was using hacks (calling the Admin API) to create a custom redirects state
- It suits way better in e2e frontend test suite with less hacky approach to start the Ghsot instance  - using custom routes file path to initialize the instance
2021-11-30 20:14:51 +13:00
Naz
961c29dc72 Added test util to load instance with custom routes
https://github.com/TryGhost/Toolbox/issues/140

- Allows to fully start an instance with a custom routes.yaml file without a need to do workarounds - e.g. we used to call an internal Admin API from a regression test suite, which is not a good practice
-  Providing "routesFilePath" to startGhost method copies that file to the default settings location and start the instance with that configuration. No need to do API calls or check if the routing service "isFinished"
2021-11-30 20:14:51 +13:00
Naz
6b81b3db02 Unified RSS frontend tests
refs https://github.com/TryGhost/Toolbox/issues/140

- Same/similar RSS tests were present in regression and e2e tests suites. It made sense to move missing cases from regression to e2e. This saves us time bootstraping db state in multiple places and keeps all test cases regarding single feature in same place
2021-11-30 20:14:51 +13:00
Naz
449c61bb1b Removed unnecessary fixture setup in redirects e2e test
refs https://github.com/TryGhost/Toolbox/issues/139

- There's no need for extra users neither extra posts for this suite to run. Less fixtures to be setup - quicker the test execution
2021-11-29 17:53:33 +04:00
Naz
1619a0f49a Removed redirects site regression test suite
refs https://github.com/TryGhost/Toolbox/issues/139

- With ec2aed5ce8 the DynamiRedirectsManager has reached 100% test coverage and most of the tests present in the removed regression suite have been ported to unit tests
- No need to keep slow tests around! :)
2021-11-29 17:51:13 +04:00
Naz
ab9a470623 Removed dead code in redirects.test
refs https://github.com/TryGhost/Toolbox/issues/139

- This code was either not executed and did nothing useful for the test suite. Shaves off extra 2s from the test runtime
2021-11-29 11:55:13 +04:00
Naz
fc5984b486 Slimmed down redirects test suites
refs https://github.com/TryGhost/Toolbox/issues/139

- The regression test suite for redirects functionality for way too big. And each restart was causing massive overhead. It's enough to have a single exhaustive test using multiple input files
- The tests testing API endpoints should've been e2e tests to start with
- The rest is covered in the unit tests for redirects api service
2021-11-26 06:18:36 +13:00
Naz
125901b466 Added a test covering backup redirects functionality
refs https://github.com/TryGhost/Toolbox/issues/139

- This test is meant to partially substitute existing regression test suite for redirects
2021-11-26 06:18:36 +13:00
Naz
6ed5f64f4b Moved backup path calculation outside redirects module
refs https://github.com/TryGhost/Toolbox/issues/139

- Having tight coupling with backup file path calculation for redirects makes it extremely hard to test. In addition, having it injected will make it easier to swap this dependency to the mechanism similar to one used for routes files
2021-11-26 06:18:36 +13:00
Naz
3315ed34ae 🐛 Fixed redirects.json file corruption on upload
refs 91efa4605c

- Referenced commit introduced a double json-stringification to uploaded redirects.json files.
- The endpoint has no stability index of any sort and is meant to be dropped in Ghost v5. It's best to rework the redirects to the yaml format as descirbe here - https://ghost.org/docs/tutorials/implementing-redirects/#file-structure
2021-11-25 18:43:45 +04:00
Hannah Wolfe
621cfd9866
Moved admin redirect middleware to named file
- moving this middleware because we're about to add a second piece of middleware
- it's easier to see what we have when each middleware is in its own file rather than in one big middleware.js file
2021-11-25 14:29:17 +00:00
Daniel Lockyer
617fec71cb
Added number of server boots to test reporting
no issue

- this commit adds a counter for the number of boots we do in tests
- which therefore allows us to calculate the average boot time we
  experience
- only useful for debugging test performance
2021-11-25 09:52:30 +01:00
Naz
b3884a9c6f Removed v2/v3 redirects tests
refs https://github.com/TryGhost/Toolbox/issues/139

- The v2 and v3 redirects APIs are unofficial and should not be used by anyone in production. There's no good reason to maintain expensive to run test suites for old unofficial APIs.
- The test cases in canary suite covers the functionality of redirects enough to be sure they work as expeted
2021-11-25 11:59:31 +04:00
Thibaut Patel
a583f7236e Updated valid.zip to the latest casper version
refs c1006ec649

- This unblocks upgrading gscan. Some tests were failing due to the old fixture.
2021-11-24 20:22:20 +01:00
Naz
4811da45f2 Fixed redirects test suites
refs https://github.com/TryGhost/Toolbox/issues/138

- These tests still rely on the frontend to be present. Needs further investigation to remove "frontend: true" flag - it slows down test runs!
2021-11-25 03:20:47 +13:00
Naz
ac3b2e5aee Switched API regression tests to use frontendless boot
refs https://github.com/TryGhost/Toolbox/issues/138

- The boot oprimization gives a boost in the boot time, which should save time running regression tests
2021-11-25 03:20:47 +13:00
Naz
222273b66b Refactored regression tests to use async/await
refs https://github.com/TryGhost/Toolbox/issues/138

- Final batch of the refactor to async/await syntax.  Doing these refactors before modifying "testUtils.startGhost" everywhere to boot only with the backend
2021-11-25 03:20:47 +13:00
Naz
4cdcb16e49 Refactored regression users tests to use async/await
refs https://github.com/TryGhost/Toolbox/issues/138

- This is a continuation of a bigger refactor to use async/await syntax before migrating "startGhost" methods to only use backend boot
- Removed a little bit of dead code (like admin user creation) which should speed up test execution too!
- Refactored user variables to be declared closer to their usecases instead of being high up in a global scope - variables shoul not live that far apart from the code that uses them
2021-11-25 03:20:47 +13:00
Naz
b19a2ed2d7 Refactored regression tests to use async/await
refs https://github.com/TryGhost/Toolbox/issues/138

- First batch of the refactor to async/await syntax. Next one will cover the rest. Doing these refactors before modifying "testUtils.startGhost" everywhere to boot only with the backend
2021-11-25 03:20:47 +13:00
Naz
231cfef086 Removed use of ghostServer variable pattern
refs https://github.com/TryGhost/Toolbox/issues/138

- There is no good reason to keep this extra variable around just call "stop" in couple very specific cases. Even for those cases, there's `testUtils.stopGhost` method which achieves the same without additional variable to track.
2021-11-25 03:20:47 +13:00
Naz
8dd33c5034 Removed "ghost = testUtils.startGhost" pattern
refs https://github.com/TryGhost/Toolbox/issues/138

- Having the "ghost" alias only added cognitive load when reading through the test code and didn't provide any additional value. Removed the pattern to keep things simpler and more explicit
2021-11-25 03:20:47 +13:00
Naz
e715c5b82d Refactored posts regressions suites to use common initialization syntax
refs https://github.com/TryGhost/Toolbox/issues/138

- Using asycn/await syntax is way more readable and allows to identify further reusable patterns in test initialization. This refactor also served as an exploreation around how the code looks like at this point
2021-11-25 03:20:47 +13:00
Hannah Wolfe
0799f02e80
Rewritten HTMLErrorRenderer w/o asset helper & template
refs: 2af9e2e12

- This new HTMLErrorRenderer is borrowed heavily from finalHandler
   - This is the module that express uses to render errors if there is no custom errorhandler
- It just renders a really simple html page wrapping err.stack in a <pre>
   - This results in a nicely formatted, but unstyled error page
- I also updated BasicErrorRenderer to use the same res.statusCode + err.stack pattern rather than err.message

Note: This error renderer is _only_ used for renderering errors on the `/ghost/` route
 - In almost all cases, errors here are rendered by Ember
 - The only error that can be rendered here is a missing template error see: 2af9e2e12
2021-11-24 13:01:06 +00:00
Naz
aee949bbf4 Removed unused parameter from isFinished method
no issue

- The disableDbReadyEvent variable does nothing here, no need to keep junk around :)
2021-11-24 05:32:20 +13:00
Naz
6ee94f66b4 Fixed invalid settings file path configuration
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings
refs e457fd5fe0 (diff-b292e8480eee007786cc602f55ed05006a06b8da9fe6934d51fbef8328013278R36)

- There were two separate instances of the SettingsPathManager in route-settings and settings-loader causing the configured paths missmatching on test environment. Because of this missmatch, uploading and resetting the routes.yaml file didn't work!
2021-11-24 05:32:20 +13:00
Naz
04ab59c859 Rewrote reload routes.yaml test to use async/await
no issue
2021-11-24 05:32:20 +13:00
Naz
f0b8e9693f Fixed loadRouteSettingsSync stubs
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings
refs e457fd5fe0 (diff-b292e8480eee007786cc602f55ed05006a06b8da9fe6934d51fbef8328013278R36)

- Because "loadRouteSettingsSync" method is now a getter function these stubs had to be changed to use a different syntax
- It's a lot of maintenance to do such renames, so if someone has to touch this exact place again it might be worth abstracting this mocking into a separate utility of some sort.
2021-11-24 05:32:20 +13:00
Naz
2fed8dbbd5 Moved all settings module bootstrap logic into init method
refs refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- The initialization outside the init method is causing problems when the configs are mocked during the test setup
2021-11-24 05:32:20 +13:00
Naz
6d6aa12afe Extracted routes.yaml path calculation into external package
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings
refs e457fd5fe0 (diff-b292e8480eee007786cc602f55ed05006a06b8da9fe6934d51fbef8328013278R36)

- The full logic for  file path calculation for routes.yaml has been duplicated in couple modules. It is aslo following similar pattern used in redirects services and should be reused there once those modules are touched
2021-11-24 05:32:20 +13:00
Hannah Wolfe
0ede559d5b
🐛 Fixed card asset init/reload behaviour
- Card asset reloading was incorrectly only happening if the API version changed 🙈
- In addition, having an init function was redundant, as theme activation happens on boot
- This meant that the card assets were being generated twice on boot
- Instead, we now only generate them on theme activation, which covers the boot case and simplifies all the logic
2021-11-23 12:53:58 +00:00
Hannah Wolfe
6e6a4822f2
Updated servePublicFile to honor v= cache keys
- Currently it's assumed that public files are 100% static
- With card assets, we're using it for files that are partially static, but can change between reboots and theme changes
- We already have a system for managing cache busting across theme changes and restarts - the ?v= key that is added via the asset helper
- This was already in place and used, but servePublicFile's internal cache didn't honor this key, and cached for the lifetime of boot
- This small change means that if a ?v= query param is present on a request for a public file, that we pay attention to it. Else we cache as before
2021-11-23 12:49:53 +00:00
Naz
9c77abebb5 Removed force start from themes test
refs https://github.com/TryGhost/Toolbox/issues/135

- Looking closer into the reason why the test was failing without "forceStart" revealed that the server only start  was overoptimized - "initServicesForFrontend" should be a part of a backend as those are generic theme services.
2021-11-22 17:47:44 +04:00
Naz
d3f899689a Removed unnecessary rewire call
no issue

- Having rewire here doens't do any difference and should not be used if absolutely needed. Usually using rewire gives a code "smell" so there's some sort of coupling that's going on and probably has to be addressed first
2021-11-22 14:53:16 +04:00
Naz
23ba543abd Removed forceStart in theme e2e tests
refs https://github.com/TryGhost/Toolbox/issues/135

- The reason the test **settings** test was failing when the force start flag was removed in the **custom themes** was the bridge! The bridge was trying to execute function on the frontend when the boot was done without initializing the frontend. The setting test was changing locale and the timezone which triggered events calling up on frontend components - we clearly don't want to do this when the instance is booted without the frontend
- To make event initialization conditional moved it to the "init". This way the event listeners are only set up when we boot with the "frontend" flag set to true
2021-11-22 14:51:23 +04:00
Naz
f0ae7592cf Removed unneeded mocks
refs https://github.com/TryGhost/Toolbox/issues/135

- These mocks were failing to execute but didn't make any difference in the test outcome
2021-11-22 21:56:32 +13:00
Naz
bbc93ff996 Renamed withBackend/withFrotned to backend/frontend
refs https://github.com/TryGhost/Toolbox/issues/135

- Shorter name still makes sense and the "with" might be causing confusion understanding what's gonig on during the boot time
2021-11-22 21:56:32 +13:00
Naz
149c100b4c Fixed frontend initialization in "mock-express" tests
refs https://github.com/TryGhost/Toolbox/issues/135

- Without sensible defaults the web app was not initializing either the backend nor the frontned parts of the application. Fixed the defaults so the problem doesn't happen again and optimized mock-express-style initialization to only initialize the frontend routing
2021-11-22 21:56:32 +13:00
Naz
9057ca0ee2 Skipped unnecessary frontend initialization
refs https://github.com/TryGhost/Toolbox/issues/135

- This optimization is expected to play a role in more consistent "backend-only" boot where the previous test state might have left over a different theme version which might cause in unwanted URL Services reainitializations.
- What has been happening here is the themes.test.js suite was uploading a theme with a v4 api and when the users api test suite loaded up it switched back to a default v2 theme, which caused routing reinitialization
- The root problem here  is the themese suite is leaving a mess behind so a "restartModeGhostStart" is not really possible anymore - this should be cleaned up separately
2021-11-22 21:56:32 +13:00
Naz
34b0196c0f Added writeDisabled flag to URL file cache
refs https://github.com/TryGhost/Toolbox/issues/135

- Allows to turn off overwriting urls/resources JSON file caches on testing environment. This is needed to have predictable state when running multiple test suites that stop the Ghost process and try to persiste URL cache.
2021-11-22 21:56:32 +13:00
Naz
ee4d2dd1a8 Extracted a local file cache class for URLs
refs https://github.com/TryGhost/Toolbox/issues/135

- This extracts the file storage knowledge out of the URL Service an allows to have optional features based on the environment - for example turning off writing cache for when running tests
2021-11-22 21:56:32 +13:00
Naz
155e96b044 Fixed undefined error
refs https://github.com/TryGhost/Toolbox/issues/135

- Not all callers provide the parameter, so an empty object default saves from unecessary "undefined" errors
2021-11-22 21:56:32 +13:00
Naz
640296f74b Changed the test environment to load withFrontend
refs https://github.com/TryGhost/Toolbox/issues/135

- The global default should stay the same as it used to be and we can introduce an override for "withFrontend:false" on casa-by-case or area-by-area bases
2021-11-22 21:56:32 +13:00
Naz
03be383d8b Renamed testUtils.startGhost to localUtils.startGhost
refs https://github.com/TryGhost/Toolbox/issues/135

- Going though local utils allows to have the "withFrontend: false" flag applied only to the e2e-api test suites. This way we can gradually introduce the no-frontend change across all test suites
2021-11-22 21:56:32 +13:00
Naz
9359ae923d Moved startGhost function to local utils
refs https://github.com/TryGhost/Toolbox/issues/135

- Having the proxy in local utils allows to disable frontend gradually in test suites instead of all at once (the latter approach didn't work out as too many other suites still depend on full frontend initialization)
2021-11-22 21:56:32 +13:00
Naz
008b6e0fae Optimized e2e-api tests using boot with no frontend
refs https://github.com/TryGhost/Toolbox/issues/135

- When running e2e-API test in most cases there's no need to boot Ghost instance with full frontend. This should improve the boot time which should reflect on the speed of running test suites
- The tests where the "forceStart" and "withFrontend" are used together indicate that there's still some work to do to fully separate frontend/backend boot line. The force start is also unnecessary, but was needed to reinitialize all services properly - should be investigated!
2021-11-22 21:56:32 +13:00
Naz
3b390639c4 Introduced booting from fixture url cache in test environment
refs https://github.com/TryGhost/Toolbox/issues/135

- To be able to reliably start ghost instance without a frontend the process needs access to urls/resources caches
- Storing the configuration in "paths" for now as there's no better place for it untill we are able to mock the content folder in pre-boot
2021-11-22 21:56:32 +13:00
Naz
5168d6a822 Updated urls/resources cache fixtures
refs https://github.com/TryGhost/Toolbox/issues/135

- These fixture had to be updated due to hardcoded ids introduced in the fixtures.json for test
- This allows to boot up a Ghost instance without recalculating urls for most common database states
2021-11-22 21:56:32 +13:00
Naz
8fd7733fdf Hardcoded id's in test fixtures
refs https://github.com/TryGhost/Toolbox/issues/135

- These fixtures needs id's to be able to form a stable urls and resources cache that would be used across all e2e tests when booting without a frontend
2021-11-22 21:56:32 +13:00
Naz
d7b7bd1b28 Updated Users API e2e tests to use 'posts' fixture
refs https://github.com/TryGhost/Toolbox/issues/135

- This way the test is performed on a "full" set of posts that will become unified within all e2e tests for performance optimization
2021-11-22 21:56:32 +13:00
Hannah Wolfe
592d02fd23 🐛 Fixed perms error when building public assets
closes: https://github.com/TryGhost/Ghost/issues/13739

- Ghost cannot write to the core folder in correctly configured production installations
- Built assets therefore need to be written to the content directory
- Ghost does not overwrite anything in the content folder as part of an upgrade, therefore static files that are provided by Ghost
  must still live inside /core
- So as a result, we now have core/frontend/public and content/public
2021-11-19 11:36:45 +00:00
Hannah Wolfe
79233b1181 Removed unnecessary load of settings
- seems to save about a second locally for me - I'll take it!
2021-11-19 10:47:21 +00:00
Hannah Wolfe
cc9e256b36 Added extra debug to test utilities
- Looking for places we can SAVE TIME running tests
2021-11-19 10:47:21 +00:00
Hannah Wolfe
80358266b2 Added perf-improving PRAGMAs in testing mode
- These two things are meant to improve performance at the cost of reliability.
- Perfect for testing, however I think they make a minimal impact on modern SSDs :(
- Still worth a shot to see if it helps with CI
2021-11-19 10:47:21 +00:00
Sam Lord
0692ddf57d Revert "Replace update user last seen middleware with package version"
This reverts commit 07f8c6efbb.

Revert "Remove unused unit test file"

This reverts commit f1798119d3.
2021-11-17 11:00:55 +00:00
Sam Lord
d4e0ae14f1 Force start in email route tests to pick up stubbed API
refs: https://github.com/TryGhost/Toolbox/issues/130

The API version stays at v2 unless we stub the getFrontendApiVersion method. But stubbing the method doesn't get picked up unless we actually restart Ghost.

TODO: Maybe change the default here so we don't need to restart Ghost just to test the current version's API
2021-11-17 10:51:46 +00:00
Hannah Wolfe
332beaaf90
Moved "vhost-utils" to config helpers
- These are simple functions that get data from config in a specific format
- They are also used by the topmost part of the application
- Config helpers seems like a reasonable fit to get them out of the web folder
- Functions have also been renamed to try to get them to make more sense
2021-11-17 08:37:08 +00:00
Kevin Ansfield
63b7ef7dc6 Added Tenor contentFilter setting to config
refs https://github.com/TryGhost/Team/issues/1217

- moved top-level `tenorApiKey` to `tenor:apiKey` and added `tenor:contentFilter`
- added base config to `defaults.json`
- updated `public-config.js` and API output serializer to use the new top-level `tenor` key
2021-11-16 17:42:26 +00:00
Sam Lord
620c12b05f Amend previous commit to prevent console.log
no issue

Large amount of unstaged changes prevented me from catching this
2021-11-16 17:12:39 +00:00
Sam Lord
a5484a0fe1 Fixed transaction logic in data importer
https://github.com/TryGhost/Toolbox/issues/130

The transaction no longer commits in the promise chain, which wasn't
valid logic for a transaction, since it is commited automatically when
the promise chain resolves, and rollsback automatically when the
promise chain rejects.

This makes code which fails during the transaction error in the right
place, instead of getting stuck here. (Especially good for writing
tests).

The tests for this code can now live in the integration folder.
2021-11-16 17:09:55 +00:00
Sam Lord
f1798119d3 Remove unused unit test file
no issue

Relates to previous commit
2021-11-16 16:05:50 +00:00
Hannah Wolfe
4f9b72ff43
Renamed middlewares to middleware consistently
- This is a minor bugbare, but it will affect some configuration I'm about to do for c8
- I've been wanting to do it for ages, middleware is plural all on it's own so it's an odd affectation in our codebase
- This also only exists in 2 places, everywhere else we use "middleware"
- Sadly it did result in a lot of churn as I did a full find and replace, but consistency is king!
2021-11-16 15:51:47 +00:00
Naz
8281388290 Hardcoded ids in the data generator
refs https://github.com/TryGhost/Toolbox/issues/116

- Allows to have deterministic routing on each start of the instance - can use cache when starting tests
- To make use of the new fixtures need to place them in the content/data
folder when the test suite is initialized, then the cache detection will
kick in and boot up the UrlService in a constant time intead of having
to check "urlServiceUtils.isFinished"
2021-11-17 04:29:55 +13:00
Hannah Wolfe
b781e47cb9
Changed to use different fixtures during testing
- this keeps production and test fixtures separate, so that changing the prod fixtures doesn't change the shape of our tests.
- we may still want to test that the production fixtures do what we expect, but that can be handled in a separate integration test, by specifically setting the fixture path
2021-11-16 14:03:42 +00:00
Hannah Wolfe
426c8bf918
Refactored fixtures to be loaded by fixture manager
refs: https://github.com/TryGhost/Toolbox/issues/133

- instead of just a collection of utils, we now have a class that manages fixtures
- this should allow us to change the path to fixtures, e.g. between prod/dev and test, so that different fixtures can be loaded by default
- also makes it easier to test the fixture manager code itself
2021-11-16 11:17:03 +00:00
Naz
0681953e1f Fixed test mocks for Url Service test suite
refs 042618fe93

- There's no longer "getValue" method passed around in UrlService, so the were unnecessary and did a wrong thing here :) Yey, less code!
2021-11-15 20:11:05 +04:00
Naz
382d2dbe94 Added missing router identified parameter in tests
refs 042618fe93

- The newly introduced identified were expected in the UrlService's intergration tests to fit new method signature
2021-11-15 19:56:28 +04:00
Naz
5a62253466 Removed "router" dependency from UrlGenerator
refs https://github.com/TryGhost/Toolbox/issues/127

- Passing around whole instance of a frontend router was an overkill when there are only 3 static pieces of information that needed to be loaded. Extracting the router out makes the UrlGenerator way more readable, tests slimer, and the memory footpring of the process should be slightly lighter
- The toString overloading didn't make sense at the time of this refactor, maybe if there's a concrete usecase we could resurect it in a form of passing in a router's name or something.
2021-11-15 18:32:34 +04:00
Naz
6e205a3f05 Extracted an explicit "permalink" parameter in UrlGenerator constructor
refs https://github.com/TryGhost/Toolbox/issues/127

- This is an effor t to define a precise set of data needed for the UrlGenerator to function, which should help with decoupling it from the frontend routes
- This is almost the last piece to free us up from the massive "router" object that has been passed around
2021-11-15 18:32:34 +04:00
Naz
677ea1073d Extracted an explicit "resourceType" parameter in UrlGenerator constructor
refs https://github.com/TryGhost/Toolbox/issues/127

- This is an effor t to define a precise set of data needed for the UrlGenerator to function, which should help with decoupling it from the frontend routes
2021-11-15 18:32:34 +04:00
Naz
ca2809d432 Extracted an explicit "filter" parameter in UrlGenerator constructor
refs https://github.com/TryGhost/Toolbox/issues/127

- This is an effor t to define a precise set of data needed for the UrlGenerator to function, which should help with decoupling it from the frontend routes
2021-11-15 18:32:34 +04:00
Naz
176c369620 Refactored UrlGenerator to use DI constructor pattern
refs https://github.com/TryGhost/Toolbox/issues/127

- This is a standard across the codebase which is good to follow for better testability
2021-11-15 18:32:34 +04:00
Kevin Ansfield
6431e1a01c
Exposed tenorApiKey via config endpoint if set (#13734)
refs https://github.com/TryGhost/Team/issues/1217

- add `tenorApiKey` to `publicConfig.config()
- update canary config endpoint output serializer to include `tenorApiKey` when the `gifsCard` labs flag is enabled
2021-11-11 18:07:19 +00:00
Fabien O'Carroll
e69d112c77 Added support for custom OEmbed providers
refs https://github.com/TryGhost/Team/issues/1211

In order to override the default OEmbeds for OpenSea NFT's we need a way
to provide out own OEmbed data. We will want this in future too for
custom Twitter embeds, so this has been built in a way which allows
extension.
2021-11-11 17:16:03 +02:00
Fabien 'egg' O'Carroll
7fae5b8341
🐛 Fixed setting Tier prices after changing Stripe accounts
refs https://github.com/TryGhost/Team/issues/1212

This now emits the event when the service is reconfigured, rather than
when we issue the reconfigure command, which causes the event and the
action to be run in the wrong order. This would then cause knock on effects
of having the database in an undefined state - with stripe data in not linked
to the current Stripe account.
2021-11-10 14:03:03 +02:00
Naz
98de2d4274 Cleaned up uncecessary "purpose" fields from tests
refs https://github.com/TryGhost/Toolbox/issues/95

- The purpose field is not used in any way on the backend, so there's no need to have it in tests for Media API either
2021-11-09 16:41:38 +04:00
Naz
9edd299905 Added audio upload support to Media API
refs https://github.com/TryGhost/Toolbox/issues/95
refs 4907b7bf1e

- We need support for audio media uploads to be able to used them in cards. The new supported formats are .mp4 and .wav
- Example source files downloaded from https://filesamples.com/
2021-11-09 16:39:33 +04:00
Naz
4721b75463 Moved `/media/thumbnail/ Admin API endpoint to /media/thumbnail/upload
refs  https://github.com/TryGhost/Toolbox/issues/120

- Changed endpoint name as it suits way better to the `/upload` postfix convention we use along with all other endpoints that support file uploads
2021-11-09 16:39:33 +04:00
Naz
61b82e3ae2 Added thumbnail upload endpoint to Media API
closes https://github.com/TryGhost/Toolbox/issues/120

- Allows to update and upload brand new thumbnail images for previusly uploaded media resources
- The endpoint is available udner alpa flag as part of Admin API at `PUT /media/thumbnail/`
- As an input accepts following parameters:
- *required* `file` field containing an image file
- *required* `url` field containing parent media file URL
- *optional* `ref` as a field to put in an ID to reference the resource on the client side

- The response has following format:
```
{
  media: [{
    url: 'http://127.0.0.1:2369/content/images/1991/11/nicevideo_thumb.png'
    ref: 'unique-id-420'
  }]
}
```
2021-11-09 16:07:23 +04:00
Naz
2a7ef77a7b Added ability to delete existing files through storage adapters
refs https://github.com/TryGhost/Toolbox/issues/120

- When editing an uploaded media thumbnail  file there'a need to remove existing thumbnail to keep media files:thumbnails 1:1. - Because the API client only has a public URL under which the resource is served it can only provide that as an API input, the `urlToPath` was also added to the base class of LocalStorageAdapter (it might be moved up to the BaseAdapter in the future if we see a need)
2021-11-09 16:07:23 +04:00
Naz
fb8005f6e2 Refactored media tests
refs https://github.com/TryGhost/Toolbox/issues/120

- Introduced a new describe block before adding tests for a new endpoint
2021-11-09 16:07:23 +04:00
Naz
a099073fde Added Files API behind an alpha flag
refs https://github.com/TryGhost/Toolbox/issues/114

- Files API is meant to be used for non-executable file uploads of all sorts
- The files are stored and retrieved for download as-is
2021-11-08 11:40:17 +04:00
Naz
f43eeacfd0 Changed thumbnail to be an optional parameter
refs https://github.com/TryGhost/Toolbox/issues/95

- With incoming support of audio media files thumbnail would not be a required parameter
2021-11-05 17:17:18 +04:00
Naz
65d79f4a74 Fixed failing test
no issue

- Not sure what the purpose of this test is. Seems like it's kind of like an db integrity check where it makes sure the change is double checked before commiting
2021-11-05 17:17:18 +04:00
Naz
ad2583530a Renamed getLocalFileStoragePath
refs https://github.com/TryGhost/Toolbox/issues/95

- getLocalImagesStoragePath makes a lot more sense in context of what the method really does
2021-11-05 17:17:18 +04:00
Naz
c802097b72 Renamed LocalFileStorage to LocalImages store
refs https://github.com/TryGhost/Toolbox/issues/95

- This naming corresponds way better to what the actual adapter does
2021-11-05 17:17:18 +04:00
Hannah Wolfe
e25f1df0ae
Added card-asset config with sensible default
- This comment removes the block on themes controlling card assets via config
- It also changes the default behaviour from "false" config (doing nothing) to excluding bookmark and gallery card assets
- This is essentially the same thing, as only bookmark and gallery card assets exist at the moment, but it's being done because it makes this feature future-proof for all theme developers.
- As we add new cards, all themes will automatically get the assets to make them work
- As theme developers want to, they can create their own custom assets and disble assets for any cards they support by adding them to the exclude list
- They can also remove any custom code they currently have to support bookmark and gallery cards, and set card_assets: true in package.json to use the defaults instead
2021-11-05 12:20:02 +00:00
Hannah Wolfe
d9bdc444a3
Ensured nonexistant public files fallback to 404
- If we register the serve public file middleware for a file that doesn't exist, this will currently throw an ENOENT error
- Instead, we want to fall back to a standard 404 so that this behaves normally
- This will be useful for the card asset service, where the cards.min.css and cards.min.js files may or may not exist
2021-11-05 09:13:23 +00:00
Naz
142eff22ee Fixed thumbnail file name
refs https://github.com/TryGhost/Toolbox/issues/95

- The uploaded media thumbnail name should have a "_thumb" postfix to be able to distinguish thumbnails from other files. This can be handy if we decide to store them in a different location in the future.
2021-11-04 19:03:45 +04:00
Rishabh Garg
3b90b1f335
Moved launchComplete user setting as global editor setting (#13703)
refs https://github.com/TryGhost/Team/issues/807

The launch wizard completed flag was previously stored at per user level in accessibility column of user table, so an administrator still got the option to complete the launch wizard even if the owner had completed it previously, which is not expected pattern. This change moves the launch complete flag for Admin to common settings from per user level so a site only needs to complete the launch wizard once irrespective of which user completes it

- adds new `editor_is_launch_complete` setting to track if a site launch steps are completed in Admin
- adds new migration util to easily allow adding new setting 
- adds migration to introduce new `editor_is_launch_complete` setting
- adds migration to update launch complete flag for a site if any of the users have already completed the launch steps
2021-11-04 18:03:51 +05:30
Hannah Wolfe
fdf38ba8c6
Initial card asset service implementation
- Requires the new @tryghost/minifier package
- Adds a new service that will handle taking config from the theme and optionally including assets for Koenig editor cards
- It supports both css and js as cards may need one or both
- For any given config, the tool can find the matching files to include and concat and minify them into one file per type
- Currently has an override in place so that this is not yet customisable in the theme - will remove this override when we're ready for the feature
2021-11-04 11:34:40 +00:00
Naz
df5c87fae3 🐛 Fixed a 500 error when uploading invalid routes.yaml
closes https://github.com/TryGhost/Toolbox/issues/111

- Just like with invalid JSON redirects files we should return a BadRequestError instead of throwing a generic 500 when the redirects.yaml file fails parsing
2021-11-04 11:52:52 +04:00
Naz
091240db48 Added thumbnail upload support to Media API
refs https://github.com/TryGhost/Toolbox/issues/95

- Each media file quires a thumbnail and these changes provide a capability to upload them along with media files.
- The thumbnail file is always required and has to be the format of already supported image formats
- The thumbnail should be uploaded as a part of "thumbnail" attachment in the request
- The regression tests added with this changeset will be claened up and moved to unit-tests (this is a dirty-but-working version!)
- The thumbnail always gets a name of the uploaded media file and keeps it's own extension.
- The thumbnails is accessible under the url present in the "thumbnail_url" reponse field
2021-11-04 10:23:29 +04:00
Thibaut Patel
c32cc3e48b 🐛 Fixed broken assets for theme/design preview
refs https://github.com/TryGhost/Team/issues/1190

- The assets were broken in Admin when the frontend and admin urls were different
- Fixed the issue by changing the `asset` helper to output absolute URLs when the frontend/admin urls are differents
2021-11-03 11:20:04 +01:00
Naz
0ccf31cdb5 Fixed error message when booting with no redirects
refs 91efa4605c

- When the instance is booted without any redirects files configured it's not supposed to error but rather default to an "empty" [] redirects configuration.
- Ideally the logic shoudl not contain try/catch block at all and fail as soon as there's any error during the initialization. This wasn't changed at this time due to possible break of existing Ghost instances
2021-11-03 13:50:24 +04:00
Naz
c080f4b77d Fixed redirects integration tests
refs refs https://linear.app/tryghost/issue/CORE-84/have-a-look-at-the-eggs-redirects-refactor-branch

- The tests needed to have a clean state with empty redirects file, which was previously ensured through "configUtils". Because configUtils don't play ball with the class initialization pattern this approach was chosen
- It's an end-to-end test with lots of logic and pobably would be enough to run against single API endpoint. Leaving it as is and to be improved in the future
2021-11-03 07:41:55 +13:00
Naz
a9952b2437 Rewrote validation regression tests to be unit tests
refs refs https://linear.app/tryghost/issue/CORE-84/have-a-look-at-the-eggs-redirects-refactor-branch

- These regression tests are slow and should have been unit tests to start with
2021-11-03 07:41:55 +13:00
Naz
d101ef5293 Rewrote validation regression tests to be unit tests
refs refs https://linear.app/tryghost/issue/CORE-84/have-a-look-at-the-eggs-redirects-refactor-branch

- These regression tests are slow and should have been unit tests to start with
2021-11-03 07:41:55 +13:00
Naz
f4e725a7ef Removed redirects regression tests in favor of unit test
refs https://linear.app/tryghost/issue/CORE-84/have-a-look-at-the-eggs-redirects-refactor-branch

- Removed "download" regression tests as those cases were ported over to much faster unit tests
2021-11-03 07:41:55 +13:00
Naz
1c4dea00b9 Removed redirects regression tests in favor of unit test
refs https://linear.app/tryghost/issue/CORE-84/have-a-look-at-the-eggs-redirects-refactor-branch

- The regression test should not be testing edge cases like this and it's far more flexible and performant to test the service on the unit test level
2021-11-03 07:41:55 +13:00
Naz
c3edd4b3d4 Fixed redirects regression tests
refs https://linear.app/tryghost/issue/CORE-84/have-a-look-at-the-eggs-redirects-refactor-branch

- The problem this change is addressing is inability to override config values once the code is extracted into a class+DI pattern
- The work around is restarting the instance with the configuration testing expected behavior - in this case missing or existing types of redirects files
2021-11-03 07:41:55 +13:00
Fabien O'Carroll
91efa4605c Used DynamicRedirectManager for Custom Redirects
refs https://github.com/TryGhost/Members/commit/9e59f5a9

Since we have a DynamicRedirectManager for handling adding/removing
redirects at runtime, we no longer need the custom-redirects middleware.
The redirects service does however need an init method now to add the
custom redirects at Ghost boot, so it's been refactored into our Class &
DI pattern.
2021-11-03 07:41:55 +13:00
Naz
7eb7e00634 Added test coverage for not supported media type
refs https://github.com/TryGhost/Toolbox/issues/95

- Only supported media types should be accepted by `/media/` enpoint
2021-11-03 00:33:28 +13:00
Naz
4a551661d9 Implemented '/media/upload' API endpoint
refs https://linear.app/tryghost/issue/CORE-121/create-a-video-storage-adapter

- This is an experimental implementation of video file upload support
- Also the output serializer skipped use of url utils in favor of inline implementatoin - this should almost certainly be it's own package
2021-11-03 00:33:28 +13:00
Naz
4907b7bf1e Added media fixtures for video files
refs https://linear.app/tryghost/issue/CORE-121/create-a-video-storage-adapter

- Example source files downloaded from https://filesamples.com/
- These fixtures will be used in media endpoint tests
- They had to go in a separate commit as git doesn't like to batch up big files
2021-11-03 00:33:28 +13:00
Naz
5242566252 Added local media storage adapter
refs https://linear.app/tryghost/issue/CORE-121/create-a-video-storage-adapter

- This is an experimental implementation of video file upload support (audio is yet to follow)
- The storage adapter still needs more thinking as it's almost the same as the "LocalStorgeAdapter" that stores images.
- Also the output serializer skipped use of url utils in favor of inline implementatoin - this should almost certainly be it's own package
2021-11-03 00:33:28 +13:00