element-web/test
kegsay e946674df3
Store refactor: use non-global stores in components (#9293)
* Add Stores and StoresContext and use it in MatrixChat and RoomView

Added a new kind of class:
- Add God object `Stores` which will hold refs to all known stores and the `MatrixClient`. This object is NOT a singleton.
- Add `StoresContext` to hold onto a ref of `Stores` for use inside components.

`StoresContext` is created via:
- Create `Stores` in `MatrixChat`, assigning the `MatrixClient` when we have one set. Currently sets the RVS to `RoomViewStore.instance`.
- Wrap `MatrixChat`s `render()` function in a `StoresContext.Provider` so it can be used anywhere.

`StoresContext` is currently only used in `RoomView` via the following changes:
- Remove the HOC, which redundantly set `mxClient` as a prop. We don't need this as `RoomView` was using the client from `this.context`.
- Change the type of context accepted from `MatrixClientContext` to `StoresContext`.
- Modify alllll the places where `this.context` is used to interact with the client and suffix `.client`.
- Modify places where we use `RoomViewStore.instance` and replace them with `this.context.roomViewStore`.

This makes `RoomView` use a non-global instance of RVS.

* Linting

* SDKContext and make client an optional constructor arg

* Move SDKContext to /src/contexts

* Inject all RVS deps

* Linting

* Remove reset calls; deep copy the INITIAL_STATE to avoid test pollution

* DI singletons used in RoomView; DI them in RoomView-test too

* Initial RoomViewStore.instance after all files are imported to avoid cyclical deps

* Lazily init stores to allow for circular dependencies

Rather than stores accepting a list of other stores in their constructors,
which doesn't work when A needs B and B needs A, make new-style stores simply
accept Stores. When a store needs another store, they access it via `Stores`
which then lazily constructs that store if it needs it. This breaks the
circular dependency at constructor time, without needing to introduce
wiring diagrams or any complex DI framework.

* Delete RoomViewStore.instance

Replaced with Stores.instance.roomViewStore

* Linting

* Move OverridableStores to test/TestStores

* Rejig how eager stores get made; don't automatically do it else tests break

* Linting

* Linting and review comments

* Fix new code to use Stores.instance

* s/Stores/SdkContextClass/g

* Update docs

* Remove unused imports

* Update src/stores/RoomViewStore.tsx

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>

* Remove empty c'tor to make sonar happy

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
2022-10-19 13:07:03 +01:00
..
__snapshots__ Location (live) share replies now provide a fallback content (#8949) 2022-07-01 08:01:22 +02:00
accessibility Convert some Enzyme tests to RTL (#9163) 2022-08-11 00:00:53 +00:00
actions/handlers Device manager - promote to beta (#9380) 2022-10-11 11:10:55 +02:00
audio Move from browser-request to fetch (#9345) 2022-10-12 18:59:07 +01:00
autocomplete Use "frequently used emojis" for autocompletion in composer (#8998) 2022-07-21 15:27:11 +02:00
components Store refactor: use non-global stores in components (#9293) 2022-10-19 13:07:03 +01:00
editor Fix soft crash around unknown room pills (#9301) 2022-09-20 17:00:31 +00:00
events Voice Broadcast live state / extract RelationsHelper (#9432) 2022-10-17 13:31:03 +01:00
hooks Add a larger buffer to useLatestResult's test (#9178) 2022-08-25 14:49:39 -06:00
i18n Fix languages.json 2017-06-01 21:10:32 +02:00
i18n-test Migrate KeyboardShortcut tests from Enzyme to RTL (#9405) 2022-10-13 14:32:45 +01:00
images Add support for Animated (A)PNG (#8158) 2022-03-28 09:38:54 +01:00
img Fix a load of warnings in the tests 2016-10-11 14:20:40 +01:00
models Disconnect other connected devices (of the same user) when joining an Element call (#9379) 2022-10-14 15:17:49 +02:00
modules Update matrix-org/react (enzyme deprecation) (#9116) 2022-08-02 15:10:43 +02:00
notifications Typescriptification - notification utils (#8209) 2022-04-01 08:45:50 +02:00
settings Fix crash when drawing blurHash for portrait videos PSB-139 (#8855) 2022-06-17 11:03:29 +00:00
setup Move from browser-request to fetch (#9345) 2022-10-12 18:59:07 +01:00
stores Store refactor: use non-global stores in components (#9293) 2022-10-19 13:07:03 +01:00
test-utils Include a file-safe room name and ISO date in chat exports (#9440) 2022-10-17 19:54:10 -06:00
toasts Device manager - silence call ringers when local notifications are silenced (#9420) 2022-10-17 09:16:04 +00:00
utils Include a file-safe room name and ISO date in chat exports (#9440) 2022-10-17 19:54:10 -06:00
voice-broadcast Add confirm end voice broadcast dialog (#9442) 2022-10-18 09:12:28 +02:00
Avatar-test.ts Wire local room logic (#9078) 2022-07-20 09:26:25 +02:00
ContentMessages-test.ts Move from browser-request to fetch (#9345) 2022-10-12 18:59:07 +01:00
createRoom-test.ts Move from browser-request to fetch (#9345) 2022-10-12 18:59:07 +01:00
DecryptionFailureTracker-test.js Fix all megolm error reported as unknown (#8916) 2022-06-30 08:55:05 +01:00
DeviceListener-test.ts Device manager - remove client information events when disabling setting (#9384) 2022-10-10 19:00:46 +00:00
globalSetup.js Eslint - require copyright header rule (#8514) 2022-05-06 09:09:28 +00:00
HtmlUtils-test.tsx Update matrix-org/react (enzyme deprecation) (#9116) 2022-08-02 15:10:43 +02:00
Image-test.ts Step 8.1: Remove skinning setup from all tests 2022-03-28 14:02:31 -06:00
KeyBindingsManager-test.ts Work towards unifying KeyboardShortcuts and KeyBindingsDefaults #2 (#7674) 2022-01-31 15:55:45 +00:00
languageHandler-test.ts Add support for overriding strings in the app (#7886) 2022-03-01 11:53:09 -07:00
LegacyCallHandler-test.ts Device manager - silence call ringers when local notifications are silenced (#9420) 2022-10-17 09:16:04 +00:00
linkify-matrix-test.ts Delete groups (legacy communities system) (#8027) 2022-03-22 23:07:37 +00:00
Markdown-test.ts Fix formatting not being applied after links (#7990) 2022-03-08 13:12:36 +00:00
MatrixClientPeg-test.ts Use doMaybeLocalRoomAction (#9038) 2022-07-13 07:56:36 +02:00
Notifier-test.ts Device manager - test coverage for Notifier (#9392) 2022-10-13 09:07:48 +02:00
PosthogAnalytics-test.ts Replace deprecated String#substr with String#slice (#8314) 2022-04-14 07:52:42 +00:00
PreferredRoomVersions-test.ts Replace MSC3244 support with in-client room version checking (#9018) 2022-07-08 00:32:38 -06:00
Reply-test.ts Location (live) share replies now provide a fallback content (#8949) 2022-07-01 08:01:22 +02:00
RoomNotifs-test.ts Fix js-sdk types (#8588) 2022-05-13 19:13:21 +00:00
ScalarAuthClient-test.ts Move from browser-request to fetch (#9345) 2022-10-12 18:59:07 +01:00
SdkConfig-test.ts Implement Voice Broadcast recording (#9307) 2022-10-11 22:31:28 +00:00
setupTests.js Move from browser-request to fetch (#9345) 2022-10-12 18:59:07 +01:00
SlashCommands-test.tsx Store refactor: use non-global stores in components (#9293) 2022-10-19 13:07:03 +01:00
Terms-test.tsx Test typescriptification - Terms/ScalarAuthClient (#8480) 2022-05-03 15:09:07 +00:00
TestStores.ts Store refactor: use non-global stores in components (#9293) 2022-10-19 13:07:03 +01:00
TextForEvent-test.ts Add notifications and toasts for Element Call calls (#9337) 2022-10-06 14:27:12 +00:00
theme-test.ts Test querySelectorAll call 2022-09-28 15:25:32 +02:00
Unread-test.ts Remove deprecated m.room.aliases references (#9431) 2022-10-17 10:58:46 +01:00
UserActivity-test.ts Typescriptification - notification utils (#8209) 2022-04-01 08:45:50 +02:00
useTopic-test.tsx Update matrix-org/react (enzyme deprecation) (#9116) 2022-08-02 15:10:43 +02:00