mirror of
https://github.com/datahub-project/datahub.git
synced 2025-07-13 20:21:33 +00:00

* finish the alc access page layout, logics and sass files * Fix css issue and request permission response error message * finish the testing part * simplify code finished * finish spinner * Finished ACL access page, testing cases, clean code format * Clean format, address comments, refactor JS code of ACL page to TS * address comments, replace type any and fix merge issue
186 lines
5.1 KiB
JavaScript
186 lines
5.1 KiB
JavaScript
import { moduleForComponent, test } from 'ember-qunit';
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
import { triggerEvent } from 'ember-native-dom-helpers';
|
|
import {
|
|
accessInfoTesting as accessInfo,
|
|
approvedResponseTesting as approvedResponse
|
|
} from 'wherehows-web/mirage/helpers/aclauth';
|
|
|
|
moduleForComponent('dataset-aclaccess', 'Integration | Component | dataset aclaccess', {
|
|
integration: true
|
|
});
|
|
|
|
//TODO: Define testing case
|
|
const currentUser = 'Mitchell_Rath';
|
|
const accessResponse = { isApproved: false };
|
|
|
|
//TODO: test each part of the component loading situation
|
|
test('it renders', function(assert) {
|
|
this.setProperties({
|
|
accessInfo: accessInfo(true),
|
|
currentUser
|
|
});
|
|
|
|
this.render(hbs`{{dataset-aclaccess accessInfo=accessInfo currentUser=currentUser}}`);
|
|
|
|
assert.ok(this.$(), 'Render without errors');
|
|
|
|
assert.ok(this.$('#acl-permissioninfo'), 'Render permission info section without errors');
|
|
|
|
assert.ok(this.$('#acl-permissionrequest'), 'Render permission request section without errors');
|
|
|
|
assert.ok(this.$('#acl-accessusers'), 'Render access users section without errors');
|
|
});
|
|
|
|
test('component content renders correctly with permission', function(assert) {
|
|
this.setProperties({
|
|
accessInfo: accessInfo(true),
|
|
currentUser
|
|
});
|
|
|
|
this.render(hbs`{{dataset-aclaccess accessInfo=accessInfo currentUser=currentUser}}`);
|
|
|
|
assert.ok(
|
|
this.$('i[title="permission"]').attr('class', 'fa fa-check-circle-o fa-lg acl-permission__success'),
|
|
'Render the icon is correctly with the permission'
|
|
);
|
|
|
|
assert.equal(
|
|
this.$('.acl-permission__meta')
|
|
.text()
|
|
.trim(),
|
|
'Mitchell_Rath, you have access to this data',
|
|
'Render the permission message'
|
|
);
|
|
|
|
assert.equal(this.$('.acl-table__header').text(), 'People with ACL Access', 'Render users list title correctly');
|
|
|
|
//table has 7 colums
|
|
assert.equal(this.$('td').length, 7, 'Render table header correctly');
|
|
});
|
|
|
|
test('component content renders correctly without permission', function(assert) {
|
|
this.setProperties({
|
|
accessInfo: accessInfo(false),
|
|
currentUser
|
|
});
|
|
|
|
this.render(hbs`{{dataset-aclaccess accessInfo=accessInfo currentUser=currentUser}}`);
|
|
|
|
assert.ok(
|
|
this.$('i[title="permission"]').attr('class', 'fa fa-ban fa-lg acl-permission__reject'),
|
|
'Render icon is correctly in permission info section'
|
|
);
|
|
|
|
assert.ok(this.$('.acl-form'), 'Render permission request section without errors');
|
|
|
|
assert.equal(
|
|
this.$('.acl-permission__meta')
|
|
.text()
|
|
.trim(),
|
|
'Mitchell_Rath, you currently do not have access to this dataset',
|
|
'Render permission message correctly'
|
|
);
|
|
|
|
assert.equal(
|
|
this.$('.acl-form__meta.acl-form__header')
|
|
.text()
|
|
.trim(),
|
|
'Request Access',
|
|
'Render request form title correctly'
|
|
);
|
|
|
|
assert.equal(
|
|
this.$('.acl-form__meta__header')
|
|
.text()
|
|
.trim(),
|
|
'Why do you need access?',
|
|
'Render request form subtitle 1 correctly'
|
|
);
|
|
|
|
assert.equal(
|
|
this.$('.acl-form__meta__content')
|
|
.text()
|
|
.trim(),
|
|
'Please add business reason you need to access this data.',
|
|
'Render request form subtitle 2 correctly'
|
|
);
|
|
});
|
|
|
|
test('component content renders permission rejected', function(assert) {
|
|
this.setProperties({
|
|
accessInfo: accessInfo(false),
|
|
currentUser,
|
|
accessResponse
|
|
});
|
|
|
|
this.render(hbs`
|
|
{{dataset-aclaccess
|
|
accessInfo=accessInfo
|
|
currentUser=currentUser
|
|
accessResponse=accessResponse}}`);
|
|
|
|
assert.ok(
|
|
this.$('i[title="permission"]').attr('class', 'acl-permission__reject'),
|
|
'Render icon is correctly in permission info section'
|
|
);
|
|
|
|
assert.equal(
|
|
this.$('.acl-permission__meta')
|
|
.children('p')
|
|
.text()
|
|
.trim(),
|
|
'If you feel this is in error, contact acreqjests@linkedin.',
|
|
'Render request form subtitle 2 correctly'
|
|
);
|
|
});
|
|
|
|
test('component content renders permission approved', function(assert) {
|
|
this.setProperties({
|
|
accessInfo: accessInfo(false),
|
|
currentUser,
|
|
accessResponse: approvedResponse
|
|
});
|
|
|
|
this.render(hbs`
|
|
{{dataset-aclaccess
|
|
accessInfo=accessInfo
|
|
currentUser=currentUser
|
|
accessResponse=accessResponse}}`);
|
|
|
|
assert.ok(
|
|
this.$('i[title="permission"]').attr('class', 'fa fa-check-circle-o fa-lg acl-permission__success'),
|
|
'Render icon is correctly when the user is approved '
|
|
);
|
|
assert.equal(
|
|
this.$('.acl-permission__meta')
|
|
.children('p')
|
|
.text()
|
|
.trim(),
|
|
'You now have access to this data',
|
|
'Render request form subtitle 2 correctly'
|
|
);
|
|
assert.equal(this.$('.dataset-author-record').length, 2, 'Render table body correctly');
|
|
});
|
|
|
|
test('it should invoke the reset action on cancel', function(assert) {
|
|
this.setProperties({
|
|
accessInfo: accessInfo(false),
|
|
currentUser,
|
|
accessResponse,
|
|
requestReason: 'request access'
|
|
});
|
|
|
|
this.render(hbs`
|
|
{{dataset-aclaccess
|
|
accessInfo=accessInfo
|
|
currentUser=currentUser
|
|
requestReason=requestReason}}`);
|
|
|
|
assert.equal(this.get('requestReason'), 'request access');
|
|
|
|
triggerEvent('.nacho-button--secondary', 'click');
|
|
|
|
assert.equal(this.get('requestReason'), '');
|
|
});
|