Ghost/ghost/admin
Chris Raible fbeecd58e6
Fixed issue with calling Posthog functions before it is loaded (#19721)
refs PA-36

- Since Posthog is loaded outside of the main Admin app bundle, we need
to check to make sure it exists before calling it. This way it will only
run on Pro and not locally or on self-hosted instances
- Previously we were checking that `window.posthog` existed, but there
are some cases where `window.posthog` may exist, but the `posthog`
object is not fully loaded yet.
- This change fixes this by checking for `window.posthog.__loaded`
instead, which is set to `true` once the `posthog` object is fully
loaded — at this point, we should be able to call whatever functions we
need to on `window.posthog`
2024-02-20 13:57:42 -08:00
..
app Fixed issue with calling Posthog functions before it is loaded (#19721) 2024-02-20 13:57:42 -08:00
config
lib
mirage Added portal default plan setting (#19238) 2023-12-06 11:39:58 +01:00
public/assets Flipped thumbs-down icon horizontally in email and Portal (#19306) 2023-12-11 13:05:11 +00:00
tests 🎨 Admin X - Offers (#19520) 2024-01-25 12:41:54 +00:00
.editorconfig
.ember-cli
.eslintignore
.eslintrc.js
.lint-todo 🎨 Admin X - Offers (#19520) 2024-01-25 12:41:54 +00:00
.lint-todorc.js
.template-lintrc.js
.watchmanconfig
ember-cli-build.js Enabled persistent filesystem caching for Ember builds 2023-12-13 16:40:18 +01:00
ember-cli-update.json
jsconfig.json
package.json Merged v5.79.4 into main 2024-02-19 11:26:02 +00:00
README.md
testem.js

Ghost-Admin

This is the home of the Ember.js-based Admin app that ships with Ghost.

Running tests

Build and run tests once:

TZ=UTC yarn test

Note the TZ=UTC environment variable which is currently required to get tests working if your system timezone doesn't match UTC.

If you are serving the admin app (e.g., when running yarn serve, or when running yarn dev in the main Ghost project), you can also run the tests in your browser by going to http://localhost:4200/tests.

This has the additional benefit that you can use await this.pauseTest() in your tests to temporarily pause tests (best to also add this.timeout(0); to avoid timeouts). This allows you to inspect the DOM in your browser to debug tests. You can resume tests by running resumeTest() in your browser console.

More information

Writing tests

When writing tests and not using the http://localhost:4200/tests browser tests, it can be easier to have a separate watching build that builds the project for the test environment (this drastically reduces the time you have to wait when running tests):

yarn build --environment=test -w -o="dist-test"

After that, you can easily run tests locally:

Run all tests:

TZ=UTC yarn test 1 --path="dist-test"

To have a cleaner output:

TZ=UTC yarn test 1 --reporter dot  --path="dist-test"

This shows a dot (.) for every successful test, and F for every failed test. At the end, it will only show the output of the failed tests.

To run a specific test file:

TZ=UTC yarn test 1 --reporter dot  --path="dist-test" -mp=tests/acceptance/settings/newsletters-test.js

Hint: you can easily copy the path of a test in VSCode by right clicking on the test file and choosing Copy Relative Path.

To have a full list of the available options, run

ember exam --help

Copyright & License

Copyright (c) 2013-2023 Ghost Foundation - Released under the MIT license. Ghost and the Ghost Logo are trademarks of Ghost Foundation Ltd. Please see our trademark policy for info on acceptable usage.