-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
[FEATURE] Add template tag component blueprints via --strict flag as per RFC #779 #20511
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
Changes from all commits
f12f0dc
146438d
6aeca69
05a4e8e
b1b5b8b
968a4f9
174fa19
b40058d
7331d88
19203ea
c75f887
8a5fdd9
5808ca0
cb32d4d
daaf12e
1b3fbf9
6ab3dfa
bc17956
812e306
0230202
45980bf
cf5cc5e
b8da89b
0cb80f4
ef12744
d6fc532
9ee888f
5808020
f297ea9
59085bd
0c8cd41
5d1c505
4aabf44
c11d10a
879e576
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<% if (testType === 'integration') { %>import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from '<%= modulePrefix %>/tests/helpers'; | ||
import { render } from '@ember/test-helpers'; | ||
import <%= componentName %> from '<%= modulePrefix %>/components/<%= componentPathName %>'; | ||
|
||
module('<%= friendlyTestDescription %>', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test('it renders', async function (assert) { | ||
// Updating values is achieved using autotracking, just like in app code. For example: | ||
// class State { @tracked myProperty = 0; }; const state = new State(); | ||
// and update using state.myProperty = 1; await rerender(); | ||
// Handle any actions with function myAction(val) { ... }; | ||
|
||
await render(<template><%= selfCloseComponent(componentName) %></template>); | ||
|
||
assert.dom().hasText(''); | ||
|
||
// Template block usage: | ||
await render(<template> | ||
<%= openComponent(componentName) %> | ||
template block text | ||
<%= closeComponent(componentName) %> | ||
</template>); | ||
|
||
assert.dom().hasText('template block text'); | ||
}); | ||
});<% } else if (testType === 'unit') { %>import { module, test } from 'qunit'; | ||
import { setupTest } from '<%= modulePrefix %>/tests/helpers'; | ||
|
||
module('<%= friendlyTestDescription %>', function (hooks) { | ||
setupTest(hooks); | ||
|
||
test('it exists', function (assert) { | ||
let component = this.owner.factoryFor('component:<%= componentPathName %>').create(); | ||
assert.ok(component); | ||
}); | ||
}); <% } %> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<template> | ||
{{yield}} | ||
</template> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<% if (testType === 'integration') { %>import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from '<%= modulePrefix %>/tests/helpers'; | ||
import { render } from '@ember/test-helpers'; | ||
import <%= componentName %> from '<%= modulePrefix %>/components/<%= componentPathName %>'; | ||
|
||
module('<%= friendlyTestDescription %>', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test('it renders', async function (assert) { | ||
// Updating values is achieved using autotracking, just like in app code. For example: | ||
// class State { @tracked myProperty = 0; }; const state = new State(); | ||
// and update using state.myProperty = 1; await rerender(); | ||
// Handle any actions with function myAction(val) { ... }; | ||
|
||
await render(<template><%= selfCloseComponent(componentName) %></template>); | ||
|
||
assert.dom().hasText(''); | ||
|
||
// Template block usage: | ||
await render(<template> | ||
<%= openComponent(componentName) %> | ||
template block text | ||
<%= closeComponent(componentName) %> | ||
</template>); | ||
|
||
assert.dom().hasText('template block text'); | ||
}); | ||
});<% } else if (testType === 'unit') { %>import { module, test } from 'qunit'; | ||
import { setupTest } from '<%= modulePrefix %>/tests/helpers'; | ||
|
||
module('<%= friendlyTestDescription %>', function (hooks) { | ||
setupTest(hooks); | ||
|
||
test('it exists', function (assert) { | ||
let component = this.owner.factoryFor('component:<%= componentPathName %>').create(); | ||
assert.ok(component); | ||
}); | ||
}); <% } %> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<template> | ||
{{yield}} | ||
</template> | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,14 @@ describe('Blueprint: component-test', function () { | |
); | ||
}); | ||
}); | ||
|
||
it('component-test x-foo --strict', function () { | ||
return emberGenerateDestroy(['component-test', 'x-foo', '--strict'], (_file) => { | ||
expect(_file('tests/integration/components/x-foo-test.gjs')).to.equal( | ||
fixture('component-test/rfc232.gjs') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fails when running the TypeScript blueprint tests:
I'm not sure what the next step is here. The other tests don't check on TypeScript-specific files. Is the expect assumed to automatically work for TS too, but it doesn't here? Welcoming any input 😄 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validating the path dynamically would work: const filePath = fs.existsSync('tests/integration/components/x-foo-test.gts')
? 'tests/integration/components/x-foo-test.gts'
: 'tests/integration/components/x-foo-test.gjs'; But that seems like logic which shouldn't be in the test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're getting TypeScript output when the TypeScript blueprints should be converted to JS by the blueprint system (unless it is a typescript project). I believe this https://github.com/ember-polyfills/ember-cli-typescript-blueprint-polyfill/blob/main/src/utils.js#L13-L15 needs to include gts, but there may be other changes needed for the blueprint system to convert gts to gjs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ping @IgnaceMaes on ^ I'd love for this to land in 5.x There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can try to find some time to push this over the finish line as well 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would be much appreciated. Realistically, I won't have time to look into this in the near future :/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, that was confusing.. 😄 I updated the polyfill and used the branch here, but that still didn't work because the polyfill disables itself if it thinks it's no longer needed. It seems we are depending on ember-cli 4.10 which does support .ts -> .js in the blueprints, but not .gts -> .gjs (which was released in 5.5 I think). Once I bump the version to 5.12 the test no longer seems to fail. What was extra confusing is that there are no tests that verify the .ts version of the blueprints: #20362 |
||
); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('with [email protected]', function () { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'my-app/tests/helpers'; | ||
import { render } from '@ember/test-helpers'; | ||
import XFoo from 'my-app/components/x-foo'; | ||
|
||
module('Integration | Component | x-foo', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test('it renders', async function (assert) { | ||
// Updating values is achieved using autotracking, just like in app code. For example: | ||
// class State { @tracked myProperty = 0; }; const state = new State(); | ||
// and update using state.myProperty = 1; await rerender(); | ||
// Handle any actions with function myAction(val) { ... }; | ||
|
||
await render(<template><XFoo /></template>); | ||
|
||
assert.dom().hasText(''); | ||
|
||
// Template block usage: | ||
await render(<template> | ||
<XFoo> | ||
template block text | ||
</XFoo> | ||
</template>); | ||
|
||
assert.dom().hasText('template block text'); | ||
}); | ||
}); |
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 we can TO types already: https://typed-ember.gitbook.io/glint/environments/ember/template-only-components