ui: Use `qunit-dom` for DOM assertions (#4455)
This commit is contained in:
parent
5bcb5992c9
commit
daacfd58f5
|
@ -86,7 +86,8 @@
|
|||
"loader.js": "^4.2.3",
|
||||
"normalize.css": "4.1.1",
|
||||
"prettier": "^1.5.3",
|
||||
"prettier-eslint-cli": "^4.2.1"
|
||||
"prettier-eslint-cli": "^4.2.1",
|
||||
"qunit-dom": "^0.6.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^4.5 || 6.* || >= 7.*"
|
||||
|
|
|
@ -97,10 +97,6 @@ test('aws backend', function(assert) {
|
|||
click(`[data-test-confirm-button]`);
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find(`[data-test-secret-link="${roleName}"]`).length,
|
||||
0,
|
||||
`aws: role is no longer in the list`
|
||||
);
|
||||
assert.dom(`[data-test-secret-link="${roleName}"]`).doesNotExist(`aws: role is no longer in the list`);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -87,11 +87,7 @@ test('replication', function(assert) {
|
|||
find('[data-test-mount-config-mode]').text().trim().toLowerCase().includes(mode),
|
||||
'show page renders the correct mode'
|
||||
);
|
||||
assert.equal(
|
||||
find('[data-test-mount-config-paths]').text().trim(),
|
||||
mountPath,
|
||||
'show page renders the correct mount path'
|
||||
);
|
||||
assert.dom('[data-test-mount-config-paths]').hasText(mountPath, 'show page renders the correct mount path');
|
||||
});
|
||||
// click edit
|
||||
|
||||
|
@ -105,9 +101,7 @@ test('replication', function(assert) {
|
|||
`/vault/replication/performance/secondaries`,
|
||||
'redirects to the secondaries page'
|
||||
);
|
||||
assert.equal(
|
||||
//TODO re-work error message test selectors
|
||||
find('[data-test-flash-message-body]:contains(The performance mount filter)').text().trim(),
|
||||
assert.dom('[data-test-flash-message-body]:contains(The performance mount filter)').hasText(
|
||||
`The performance mount filter config for the secondary ${secondaryName} was successfully deleted.`,
|
||||
'renders success flash upon deletion'
|
||||
);
|
||||
|
@ -155,8 +149,7 @@ test('replication', function(assert) {
|
|||
});
|
||||
click('[data-test-replication-link="secondaries"]');
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find('[data-test-secondary-name]').text().trim(),
|
||||
assert.dom('[data-test-secondary-name]').hasText(
|
||||
secondaryName,
|
||||
'it displays the secondary in the list of known secondaries'
|
||||
);
|
||||
|
|
|
@ -51,11 +51,7 @@ test('it renders the show page', function(assert) {
|
|||
'vault.cluster.access.leases.show',
|
||||
'a lease for the secret is in the list'
|
||||
);
|
||||
assert.equal(
|
||||
find('[data-test-lease-renew-picker]').length,
|
||||
0,
|
||||
'non-renewable lease does not render a renew picker'
|
||||
);
|
||||
assert.dom('[data-test-lease-renew-picker]').doesNotExist('non-renewable lease does not render a renew picker');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -69,7 +65,7 @@ skip('it renders the show page with a picker', function(assert) {
|
|||
'vault.cluster.access.leases.show',
|
||||
'a lease for the secret is in the list'
|
||||
);
|
||||
assert.equal(find('[data-test-lease-renew-picker]').length, 1, 'renewable lease renders a renew picker');
|
||||
assert.dom('[data-test-lease-renew-picker]').exists({ count: 1 }, 'renewable lease renders a renew picker');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -88,11 +84,7 @@ test('it removes leases upon revocation', function(assert) {
|
|||
click(`[data-test-lease-link="${this.enginePath}/"]`);
|
||||
click('[data-test-lease-link="data/"]');
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find(`[data-test-lease-link="${this.enginePath}/data/${this.name}/"]`).length,
|
||||
0,
|
||||
'link to the lease was removed with revocation'
|
||||
);
|
||||
assert.dom(`[data-test-lease-link="${this.enginePath}/data/${this.name}/"]`).doesNotExist('link to the lease was removed with revocation');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -107,19 +99,14 @@ test('it removes branches when a prefix is revoked', function(assert) {
|
|||
'vault.cluster.access.leases.list-root',
|
||||
'it navigates back to the leases root on revocation'
|
||||
);
|
||||
assert.equal(
|
||||
find(`[data-test-lease-link="${this.enginePath}/"]`).length,
|
||||
0,
|
||||
'link to the prefix was removed with revocation'
|
||||
);
|
||||
assert.dom(`[data-test-lease-link="${this.enginePath}/"]`).doesNotExist('link to the prefix was removed with revocation');
|
||||
});
|
||||
});
|
||||
|
||||
test('lease not found', function(assert) {
|
||||
visit('/vault/access/leases/show/not-found');
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find('[data-test-lease-error]').text().trim(),
|
||||
assert.dom('[data-test-lease-error]').hasText(
|
||||
'not-found is not a valid lease ID',
|
||||
'it shows an error when the lease is not found'
|
||||
);
|
||||
|
|
|
@ -31,7 +31,7 @@ test('top-level not-found', function(assert) {
|
|||
test('vault route not-found', function(assert) {
|
||||
visit('/vault/404');
|
||||
andThen(() => {
|
||||
assert.ok(find('[data-test-not-found]'), 'renders the not found component');
|
||||
assert.dom('[data-test-not-found]').exists('renders the not found component');
|
||||
assert.ok(find('[data-test-header-with-nav]').length, 'renders header with nav');
|
||||
});
|
||||
});
|
||||
|
@ -39,7 +39,7 @@ test('vault route not-found', function(assert) {
|
|||
test('cluster route not-found', function(assert) {
|
||||
visit('/vault/secrets/secret/404/show');
|
||||
andThen(() => {
|
||||
assert.ok(find('[data-test-not-found]'), 'renders the not found component');
|
||||
assert.dom('[data-test-not-found]').exists('renders the not found component');
|
||||
assert.ok(find('[data-test-header-with-nav]').length, 'renders header with nav');
|
||||
});
|
||||
});
|
||||
|
@ -47,6 +47,6 @@ test('cluster route not-found', function(assert) {
|
|||
test('secret not-found', function(assert) {
|
||||
visit('/vault/secrets/secret/show/404');
|
||||
andThen(() => {
|
||||
assert.ok(find('[data-test-secret-not-found]'), 'renders the message about the secret not being found');
|
||||
assert.dom('[data-test-secret-not-found]').exists('renders the message about the secret not being found');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -31,7 +31,7 @@ test('policies', function(assert) {
|
|||
fillIn('[data-test-policy-input="name"]', policyName);
|
||||
click('[data-test-policy-save]');
|
||||
andThen(function() {
|
||||
assert.equal(find('[data-test-error]').length, 1, 'renders error messages on save');
|
||||
assert.dom('[data-test-error]').exists({ count: 1 }, 'renders error messages on save');
|
||||
find('.CodeMirror').get(0).CodeMirror.setValue(policyString);
|
||||
});
|
||||
click('[data-test-policy-save]');
|
||||
|
@ -41,20 +41,12 @@ test('policies', function(assert) {
|
|||
`/vault/policy/acl/${encodeURIComponent(policyLower)}`,
|
||||
'navigates to policy show on successful save'
|
||||
);
|
||||
assert.equal(
|
||||
find('[data-test-policy-name]').text().trim(),
|
||||
policyLower,
|
||||
'displays the policy name on the show page'
|
||||
);
|
||||
assert.equal(
|
||||
find('[data-test-flash-message].is-info').length,
|
||||
0,
|
||||
'no flash message is displayed on save'
|
||||
);
|
||||
assert.dom('[data-test-policy-name]').hasText(policyLower, 'displays the policy name on the show page');
|
||||
assert.dom('[data-test-flash-message].is-info').doesNotExist('no flash message is displayed on save');
|
||||
});
|
||||
click('[data-test-policy-list-link]');
|
||||
andThen(function() {
|
||||
assert.equal(find(`[data-test-policy-link="${policyLower}"]`).length, 1, 'new policy shown in the list');
|
||||
assert.dom(`[data-test-policy-link="${policyLower}"]`).exists({ count: 1 }, 'new policy shown in the list');
|
||||
});
|
||||
|
||||
// policy deletion
|
||||
|
@ -64,11 +56,7 @@ test('policies', function(assert) {
|
|||
click('[data-test-confirm-button]');
|
||||
andThen(function() {
|
||||
assert.equal(currentURL(), `/vault/policies/acl`, 'navigates to policy list on successful deletion');
|
||||
assert.equal(
|
||||
find(`[data-test-policy-item="${policyLower}"]`).length,
|
||||
0,
|
||||
'deleted policy is not shown in the list'
|
||||
);
|
||||
assert.dom(`[data-test-policy-item="${policyLower}"]`).doesNotExist('deleted policy is not shown in the list');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -92,6 +80,6 @@ test('it properly fetches policies when the name ends in a ,', function(assert)
|
|||
`/vault/policy/acl/${policyName}`,
|
||||
'navigates to policy show on successful save'
|
||||
);
|
||||
assert.equal(find('[data-test-policy-edit-toggle]').length, 1, 'shows the edit toggle');
|
||||
assert.dom('[data-test-policy-edit-toggle]').exists({ count: 1 }, 'shows the edit toggle');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -24,10 +24,10 @@ const ROLES = [
|
|||
},
|
||||
assertAfterGenerate(assert, sshPath) {
|
||||
assert.equal(currentURL(), `/vault/secrets/${sshPath}/sign/${this.name}`, 'ca sign url is correct');
|
||||
assert.equal(find('[data-test-row-label="Signed key"]').length, 1, 'renders the signed key');
|
||||
assert.equal(find('[data-test-row-value="Signed key"]').length, 1, "renders the signed key's value");
|
||||
assert.equal(find('[data-test-row-label="Serial number"]').length, 1, 'renders the serial');
|
||||
assert.equal(find('[data-test-row-value="Serial number"]').length, 1, 'renders the serial value');
|
||||
assert.dom('[data-test-row-label="Signed key"]').exists({ count: 1 }, 'renders the signed key');
|
||||
assert.dom('[data-test-row-value="Signed key"]').exists({ count: 1 }, "renders the signed key's value");
|
||||
assert.dom('[data-test-row-label="Serial number"]').exists({ count: 1 }, 'renders the serial');
|
||||
assert.dom('[data-test-row-value="Serial number"]').exists({ count: 1 }, 'renders the serial value');
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -48,10 +48,10 @@ const ROLES = [
|
|||
`/vault/secrets/${sshPath}/credentials/${this.name}`,
|
||||
'otp credential url is correct'
|
||||
);
|
||||
assert.equal(find('[data-test-row-label="Key"]').length, 1, 'renders the key');
|
||||
assert.equal(find('[data-test-row-value="Key"]').length, 1, "renders the key's value");
|
||||
assert.equal(find('[data-test-row-label="Port"]').length, 1, 'renders the port');
|
||||
assert.equal(find('[data-test-row-value="Port"]').length, 1, "renders the port's value");
|
||||
assert.dom('[data-test-row-label="Key"]').exists({ count: 1 }, 'renders the key');
|
||||
assert.dom('[data-test-row-value="Key"]').exists({ count: 1 }, "renders the key's value");
|
||||
assert.dom('[data-test-row-label="Port"]').exists({ count: 1 }, 'renders the port');
|
||||
assert.dom('[data-test-row-value="Port"]').exists({ count: 1 }, "renders the port's value");
|
||||
},
|
||||
},
|
||||
];
|
||||
|
@ -143,11 +143,7 @@ test('ssh backend', function(assert) {
|
|||
click(`[data-test-confirm-button]`);
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find(`[data-test-secret-link="${role.name}"]`).length,
|
||||
0,
|
||||
`${role.type}: role is no longer in the list`
|
||||
);
|
||||
assert.dom(`[data-test-secret-link="${role.name}"]`).doesNotExist(`${role.type}: role is no longer in the list`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -101,7 +101,7 @@ test('tools functionality', function(assert) {
|
|||
//random
|
||||
click('[data-test-tools-action-link="random"]');
|
||||
andThen(() => {
|
||||
assert.equal(find('[data-test-tools-input="bytes"]').val(), 32, 'defaults to 32 bytes');
|
||||
assert.dom('[data-test-tools-input="bytes"]').hasValue('32', 'defaults to 32 bytes');
|
||||
});
|
||||
click('[data-test-tools-submit]');
|
||||
andThen(() => {
|
||||
|
@ -117,8 +117,7 @@ test('tools functionality', function(assert) {
|
|||
click('[data-test-tools-b64-toggle="input"]');
|
||||
click('[data-test-tools-submit]');
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find('[data-test-tools-input="sum"]').val(),
|
||||
assert.dom('[data-test-tools-input="sum"]').hasValue(
|
||||
'LCa0a2j/xo/5m0U8HTBBNBNCLXBkg7+g+YpeiGJm564=',
|
||||
'hashes the data, encodes input'
|
||||
);
|
||||
|
@ -128,8 +127,7 @@ test('tools functionality', function(assert) {
|
|||
|
||||
click('[data-test-tools-submit]');
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find('[data-test-tools-input="sum"]').val(),
|
||||
assert.dom('[data-test-tools-input="sum"]').hasValue(
|
||||
'JmSi2Hhbgu2WYOrcOyTqqMdym7KT3sohCwAwaMonVrc=',
|
||||
'hashes the data, passes b64 input through'
|
||||
);
|
||||
|
|
|
@ -101,16 +101,14 @@ const testEncryption = (assert, keyName) => {
|
|||
);
|
||||
},
|
||||
assertBeforeDecrypt: key => {
|
||||
assert.equal(
|
||||
find('[data-test-transit-input="context"]').val(),
|
||||
assert.dom('[data-test-transit-input="context"]').hasValue(
|
||||
'nqR8LiVgNh/lwO2rArJJE9F9DMhh0lKo4JX9DAAkCDw=',
|
||||
`${key}: the ui shows the base64-encoded context`
|
||||
);
|
||||
},
|
||||
|
||||
assertAfterDecrypt: key => {
|
||||
assert.equal(
|
||||
find('[data-test-transit-input="plaintext"]').val(),
|
||||
assert.dom('[data-test-transit-input="plaintext"]').hasValue(
|
||||
'NaXud2QW7KjyK6Me9ggh+zmnCeBGdG93LQED49PtoOI=',
|
||||
`${key}: the ui shows the base64-encoded plaintext`
|
||||
);
|
||||
|
@ -130,15 +128,10 @@ const testEncryption = (assert, keyName) => {
|
|||
);
|
||||
},
|
||||
assertBeforeDecrypt: key => {
|
||||
assert.equal(
|
||||
find('[data-test-transit-input="context"]').val(),
|
||||
encodeString('context'),
|
||||
`${key}: the ui shows the input context`
|
||||
);
|
||||
assert.dom('[data-test-transit-input="context"]').hasValue(encodeString('context'), `${key}: the ui shows the input context`);
|
||||
},
|
||||
assertAfterDecrypt: key => {
|
||||
assert.equal(
|
||||
find('[data-test-transit-input="plaintext"]').val(),
|
||||
assert.dom('[data-test-transit-input="plaintext"]').hasValue(
|
||||
'NaXud2QW7KjyK6Me9ggh+zmnCeBGdG93LQED49PtoOI=',
|
||||
`${key}: the ui shows the base64-encoded plaintext`
|
||||
);
|
||||
|
@ -158,18 +151,10 @@ const testEncryption = (assert, keyName) => {
|
|||
);
|
||||
},
|
||||
assertBeforeDecrypt: key => {
|
||||
assert.equal(
|
||||
find('[data-test-transit-input="context"]').val(),
|
||||
encodeString('context'),
|
||||
`${key}: the ui shows the input context`
|
||||
);
|
||||
assert.dom('[data-test-transit-input="context"]').hasValue(encodeString('context'), `${key}: the ui shows the input context`);
|
||||
},
|
||||
assertAfterDecrypt: key => {
|
||||
assert.equal(
|
||||
find('[data-test-transit-input="plaintext"]').val(),
|
||||
'This is the secret',
|
||||
`${key}: the ui decodes plaintext`
|
||||
);
|
||||
assert.dom('[data-test-transit-input="plaintext"]').hasValue('This is the secret', `${key}: the ui decodes plaintext`);
|
||||
},
|
||||
},
|
||||
|
||||
|
@ -188,19 +173,11 @@ const testEncryption = (assert, keyName) => {
|
|||
);
|
||||
},
|
||||
assertBeforeDecrypt: key => {
|
||||
assert.equal(
|
||||
find('[data-test-transit-input="context"]').val(),
|
||||
encodeString('secret 2'),
|
||||
`${key}: the ui shows the encoded context`
|
||||
);
|
||||
assert.dom('[data-test-transit-input="context"]').hasValue(encodeString('secret 2'), `${key}: the ui shows the encoded context`);
|
||||
},
|
||||
assertAfterDecrypt: key => {
|
||||
assert.ok(findWithAssert('[data-test-transit-input="plaintext"]'), `${key}: plaintext box shows`);
|
||||
assert.equal(
|
||||
find('[data-test-transit-input="plaintext"]').val(),
|
||||
'There are many secrets 🤐',
|
||||
`${key}: the ui decodes plaintext`
|
||||
);
|
||||
assert.dom('[data-test-transit-input="plaintext"]').hasValue('There are many secrets 🤐', `${key}: the ui decodes plaintext`);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
@ -252,20 +229,12 @@ test('transit backend', function(assert) {
|
|||
if (index === 0) {
|
||||
click('[data-test-transit-link="versions"]');
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find('[data-test-transit-key-version-row]').length,
|
||||
1,
|
||||
`${key.name}: only one key version`
|
||||
);
|
||||
assert.dom('[data-test-transit-key-version-row]').exists({ count: 1 }, `${key.name}: only one key version`);
|
||||
});
|
||||
click('[data-test-transit-key-rotate] button');
|
||||
click('[data-test-confirm-button]');
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find('[data-test-transit-key-version-row]').length,
|
||||
2,
|
||||
`${key.name}: two key versions after rotate`
|
||||
);
|
||||
assert.dom('[data-test-transit-key-version-row]').exists({ count: 2 }, `${key.name}: two key versions after rotate`);
|
||||
});
|
||||
}
|
||||
click('[data-test-transit-key-actions-link]');
|
||||
|
@ -287,11 +256,7 @@ test('transit backend', function(assert) {
|
|||
`${key.name}: exportable key has a link to export action`
|
||||
);
|
||||
} else {
|
||||
assert.equal(
|
||||
find('[data-test-transit-action-link="export"]').length,
|
||||
0,
|
||||
`${key.name}: non-exportable key does not link to export action`
|
||||
);
|
||||
assert.dom('[data-test-transit-action-link="export"]').doesNotExist(`${key.name}: non-exportable key does not link to export action`);
|
||||
}
|
||||
if (key.convergent && key.supportsEncryption) {
|
||||
testEncryption(assert, key.name);
|
||||
|
|
|
@ -23,11 +23,11 @@ test('it asserts on unknown features', function(assert) {
|
|||
test('it is true with existing features', function(assert) {
|
||||
this.set('versionService.features', ['HSM']);
|
||||
this.render(hbs`{{if (has-feature 'HSM') 'It works' null}}`);
|
||||
assert.equal(this._element.textContent.trim(), 'It works', 'present features evaluate to true');
|
||||
assert.dom(this._element).hasText('It works', 'present features evaluate to true');
|
||||
});
|
||||
|
||||
test('it is false with missing features', function(assert) {
|
||||
this.set('versionService.features', ['MFA']);
|
||||
this.render(hbs`{{if (has-feature 'HSM') 'It works' null}}`);
|
||||
assert.equal(this._element.textContent.trim(), '', 'missing features evaluate to false');
|
||||
assert.dom(this._element).hasText('', 'missing features evaluate to false');
|
||||
});
|
||||
|
|
|
@ -6291,6 +6291,13 @@ quick-temp@^0.1.0, quick-temp@^0.1.2, quick-temp@^0.1.3, quick-temp@^0.1.5, quic
|
|||
rimraf "^2.5.4"
|
||||
underscore.string "~3.3.4"
|
||||
|
||||
qunit-dom@^0.6.2:
|
||||
version "0.6.2"
|
||||
resolved "https://registry.yarnpkg.com/qunit-dom/-/qunit-dom-0.6.2.tgz#0b37012cbbc838f09eba760b3d39924ad5ccbccb"
|
||||
dependencies:
|
||||
broccoli-funnel "^2.0.0"
|
||||
broccoli-merge-trees "^2.0.0"
|
||||
|
||||
qunit-notifications@^0.1.1:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/qunit-notifications/-/qunit-notifications-0.1.1.tgz#3001afc6a6a77dfbd962ccbcddde12dec5286c09"
|
||||
|
|
Loading…
Reference in New Issue