-
Notifications
You must be signed in to change notification settings - Fork 39
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
fix: test and visual testing update for otter training #2638
Conversation
View your CI Pipeline Execution ↗ for commit bfa43cb.
☁️ Nx Cloud last updated this comment at |
@@ -195,7 +195,9 @@ export class CodeEditorViewComponent implements OnDestroy { | |||
*/ | |||
private readonly monacoPromise = firstValueFrom(this.newMonacoEditorCreated.pipe( | |||
map(() => window.monaco) | |||
)); | |||
)).catch( | |||
(err) => console.error(err) |
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.
Should not use the logger instead?
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 don't think we set a logger for now on the Otter showcase
If we don't have one set up, I would expect to do it in another PR
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.
shouldn't we let it throw
? Lot of things will be broken if we don't have the global monaco
instance
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.
It will throw if the monaco editor is never instantiated and the newMonacoEditorCreated subject is completed.
This is the case in the unit tests.
I could catch the monacoPromise in the tests themselves but that would require making it public and I prefer adding a catch than transforming a private property into a public one for testing purposes.
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.
we should be able to test monaco-editor in the unit-tests? only the webcontainer part should be mocked?
@@ -195,7 +195,9 @@ export class CodeEditorViewComponent implements OnDestroy { | |||
*/ | |||
private readonly monacoPromise = firstValueFrom(this.newMonacoEditorCreated.pipe( |
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.
To have a better typing for monacoPromise
, maybe you can caught error in the observable and use the second parameter of firstValueFrom
to define { defaultValue: undefined }
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.
Currently the typing is Promise<void | typeof Monaco>
, the void
comes from the .catch
so adding { defaultValue: undefined }
will change the type to Promise<void | typeof Monaco | undefined>
if we want to have Promise<typeof Monaco | undefined>
, we should either have
(err) => {
console.error(err);
return undefined;
}
or
.catch<undefined>(...)
I checked the implementation of the option defaultValue
it is used only if the subject newMonacoEditorCreated
complete before providing a value.
implementation of firstValueFrom
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.
Actually I think defaultValue might better fit my use case here.
@@ -12,6 +12,7 @@ import { | |||
changeDetection: ChangeDetectionStrategy.OnPush, | |||
standalone: true, | |||
imports: [], | |||
providers: [NgbActiveModal], |
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 you have to add this ?
I don't see it on the bootstrap exemple
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 choose to put it here instead of inside the unit test to keep the SaveCodeDialog as a standalone, but maybe I should add it in the unit tests themselves.
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.
ok, I don't have opinion if it should be done one UT or in the component itself
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 had a similar problem with markdown
and I had to put it on the tests otherwise the component would not receive the instance provided globally (the global config for markdown was not applied)
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 will go for the same solution in that case
3b0e4b2
to
bfa43cb
Compare
Proposed change
Related issues
- No issue associated -