File tree Expand file tree Collapse file tree 3 files changed +26
-4
lines changed
tests/integration/components Expand file tree Collapse file tree 3 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -7,8 +7,9 @@ export default Component.extend({
7
7
serverError : null ,
8
8
9
9
didInsertElement ( ) {
10
- if ( this . get ( 'api_token.isNew' ) ) {
11
- this . $ ( 'input' ) . focus ( ) ;
10
+ let input = this . element . querySelector ( 'input' ) ;
11
+ if ( input . focus ) {
12
+ input . focus ( ) ;
12
13
}
13
14
} ,
14
15
Original file line number Diff line number Diff line change 6
6
placeholder =" New token name"
7
7
disabled =api_token.isSaving
8
8
value =api_token.name
9
- autofocus =true
10
- enter =" saveToken" }}
9
+ autofocus =" autofocus"
10
+ enter =" saveToken"
11
+ data-test-focused-input =true
12
+ }}
11
13
{{ else }}
12
14
{{ api_token.name }}
13
15
{{ /if }}
Original file line number Diff line number Diff line change
1
+ import { module , test } from 'qunit' ;
2
+ import { setupRenderingTest } from 'ember-qunit' ;
3
+ import { render } from '@ember/test-helpers' ;
4
+ import hbs from 'htmlbars-inline-precompile' ;
5
+
6
+ module ( 'Integration | Component | api-token-row' , function ( hooks ) {
7
+ setupRenderingTest ( hooks ) ;
8
+
9
+ test ( 'input is focused if token is new' , async function ( assert ) {
10
+ // Set any properties with this.set('myProperty', 'value');
11
+ // Handle any actions with this.set('myAction', function(val) { ... });
12
+ this . set ( 'api_token' , {
13
+ isNew : true ,
14
+ } ) ;
15
+
16
+ await render ( hbs `{{api-token-row api_token=api_token}}` ) ;
17
+ assert . dom ( '[data-test-focused-input]' ) . isFocused ( ) ;
18
+ } ) ;
19
+ } ) ;
You can’t perform that action at this time.
0 commit comments