-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[Glimmer2] Component invocation tests #12890
Conversation
c4d98f9
to
2547210
Compare
I added a |
☔ The latest upstream changes (presumably #12928) made this pull request unmergeable. Please resolve the merge conflicts. |
dbe8463
to
4242676
Compare
moduleFor
for component invocation tests
Updated title and description for new approach. |
☔ The latest upstream changes (presumably #13067) made this pull request unmergeable. Please resolve the merge conflicts. |
I'm not sure if we already added |
That is not implemented in the Glimmer 2 compiler yet, although we can certainly (and most likely have to) bring it back. Is there any chance that we can collect up all those tests in its own file (or module at least) and make them |
Hey @Serabe! I pulled your changes locally and played with it. I rebased it against current master and pushed the result here with a few changes: tildeio@51fdc08 I think we ran into much of the same problems when we were porting other tests, and we have arrived at some similar solutions. Specifically:
Does that make sense? Also, it would be great if you can port the tests to follow the style guide in #13127, in particular the I-N-U-R cycle and probably the Do you still want to keep working on this? (Sorry for the huge gap between you submitting this and the review.) I think you have done a lot of great work here, and even if you don't have time to finish this it would be a very helpful starting point for someone else (or us). |
[WIP] [FEATURE beta] Use RenderingTest class and `moduleFor` for component invocation tests
Thank you for your comments. I will address them tomorrow morning (it is
pretty late in Spain and I'm on my phone now) but I am still working on
them. I have started a branch from master directly and I'm moving tests to
curly components test as suggested.
Furthermore, I'll take on closure component helper if I have time since I
have another WIP somewhere for the glimmer version as well.
|
Sorry for the delay, @chancancode. I have a few questions:
Thank you! |
Most of the tests are already in this file in the |
b131c4a
to
fd34483
Compare
I've push a first batch on tests so reviewing is easier. I have some questions from when I have been porting these:
|
Sounds fine!
You can use
I think @mmun has an implementation that he will publish soon |
☔ The latest upstream changes (presumably #13160) made this pull request unmergeable. Please resolve the merge conflicts. |
fd34483
to
8a884d7
Compare
@chancancode, I need some help with a test. I ported this test in old component invocation to this piece of code. It does not work for glimmer, since positional parameters are not yet supported. The sad part is that, though the original tests passes, partial updates are failing in htmlbars as well, but only if the component is invoked via the |
@Serabe if I understand correctly, I think @GavinJoyce bumped into this exact problem when porting the component helper tests: https://github.com/emberjs/ember.js/pull/13140/files#r56916691 He ended up commenting out the update part of the test and opened #13158 to track it. Does that mean this test you are porting is exactly the same as the one he ported? If so, we can just delete this one probably. Otherwise, what he did there is fine here too. Another alternative is we set a |
No, the intent of the test is to check if the dynamic version of positional params work, but it is affected but the same bug. Thank you! |
ae4c276
to
8c79ee6
Compare
This is (almost) ready for merge. The only thing left to discuss is two tests I left on When this is merged, I'll open a bug since |
moduleFor
for component invocation testsrunAppend(view); | ||
}); | ||
|
||
QUnit.test('{{component}} helper works with positional params', function() { |
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.
@Serabe I assume this is deleted without replacement because it's now covered in https://github.com/emberjs/ember.js/blob/master/packages/ember-glimmer/tests/integration/components/dynamic-components-test.js ?
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.
Only partly, thought about it but then decided it would be best to do that later once this is accepted and I had the chance to talk to you what would be the best way to approach this (most tests in this file should be shareable between curly-components
and dynamic-components
tests). I thought this file was already too big to review so adding more complexity to it would not be worth it in a first review. My apologies!
ZOMG! I just finished reviewing this 🎉 @Serabe thank you for your work, sorry it has taken so long (it's one of the biggest test file!). I think this is basically good to go. The new tests are excellent! Just a few more questions regarding the |
aadfd8e
to
b3e73c2
Compare
@chancancode thanks to you! I've tried to comment the minimum amount of code in those skipped tests, though some still remain skipped because the don't even pass the N phase. Most of the problems seem to be about parameters in rerenders. For example, I'm concerned about Thank you so much for your time! |
☔ The latest upstream changes (presumably #13290) made this pull request unmergeable. Please resolve the merge conflicts. |
Port most of the test from component invocation.
b3e73c2
to
e79ae82
Compare
Fixed! |
Thanks @Serabe! |
Port most of the test from component invocation.
This PR explores the use of Glimmer
RenderingTest
andmoduleFor
, by @chancancode and @wycats, for Ember testing. This was originally a duplicate effort with a similar DSL for test, though it used plain QUnit.First file to be ported has been
component_invocation_test.js
, though we have only changed superficial methods and I'll go through the file again to use some of the assertions included inRenderingTest
.A few comments on the experience:
render()
andrerender()
to be wrapped inside arun
by default.For the
render()
andrerender()
case, I think it is easier to read:than:
If for any reason the test needed to render the component without being inside a
run
,this.component.render()
would be enough.And just curious, why are all test names surrounded by
[]
, babel seems to be ok with just'@test something'(){}
Old PR
This PR adds a module to improve internal testing. The final purpose is toavoid the use of
View
s for testing.This PR is in WIP until:A name formoduleForApp
has been chosen.The API has been approved.The API has been created to avoid the need of using the internal variables (no more need to useview
as the variable to make theteardown
work).APIthis.getOwner()
Returns theowner
created for this test run.this.register(fullName, factory, options)
Registers in theowner
thefactory
with the namefullName
and the givenoptions
. Returns the registeredfactory
.this.render(template, hash={})
Creates a new anonymous component with theowner
for the tests and the giventemplate
. It instances said component with the passedhash
and appends it to the view.Currently,template
needs to be compiled previously.The instance is kept to be destroyed in theteardown
process.It returns the component instance.Calling it more than once makes the test fails~~
this.rerender()
~~Same asrun(component, 'rerender')
, where component is the onethis.render
instantiated.this.$()
Calls$()
in thecomponent
created while usingthis.render()
.