Fixed tests for labels (#1493)

no issue

- Updated member settings css property in tests
- Added mock for label API
This commit is contained in:
Rishabh Garg 2020-02-14 16:37:25 +05:30 committed by GitHub
parent d115204d9f
commit 78e453c1b0
3 changed files with 41 additions and 12 deletions

View File

@ -4,6 +4,7 @@ import mockConfig from './config/config';
import mockEmails from './config/emails';
import mockIntegrations from './config/integrations';
import mockInvites from './config/invites';
import mockLabels from './config/labels';
import mockMembers from './config/members';
import mockPages from './config/pages';
import mockPosts from './config/posts';
@ -59,6 +60,7 @@ export function testConfig() {
mockIntegrations(this);
mockInvites(this);
mockMembers(this);
mockLabels(this);
mockPages(this);
mockPosts(this);
mockRoles(this);

View File

@ -0,0 +1,27 @@
import {paginatedResponse} from '../utils';
export default function mockLabels(server) {
server.post('/labels/', function ({labels}) {
let attrs = this.normalizedRequestAttrs();
return labels.create(Object.assign({}, attrs, {id: 99}));
});
server.get('/labels/', paginatedResponse('labels'));
server.get('/labels/:id/', function ({labels}, {params}) {
let {id} = params;
let label = labels.find(id);
return label || new Response(404, {}, {
errors: [{
type: 'NotFoundError',
message: 'Label not found.'
}]
});
});
server.put('/labels/:id/');
server.del('/labels/:id/');
}

View File

@ -86,15 +86,15 @@ describe('Acceptance: Members', function () {
await wait();
// it shows selected member form
expect(find('.gh-member-basic-settings-form input[name="name"]').value, 'loads correct member into form')
expect(find('.gh-member-settings-primary input[name="name"]').value, 'loads correct member into form')
.to.equal(member1.name);
expect(find('.gh-member-basic-settings-form input[name="email-disabled"]').disabled, 'makes sure email is disabled')
expect(find('.gh-member-settings-primary input[name="email-disabled"]').disabled, 'makes sure email is disabled')
.to.equal(true);
// trigger save
await fillIn('.gh-member-basic-settings-form input[name="name"]', 'New Name');
await blur('.gh-member-basic-settings-form input[name="name"]');
await fillIn('.gh-member-settings-primary input[name="name"]', 'New Name');
await blur('.gh-member-settings-primary input[name="name"]');
await click('[data-test-button="save"]');
@ -138,28 +138,28 @@ describe('Acceptance: Members', function () {
.to.contain('New member');
// // all fields start blank
findAll('.gh-member-basic-settings-form .gh-input').forEach(function (elem) {
findAll('.gh-member-settings-primary .gh-input').forEach(function (elem) {
expect(elem.value, `input field for ${elem.getAttribute('name')}`)
.to.be.empty;
});
expect(find('.gh-member-basic-settings-form input[name="email"]').disabled, 'makes sure email is disabled')
expect(find('.gh-member-settings-primary input[name="email"]').disabled, 'makes sure email is disabled')
.to.equal(false);
// save new member
await fillIn('.gh-member-basic-settings-form input[name="name"]', 'New Name');
await blur('.gh-member-basic-settings-form input[name="name"]');
await fillIn('.gh-member-settings-primary input[name="name"]', 'New Name');
await blur('.gh-member-settings-primary input[name="name"]');
await fillIn('.gh-member-basic-settings-form input[name="email"]', 'example@domain.com');
await blur('.gh-member-basic-settings-form input[name="email"]');
await fillIn('.gh-member-settings-primary input[name="email"]', 'example@domain.com');
await blur('.gh-member-settings-primary input[name="email"]');
await click('[data-test-button="save"]');
await wait();
expect(find('.gh-member-basic-settings-form input[name="name"]').value, 'name has been preserved')
expect(find('.gh-member-settings-primary input[name="name"]').value, 'name has been preserved')
.to.equal('New Name');
expect(find('.gh-member-basic-settings-form input[name="email-disabled"]').disabled, 'makes sure email is disabled')
expect(find('.gh-member-settings-primary input[name="email-disabled"]').disabled, 'makes sure email is disabled')
.to.equal(true);
});
});