-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Technical requirements for behavioural unit tests #5084
Conversation
fbb7fe2
to
d99771b
Compare
"@ogre-tools/injectable-react": "5.1.2", | ||
"@ogre-tools/injectable": "5.2.0", | ||
"@ogre-tools/injectable-react": "5.2.0", | ||
"@ogre-tools/fp": "5.2.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to raise notice against using this. I find that even with types pipeline
is very hard to read. I would like to motion that chaining is better ergonomically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opinion noted! :)
Given a bit of time and familiarity, the pattern of pipeline
will once again present itself as very easy to read, instead of anything else. This will become more apparent in more complex algorithms.
As with most design patterns, truly realized ergonomy comes from repetition ;)
Noteworthy: pipeline
has multiple advantages over the proposed Collection chaining -pattern:
- Better support for functional composition, and other functional patterns, such as
flow
or ternary functions. - Better refactorability, especially for nested or recursed scenarios.
- Power to control flow and aspect: eg. if required,
pipeline
can abstract promises and even generators. - Full control of vocabulary (and not just
map
,reduce
,filter
, etc.) leads to more expressive code. - It can be used for other than collections (yet, so can eg.
lodash.chain
, but then again this). - Etc.
We used Collection chaining for years before growing out of it. As with everything, we do not use something like pipeline
to flex, but instead for the necessity of the Greater good ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the pipeline syntax is good, but I'm a bit wary of adding this particular dependency, which appears to be quite a thin wrapper over lodash. This dependency has really small usage. Perhaps there's another alternative that is more commonly used in the ecosystem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@panuhorsmalahti hmm, interesting point. Here's some thoughts:
-
We control this library ourselves, and for that, it is flexible and without magic.
-
We created the library only recently, and therefore there is yet little adoption in the ecosystem.
-
We could have implemented this function in Lens as well, but it is pretty general to be local. Eg., also
injectable
uses it. -
To look for an alternative full foreign library for this "thin wrapper" is a bit of an overkill, as the proposed pattern is universal, and does not require certain library to work properly with. Instead, any function with arity of one can participate in composition. Therefore a full alternate library would add extra weight with all the other bells and whistles. I mean, we already have
lodash
.
27100d9
to
0e7fe20
Compare
075a647
to
799e43b
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
799e43b
to
0835fa6
Compare
Conflicts have been resolved. A maintainer will review the pull request shortly. |
src/extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api.ts
Show resolved
Hide resolved
9352219
to
3c86646
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still going...
...talog-entities/general-catalog-entities/implementations/catalog-catalog-entity.injectable.ts
Show resolved
Hide resolved
src/common/front-end-routing/routes/cluster/overview/cluster-overview-route.injectable.ts
Show resolved
Hide resolved
import { getInjectable } from "@ogre-tools/injectable"; | ||
import navigateToAppPreferencesInjectable from "./app/navigate-to-app-preferences.injectable"; | ||
|
||
const navigateToPreferencesInjectable = getInjectable({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this? Can't navigateToAppPreferencesInjectable
be used directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to navigate to first page of preferences you should use navigateToPreferences
. If you want to navigate to specific tab in preferences, you should use e.g. navigateToAppPreferences
.
Motivation is to allow change of mind in future without need for multiple modifications.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean so one day navigateToAppPreferences
may take optional param(s) to select the tab?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. navigateToAppPreferences
doesn't need any parameters. However we might change our mind that navigateToPreferences
doesn't go to app preferences. One day it might go to editor preferences and for that change we would need to change lot of file instead of one.
Implementation for navigateToPreferences
could even be "go to first tab in preferences" and it shouldn't need to know which tab is first. In that case navigateToPreferences
doesn't have to change at all if someday we change order of tabs in preferences.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do more reviewing today.
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
…icit side effect Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
…e effect Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
Co-authored-by: Janne Savolainen <janne.savolainen@live.fi> Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
…ution Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
0c72746
to
7915e04
Compare
Conflicts have been resolved. A maintainer will review the pull request shortly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My qualms about some specific design aspects should be all non-breaking to fix later.
Implement a lot of technical requirements for behavioural unit tests
With this:
Note: the crux of this was to make routing env-agnostic, and not based on URLs as magic strings, but instead something type-enforced.
Note: extension-based routes comply to same exact interface by "late-registering" their routes when installed. Routes are injectables which implement a shared injection token.
Note: another chunk of global shared state is no more.
Note: a lot of stuff has become reactive as part if this.
Note: a lot of explicit side effects have been cornered to injectables with
causesSideEffects: true
.Note: old unit tests which want to test what is
causesSideEffects: true
can now do so withdi.permitSideEffects(someInjectable);
.