This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests
David Taylor 84c2c2f477
DEV: Refactor Site creation in tests (#15707)
Previously, `resetSite()` would immediately generate a new `Site` instance, and run all the initialization logic within the model. This included initializing Category objects.

This was problematic because `resetSite()` is called before any initializers have been run. That means that any modifications to the Site or Category classes would not have any effect on the already-initialized Site/Category instances.

This commit makes two main changes so so that the test environment is more production-like:

1. Update `resetSite` so that it simply stores the new data in the PreloadStore, and destroys the old Site instance. Initialization of a new site instance happens 'just in time' (normally during the `inject-discourse-objects` initializer)

2. Update the `helperContext` in tests to use getters. This avoids the need to look up `Site.current()` before initializers have run

It also makes a minor adjustment to one test which was relying on a side-effect of the previous behavior.

This should resolve the failing tests for discourse-category-expert under Ember-CLI: https://github.com/discourse/discourse-category-experts/pull/69
2022-02-03 10:02:47 +00:00
..
acceptance DEV: Refactor Site creation in tests (#15707) 2022-02-03 10:02:47 +00:00
fixtures FEATURE: Validate domain settings for blocked_onebox_domain only (#15754) 2022-02-03 11:26:53 +08:00
helpers DEV: Refactor Site creation in tests (#15707) 2022-02-03 10:02:47 +00:00
integration FEATURE: Validate domain settings for blocked_onebox_domain only (#15754) 2022-02-03 11:26:53 +08:00
unit DEV: Revisit skipped tests (#15769) 2022-02-02 12:09:03 -05:00
active-plugins.js.erb DEV: Support for running theme test with Ember CLI (third attempt) 2022-01-13 16:02:07 -05:00
core-tests.js DEV: Support for running theme test with Ember CLI (third attempt) 2022-01-13 16:02:07 -05:00
index.html DEV: Update plugin JS loading in Ember CLI testem environment 2022-01-18 10:16:29 +00:00
plugin-tests.js.erb DEV: Support for running theme test with Ember CLI (third attempt) 2022-01-13 16:02:07 -05:00
setup-tests.js DEV: Refactor Site creation in tests (#15707) 2022-02-03 10:02:47 +00:00
test_starter.js DEV: Bump eslint-config-discourse (#14868) 2021-11-10 09:31:41 +10:00
test-boot-ember-cli.js Revert "Revert "DEV: Run Ember CLI tests in random order" (#15717)" 2022-01-27 12:22:20 -05:00
test-helpers-rails.js DEV: Support for running theme test with Ember CLI (third attempt) 2022-01-13 16:02:07 -05:00
test-support-rails.js DEV: Support for running theme test with Ember CLI (third attempt) 2022-01-13 16:02:07 -05:00
theme_qunit_ember_jquery.js FIX: Theme tests should work in production (#13333) 2021-06-08 22:03:59 +03:00