mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Invite Users step
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import { componentTest } from 'wizard/test/helpers/component-test';
|
||||
|
||||
moduleForComponent('invite-list', { integration: true });
|
||||
|
||||
componentTest('can add users', {
|
||||
template: `{{invite-list field=field}}`,
|
||||
|
||||
setup() {
|
||||
this.set('field', {});
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.ok(this.$('.users-list .invite-list-user').length === 0, 'no users at first');
|
||||
assert.ok(this.$('.new-user .invalid').length === 0, 'not invalid at first');
|
||||
|
||||
const firstVal = JSON.parse(this.get('field.value'));
|
||||
assert.equal(firstVal.length, 0, 'empty JSON at first');
|
||||
|
||||
click('.add-user');
|
||||
andThen(() => {
|
||||
assert.ok(this.$('.users-list .invite-list-user').length === 0, "doesn't add a blank user");
|
||||
assert.ok(this.$('.new-user .invalid').length === 1);
|
||||
});
|
||||
|
||||
fillIn('.invite-email', 'eviltrout@example.com');
|
||||
click('.add-user');
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(this.$('.users-list .invite-list-user').length === 1, 'adds the user');
|
||||
assert.ok(this.$('.new-user .invalid').length === 0);
|
||||
|
||||
const val = JSON.parse(this.get('field.value'));
|
||||
assert.equal(val.length, 1);
|
||||
assert.equal(val[0].email, 'eviltrout@example.com', 'adds the email to the JSON');
|
||||
assert.ok(val[0].role.length, 'adds the role to the JSON');
|
||||
});
|
||||
|
||||
fillIn('.invite-email', 'eviltrout@example.com');
|
||||
click('.add-user');
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(this.$('.users-list .invite-list-user').length === 1, "can't add the same user twice");
|
||||
assert.ok(this.$('.new-user .invalid').length === 1);
|
||||
});
|
||||
|
||||
fillIn('.invite-email', 'not-an-email');
|
||||
click('.add-user');
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(this.$('.users-list .invite-list-user').length === 1, "won't add an invalid email");
|
||||
assert.ok(this.$('.new-user .invalid').length === 1);
|
||||
});
|
||||
|
||||
click('.invite-list .invite-list-user:eq(0) .remove-user');
|
||||
andThen(() => {
|
||||
assert.ok(this.$('.users-list .invite-list-user').length === 0, 'removed the user');
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user