From 14efea59f03081e2c7f849218f02e96fcc78f6f5 Mon Sep 17 00:00:00 2001 From: Jordan Reimer Date: Tue, 25 Jan 2022 13:27:26 -0700 Subject: [PATCH] Remove Faker (#13778) * removes faker * attempts to fix global error in circle ci run * adds comments for destroyed check in file-to-array-buffer component --- ui/app/components/file-to-array-buffer.js | 6 +++++- ui/mirage/factories/configuration.js | 5 ++--- ui/mirage/factories/secret-engine.js | 25 +++++++---------------- ui/mirage/factories/server.js | 7 +++---- ui/package.json | 1 - ui/tests/.eslintrc.js | 1 - 6 files changed, 17 insertions(+), 28 deletions(-) diff --git a/ui/app/components/file-to-array-buffer.js b/ui/app/components/file-to-array-buffer.js index def353e9fd..fb738e4cda 100644 --- a/ui/app/components/file-to-array-buffer.js +++ b/ui/app/components/file-to-array-buffer.js @@ -29,7 +29,11 @@ export default Component.extend({ readFile(file) { const reader = new FileReader(); - reader.onload = () => this.send('onChange', reader.result, file); + // raft-snapshot-restore test was failing on CI trying to send action on destroyed object + // ensure that the component has not been torn down prior to sending onChange action + if (!this.isDestroyed && !this.isDestroying) { + reader.onload = () => this.send('onChange', reader.result, file); + } reader.readAsArrayBuffer(file); }, diff --git a/ui/mirage/factories/configuration.js b/ui/mirage/factories/configuration.js index 3adea1e6ca..a64f830923 100644 --- a/ui/mirage/factories/configuration.js +++ b/ui/mirage/factories/configuration.js @@ -1,13 +1,12 @@ import { Factory, trait } from 'ember-cli-mirage'; -import faker from 'faker'; export default Factory.extend({ auth: null, data: null, // populated via traits lease_duration: 0, lease_id: '', - renewable: () => faker.datatype.boolean(), - request_id: () => faker.datatype.uuid(), + renewable: true, + request_id: '22068a49-a504-41ad-b5b0-1eac71659190', warnings: null, wrap_info: null, diff --git a/ui/mirage/factories/secret-engine.js b/ui/mirage/factories/secret-engine.js index 5d6e66a8f9..57f5c09089 100644 --- a/ui/mirage/factories/secret-engine.js +++ b/ui/mirage/factories/secret-engine.js @@ -1,30 +1,19 @@ import { Factory } from 'ember-cli-mirage'; -import faker from 'faker'; -import { supportedSecretBackends } from 'vault/helpers/supported-secret-backends'; export default Factory.extend({ - path: () => faker.system.directoryPath(), - description: () => faker.git.commitMessage(), - local: () => faker.datatype.boolean(), - sealWrap: () => faker.datatype.boolean(), + path: 'foo/', + description: 'secret-engine generated by mirage', + local: true, + sealWrap: true, // set in afterCreate - accessor: null, - type: null, + accessor: 'type_7f52940', + type: 'kv', options: null, afterCreate(secretEngine) { - if (!secretEngine.type) { - const type = faker.random.arrayElement(supportedSecretBackends()); - secretEngine.type = type; - - if (!secretEngine.accessor) { - secretEngine.accessor = `type_${faker.git.shortSha()}`; - } - } - if (!secretEngine.options && ['generic', 'kv'].includes(secretEngine.type)) { secretEngine.options = { - version: faker.random.arrayElement('1', '2'), + version: '2', }; } }, diff --git a/ui/mirage/factories/server.js b/ui/mirage/factories/server.js index 2da3c70f01..2d9100b4d0 100644 --- a/ui/mirage/factories/server.js +++ b/ui/mirage/factories/server.js @@ -1,10 +1,9 @@ import { Factory } from 'ember-cli-mirage'; -import faker from 'faker'; export default Factory.extend({ - address: () => faker.internet.ip(), + address: '127.0.0.1', node_id: (i) => `raft_node_${i}`, protocol_version: '3', - voter: () => faker.datatype.boolean(), - leader: () => faker.datatype.boolean(), + voter: true, + leader: true, }); diff --git a/ui/package.json b/ui/package.json index ceb5ce0049..2e328bd580 100644 --- a/ui/package.json +++ b/ui/package.json @@ -231,7 +231,6 @@ ] }, "dependencies": { - "faker": "^5.5.3", "handlebars": "^4.3.0", "highlight.js": "^10.4.1", "jquery": "^3.5.0", diff --git a/ui/tests/.eslintrc.js b/ui/tests/.eslintrc.js index 182d28b6c2..dbd2a5460c 100644 --- a/ui/tests/.eslintrc.js +++ b/ui/tests/.eslintrc.js @@ -4,7 +4,6 @@ module.exports = { embertest: true, }, globals: { - faker: true, server: true, $: true, authLogout: false,