Skip to content

Commit

Permalink
Feat: prefill first name in input for events (#873)
Browse files Browse the repository at this point in the history
* Feat: prefill first_name in input for events

* add test to check if name is being prefilled

* test: check using controller name

---------

Co-authored-by: Jayasurya <jayasurya@digital.ai>
  • Loading branch information
jsuryakt and jsuryakt authored Feb 21, 2024
1 parent 6bbd640 commit f9f25be
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/live.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default class LiveController extends Controller {
];
@tracked activeTab = 'Screenshare';
@tracked isLoading = false;
@tracked name = '';
@tracked name = this.login?.userData?.first_name ?? '';
@tracked role = '';
@tracked roomCode = '';
@tracked isCopied = false;
Expand Down
42 changes: 42 additions & 0 deletions tests/integration/components/live-join-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,46 @@ module('Integration | Component | live-join', function (hooks) {

assert.dom('[data-test-live-join-title]').containsText('Create a Event');
});

test('it should prefill first name in input box', async function (assert) {
const loginService = this.owner.lookup('service:login');
loginService.userData = { first_name: 'Jayasurya' };

const controller = this.owner.lookup('controller:live');
assert.deepEqual(controller.name, 'Jayasurya');

const objToCheckFunctions = {
isInputHandler: assert.ok(true, 'inputHandler is working fine!'),
isClickHandlerWorks: assert.ok(true, 'clickHandler is working fine!'),
isBackHandlerWorks: assert.ok(true, 'backHandler is working fine!'),
};
this.setProperties({
role: 'host',
name: controller.name,
roomCode: '',
inputHandler: () => {
objToCheckFunctions.isInputHandler;
},
clickHandler: () => {
objToCheckFunctions.isClickHandlerWorks;
},
backHandler: () => {
objToCheckFunctions.isBackHandlerWorks;
},
buttonText: 'Create',
});

await render(hbs`
<LiveJoin
@role={{this.role}}
@name={{this.name}}
@roomCode={{this.roomCode}}
@inputHandler={{this.inputHandler}}
@clickHandler={{this.clickHandler}}
@backHandler={{this.backHandler}}
@buttonText={{this.buttonText}}
/>`);

assert.dom('[data-test-input-field]').hasProperty('value', 'Jayasurya');
});
});

0 comments on commit f9f25be

Please sign in to comment.