-
Notifications
You must be signed in to change notification settings - Fork 41
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
[WIP] Auto-tag components #26
Closed
Closed
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1dfb978
update libraries
marcoow 072b3b6
automatically add data-test-* attrs to components
marcoow 24416fa
add all kinds of component examples
marcoow 2dcea15
improve code that generates component name
marcoow 17225c6
automatically bind all data-test- attributes
marcoow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,5 +13,5 @@ | |
/connect.lock | ||
/coverage/* | ||
/libpeerconnection.log | ||
npm-debug.log | ||
npm-debug.log* | ||
testem.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Ember from 'ember'; | ||
|
||
const { getPrototypeOf } = Object; | ||
const { computed, Component, get } = Ember; | ||
|
||
const nameOfComponent = function nameOfComponent(component, config) { | ||
let templateName = component._renderNode.lastResult.template.meta.moduleName; | ||
templateName = templateName.replace(/\.hbs$/, ''); | ||
templateName = templateName.replace(new RegExp(`${config.modulePrefix}\/templates\/components\/`), ''); | ||
return templateName; | ||
} | ||
|
||
export default function addTestSelectorsToComponents(config) { | ||
Component.reopen({ | ||
init() { | ||
let attributeBinding = `-data-test-component-selector:data-test-component`; | ||
this.attributeBindings = (this.attributeBindings || []).concat([attributeBinding]); | ||
|
||
return this._super(...arguments); | ||
}, | ||
|
||
'-data-test-component-selector': computed(function() { | ||
return nameOfComponent(this, config); | ||
}) | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import addTestSelectorsToComponents from 'ember-test-selectors/initializers/add-test-selectors-to-components'; | ||
import config from '../config/environment'; | ||
|
||
export default { | ||
name: 'ember-test-selectors', | ||
initialize: function() { | ||
addTestSelectorsToComponents(config); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
{ | ||
"name": "ember-test-selectors", | ||
"dependencies": { | ||
"ember": "~2.7.0", | ||
"ember-cli-shims": "0.1.1", | ||
"ember-qunit-notifications": "0.1.0" | ||
"ember": "~2.9.0", | ||
"ember-cli-shims": "0.1.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
tests/dummy/app/components/nesting-level/test-component-with-impl.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Component.extend(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Component.extend(); |
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
tests/dummy/app/templates/components/nesting-level/test-component-with-impl.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<h2>Nested Test Component with implementation</h2> | ||
|
||
<blockquote> | ||
<p>"Please disperse. Nothing to see here." - Frank Drebin</p> | ||
</blockquote> | ||
|
||
<p> | ||
This component only exists so we can convenietly use | ||
<code>moduleForComponent</code> for the tests which check that | ||
<code>data-test-*</code> attributes are stripped. | ||
</p> |
11 changes: 11 additions & 0 deletions
11
tests/dummy/app/templates/components/nesting-level/test-component-without-impl.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<h2>Nested Test Component without implementation</h2> | ||
|
||
<blockquote> | ||
<p>"Please disperse. Nothing to see here." - Frank Drebin</p> | ||
</blockquote> | ||
|
||
<p> | ||
This component only exists so we can convenietly use | ||
<code>moduleForComponent</code> for the tests which check that | ||
<code>data-test-*</code> attributes are stripped. | ||
</p> |
11 changes: 11 additions & 0 deletions
11
tests/dummy/app/templates/components/test-component-with-impl.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<h2>Test Component with implementation</h2> | ||
|
||
<blockquote> | ||
<p>"Please disperse. Nothing to see here." - Frank Drebin</p> | ||
</blockquote> | ||
|
||
<p> | ||
This component only exists so we can convenietly use | ||
<code>moduleForComponent</code> for the tests which check that | ||
<code>data-test-*</code> attributes are stripped. | ||
</p> |
11 changes: 11 additions & 0 deletions
11
tests/dummy/app/templates/components/test-component-without-impl.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<h2>Test Component without implementation</h2> | ||
|
||
<blockquote> | ||
<p>"Please disperse. Nothing to see here." - Frank Drebin</p> | ||
</blockquote> | ||
|
||
<p> | ||
This component only exists so we can convenietly use | ||
<code>moduleForComponent</code> for the tests which check that | ||
<code>data-test-*</code> attributes are stripped. | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{{test-component-with-impl}} | ||
|
||
{{test-component-without-impl}} | ||
|
||
{{nesting-level/test-component-with-impl}} | ||
|
||
{{nesting-level/test-component-without-impl}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
perhaps I'm just not following, but I don't see anywhere to add custom selectors. This seems to only add a selector based upon the component name.
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.
Yes, for now I want to support attributes with the component name and then for all
data-test-*
attributes afterwards.