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/helpers
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
..
component-test.js DEV: Avoid using globals (#14909) 2021-11-13 13:10:13 +01:00
create-pretender.js DEV: Update fixture to fix tests (#15699) 2022-01-25 00:44:14 +03:00
create-store.js DEV: Refactor Site creation in tests (#15707) 2022-02-03 10:02:47 +00:00
d-editor-helper.js REFACTOR: Move javascript tests inside discourse app 2020-10-02 11:29:36 -04:00
fixture-pretender.js Support for Testem in Ember CLI (#12442) 2021-03-19 09:32:46 -04:00
presence-pretender.js DEV: prevents Firefox ESR tests to crash on ||= (#14758) 2021-10-28 10:55:22 +02:00
qunit-helpers.js DEV: Refactor Site creation in tests (#15707) 2022-02-03 10:02:47 +00:00
review-pretender.js FEATURE: reason to reject user signup (#11700) 2021-01-15 09:43:26 +11:00
select-kit-helper.js DEV: Remove jQuery global usage where possible (#14905) 2021-11-12 19:23:20 +01:00
site-settings.js FEATURE: Make allow_uploaded_avatars accept TL (#14091) 2021-08-24 10:46:28 +03:00
site.js DEV: Remove hints of jshint (#14828) 2021-11-08 09:12:37 +08:00
store-pretender.js REFACTOR: Move javascript tests inside discourse app 2020-10-02 11:29:36 -04:00
textarea-selection-helper.js REFACTOR: Move javascript tests inside discourse app 2020-10-02 11:29:36 -04:00
widget-test.js FIX: Lots of plugin tests were using old, non-Ember compat CLI APIs (#13320) 2021-06-09 10:58:55 -04:00