From e4b4899cc068846029f659ced94e0036b222e938 Mon Sep 17 00:00:00 2001 From: Sam David Date: Mon, 5 Feb 2024 23:39:12 +0530 Subject: [PATCH] upgrade ember-modal-dialog & test refactor --- app/components/file-chart/index.ts | 12 +- .../view-scenario/header/index.ts | 1 - app/models/file.ts | 12 +- app/serializers/file.js | 5 +- mirage/factories/analysis.js | 2 +- .../factories/partner/registration-request.ts | 8 +- mirage/factories/sbom-component.ts | 2 +- package-lock.json | 633 +++--------------- package.json | 2 +- tests/acceptance/file-compare-test.js | 265 ++++++++ tests/acceptance/file-details-test.js | 246 +++++++ tests/acceptance/organization-members-test.js | 369 ++++++++++ tests/acceptance/organization-teams-test.js | 174 +++++ tests/acceptance/partner/clients-nav-test.js | 153 +++++ .../dynamicscan-automation-settings-test.js | 345 ++++++++++ tests/acceptance/sbom-test.js | 205 ++++++ tests/helpers/acceptance-utils.js | 97 +++ .../file-compare/compare-list-test.js | 46 -- .../components/file-compare/header-test.js | 35 +- .../components/file-compare/index-test.js | 80 --- .../vulnerability-analysis-test.js | 50 -- .../integration/components/file-list-test.js | 52 -- .../report-drawer/sbom-reports/index-test.js | 76 +-- .../components/organization-details-test.js | 3 + .../organization-invitation-list-test.js | 185 +---- .../organization-member/list-test.js | 90 +-- .../organization-team/index-test.js | 140 +--- .../components/partner/clients-nav-test.js | 84 --- .../partner/invitation-list-test.js | 12 +- .../registration-request-pending-list-test.js | 102 +-- .../scenario-test.js | 58 -- .../view-scenario/header-test.js | 121 +--- .../components/sbom/app-list-test.js | 62 -- .../components/sbom/app-scan-test.js | 51 +- .../sbom/scan-details/component-list-test.js | 108 +-- 35 files changed, 2060 insertions(+), 1826 deletions(-) create mode 100644 tests/acceptance/file-compare-test.js create mode 100644 tests/acceptance/file-details-test.js create mode 100644 tests/acceptance/organization-members-test.js create mode 100644 tests/acceptance/organization-teams-test.js create mode 100644 tests/acceptance/partner/clients-nav-test.js create mode 100644 tests/acceptance/project-settings/dynamicscan-automation-settings-test.js create mode 100644 tests/acceptance/sbom-test.js create mode 100644 tests/helpers/acceptance-utils.js delete mode 100644 tests/integration/components/partner/clients-nav-test.js diff --git a/app/components/file-chart/index.ts b/app/components/file-chart/index.ts index 3b139ce9d..d95d8c3e3 100644 --- a/app/components/file-chart/index.ts +++ b/app/components/file-chart/index.ts @@ -34,27 +34,27 @@ export default class FileChartComponent extends Component { const severityCountObjects = [ { - value: file?.countRiskCritical, + value: file?.get('countRiskCritical'), name: this.intl.t('critical'), severityType: 'critical', }, { - value: file?.countRiskHigh, + value: file?.get('countRiskHigh'), name: this.intl.t('high'), severityType: 'high', }, { - value: file?.countRiskMedium, + value: file?.get('countRiskMedium'), name: this.intl.t('medium'), severityType: 'medium', }, { - value: file?.countRiskLow, + value: file?.get('countRiskLow'), name: this.intl.t('low'), severityType: 'low', }, { - value: file?.countRiskNone, + value: file?.get('countRiskNone'), name: this.intl.t('passed'), severityType: 'passed', }, @@ -62,7 +62,7 @@ export default class FileChartComponent extends Component { if (this.unknownAnalysisStatus?.status) { severityCountObjects.push({ - value: file?.countRiskUnknown, + value: file?.get('countRiskUnknown'), name: this.intl.t('untested'), severityType: 'none', }); diff --git a/app/components/project-settings/view-scenario/header/index.ts b/app/components/project-settings/view-scenario/header/index.ts index 248456cb1..9478fc8dc 100644 --- a/app/components/project-settings/view-scenario/header/index.ts +++ b/app/components/project-settings/view-scenario/header/index.ts @@ -49,7 +49,6 @@ export default class ProjectSettingsViewScenarioHeaderComponent extends Componen const adapterOptions = { projectId: this.args.project?.id }; await this.scenario.destroyRecord({ adapterOptions }); - this.scenario.unloadRecord(); this.notify.success( this.intl.t('dastAutomation.scenarioDeleted', { diff --git a/app/models/file.ts b/app/models/file.ts index f8aede5c6..0d2c6b169 100644 --- a/app/models/file.ts +++ b/app/models/file.ts @@ -5,7 +5,9 @@ import { attr, belongsTo, hasMany, + SyncHasMany, } from '@ember-data/model'; + import ComputedProperty, { sort } from '@ember/object/computed'; import { computed } from '@ember/object'; import { inject as service } from '@ember/service'; @@ -25,7 +27,7 @@ import SbomFileModel from './sbom-file'; import SubmissionModel from './submission'; const _getAnalysesCount = ( - analysis: AsyncHasMany, + analysis: SyncHasMany, risk: number ) => { return analysis.filter((analysis) => analysis.computedRisk === risk).length; @@ -107,14 +109,14 @@ export default class FileModel extends ModelBaseMixin { @attr('boolean') declare canRunAutomatedDynamicscan: boolean; - @hasMany('tag') - declare tags: AsyncHasMany; + @hasMany('tag', { async: false }) + declare tags: SyncHasMany; @hasMany('file-report', { async: true }) declare reports: AsyncHasMany; - @hasMany('analysis', { inverse: 'file' }) - declare analyses: AsyncHasMany; + @hasMany('analysis', { inverse: 'file', async: false }) + declare analyses: SyncHasMany; @belongsTo('project', { inverse: 'files' }) declare project: AsyncBelongsTo; diff --git a/app/serializers/file.js b/app/serializers/file.js index 10761b1ba..9f48f9d6b 100644 --- a/app/serializers/file.js +++ b/app/serializers/file.js @@ -1,10 +1,9 @@ -/* eslint-disable prettier/prettier */ import DRFSerializer from './drf'; import { EmbeddedRecordsMixin } from '@ember-data/serializer/rest'; export default DRFSerializer.extend(EmbeddedRecordsMixin, { attrs: { analyses: { embedded: 'always' }, - tags: { embedded: 'always'} - } + tags: { embedded: 'always' }, + }, }); diff --git a/mirage/factories/analysis.js b/mirage/factories/analysis.js index c5c106ab0..6ba1051b0 100644 --- a/mirage/factories/analysis.js +++ b/mirage/factories/analysis.js @@ -35,7 +35,7 @@ export default Factory.extend({ findings() { let desc = []; - const uuid = faker.datatype.uuid(); + const uuid = faker.string.uuid(); for (let i = 0; i < 3; i++) { desc.push({ diff --git a/mirage/factories/partner/registration-request.ts b/mirage/factories/partner/registration-request.ts index 6e479e3a7..ed2a44668 100644 --- a/mirage/factories/partner/registration-request.ts +++ b/mirage/factories/partner/registration-request.ts @@ -7,11 +7,11 @@ export default Factory.extend({ return `test${i}@example.test`; }, - createdOn() { + created_on() { return dayjs(faker.date.past()).toISOString(); }, - updatedOn() { + updated_on() { return dayjs(faker.date.recent()).toISOString(); }, @@ -27,11 +27,11 @@ export default Factory.extend({ ]); }, - isActivated() { + is_activated() { return false; }, - approvalStatus() { + approval_status() { return faker.helpers.arrayElement(['pending', 'rejected', 'approved']); }, diff --git a/mirage/factories/sbom-component.ts b/mirage/factories/sbom-component.ts index dc5f8d1bb..40ac0efac 100644 --- a/mirage/factories/sbom-component.ts +++ b/mirage/factories/sbom-component.ts @@ -36,7 +36,7 @@ export default Factory.extend({ }, vulnerabilities_count() { - return faker.helpers.arrayElement([faker.datatype.number(1000), 0]); + return faker.helpers.arrayElement([faker.number.int(1000), 0]); }, remediation: () => faker.lorem.paragraphs(), diff --git a/package-lock.json b/package-lock.json index 4d2a052dc..219bb3f8d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -122,7 +122,7 @@ "ember-intl": "^6.0.0-beta.4", "ember-load-initializers": "^2.1.2", "ember-maybe-import-regenerator": "^0.1.6", - "ember-modal-dialog": "^3.0.1", + "ember-modal-dialog": "^4.1.3", "ember-modifier": "^3.2.7", "ember-named-blocks-polyfill": "^0.2.5", "ember-page-title": "^6.2.2", @@ -4379,6 +4379,44 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, + "node_modules/@ember-decorators/component": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/@ember-decorators/component/-/component-6.1.1.tgz", + "integrity": "sha512-Cj8tY/c0MC/rsipqsiWLh3YVN72DK92edPYamD/HzvftwzC6oDwawWk8RmStiBnG9PG/vntAt41l3S7HSSA+1Q==", + "dev": true, + "dependencies": { + "@ember-decorators/utils": "^6.1.1", + "ember-cli-babel": "^7.1.3" + }, + "engines": { + "node": ">= 8.*" + } + }, + "node_modules/@ember-decorators/object": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/@ember-decorators/object/-/object-6.1.1.tgz", + "integrity": "sha512-cb4CNR9sRoA31J3FCOFLDuR9ztM4wO9w1WlS4JeNRS7Z69SlB/XSXB/vplA3i9OOaXEy/zKWbu5ndZrHz0gvLw==", + "dev": true, + "dependencies": { + "@ember-decorators/utils": "^6.1.1", + "ember-cli-babel": "^7.1.3" + }, + "engines": { + "node": ">= 8.*" + } + }, + "node_modules/@ember-decorators/utils": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/@ember-decorators/utils/-/utils-6.1.1.tgz", + "integrity": "sha512-0KqnoeoLKb6AyoSU65TRF5T85wmS4uDn06oARddwNPxxf/lt5jQlh41uX3W7V/fWL9tPu8x1L1Vvpc80MN1+YA==", + "dev": true, + "dependencies": { + "ember-cli-babel": "^7.1.3" + }, + "engines": { + "node": ">= 8.*" + } + }, "node_modules/@ember-template-lint/todo-utils": { "version": "10.0.0", "resolved": "https://registry.npmjs.org/@ember-template-lint/todo-utils/-/todo-utils-10.0.0.tgz", @@ -29780,6 +29818,20 @@ "integrity": "sha512-QvzAURSbQ0pKdIye2txOzNaHmxtUBXerpY0FJsFXUMKbIZeFm5ht1LS/jFsrncjnmtv8HsG0W2g6c0zUjZWmpA==", "dev": true }, + "node_modules/ember-decorators": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/ember-decorators/-/ember-decorators-6.1.1.tgz", + "integrity": "sha512-63vZPntPn1aqMyeNRLoYjJD+8A8obd+c2iZkJflswpDRNVIsp2m7aQdSCtPt4G0U/TEq2251g+N10maHX3rnJQ==", + "dev": true, + "dependencies": { + "@ember-decorators/component": "^6.1.1", + "@ember-decorators/object": "^6.1.1", + "ember-cli-babel": "^7.7.3" + }, + "engines": { + "node": ">= 8.*" + } + }, "node_modules/ember-destroyable-polyfill": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/ember-destroyable-polyfill/-/ember-destroyable-polyfill-2.0.3.tgz", @@ -30707,157 +30759,6 @@ "mkdirp": "bin/cmd.js" } }, - "node_modules/ember-ignore-children-helper": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/ember-ignore-children-helper/-/ember-ignore-children-helper-1.0.1.tgz", - "integrity": "sha512-AgKkrvd1/hIBWdLn42gITlweVsALUGPYF9fMpQ2IDqp7QnRmtO8ocRbZEmMddPDWY9Xu7W5qO2f35rbD7OSpYw==", - "dev": true, - "dependencies": { - "ember-cli-babel": "^6.8.2" - }, - "engines": { - "node": "^4.5 || 6.* || >= 7.*" - } - }, - "node_modules/ember-ignore-children-helper/node_modules/amd-name-resolver": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/amd-name-resolver/-/amd-name-resolver-1.2.0.tgz", - "integrity": "sha512-hlSTWGS1t6/xq5YCed7YALg7tKZL3rkl7UwEZ/eCIkn8JxmM6fU6Qs/1hwtjQqfuYxlffuUcgYEm0f5xP4YKaA==", - "dev": true, - "dependencies": { - "ensure-posix-path": "^1.0.1" - } - }, - "node_modules/ember-ignore-children-helper/node_modules/babel-plugin-debug-macros": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/babel-plugin-debug-macros/-/babel-plugin-debug-macros-0.2.0.tgz", - "integrity": "sha512-Wpmw4TbhR3Eq2t3W51eBAQSdKlr+uAyF0GI4GtPfMCD12Y4cIdpKC9l0RjNTH/P9isFypSqqewMPm7//fnZlNA==", - "dev": true, - "dependencies": { - "semver": "^5.3.0" - }, - "engines": { - "node": ">=4" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-beta.42" - } - }, - "node_modules/ember-ignore-children-helper/node_modules/broccoli-babel-transpiler": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/broccoli-babel-transpiler/-/broccoli-babel-transpiler-6.5.1.tgz", - "integrity": "sha512-w6GcnkxvHcNCte5FcLGEG1hUdQvlfvSN/6PtGWU/otg69Ugk8rUk51h41R0Ugoc+TNxyeFG1opRt2RlA87XzNw==", - "dev": true, - "dependencies": { - "babel-core": "^6.26.0", - "broccoli-funnel": "^2.0.1", - "broccoli-merge-trees": "^2.0.0", - "broccoli-persistent-filter": "^1.4.3", - "clone": "^2.0.0", - "hash-for-dep": "^1.2.3", - "heimdalljs-logger": "^0.1.7", - "json-stable-stringify": "^1.0.0", - "rsvp": "^4.8.2", - "workerpool": "^2.3.0" - }, - "engines": { - "node": ">= 4" - } - }, - "node_modules/ember-ignore-children-helper/node_modules/broccoli-merge-trees": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/broccoli-merge-trees/-/broccoli-merge-trees-2.0.1.tgz", - "integrity": "sha512-WjaexJ+I8BxP5V5RNn6um/qDRSmKoiBC/QkRi79FT9ClHfldxRyCDs9mcV7mmoaPlsshmmPaUz5jdtcKA6DClQ==", - "dev": true, - "dependencies": { - "broccoli-plugin": "^1.3.0", - "merge-trees": "^1.0.1" - } - }, - "node_modules/ember-ignore-children-helper/node_modules/broccoli-source": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/broccoli-source/-/broccoli-source-1.1.0.tgz", - "integrity": "sha512-ahvqmwF6Yvh6l+sTJJdey4o4ynwSH8swSSBSGmUXGSPPCqBWvquWB/4rWN65ZArKilBFq/29O0yQnZNIf//sTg==", - "dev": true - }, - "node_modules/ember-ignore-children-helper/node_modules/ember-cli-babel": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/ember-cli-babel/-/ember-cli-babel-6.18.0.tgz", - "integrity": "sha512-7ceC8joNYxY2wES16iIBlbPSxwKDBhYwC8drU3ZEvuPDMwVv1KzxCNu1fvxyFEBWhwaRNTUxSCsEVoTd9nosGA==", - "dev": true, - "dependencies": { - "amd-name-resolver": "1.2.0", - "babel-plugin-debug-macros": "^0.2.0-beta.6", - "babel-plugin-ember-modules-api-polyfill": "^2.6.0", - "babel-plugin-transform-es2015-modules-amd": "^6.24.0", - "babel-polyfill": "^6.26.0", - "babel-preset-env": "^1.7.0", - "broccoli-babel-transpiler": "^6.5.0", - "broccoli-debug": "^0.6.4", - "broccoli-funnel": "^2.0.0", - "broccoli-source": "^1.1.0", - "clone": "^2.0.0", - "ember-cli-version-checker": "^2.1.2", - "semver": "^5.5.0" - }, - "engines": { - "node": "^4.5 || 6.* || >= 7.*" - } - }, - "node_modules/ember-ignore-children-helper/node_modules/ember-cli-version-checker": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/ember-cli-version-checker/-/ember-cli-version-checker-2.2.0.tgz", - "integrity": "sha512-G+KtYIVlSOWGcNaTFHk76xR4GdzDLzAS4uxZUKdASuFX0KJE43C6DaqL+y3VTpUFLI2FIkAS6HZ4I1YBi+S3hg==", - "dev": true, - "dependencies": { - "resolve": "^1.3.3", - "semver": "^5.3.0" - }, - "engines": { - "node": ">= 4" - } - }, - "node_modules/ember-ignore-children-helper/node_modules/merge-trees": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-trees/-/merge-trees-1.0.1.tgz", - "integrity": "sha512-O7TWwipLHhc9tErjq3WBvNP7I1g7Wgudl1ZkLqpT7F2MZy1yEdgnI9cpZZxBaqk+wJZu+2b9FE7D3ubUmGFHFA==", - "dev": true, - "dependencies": { - "can-symlink": "^1.0.0", - "fs-tree-diff": "^0.5.4", - "heimdalljs": "^0.2.1", - "heimdalljs-logger": "^0.1.7", - "rimraf": "^2.4.3", - "symlink-or-copy": "^1.0.0" - } - }, - "node_modules/ember-ignore-children-helper/node_modules/rsvp": { - "version": "4.8.5", - "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.5.tgz", - "integrity": "sha512-nfMOlASu9OnRJo1mbEk2cz0D56a1MBNrJ7orjRZQG10XDyuvwksKbuXNp6qa+kbn839HwjwhBzhFmdsaEAfauA==", - "dev": true, - "engines": { - "node": "6.* || >= 7.*" - } - }, - "node_modules/ember-ignore-children-helper/node_modules/semver": { - "version": "5.7.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", - "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", - "dev": true, - "bin": { - "semver": "bin/semver" - } - }, - "node_modules/ember-ignore-children-helper/node_modules/workerpool": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-2.3.4.tgz", - "integrity": "sha512-c2EWrgB9IKHi1jbf4LG9sxKgHYOY+Ej5li6siEGtFecCXWG7eQOqATPEJ0rg1KFETXROEkErc1t5XiNrLG666Q==", - "dev": true, - "dependencies": { - "object-assign": "4.1.1" - } - }, "node_modules/ember-in-element-polyfill": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/ember-in-element-polyfill/-/ember-in-element-polyfill-1.0.1.tgz", @@ -32361,429 +32262,53 @@ "dev": true }, "node_modules/ember-modal-dialog": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/ember-modal-dialog/-/ember-modal-dialog-3.0.3.tgz", - "integrity": "sha512-a3WHPIZMbnM4GDZdyNseClUIKWcI6AZuhXdNpw0XbfKzpocW2vAqhwLmQ17Fo+W5mCwQXU131DAROFWeOP68xQ==", + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/ember-modal-dialog/-/ember-modal-dialog-4.1.3.tgz", + "integrity": "sha512-AJGMTecp1Hic0HM7PpgEBgFcNfYhL6XIy1P5te4mepWlIbP/7RCNv2TC6j1zmsnSfm6bXKpp3XjuF7bJtwmNUQ==", "dev": true, "dependencies": { - "ember-cli-babel": "^7.23.0", - "ember-cli-htmlbars": "^3.0.0", + "@embroider/macros": "^1.0.0", + "@embroider/util": "^1.0.0", + "ember-cli-babel": "^7.26.8", + "ember-cli-htmlbars": "^6.0.1", "ember-cli-version-checker": "^2.1.0", - "ember-ignore-children-helper": "^1.0.1", - "ember-wormhole": "^0.5.5" - }, - "engines": { - "node": "8.* || >= 10.*" - } - }, - "node_modules/ember-modal-dialog/node_modules/amd-name-resolver": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/amd-name-resolver/-/amd-name-resolver-1.2.0.tgz", - "integrity": "sha512-hlSTWGS1t6/xq5YCed7YALg7tKZL3rkl7UwEZ/eCIkn8JxmM6fU6Qs/1hwtjQqfuYxlffuUcgYEm0f5xP4YKaA==", - "dev": true, - "dependencies": { - "ensure-posix-path": "^1.0.1" - } - }, - "node_modules/ember-modal-dialog/node_modules/babel-plugin-debug-macros": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/babel-plugin-debug-macros/-/babel-plugin-debug-macros-0.2.0.tgz", - "integrity": "sha512-Wpmw4TbhR3Eq2t3W51eBAQSdKlr+uAyF0GI4GtPfMCD12Y4cIdpKC9l0RjNTH/P9isFypSqqewMPm7//fnZlNA==", - "dev": true, - "dependencies": { - "semver": "^5.3.0" + "ember-decorators": "^6.1.1", + "ember-wormhole": "^0.6.0" }, "engines": { - "node": ">=4" + "node": "12.* || 14.* || >= 16" }, "peerDependencies": { - "@babel/core": "^7.0.0-beta.42" + "ember-tether": "^3.0.0" + }, + "peerDependenciesMeta": { + "ember-tether": { + "optional": true + } } }, - "node_modules/ember-modal-dialog/node_modules/broccoli-babel-transpiler": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/broccoli-babel-transpiler/-/broccoli-babel-transpiler-6.5.1.tgz", - "integrity": "sha512-w6GcnkxvHcNCte5FcLGEG1hUdQvlfvSN/6PtGWU/otg69Ugk8rUk51h41R0Ugoc+TNxyeFG1opRt2RlA87XzNw==", + "node_modules/ember-modal-dialog/node_modules/ember-cli-version-checker": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/ember-cli-version-checker/-/ember-cli-version-checker-2.2.0.tgz", + "integrity": "sha512-G+KtYIVlSOWGcNaTFHk76xR4GdzDLzAS4uxZUKdASuFX0KJE43C6DaqL+y3VTpUFLI2FIkAS6HZ4I1YBi+S3hg==", "dev": true, "dependencies": { - "babel-core": "^6.26.0", - "broccoli-funnel": "^2.0.1", - "broccoli-merge-trees": "^2.0.0", - "broccoli-persistent-filter": "^1.4.3", - "clone": "^2.0.0", - "hash-for-dep": "^1.2.3", - "heimdalljs-logger": "^0.1.7", - "json-stable-stringify": "^1.0.0", - "rsvp": "^4.8.2", - "workerpool": "^2.3.0" + "resolve": "^1.3.3", + "semver": "^5.3.0" }, "engines": { "node": ">= 4" } }, - "node_modules/ember-modal-dialog/node_modules/broccoli-babel-transpiler/node_modules/broccoli-persistent-filter": { - "version": "1.4.6", - "resolved": "https://registry.npmjs.org/broccoli-persistent-filter/-/broccoli-persistent-filter-1.4.6.tgz", - "integrity": "sha512-0RejLwoC95kv4kta8KAa+FmECJCK78Qgm8SRDEK7YyU0N9Cx6KpY3UCDy9WELl3mCXLN8TokNxc7/hp3lL4lfw==", - "dev": true, - "dependencies": { - "async-disk-cache": "^1.2.1", - "async-promise-queue": "^1.0.3", - "broccoli-plugin": "^1.0.0", - "fs-tree-diff": "^0.5.2", - "hash-for-dep": "^1.0.2", - "heimdalljs": "^0.2.1", - "heimdalljs-logger": "^0.1.7", - "mkdirp": "^0.5.1", - "promise-map-series": "^0.2.1", - "rimraf": "^2.6.1", - "rsvp": "^3.0.18", - "symlink-or-copy": "^1.0.1", - "walk-sync": "^0.3.1" - } - }, - "node_modules/ember-modal-dialog/node_modules/broccoli-babel-transpiler/node_modules/broccoli-persistent-filter/node_modules/rsvp": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-3.6.2.tgz", - "integrity": "sha512-OfWGQTb9vnwRjwtA2QwpG2ICclHC3pgXZO5xt8H2EfgDquO0qVdSb5T88L4qJVAEugbS56pAuV4XZM58UX8ulw==", - "dev": true, - "engines": { - "node": "0.12.* || 4.* || 6.* || >= 7.*" - } - }, - "node_modules/ember-modal-dialog/node_modules/broccoli-babel-transpiler/node_modules/fs-tree-diff": { - "version": "0.5.9", - "resolved": "https://registry.npmjs.org/fs-tree-diff/-/fs-tree-diff-0.5.9.tgz", - "integrity": "sha512-872G8ax0kHh01m9n/2KDzgYwouKza0Ad9iFltBpNykvROvf2AGtoOzPJgGx125aolGPER3JuC7uZFrQ7bG1AZw==", - "dev": true, - "dependencies": { - "heimdalljs-logger": "^0.1.7", - "object-assign": "^4.1.0", - "path-posix": "^1.0.0", - "symlink-or-copy": "^1.1.8" - } - }, - "node_modules/ember-modal-dialog/node_modules/broccoli-babel-transpiler/node_modules/walk-sync": { - "version": "0.3.4", - "resolved": "https://registry.npmjs.org/walk-sync/-/walk-sync-0.3.4.tgz", - "integrity": "sha512-ttGcuHA/OBnN2pcM6johpYlEms7XpO5/fyKIr48541xXedan4roO8cS1Q2S/zbbjGH/BarYDAMeS2Mi9HE5Tig==", - "dev": true, - "dependencies": { - "ensure-posix-path": "^1.0.0", - "matcher-collection": "^1.0.0" - } - }, - "node_modules/ember-modal-dialog/node_modules/broccoli-merge-trees": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/broccoli-merge-trees/-/broccoli-merge-trees-2.0.1.tgz", - "integrity": "sha512-WjaexJ+I8BxP5V5RNn6um/qDRSmKoiBC/QkRi79FT9ClHfldxRyCDs9mcV7mmoaPlsshmmPaUz5jdtcKA6DClQ==", - "dev": true, - "dependencies": { - "broccoli-plugin": "^1.3.0", - "merge-trees": "^1.0.1" - } - }, - "node_modules/ember-modal-dialog/node_modules/broccoli-persistent-filter": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/broccoli-persistent-filter/-/broccoli-persistent-filter-2.3.1.tgz", - "integrity": "sha512-hVsmIgCDrl2NFM+3Gs4Cr2TA6UPaIZip99hN8mtkaUPgM8UeVnCbxelCvBjUBHo0oaaqP5jzqqnRVvb568Yu5g==", - "dev": true, - "dependencies": { - "async-disk-cache": "^1.2.1", - "async-promise-queue": "^1.0.3", - "broccoli-plugin": "^1.0.0", - "fs-tree-diff": "^2.0.0", - "hash-for-dep": "^1.5.0", - "heimdalljs": "^0.2.1", - "heimdalljs-logger": "^0.1.7", - "mkdirp": "^0.5.1", - "promise-map-series": "^0.2.1", - "rimraf": "^2.6.1", - "rsvp": "^4.7.0", - "symlink-or-copy": "^1.0.1", - "sync-disk-cache": "^1.3.3", - "walk-sync": "^1.0.0" - }, - "engines": { - "node": "6.* || >= 8.*" - } - }, - "node_modules/ember-modal-dialog/node_modules/broccoli-source": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/broccoli-source/-/broccoli-source-1.1.0.tgz", - "integrity": "sha512-ahvqmwF6Yvh6l+sTJJdey4o4ynwSH8swSSBSGmUXGSPPCqBWvquWB/4rWN65ZArKilBFq/29O0yQnZNIf//sTg==", - "dev": true - }, - "node_modules/ember-modal-dialog/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/ember-modal-dialog/node_modules/ember-cli-htmlbars": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/ember-cli-htmlbars/-/ember-cli-htmlbars-3.1.0.tgz", - "integrity": "sha512-cgvRJM73IT0aePUG7oQ/afB7vSRBV3N0wu9BrWhHX2zkR7A7cUBI7KC9VPk6tbctCXoM7BRGsCC4aIjF7yrfXA==", - "dev": true, - "dependencies": { - "broccoli-persistent-filter": "^2.3.1", - "hash-for-dep": "^1.5.1", - "json-stable-stringify": "^1.0.1", - "strip-bom": "^3.0.0" - }, - "engines": { - "node": "6.* || 8.* || >= 10.*" - } - }, - "node_modules/ember-modal-dialog/node_modules/ember-cli-version-checker": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/ember-cli-version-checker/-/ember-cli-version-checker-2.2.0.tgz", - "integrity": "sha512-G+KtYIVlSOWGcNaTFHk76xR4GdzDLzAS4uxZUKdASuFX0KJE43C6DaqL+y3VTpUFLI2FIkAS6HZ4I1YBi+S3hg==", - "dev": true, - "dependencies": { - "resolve": "^1.3.3", - "semver": "^5.3.0" - }, - "engines": { - "node": ">= 4" - } - }, - "node_modules/ember-modal-dialog/node_modules/ember-wormhole": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/ember-wormhole/-/ember-wormhole-0.5.5.tgz", - "integrity": "sha512-z8l3gpoKmRA2BnTwvnYRk4jKVcETKHpddsD6kpS+EJ4EfyugadFS3zUqBmRDuJhFbNP8BVBLXlbbATj+Rk1Kgg==", - "dev": true, - "dependencies": { - "ember-cli-babel": "^6.10.0", - "ember-cli-htmlbars": "^2.0.1" - }, - "engines": { - "node": "^4.5 || 6.* || >= 7.*" - } - }, - "node_modules/ember-modal-dialog/node_modules/ember-wormhole/node_modules/broccoli-persistent-filter": { - "version": "1.4.6", - "resolved": "https://registry.npmjs.org/broccoli-persistent-filter/-/broccoli-persistent-filter-1.4.6.tgz", - "integrity": "sha512-0RejLwoC95kv4kta8KAa+FmECJCK78Qgm8SRDEK7YyU0N9Cx6KpY3UCDy9WELl3mCXLN8TokNxc7/hp3lL4lfw==", - "dev": true, - "dependencies": { - "async-disk-cache": "^1.2.1", - "async-promise-queue": "^1.0.3", - "broccoli-plugin": "^1.0.0", - "fs-tree-diff": "^0.5.2", - "hash-for-dep": "^1.0.2", - "heimdalljs": "^0.2.1", - "heimdalljs-logger": "^0.1.7", - "mkdirp": "^0.5.1", - "promise-map-series": "^0.2.1", - "rimraf": "^2.6.1", - "rsvp": "^3.0.18", - "symlink-or-copy": "^1.0.1", - "walk-sync": "^0.3.1" - } - }, - "node_modules/ember-modal-dialog/node_modules/ember-wormhole/node_modules/ember-cli-babel": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/ember-cli-babel/-/ember-cli-babel-6.18.0.tgz", - "integrity": "sha512-7ceC8joNYxY2wES16iIBlbPSxwKDBhYwC8drU3ZEvuPDMwVv1KzxCNu1fvxyFEBWhwaRNTUxSCsEVoTd9nosGA==", - "dev": true, - "dependencies": { - "amd-name-resolver": "1.2.0", - "babel-plugin-debug-macros": "^0.2.0-beta.6", - "babel-plugin-ember-modules-api-polyfill": "^2.6.0", - "babel-plugin-transform-es2015-modules-amd": "^6.24.0", - "babel-polyfill": "^6.26.0", - "babel-preset-env": "^1.7.0", - "broccoli-babel-transpiler": "^6.5.0", - "broccoli-debug": "^0.6.4", - "broccoli-funnel": "^2.0.0", - "broccoli-source": "^1.1.0", - "clone": "^2.0.0", - "ember-cli-version-checker": "^2.1.2", - "semver": "^5.5.0" - }, - "engines": { - "node": "^4.5 || 6.* || >= 7.*" - } - }, - "node_modules/ember-modal-dialog/node_modules/ember-wormhole/node_modules/ember-cli-htmlbars": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/ember-cli-htmlbars/-/ember-cli-htmlbars-2.0.5.tgz", - "integrity": "sha512-3f3PAxdnQ/fhQa8XP/3z4RLRgLHxV8j4Ln75aHbRdemOCjBa048KxL9l+acRLhCulbGQCMnLiIUIC89PAzLrcA==", - "dev": true, - "dependencies": { - "broccoli-persistent-filter": "^1.4.3", - "hash-for-dep": "^1.2.3", - "json-stable-stringify": "^1.0.0", - "strip-bom": "^3.0.0" - }, - "engines": { - "node": ">= 4.0.0" - } - }, - "node_modules/ember-modal-dialog/node_modules/ember-wormhole/node_modules/fs-tree-diff": { - "version": "0.5.9", - "resolved": "https://registry.npmjs.org/fs-tree-diff/-/fs-tree-diff-0.5.9.tgz", - "integrity": "sha512-872G8ax0kHh01m9n/2KDzgYwouKza0Ad9iFltBpNykvROvf2AGtoOzPJgGx125aolGPER3JuC7uZFrQ7bG1AZw==", - "dev": true, - "dependencies": { - "heimdalljs-logger": "^0.1.7", - "object-assign": "^4.1.0", - "path-posix": "^1.0.0", - "symlink-or-copy": "^1.1.8" - } - }, - "node_modules/ember-modal-dialog/node_modules/ember-wormhole/node_modules/rsvp": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-3.6.2.tgz", - "integrity": "sha512-OfWGQTb9vnwRjwtA2QwpG2ICclHC3pgXZO5xt8H2EfgDquO0qVdSb5T88L4qJVAEugbS56pAuV4XZM58UX8ulw==", - "dev": true, - "engines": { - "node": "0.12.* || 4.* || 6.* || >= 7.*" - } - }, - "node_modules/ember-modal-dialog/node_modules/ember-wormhole/node_modules/walk-sync": { - "version": "0.3.4", - "resolved": "https://registry.npmjs.org/walk-sync/-/walk-sync-0.3.4.tgz", - "integrity": "sha512-ttGcuHA/OBnN2pcM6johpYlEms7XpO5/fyKIr48541xXedan4roO8cS1Q2S/zbbjGH/BarYDAMeS2Mi9HE5Tig==", - "dev": true, - "dependencies": { - "ensure-posix-path": "^1.0.0", - "matcher-collection": "^1.0.0" - } - }, - "node_modules/ember-modal-dialog/node_modules/fs-tree-diff": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fs-tree-diff/-/fs-tree-diff-2.0.1.tgz", - "integrity": "sha512-x+CfAZ/lJHQqwlD64pYM5QxWjzWhSjroaVsr8PW831zOApL55qPibed0c+xebaLWVr2BnHFoHdrwOv8pzt8R5A==", - "dev": true, - "dependencies": { - "@types/symlink-or-copy": "^1.2.0", - "heimdalljs-logger": "^0.1.7", - "object-assign": "^4.1.0", - "path-posix": "^1.0.0", - "symlink-or-copy": "^1.1.8" - }, - "engines": { - "node": "6.* || 8.* || >= 10.*" - } - }, - "node_modules/ember-modal-dialog/node_modules/matcher-collection": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/matcher-collection/-/matcher-collection-1.1.2.tgz", - "integrity": "sha512-YQ/teqaOIIfUHedRam08PB3NK7Mjct6BvzRnJmpGDm8uFXpNr1sbY4yuflI5JcEs6COpYA0FpRQhSDBf1tT95g==", - "dev": true, - "dependencies": { - "minimatch": "^3.0.2" - } - }, - "node_modules/ember-modal-dialog/node_modules/merge-trees": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-trees/-/merge-trees-1.0.1.tgz", - "integrity": "sha512-O7TWwipLHhc9tErjq3WBvNP7I1g7Wgudl1ZkLqpT7F2MZy1yEdgnI9cpZZxBaqk+wJZu+2b9FE7D3ubUmGFHFA==", - "dev": true, - "dependencies": { - "can-symlink": "^1.0.0", - "fs-tree-diff": "^0.5.4", - "heimdalljs": "^0.2.1", - "heimdalljs-logger": "^0.1.7", - "rimraf": "^2.4.3", - "symlink-or-copy": "^1.0.0" - } - }, - "node_modules/ember-modal-dialog/node_modules/merge-trees/node_modules/fs-tree-diff": { - "version": "0.5.9", - "resolved": "https://registry.npmjs.org/fs-tree-diff/-/fs-tree-diff-0.5.9.tgz", - "integrity": "sha512-872G8ax0kHh01m9n/2KDzgYwouKza0Ad9iFltBpNykvROvf2AGtoOzPJgGx125aolGPER3JuC7uZFrQ7bG1AZw==", - "dev": true, - "dependencies": { - "heimdalljs-logger": "^0.1.7", - "object-assign": "^4.1.0", - "path-posix": "^1.0.0", - "symlink-or-copy": "^1.1.8" - } - }, - "node_modules/ember-modal-dialog/node_modules/minimist": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", - "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", - "dev": true, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/ember-modal-dialog/node_modules/mkdirp": { - "version": "0.5.6", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", - "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", - "dev": true, - "dependencies": { - "minimist": "^1.2.6" - }, - "bin": { - "mkdirp": "bin/cmd.js" - } - }, - "node_modules/ember-modal-dialog/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", - "dev": true - }, - "node_modules/ember-modal-dialog/node_modules/rsvp": { - "version": "4.8.5", - "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.5.tgz", - "integrity": "sha512-nfMOlASu9OnRJo1mbEk2cz0D56a1MBNrJ7orjRZQG10XDyuvwksKbuXNp6qa+kbn839HwjwhBzhFmdsaEAfauA==", - "dev": true, - "engines": { - "node": "6.* || >= 7.*" - } - }, - "node_modules/ember-modal-dialog/node_modules/semver": { - "version": "5.7.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", - "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "node_modules/ember-modal-dialog/node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", "dev": true, "bin": { "semver": "bin/semver" } }, - "node_modules/ember-modal-dialog/node_modules/sync-disk-cache": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/sync-disk-cache/-/sync-disk-cache-1.3.4.tgz", - "integrity": "sha512-GlkGeM81GPPEKz/lH7QUTbvqLq7K/IUTuaKDSMulP9XQ42glqNJIN/RKgSOw4y8vxL1gOVvj+W7ruEO4s36eCw==", - "dev": true, - "dependencies": { - "debug": "^2.1.3", - "heimdalljs": "^0.2.3", - "mkdirp": "^0.5.0", - "rimraf": "^2.2.8", - "username-sync": "^1.0.2" - } - }, - "node_modules/ember-modal-dialog/node_modules/walk-sync": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/walk-sync/-/walk-sync-1.1.4.tgz", - "integrity": "sha512-nowc9thB/Jg0KW4TgxoRjLLYRPvl3DB/98S89r4ZcJqq2B0alNcKDh6pzLkBSkPMzRSMsJghJHQi79qw0YWEkA==", - "dev": true, - "dependencies": { - "@types/minimatch": "^3.0.3", - "ensure-posix-path": "^1.1.0", - "matcher-collection": "^1.1.1" - } - }, - "node_modules/ember-modal-dialog/node_modules/workerpool": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-2.3.4.tgz", - "integrity": "sha512-c2EWrgB9IKHi1jbf4LG9sxKgHYOY+Ej5li6siEGtFecCXWG7eQOqATPEJ0rg1KFETXROEkErc1t5XiNrLG666Q==", - "dev": true, - "dependencies": { - "object-assign": "4.1.1" - } - }, "node_modules/ember-modifier": { "version": "3.2.7", "resolved": "https://registry.npmjs.org/ember-modifier/-/ember-modifier-3.2.7.tgz", diff --git a/package.json b/package.json index a11b26d98..5cb0923ea 100644 --- a/package.json +++ b/package.json @@ -134,7 +134,7 @@ "ember-intl": "^6.0.0-beta.4", "ember-load-initializers": "^2.1.2", "ember-maybe-import-regenerator": "^0.1.6", - "ember-modal-dialog": "^3.0.1", + "ember-modal-dialog": "^4.1.3", "ember-modifier": "^3.2.7", "ember-named-blocks-polyfill": "^0.2.5", "ember-page-title": "^6.2.2", diff --git a/tests/acceptance/file-compare-test.js b/tests/acceptance/file-compare-test.js new file mode 100644 index 000000000..aa7981aec --- /dev/null +++ b/tests/acceptance/file-compare-test.js @@ -0,0 +1,265 @@ +import { module, test } from 'qunit'; +import { currentURL, click, visit } from '@ember/test-helpers'; +import { setupApplicationTest } from 'ember-qunit'; +import { setupRequiredEndpoints } from '../helpers/acceptance-utils'; +import { setupMirage } from 'ember-cli-mirage/test-support'; +import Service from '@ember/service'; + +class IntegrationStub extends Service { + async configure(user) { + this.currentUser = user; + } + + isPendoEnabled() { + return false; + } + + isCrispEnabled() { + return false; + } +} + +class WebsocketStub extends Service { + async connect() {} + + async configure() {} +} + +module('Acceptance | file compare', function (hooks) { + setupApplicationTest(hooks); + setupMirage(hooks); + + hooks.beforeEach(async function () { + const { vulnerabilities } = await setupRequiredEndpoints(this.server); + + const project = this.server.create('project'); + const profile = this.server.create('profile'); + + const analyses = vulnerabilities.map((v, id) => + this.server.create('analysis', { id, vulnerability: v.id }).toJSON() + ); + + // File Models + const files = this.server.createList('file', 3, { + project: project.id, + profile: profile.id, + analyses, + }); + + // Unknown Analysis Status + this.server.createList('unknown-analysis-status', 3, { + status: true, + }); + + this.server.get('/organizations/:id', (schema, req) => + schema.organizationMes.find(`${req.params.id}`)?.toJSON() + ); + + this.server.get('/projects/:id/files', (schema) => { + const files = schema.files.all().models; + + return { + count: files.length, + next: null, + previous: null, + results: files, + }; + }); + + this.server.get('/v2/files/:id', (schema, req) => { + return schema.files.find(`${req.params.id}`)?.toJSON(); + }); + + this.server.get('/v2/projects/:id', (schema, req) => { + return schema.projects.find(req.params.id).toJSON(); + }); + + this.server.get('/profiles/:id', (schema, req) => + schema.profiles.find(`${req.params.id}`)?.toJSON() + ); + + this.server.get('/profiles/:id/unknown_analysis_status', (_, req) => { + return { + id: req.params.id, + status: true, + }; + }); + + this.owner.register('service:integration', IntegrationStub); + this.owner.register('service:websocket', WebsocketStub); + + this.setProperties({ + project, + fileOld: files[0], + fileRecords: files, + }); + }); + + test('It compares selected files', async function (assert) { + await visit(`/choose/${this.fileOld?.id}`); + + assert.strictEqual(currentURL(), `/choose/${this.fileOld?.id}`); + + const compareFile = this.fileRecords[1]; + const compareFileSelector = `[data-test-fileCompare-compareList-fileOverview='${compareFile.id}']`; + + await click( + `${compareFileSelector} [data-test-fileCompare-fileOverview-selectCheckBox]` + ); + + assert + .dom('[data-test-fileCompare-compareListHeader-compareBtn]') + .exists() + .hasText('Compare'); + + await click('[data-test-fileCompare-compareListHeader-compareBtn]'); + + assert.strictEqual( + currentURL(), + `/dashboard/compare/${this.fileOld.id}...${compareFile.id}` + ); + }); + + test('it compares two selected files', async function (assert) { + await visit(`/project/${this.fileOld?.id}/files`); + + const [baseFile, compareFile] = this.fileRecords; + + const baseFileSelector = `[data-test-fileList-fileOverview='${baseFile.id}']`; + const compareFileSelector = `[data-test-fileList-fileOverview='${compareFile.id}']`; + + // Selects base and compare files + await click( + `${baseFileSelector} [data-test-fileCompare-fileOverview-selectCheckBox]` + ); + + await click( + `${compareFileSelector} [data-test-fileCompare-fileOverview-selectCheckBox]` + ); + + await click('[data-test-fileList-projectOverview-header-compareBtn]'); + + assert.strictEqual( + currentURL(), + `/dashboard/compare/${baseFile?.id}...${compareFile?.id}?referrer=all_uploads` + ); + }); + + test('it redirects to settings page if button is clicked', async function (assert) { + const notify = this.owner.lookup('service:notifications'); + + notify.setDefaultClearDuration(0); + + await visit(`/project/${this.fileOld?.id}/files`); + + const profile = this.server.create('profile', { id: '1' }); + + this.server.get('/profiles/:id/proxy_settings', (_, req) => { + return { + id: req.params.id, + host: '', + port: '', + enabled: false, + }; + }); + + this.server.get( + '/organizations/:id/projects/:projectID/collaborators', + (schema) => { + const results = schema.projectCollaborators.all().models; + return { count: results.length, next: null, previous: null, results }; + } + ); + + this.server.get( + '/organizations/:id/projects/:projectID/teams', + (schema) => { + const results = schema.projectTeams.all().models; + return { count: results.length, next: null, previous: null, results }; + } + ); + + this.server.get('/profiles/:id/device_preference', (schema, req) => { + return schema.devicePreferences.find(`${req.params.id}`)?.toJSON(); + }); + + this.server.get('/projects/:id/available-devices', (schema) => { + const results = schema.projectAvailableDevices.all().models; + + return { count: results.length, next: null, previous: null, results }; + }); + + this.server.get('/profiles/:id/api_scan_options', (_, req) => { + return { api_url_filters: '', id: req.params.id }; + }); + + this.server.create('device-preference', { + id: profile.id, + }); + + this.server.get('/organizations/:id/jira_projects', () => { + return { count: 0, next: null, previous: null, results: [] }; + }); + + this.server.get('/projects/:id/github', () => { + return {}; + }); + + this.server.get('/organizations/:id/github_repos', () => { + return { count: 0, next: null, previous: null, results: [] }; + }); + + assert + .dom('[data-test-fileCompareHeader-projectOverview-settingsBtn]') + .exists(); + + await click('[data-test-fileCompareHeader-projectOverview-settingsBtn]'); + + assert.strictEqual(currentURL(), `/project/${this.fileOld?.id}/settings`); + }); + + test('it renders all upload page breadcrumbs if page referrer is "all_uploads"', async function (assert) { + const [baseFile, compareFile] = this.fileRecords; + + await visit( + `/dashboard/compare/${baseFile?.id}...${compareFile?.id}?referrer=all_uploads` + ); + + const project = this.server.db.projects.find(this.fileOld.project); + + const breadcrumbItems = ['All Projects', project.package_name, 'Compare']; + + assert.dom('[data-test-fileCompare-header]').exists(); + assert.dom('[data-test-fileCompare-breadcrumbContainer]').exists(); + + breadcrumbItems.map((item) => + assert.dom(`[data-test-fileCompare-breadcrumbItem="${item}"]`).exists() + ); + }); + + test('it redirects to all uploads page if compare file edit icon is clicked and page referrer is "all_uploads"', async function (assert) { + const [baseFile, compareFile] = this.fileRecords; + + await visit( + `/dashboard/compare/${baseFile?.id}...${compareFile?.id}?referrer=all_uploads` + ); + + assert.dom('[data-test-fileCompare-header-compareFileEditIcon]').exists(); + + await click('[data-test-fileCompare-header-compareFileEditIcon]'); + + assert.strictEqual(currentURL(), `/project/${baseFile?.id}/files`); + }); + + test('it redirects to compare list page if compare file edit icon is clicked and page referrer is empty', async function (assert) { + const [baseFile, compareFile] = this.fileRecords; + + await visit(`/dashboard/compare/${baseFile?.id}...${compareFile?.id}`); + + assert.dom('[data-test-fileCompare-header-compareFileEditIcon]').exists(); + + await click('[data-test-fileCompare-header-compareFileEditIcon]'); + + assert.strictEqual(currentURL(), `/choose/${baseFile?.id}`); + }); +}); diff --git a/tests/acceptance/file-details-test.js b/tests/acceptance/file-details-test.js new file mode 100644 index 000000000..d7a863985 --- /dev/null +++ b/tests/acceptance/file-details-test.js @@ -0,0 +1,246 @@ +import { module, test } from 'qunit'; +import { currentURL, click, visit, findAll } from '@ember/test-helpers'; +import { setupRequiredEndpoints } from '../helpers/acceptance-utils'; +import { setupApplicationTest } from 'ember-qunit'; +import { setupMirage } from 'ember-cli-mirage/test-support'; +import { t } from 'ember-intl/test-support'; +import Service from '@ember/service'; + +import { serializer } from 'irene/tests/test-utils'; +import ENUMS from 'irene/enums'; + +class IntegrationStub extends Service { + async configure(user) { + this.currentUser = user; + } + + isPendoEnabled() { + return false; + } + + isCrispEnabled() { + return false; + } +} + +class WebsocketStub extends Service { + async connect() {} + + async configure() {} +} + +class PollServiceStub extends Service { + callback = null; + interval = null; + + startPolling(cb, interval) { + function stop() {} + + this.callback = cb; + this.interval = interval; + + return stop; + } +} + +module('Acceptance | file details', function (hooks) { + setupApplicationTest(hooks); + setupMirage(hooks); + + hooks.beforeEach(async function () { + const { organization, vulnerabilities } = await setupRequiredEndpoints( + this.server + ); + + this.owner.register('service:integration', IntegrationStub); + this.owner.register('service:websocket', WebsocketStub); + this.owner.register('service:poll', PollServiceStub); + + const analyses = vulnerabilities.map((v, id) => + this.server.create('analysis', { id, vulnerability: v.id }).toJSON() + ); + + const profile = this.server.create('profile', { id: '1' }); + + const project = this.server.create('project', { + active_profile_id: profile.id, + }); + + const file = this.server.create('file', { + is_static_done: true, + dynamic_status: ENUMS.DYNAMIC_STATUS.NONE, + project: project.id, + analyses, + }); + + this.server.createList('unknown-analysis-status', 3, { + status: true, + }); + + this.server.create('dynamicscan', { expires_on: null }); + + this.server.create('device-preference', { + id: profile.id, + }); + + // Server mocks + this.server.get('/organizations/:id', (schema, req) => + schema.organizationMes.find(`${req.params.id}`)?.toJSON() + ); + + this.server.get('organizations/:id/projects', (schema) => { + const results = schema.projects.all().models; + + return { count: results.length, next: null, previous: null, results }; + }); + + this.server.get('/v2/files/:id', (schema, req) => { + return schema.files.find(`${req.params.id}`)?.toJSON(); + }); + + this.server.get('/v2/projects/:id', (schema, req) => { + return schema.projects.find(req.params.id).toJSON(); + }); + + this.server.get('/profiles/:id', (schema, req) => + schema.profiles.find(`${req.params.id}`)?.toJSON() + ); + + this.server.get('/profiles/:id/unknown_analysis_status', (_, req) => { + return { + id: req.params.id, + status: true, + }; + }); + + this.server.get('/dynamicscan/:id', (schema, req) => { + return schema.dynamicscans.find(`${req.params.id}`)?.toJSON(); + }); + + this.server.get('/profiles/:id/device_preference', (schema, req) => { + return schema.devicePreferences.find(`${req.params.id}`)?.toJSON(); + }); + + this.server.get('/projects/:id/available-devices', (schema) => { + const results = schema.projectAvailableDevices.all().models; + + return { count: results.length, next: null, previous: null, results }; + }); + + this.server.get('/manualscans/:id', (schema, req) => { + return { id: req.params.id }; + }); + + this.setProperties({ + project, + file, + profile, + organization, + }); + }); + + test('it renders and triggers go to latest file CTA button when current file is not latest and no sbom file exists', async function (assert) { + this.organization.update({ + features: { + sbom: true, + }, + }); + + this.server.create('file-report', { id: '1', progress: 100 }); + + // Creates a new file with id of 2 + const latestFile = this.server.create('file', { + dynamic_status: ENUMS.DYNAMIC_STATUS.NONE, + }); + + // project that has a latest file of id 2 + this.project.update({ last_file_id: latestFile.id }); + + // Updates file with id of 1 with project that has a latest file of id 2 + latestFile.update({ is_static_done: true, project: this.project.id }); + + this.server.get('/v2/files/:fileId/reports', (schema) => { + return serializer(schema.fileReports.all(), true); + }); + + this.server.get('/v2/sb_projects/:id', (schema, req) => { + return schema.sbomProjects.find(req.params.id)?.toJSON(); + }); + + this.server.get('/v2/sb_reports/:id', (schema, req) => { + return schema.sbomReports.find(`${req.params.id}`)?.toJSON(); + }); + + this.server.get('/v2/sb_files/:id', (schema, req) => { + return schema.sbomFiles.find(`${req.params.id}`)?.toJSON(); + }); + + this.server.get('/v2/files/:id/sb_file', () => { + return { + id: 1, + file: 1, + }; + }); + + this.server.get('/v2/sb_files/:id/sb_reports', (schema) => { + const results = schema.sbomReports.all().models; + return { count: results.length, next: null, previous: null, results }; + }); + + // Current file in route has an fileid of 1 + await visit('/dashboard/file/1'); + + assert.dom('[data-test-fileReportBtn]').exists(); + + await click('[data-test-fileReportBtn]'); + + assert + .dom(`[data-test-fileReportDrawer-groupItem="sbom-reports"]`) + .exists(); + + await click( + '[data-test-fileReportDrawer-groupItem="sbom-reports"] [data-test-ak-accordion-summary]' + ); + + assert + .dom( + `[data-test-fileReportDrawer-groupItem="sbom-reports"] [data-test-ak-accordion-content-wrapper]` + ) + .exists() + .hasClass(/expanded/); + + assert + .dom('[data-test-fileReportDrawer-sbomReports-latestFileCTABtn]') + .exists() + .hasText(t('fileReport.goToLatestFile')); + + await click('[data-test-fileReportDrawer-sbomReports-latestFileCTABtn]'); + + assert.strictEqual(currentURL(), `/dashboard/file/${latestFile.id}`); + }); + + test('test analysis row click to navigate to analysis page', async function (assert) { + this.server.get('/v2/analyses/:id', (schema, req) => { + return schema.analyses.find(`${req.params.id}`)?.toJSON(); + }); + + await visit('/dashboard/file/1'); + + assert + .dom('[data-test-vulnerability-analysis-title]') + .hasText(t('vulnerabilityDetails')); + + const rows = findAll('[data-test-vulnerability-analysis-row]'); + + await click(rows[1]); + + const analyses = this.file.analyses + .toArray() + .sort((a, b) => b.computed_risk - a.computed_risk); // sort by computedRisk:desc + + assert.strictEqual( + currentURL(), + `/dashboard/file/${this.file.id}/analysis/${analyses[1].id}` + ); + }); +}); diff --git a/tests/acceptance/organization-members-test.js b/tests/acceptance/organization-members-test.js new file mode 100644 index 000000000..7f688e3d8 --- /dev/null +++ b/tests/acceptance/organization-members-test.js @@ -0,0 +1,369 @@ +import { module, test } from 'qunit'; + +import { + click, + visit, + findAll, + currentURL, + fillIn, + triggerEvent, +} from '@ember/test-helpers'; + +import { setupApplicationTest } from 'ember-qunit'; +import { setupRequiredEndpoints } from '../helpers/acceptance-utils'; +import { setupMirage } from 'ember-cli-mirage/test-support'; +import { t } from 'ember-intl/test-support'; +import { Response } from 'miragejs'; +import Service from '@ember/service'; +import dayjs from 'dayjs'; + +class IntegrationStub extends Service { + async configure(user) { + this.currentUser = user; + } + + isPendoEnabled() { + return false; + } + + isCrispEnabled() { + return false; + } +} + +class WebsocketStub extends Service { + async connect() {} + + async configure() {} +} + +module('Acceptance | organization members', function (hooks) { + setupApplicationTest(hooks); + setupMirage(hooks); + + hooks.beforeEach(async function () { + await setupRequiredEndpoints(this.server); + + const organizationMembers = this.server.createList( + 'organization-member', + 5 + ); + + const users = this.server.createList('organization-user', 5); + + // 0 is member, 1 is owner, 2 is admin + organizationMembers.forEach((orgMember, index) => { + orgMember.update({ + role: index === 1 ? 0 : index === 3 ? 2 : 1, + }); + }); + + organizationMembers[4].update({ + is_active: false, + }); + + users[4].update({ + is_active: false, + }); + + const organizationInvitations = this.server.createList( + 'organization-invitation', + 3 + ); + + organizationInvitations + .filter((oi) => Boolean(oi.team)) + .forEach((oi) => { + this.server.create('organization-team', { id: oi.team }); + }); + + this.owner.register('service:integration', IntegrationStub); + this.owner.register('service:websocket', WebsocketStub); + + this.setProperties({ + organizationInvitations, + }); + }); + + test.each( + 'test organization user invitation delete', + [{ fail: false }, { fail: true }], + async function (assert, { fail }) { + const notify = this.owner.lookup('service:notifications'); + + notify.setDefaultClearDuration(0); + + this.server.get('/organizations/:id/invitations', (schema) => { + const results = schema.organizationInvitations.all().models; + + return { count: results.length, next: null, previous: null, results }; + }); + + this.server.delete( + '/organizations/:id/invitations/:inviteId', + (schema, req) => { + if (!fail) { + schema.db.organizationInvitations.remove(req.params.inviteId); + } + + return new Response(fail ? 500 : 204); + } + ); + + this.server.get('/organizations/:id/users/:userId', (schema, req) => { + return schema.organizationUsers.find(req.params.userId)?.toJSON(); + }); + + this.server.get('/organizations/:id/teams/:teamId', (schema, req) => { + return schema.organizationTeams.find(req.params.teamId)?.toJSON(); + }); + + await visit('/organization/users'); + + assert.dom('[data-test-invitation-list]').exists(); + + const contentRows = findAll('[data-test-invitation-list-row]'); + + const firstRow = contentRows[0].querySelectorAll( + '[data-test-invitation-list-cell]' + ); + + assert + .dom('[data-test-invitation-delete-btn]', firstRow[4]) + .exists() + .isNotDisabled(); + + await click(`#${firstRow[4].id} [data-test-invitation-delete-btn]`); + + assert.dom('[data-test-ak-modal-header]').hasText(t('confirm')); + + assert + .dom('[data-test-confirmbox-description]') + .hasText(t('confirmBox.deleteInvitation')); + + assert + .dom('[data-test-confirmbox-confirmBtn]') + .exists() + .isNotDisabled() + .hasText(t('delete')); + + assert + .dom('[data-test-confirmbox-cancelBtn]') + .exists() + .isNotDisabled() + .hasText(t('cancel')); + + await click('[data-test-confirmbox-confirmBtn]'); + + if (fail) { + assert.strictEqual( + findAll('[data-test-invitation-list-row]').length, + this.organizationInvitations.length + ); + + assert.dom('[data-test-ak-modal-header]').exists(); + assert.dom('[data-test-confirmbox-confirmBtn]').exists(); + } else { + assert.strictEqual( + findAll('[data-test-invitation-list-row]').length, + this.organizationInvitations.length - 1 + ); + + assert.dom('[data-test-ak-modal-header]').doesNotExist(); + assert.dom('[data-test-confirmbox-confirmBtn]').doesNotExist(); + } + } + ); + + test('test organization user invitation list reload', async function (assert) { + const notify = this.owner.lookup('service:notifications'); + + notify.setDefaultClearDuration(0); + + // remove all invites + this.server.db.organizationInvitations.remove(); + + const createOrgInvite = ({ email }) => + this.server.create('organization-invitation', { email, team: null }); + + this.server.get('/organizations/:id/invitations', (schema) => { + const results = schema.organizationInvitations.all().models; + return { count: results.length, next: null, previous: null, results }; + }); + + this.server.post('/organizations/:id/invitations', (_, req) => { + const data = JSON.parse(req.requestBody); + + const invite = createOrgInvite(data); + + return invite.toJSON(); + }); + + this.server.get('/organizations/:id/users/:userId', (schema, req) => { + const user = schema.organizationUsers.find(req.params.userId); + + return user?.toJSON(); + }); + + this.server.get('/organizations/:id/teams/:teamId', (schema, req) => { + const user = schema.organizationTeams.find(req.params.teamId); + + return user?.toJSON(); + }); + + await visit('/organization/users'); + + assert + .dom('[data-test-invite-member-btn]') + .isNotDisabled() + .hasText('Invite Users'); + + assert.dom('[data-test-invitation-list-title]').doesNotExist(); + assert.dom('[data-test-invitation-list]').doesNotExist(); + + await click('[data-test-invite-member-btn]'); + + const emailText = 'test@mail.com, test1@mail.com'; + + assert + .dom('[data-test-invite-member-input]') + .exists() + .isNotDisabled() + .hasNoValue(); + + await fillIn('[data-test-invite-member-input]', emailText); + + assert.dom('[data-test-invite-member-input]').hasValue(emailText); + + await click('[data-test-send-invite-btn]'); + + assert + .dom('[data-test-invitation-list-title]') + .exists() + .hasText(t('pendingInvitations')); + + assert.dom('[data-test-invitation-list]').exists(); + + const contentRows = findAll('[data-test-invitation-list-row]'); + + assert.strictEqual(contentRows.length, 2); + + const firstRow = contentRows[0].querySelectorAll( + '[data-test-invitation-list-cell]' + ); + + assert.dom(firstRow[0]).hasText('test@mail.com'); + assert.dom(firstRow[1]).hasText(t('organization')); + + assert + .dom(firstRow[2]) + .hasText(dayjs(this.organizationInvitations[0].created_on).fromNow()); + + assert + .dom('[data-test-invitation-resend-btn]', firstRow[3]) + .exists() + .isNotDisabled(); + }); + + test('test organization user inactive user checkbox', async function (assert) { + this.server.get('/organizations/:id/invitations', () => { + return { count: 0, next: null, previous: null, results: [] }; + }); + + this.server.get('/organizations/:id/members', (schema, req) => { + const showOnlyActive = req.queryParams.is_active + ? JSON.parse(req.queryParams.is_active) + : req.queryParams.is_active; + + this.set('is_active', showOnlyActive); + + const results = showOnlyActive + ? schema.organizationMembers.where((it) => it.is_active).models + : schema.organizationMembers.all().models; + + return { count: results.length, next: null, previous: null, results }; + }); + + this.server.get('/organizations/:id/users/:userId', (schema, req) => { + const user = schema.organizationUsers.find(req.params.userId); + + return user?.toJSON(); + }); + + await visit('/organization/users'); + + let contentRows = findAll('[data-test-org-user-row]'); + + // 4 active members created in this test and 1 for current user + assert.strictEqual(contentRows.length, 5); + + assert.true(this.is_active); + + await click('[data-test-inactive-user-label]'); + + assert.dom('[data-test-inactive-user-checkbox]').isChecked(); + + assert.ok(currentURL().includes('show_inactive_user=true')); + + contentRows = findAll('[data-test-org-user-row]'); + + // 4 active, 1 inactive and 1 for current user + assert.strictEqual(contentRows.length, 6); + + assert.strictEqual(typeof this.is_active, 'undefined'); + + await click('[data-test-inactive-user-label]'); + + assert.dom('[data-test-inactive-user-checkbox]').isNotChecked(); + + contentRows = findAll('[data-test-org-user-row]'); + + // 4 active members and 1 for current user + assert.strictEqual(contentRows.length, 5); + + assert.ok(currentURL().includes('show_inactive_user=false')); + }); + + test('test organization user search', async function (assert) { + this.server.get('/organizations/:id/invitations', () => { + return { count: 0, next: null, previous: null, results: [] }; + }); + + this.server.get('/organizations/:id/members', (schema, req) => { + this.set('query', req.queryParams.q); + + const results = schema.organizationMembers.all().models; + + return { count: results.length, next: null, previous: null, results }; + }); + + this.server.get('/organizations/:id/users/:userId', (schema, req) => { + const user = schema.organizationUsers.find(req.params.userId); + + return user?.toJSON(); + }); + + await visit('/organization/users'); + + const contentRows = findAll('[data-test-org-user-row]'); + + // 4 active, 1 inactive and 1 for current user + assert.strictEqual(contentRows.length, 6); + + assert + .dom('[data-test-user-search-input]') + .exists() + .isNotDisabled() + .hasNoValue(); + + assert.strictEqual(this.query, ''); + + await fillIn('[data-test-user-search-input]', 'test'); + await triggerEvent('[data-test-user-search-input]', 'keyup'); + + assert.dom('[data-test-user-search-input]').hasValue('test'); + + assert.strictEqual(this.query, 'test'); + assert.ok(currentURL().includes('user_query=test')); + }); +}); diff --git a/tests/acceptance/organization-teams-test.js b/tests/acceptance/organization-teams-test.js new file mode 100644 index 000000000..c9c0cc0b9 --- /dev/null +++ b/tests/acceptance/organization-teams-test.js @@ -0,0 +1,174 @@ +import { module, test } from 'qunit'; + +import { + click, + visit, + findAll, + currentURL, + fillIn, + triggerEvent, +} from '@ember/test-helpers'; + +import { setupApplicationTest } from 'ember-qunit'; +import { setupRequiredEndpoints } from '../helpers/acceptance-utils'; +import { setupMirage } from 'ember-cli-mirage/test-support'; +import { t } from 'ember-intl/test-support'; +import { Response } from 'miragejs'; +import Service from '@ember/service'; + +class IntegrationStub extends Service { + async configure(user) { + this.currentUser = user; + } + + isPendoEnabled() { + return false; + } + + isCrispEnabled() { + return false; + } +} + +class WebsocketStub extends Service { + async connect() {} + + async configure() {} +} + +module('Acceptance | organization teams', function (hooks) { + setupApplicationTest(hooks); + setupMirage(hooks); + + hooks.beforeEach(async function () { + await setupRequiredEndpoints(this.server); + + const organizationTeams = this.server.createList('organization-team', 3); + + this.owner.register('service:integration', IntegrationStub); + this.owner.register('service:websocket', WebsocketStub); + + this.setProperties({ + organizationTeams, + }); + }); + + test('test organization-team search input & query', async function (assert) { + this.server.get('/organizations/:id/teams', (schema, req) => { + this.set('query', req.queryParams.q); + + const results = schema.organizationTeams.all().models; + + return { count: results.length, next: null, previous: null, results }; + }); + + await visit('/organization/teams'); + + assert.dom('[data-test-orgTeamSearch-input]').isNotDisabled().hasNoValue(); + assert.notOk(this.query); + + await fillIn('[data-test-orgTeamSearch-input]', 'test'); + await triggerEvent('[data-test-orgTeamSearch-input]', 'keyup'); + + assert.dom('[data-test-orgTeamSearch-input]').hasValue('test'); + assert.strictEqual(this.query, 'test'); + + assert.ok(currentURL().includes('team_query=test')); + }); + + test.each( + 'test organization-team create team', + [{ fail: false }, { fail: true }], + async function (assert, { fail }) { + const notify = this.owner.lookup('service:notifications'); + + notify.setDefaultClearDuration(0); + + const server = this.server; + + this.server.get('/organizations/:id/teams', (schema) => { + const results = schema.organizationTeams + .all() + .models.sortBy('created_on'); + + return { count: results.length, next: null, previous: null, results }; + }); + + this.server.post('/organizations/:id/teams', (schema, req) => { + return fail + ? new Response(500) + : server + .create('organization-team', { + name: JSON.parse(req.requestBody).name, + created_on: Date(), + }) + .toJSON(); + }); + + this.server.get('/organizations/:id', (schema, req) => + schema.organizations.find(`${req.params.id}`)?.toJSON() + ); + + await visit('/organization/teams'); + + assert + .dom('[data-test-orgCreateTeam-btn]') + .isNotDisabled() + .hasText(t('createTeam')); + + const teamList = findAll('[data-test-orgTeamOverview]'); + + assert.strictEqual(teamList.length, this.organizationTeams.length); + + await click('[data-test-orgCreateTeam-btn]'); + + assert.dom('[data-test-ak-modal-header]').hasText(t('createTeam')); + + assert.dom('[data-test-form-label]').hasText(t('createTeamInputLabel')); + + assert + .dom('[data-test-orgCreateTeam-input]') + .hasNoValue() + .isNotDisabled(); + + assert + .dom('[data-test-orgCreateTeam-submitBtn]') + .hasText(t('createTeam')) + .isNotDisabled(); + + // empty input case + await click('[data-test-orgCreateTeam-submitBtn]'); + + // TODO: find a way to check notification message + + // fill value + await fillIn('[data-test-orgCreateTeam-input]', 'testTeam'); + + await click('[data-test-orgCreateTeam-submitBtn]'); + + if (fail) { + assert.dom('[data-test-ak-modal-header]').exists(); + assert.dom('[data-test-orgCreateTeam-submitBtn]').exists(); + + assert + .dom('[data-test-orgCreateTeam-input]') + .exists() + .hasValue('testTeam'); + + assert.strictEqual(teamList.length, this.organizationTeams.length); + } else { + assert.dom('[data-test-ak-modal-header]').doesNotExist(); + assert.dom('[data-test-orgCreateTeam-submitBtn]').doesNotExist(); + assert.dom('[data-test-orgCreateTeam-input]').doesNotExist(); + + const teamList = findAll('[data-test-orgTeamOverview]'); + + assert.strictEqual(teamList.length, this.organizationTeams.length + 1); + + assert + .dom('[data-test-orgTeamOverview-name]', teamList[0]) + .hasText('testTeam'); + } + } + ); +}); diff --git a/tests/acceptance/partner/clients-nav-test.js b/tests/acceptance/partner/clients-nav-test.js new file mode 100644 index 000000000..42ce7c4f0 --- /dev/null +++ b/tests/acceptance/partner/clients-nav-test.js @@ -0,0 +1,153 @@ +import { module, test } from 'qunit'; +import { currentURL, visit } from '@ember/test-helpers'; +import { setupApplicationTest } from 'ember-qunit'; +import { setupRequiredEndpoints } from 'irene/tests/helpers/acceptance-utils'; +import { setupMirage } from 'ember-cli-mirage/test-support'; +import { t } from 'ember-intl/test-support'; +import Service from '@ember/service'; + +import styles from 'irene/components/partner/clients-nav/index.scss'; + +class IntegrationStub extends Service { + async configure(user) { + this.currentUser = user; + } + + isPendoEnabled() { + return false; + } + + isCrispEnabled() { + return false; + } +} + +class WebsocketStub extends Service { + async connect() {} + + async configure() {} +} + +module('Acceptance | partner/clients nav', function (hooks) { + setupApplicationTest(hooks); + setupMirage(hooks); + + hooks.beforeEach(async function () { + const { currentOrganizationMe } = await setupRequiredEndpoints(this.server); + + currentOrganizationMe.update({ + can_access_partner_dashboard: true, + }); + + const partner = this.server.create('partner/partner'); + + this.server.createList('partner/partnerclient', 2); + this.server.createList('partner/registration-request', 15); + + this.owner.register('service:integration', IntegrationStub); + this.owner.register('service:websocket', WebsocketStub); + + this.server.get('/v2/partners/:id', (schema) => { + return schema['partner/partners'].first()?.toJSON(); + }); + + this.server.get('/v2/partnerclients', (schema) => { + const results = schema['partner/partnerclients'].all().models; + + return { + count: results.length, + previous: null, + next: null, + results, + }; + }); + + this.server.get('/v2/partners/:id/registration_requests', (schema, req) => { + const status = req.queryParams.approval_status; + + const results = schema['partner/registrationRequests'].where( + (it) => it.approval_status === status + ).models; + + return { + count: results.length, + previous: null, + next: null, + results, + }; + }); + + this.setProperties({ + partner, + }); + }); + + test('it should render overview & invitations tabs always', async function (assert) { + await visit('/partner/clients/overview'); + + assert.dom('[data-test-clients-nav]').exists(); + + assert.dom('[data-test-nav-tab="overview"]').exists(); + assert.dom('[data-test-nav-tab="invitations"]').exists(); + + assert.dom('[data-test-nav-tab="overview"]').hasText(t('overview')); + assert.dom('[data-test-nav-tab="invitations"]').hasText(t('invitations')); + }); + + test('it should not render registration requests tab if admin_registration privilege is false', async function (assert) { + this.partner.update({ + access: { + admin_registration: false, + }, + }); + + await visit('/partner/clients/overview'); + + assert.dom('[data-test-nav-tab="registration-requests"]').doesNotExist(); + }); + + test('it should render registration requests tab if admin_registration privilege is true', async function (assert) { + this.partner.update({ + access: { + admin_registration: true, + }, + }); + + await visit('/partner/clients/overview'); + + assert.dom('[data-test-nav-tab="registration-requests"]').exists(); + + assert + .dom('[data-test-nav-tab="registration-requests"]') + .hasText(t('registrationRequests')); + }); + + test('it should activate tab of current route', async function (assert) { + this.partner.update({ + access: { + admin_registration: true, + }, + }); + + // current route: overview + await visit('/partner/clients/overview'); + + assert.dom('[data-test-nav-tab="overview"]').hasClass(styles['active']); + assert.strictEqual(currentURL(), '/partner/clients/overview'); + + // current route: invitations + await visit('/partner/clients/invitations'); + + assert.dom('[data-test-nav-tab="invitations"]').hasClass(styles['active']); + assert.strictEqual(currentURL(), '/partner/clients/invitations'); + + // current route: registration-requests + await visit('/partner/clients/registration-requests'); + + assert + .dom('[data-test-nav-tab="registration-requests"]') + .hasClass(styles['active']); + + assert.strictEqual(currentURL(), '/partner/clients/registration-requests'); + }); +}); diff --git a/tests/acceptance/project-settings/dynamicscan-automation-settings-test.js b/tests/acceptance/project-settings/dynamicscan-automation-settings-test.js new file mode 100644 index 000000000..6a5018173 --- /dev/null +++ b/tests/acceptance/project-settings/dynamicscan-automation-settings-test.js @@ -0,0 +1,345 @@ +import { module, test } from 'qunit'; + +import { + visit, + currentURL, + click, + fillIn, + findAll, + triggerEvent, + find, +} from '@ember/test-helpers'; + +import { setupApplicationTest } from 'ember-qunit'; +import { setupRequiredEndpoints } from 'irene/tests/helpers/acceptance-utils'; +import { setupMirage } from 'ember-cli-mirage/test-support'; +import { t } from 'ember-intl/test-support'; +import Service from '@ember/service'; +import { Response } from 'miragejs'; + +class IntegrationStub extends Service { + async configure(user) { + this.currentUser = user; + } + + isPendoEnabled() { + return false; + } + + isCrispEnabled() { + return false; + } +} + +class WebsocketStub extends Service { + async connect() {} + + async configure() {} +} + +const selectors = { + addScenarioBtn: '[data-test-genSettings-dynScanAutoSettings-scenarioAddBtn]', + scenarioNameTextfield: + '[data-test-genSettings-dynScanAutoSettings-scenarioAddModal-scenarioNameTextfield]', + scenarioAddConfirmBtn: + '[data-test-genSettings-dynScanAutoSettings-scenarioAddModal-confirmBtn]', + scenarioTableRow: + '[data-test-genSettings-dynScanAutoSettings-scenarioTableRow]', + scenarioStatusToggle: + '[data-test-projectSettings-dastScenario-toggle] [data-test-toggle-input]', + deleteDefaultScenarioTooltip: + '[data-test-projectSettings-viewScenarioHeader-deleteDefaultScenarioInfo-tooltip]', + deleteScenarioModalTrigger: + '[data-test-projectSettings-viewScenarioHeader-deleteScenarioModalTrigger]', + deleteConfirmTextSelector: + '[data-test-projectSettings-viewScenario-deleteScenarioConfirmText]', + deleteBtnSelector: + '[data-test-projectSettings-viewScenario-deleteScenarioDeleteBtn]', + deleteCancelBtnSelector: + '[data-test-projectSettings-viewScenario-deleteScenarioCancelBtn]', +}; + +module( + 'Acceptance | project settings/dynamicscan automation settings', + function (hooks) { + setupApplicationTest(hooks); + setupMirage(hooks); + + hooks.beforeEach(async function () { + const { vulnerabilities, organization } = await setupRequiredEndpoints( + this.server + ); + + organization.update({ + features: { + dynamicscan_automation: true, + }, + }); + + const project = this.server.create('project'); + const profile = this.server.create('profile'); + + const analyses = vulnerabilities.map((v, id) => + this.server.create('analysis', { id, vulnerability: v.id }).toJSON() + ); + + // File Models + const files = this.server.createList('file', 3, { + project: project.id, + profile: profile.id, + analyses, + }); + + this.server.create('device-preference', { + id: profile.id, + }); + + this.server.create('proxy-setting', { id: profile.id }); + this.server.create('dynamicscan-mode', { id: profile.id }); + + this.owner.register('service:integration', IntegrationStub); + this.owner.register('service:websocket', WebsocketStub); + + this.server.get('/v2/projects/:id', (schema, req) => { + return schema.projects.find(req.params.id).toJSON(); + }); + + this.server.get('/profiles/:id', (schema, req) => + schema.profiles.find(`${req.params.id}`)?.toJSON() + ); + + this.server.get('/dynamicscan/:id', (schema, req) => { + return schema.dynamicscans.find(`${req.params.id}`)?.toJSON(); + }); + + this.server.get('/profiles/:id/device_preference', (schema, req) => { + return schema.devicePreferences.find(`${req.params.id}`)?.toJSON(); + }); + + this.server.get('/projects/:id/available-devices', (schema) => { + const results = schema.projectAvailableDevices.all().models; + + return { count: results.length, next: null, previous: null, results }; + }); + + this.server.get('/profiles/:id/proxy_settings', (schema, req) => { + return schema.proxySettings.find(`${req.params.id}`)?.toJSON(); + }); + + this.server.get('/profiles/:id/api_scan_options', (_, req) => ({ + id: req.params.id, + api_url_filters: '', + })); + + this.server.get( + '/organizations/:id/projects/:projectId/collaborators', + (schema) => { + const results = schema.projectCollaborators.all().models; + + return { count: results.length, next: null, previous: null, results }; + } + ); + + this.server.get( + '/organizations/:orgId/projects/:projectId/teams', + (schema) => { + const results = schema.projectTeams.all().models; + + return { count: results.length, next: null, previous: null, results }; + } + ); + + this.server.get('/profiles/:id/dynamicscan_mode', (schema, req) => { + return schema.dynamicscanModes.find(req.params.id).toJSON(); + }); + + this.server.get('/v2/scan_parameter_groups/:id', (schema, req) => + schema.scanParameterGroups.find(req.params.id).toJSON() + ); + + this.server.get( + '/v2/projects/:projectId/scan_parameter_groups/:id', + (schema, req) => schema.scanParameterGroups.find(req.params.id).toJSON() + ); + + this.server.get( + '/v2/projects/:projectId/scan_parameter_groups', + function (schema) { + const data = schema.scanParameterGroups.all().models; + + return { + count: data.length, + next: null, + previous: null, + results: data, + }; + } + ); + + this.server.get( + '/v2/scan_parameter_groups/:id/scan_parameters', + (schema) => { + const data = schema.scanParameters.all().models; + + return { + count: data.length, + next: null, + previous: null, + results: data, + }; + } + ); + + this.server.get( + '/organizations/:id/github_repos', + () => new Response(404, {}, { detail: 'Github not integrated' }) + ); + + this.server.get( + '/projects/:id/github', + () => new Response(400, {}, { detail: 'Github not integrated' }) + ); + + this.server.get( + '/organizations/:id/jira_projects', + () => new Response(404, {}, { detail: 'JIRA not integrated' }) + ); + + this.server.get( + '/projects/:id/jira', + () => new Response(404, {}, { detail: 'JIRA not integrated' }) + ); + + // to dissmiss notification quickly + const notify = this.owner.lookup('service:notifications'); + + notify.setDefaultClearDuration(0); + + this.setProperties({ + project, + files, + }); + }); + + test('it navigates to project scenario page on scenario click', async function (assert) { + this.server.post( + '/v2/projects/:projectId/scan_parameter_groups', + function (schema, request) { + const { name, description } = JSON.parse(request.requestBody); + + return schema.scanParameterGroups + .create({ + name, + description, + project: request.params.projectId, + }) + .toJSON(); + } + ); + + const scenario1Name = 'New Scenario Name 1'; + + await visit(`/project/${this.project.id}/settings`); + + await click(selectors.addScenarioBtn); + + // Add first scenario with status of false + await fillIn(selectors.scenarioNameTextfield, scenario1Name); + await click(selectors.scenarioAddConfirmBtn); + + // Sanity Check for scenario items + const rows = findAll(selectors.scenarioTableRow); + + // assert first row + const firstRowCells = rows[0]; + + assert.dom(firstRowCells).containsText(scenario1Name); + assert.dom(selectors.scenarioStatusToggle, firstRowCells).isNotChecked(); + + // Click first row item + await click(firstRowCells); + + // In DAST Automation route + assert.strictEqual( + currentURL(), + `/project/${this.project.id}/settings/dast-automation-scenario/1` + ); + }); + + test.each( + 'it deletes a scenario if not default', + [true, false], + async function (assert, is_default) { + // Scenario Model - Sets default to true + const scenario = this.server.create('scan-parameter-group', { + project: this.project.id, + name: is_default ? 'Default' : 'Test', + is_active: false, + is_default: is_default, + }); + + this.server.delete( + '/v2/projects/:projectId/scan_parameter_groups/:id', + function (schema, request) { + schema.db.scanParameterGroups.remove(request.params.id); + + return new Response(204, {}, ''); + } + ); + + await visit( + `/project/${this.project.id}/settings/dast-automation-scenario/${scenario.id}` + ); + + if (is_default) { + // Tootlip selector for default scenario + assert + .dom(selectors.deleteScenarioModalTrigger) + .exists() + .hasAttribute('disabled'); + + const deleteDefaultScenarioInfoTooltip = find( + selectors.deleteDefaultScenarioTooltip + ); + + await triggerEvent(deleteDefaultScenarioInfoTooltip, 'mouseenter'); + + assert + .dom('[data-test-ak-tooltip-content]') + .exists() + .containsText(t('dastAutomation.deleteDefaultScenarioInfo')); + } else { + assert + .dom(selectors.deleteScenarioModalTrigger) + .exists() + .doesNotHaveAttribute('disabled'); + + await click(selectors.deleteScenarioModalTrigger); + + assert + .dom(selectors.deleteConfirmTextSelector) + .exists() + .containsText('Would you like to delete Scenario - Test?'); + + assert + .dom(selectors.deleteCancelBtnSelector) + .exists() + .containsText(t('cancel')); + + assert + .dom(selectors.deleteBtnSelector) + .exists() + .containsText(t('yesDelete')); + + await click(selectors.deleteBtnSelector); + + // Navigates to project settings after delete + assert.strictEqual( + currentURL(), + `/project/${this.project.id}/settings` + ); + } + } + ); + } +); diff --git a/tests/acceptance/sbom-test.js b/tests/acceptance/sbom-test.js new file mode 100644 index 000000000..8acae6ff1 --- /dev/null +++ b/tests/acceptance/sbom-test.js @@ -0,0 +1,205 @@ +import { module, test } from 'qunit'; +import { visit, currentURL, findAll, click } from '@ember/test-helpers'; +import { setupApplicationTest } from 'ember-qunit'; +import { setupRequiredEndpoints } from 'irene/tests/helpers/acceptance-utils'; +import { setupMirage } from 'ember-cli-mirage/test-support'; +import { t } from 'ember-intl/test-support'; +import Service from '@ember/service'; + +import { SbomScanStatus } from 'irene/models/sbom-file'; + +class IntegrationStub extends Service { + async configure(user) { + this.currentUser = user; + } + + isPendoEnabled() { + return false; + } + + isCrispEnabled() { + return false; + } +} + +class WebsocketStub extends Service { + async connect() {} + + async configure() {} +} + +module('Acceptance | sbom', function (hooks) { + setupApplicationTest(hooks); + setupMirage(hooks); + + hooks.beforeEach(async function () { + const { organization } = await setupRequiredEndpoints(this.server); + + organization.update({ + features: { + sbom: true, + }, + }); + + const files = this.server.createList('file', 5); + + files.map((file) => + this.server.create('project', { last_file_id: file.id }) + ); + + const sbomFiles = this.server.createList('sbom-file', 5); + + sbomFiles[1].update({ + status: SbomScanStatus.COMPLETED, + }); + + const sbomProjects = sbomFiles.map((sbomFile) => + this.server.create('sbom-project', { latest_sb_file: sbomFile.id }) + ); + + this.server.create('sbom-scan-summary'); + + const sbomComponents = this.server.createList('sbom-component', 10); + + this.server.get('/v2/server_configuration', () => { + return { + enterprise: false, + }; + }); + + this.server.get('/v2/sb_projects', (schema) => { + const results = schema.sbomProjects.all().models; + + return { count: results.length, next: null, previous: null, results }; + }); + + this.server.get('/v2/sb_projects/:id', (schema, req) => { + return schema.sbomProjects.find(`${req.params.id}`)?.toJSON(); + }); + + this.server.get('/v2/sb_files/:id', (schema, req) => { + return schema.sbomFiles.find(`${req.params.id}`)?.toJSON(); + }); + + this.server.get('/v2/projects/:id', (schema, req) => { + return schema.projects.find(`${req.params.id}`)?.toJSON(); + }); + + this.server.get('/v2/files/:id', (schema, req) => { + return schema.files.find(`${req.params.id}`)?.toJSON(); + }); + + this.server.get( + '/v2/sb_projects/:id/sb_files/:fileId/summary', + (schema) => { + return schema.sbomScanSummaries.first()?.toJSON(); + } + ); + + this.server.get('/v2/sb_files/:scan_id/sb_components', (schema) => { + const results = schema.sbomComponents.all().models; + + return { count: results.length, next: null, previous: null, results }; + }); + + this.owner.register('service:integration', IntegrationStub); + this.owner.register('service:websocket', WebsocketStub); + + this.setProperties({ + sbomProjects, + sbomFiles, + sbomComponents, + }); + }); + + test('test sbom app list row click should navigate to scan details', async function (assert) { + await visit('/dashboard/sbom/apps'); + + const contentRows = findAll('[data-test-sbomApp-row]'); + + assert.strictEqual(contentRows.length, this.sbomProjects.length); + + await click(contentRows[1]); + + assert.strictEqual( + currentURL(), + `/dashboard/sbom/apps/${this.sbomProjects[1].id}/scans/${this.sbomFiles[1].id}` + ); + }); + + test('test navigate to past scans & sbom scan list row click', async function (assert) { + this.server.get('/v2/sb_projects/:id/sb_files', (schema) => { + const results = schema.sbomFiles.all().models; + + return { count: results.length, next: null, previous: null, results }; + }); + + await visit('/dashboard/sbom/apps'); + + const sbomAppRows = findAll('[data-test-sbomApp-row]'); + + assert.strictEqual(sbomAppRows.length, this.sbomProjects.length); + + const secondRow = sbomAppRows[1].querySelectorAll( + '[data-test-sbomApp-cell]' + ); + + await click(secondRow[4].querySelector('[data-test-sbomApp-actionBtn]')); + + const menuItems = findAll('[data-test-sbomApp-actionMenuItem]'); + + assert.strictEqual(menuItems.length, 2); + + assert.dom('a', menuItems[0]).hasText(t('sbomModule.pastSbomAnalyses')); + + await click(menuItems[0].querySelector('a')); + + assert.strictEqual( + currentURL(), + `/dashboard/sbom/apps/${this.sbomProjects[1].id}/scans` + ); + + const sbomFileRows = findAll('[data-test-sbomScan-row]'); + + assert.strictEqual(sbomFileRows.length, this.sbomFiles.length); + + await click(sbomFileRows[1]); + + assert.strictEqual( + currentURL(), + `/dashboard/sbom/apps/${this.sbomProjects[1].id}/scans/${this.sbomFiles[1].id}` + ); + }); + + test('it triggers sbom scan component details route on row click', async function (assert) { + this.server.createList('sbom-vulnerability-audit', 3); + + this.server.get('/v2/sb_components/:id', (schema, req) => + schema.sbomComponents.find(`${req.params.id}`)?.toJSON() + ); + + this.server.get( + '/v2/sb_components/:comp_id/sb_vulnerability_audits', + (schema) => { + const results = schema.sbomVulnerabilityAudits.all().models; + + return { count: results.length, next: null, previous: null, results }; + } + ); + + await visit( + `/dashboard/sbom/apps/${this.sbomProjects[1].id}/scans/${this.sbomFiles[1].id}` + ); + + const contentRows = findAll('[data-test-sbomComponent-row]'); + + assert.strictEqual(contentRows.length, this.sbomComponents.length); + + await click(contentRows[2]); + + assert.strictEqual( + currentURL(), + `/dashboard/sbom/apps/${this.sbomProjects[1].id}/scans/${this.sbomFiles[1].id}/components/${this.sbomComponents[2].id}` + ); + }); +}); diff --git a/tests/helpers/acceptance-utils.js b/tests/helpers/acceptance-utils.js new file mode 100644 index 000000000..7c6adaa16 --- /dev/null +++ b/tests/helpers/acceptance-utils.js @@ -0,0 +1,97 @@ +import { authenticateSession } from 'ember-simple-auth/test-support'; + +import { faker } from '@faker-js/faker'; + +export async function setupRequiredEndpoints(server, skipLogin = true) { + // clear out default data + server.db.emptyData(); + + const currentUser = server.create('user'); + const vulnerabilities = server.createList('vulnerability', 20); + const organization = server.create('organization'); + + const currentOrganizationMember = server.create('organization-member', { + id: currentUser.id, + member: currentUser.id, + }); + + const currentOrganizationUser = server.create('organization-user', { + id: currentOrganizationMember.member, + }); + + const currentOrganizationMe = server.create('organization-me', { + id: currentUser.id, + }); + + if (skipLogin) { + await authenticateSession({ + authToken: faker.git.commitSha(), + user_id: currentUser.id, + }); + } else { + // login endpoints + } + + server.get('/hudson-api/projects', () => { + return new Response(200); + }); + + server.get('/vulnerabilities', (schema) => { + return { + data: schema.vulnerabilities.all().models.map((model) => ({ + attributes: model, + id: model.id, + relationships: {}, + type: 'vulnerabilities', + })), + }; + }); + + server.get('/users/:id', (schema, req) => { + return { + data: { + attributes: schema.users.find(`${req.params.id}`)?.toJSON(), + id: req.params.id, + relationships: {}, + type: 'users', + }, + }; + }); + + server.get('/organizations', (schema) => { + const results = schema.organizations.all().models; + + return { + count: results.length, + previous: null, + next: null, + results, + }; + }); + + server.get('/organizations/:id/me', function () { + return currentOrganizationMe.toJSON(); + }); + + server.get('/organizations/:orgId/members/:memId', (schema, request) => { + return schema.organizationMembers.find(request.params.memId)?.toJSON(); + }); + + server.get('/submissions', () => { + return { + count: 0, + previous: null, + next: null, + results: [], + }; + }); + + return { + currentUser, + currentOrganizationMe, + currentOrganizationMember, + currentOrganizationUser, + vulnerabilities, + organization, + }; +} diff --git a/tests/integration/components/file-compare/compare-list-test.js b/tests/integration/components/file-compare/compare-list-test.js index 553c43f69..43cb5b05a 100644 --- a/tests/integration/components/file-compare/compare-list-test.js +++ b/tests/integration/components/file-compare/compare-list-test.js @@ -4,17 +4,6 @@ import { click, findAll, render, waitFor } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { setupIntl } from 'ember-intl/test-support'; import { setupMirage } from 'ember-cli-mirage/test-support'; -import Service from '@ember/service'; - -class RouterStub extends Service { - currentRouteName = 'authenticated.dashboard.compare'; - selectedFiles = ''; - - transitionTo(routeName, selectedFiles) { - this.currentRouteName = routeName; - this.selectedFiles = selectedFiles; - } -} module('Integration | Component | file-compare/compare-list', function (hooks) { setupRenderingTest(hooks); @@ -233,39 +222,4 @@ module('Integration | Component | file-compare/compare-list', function (hooks) { .dom('[data-test-fileCompare-compareListHeader-compareBtn]') .hasAttribute('disabled'); }); - - test('it compares selected files', async function (assert) { - this.owner.register('service:router', RouterStub); - - await render( - hbs`` - ); - - // Selects second file in list - const compareFile = this.fileRecords[1]; - const compareFileSelector = `[data-test-fileCompare-compareList-fileOverview='${compareFile.id}']`; - - await click( - `${compareFileSelector} [data-test-fileCompare-fileOverview-selectCheckBox]` - ); - - assert - .dom('[data-test-fileCompare-compareListHeader-compareBtn]') - .exists() - .hasText('t:compare:()'); - - await click('[data-test-fileCompare-compareListHeader-compareBtn]'); - - const router = this.owner.lookup('service:router'); - - assert.strictEqual( - router.currentRouteName, - 'authenticated.dashboard.compare' - ); - - assert.strictEqual( - router.selectedFiles, - `${this.fileOld?.id}...${compareFile?.id}` - ); - }); }); diff --git a/tests/integration/components/file-compare/header-test.js b/tests/integration/components/file-compare/header-test.js index 4a3068168..b55fe7444 100644 --- a/tests/integration/components/file-compare/header-test.js +++ b/tests/integration/components/file-compare/header-test.js @@ -2,17 +2,8 @@ import { module, test } from 'qunit'; import { setupIntl } from 'ember-intl/test-support'; import { setupMirage } from 'ember-cli-mirage/test-support'; import { setupRenderingTest } from 'ember-qunit'; -import { click, render } from '@ember/test-helpers'; +import { render } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; -import Service from '@ember/service'; - -class RouterStub extends Service { - currentRouteName = 'authenticated.dashboard.compare'; - - transitionTo(routeName) { - this.currentRouteName = routeName; - } -} module('Integration | Component | file-compare/header', function (hooks) { setupRenderingTest(hooks); @@ -26,7 +17,6 @@ module('Integration | Component | file-compare/header', function (hooks) { }); this.store = this.owner.lookup('service:store'); - this.owner.register('service:router', RouterStub); const files = this.server.createList('file', 6); const project = this.server.create('project'); @@ -124,29 +114,6 @@ module('Integration | Component | file-compare/header', function (hooks) { .exists(); }); - test('it redirects to settings page if button is clicked', async function (assert) { - await render( - hbs`` - ); - - assert - .dom('[data-test-fileCompareHeader-projectOverview-settingsBtn]') - .exists(); - - await click('[data-test-fileCompareHeader-projectOverview-settingsBtn]'); - - const router = this.owner.lookup('service:router'); - - assert.strictEqual( - router.currentRouteName, - 'authenticated.project.settings' - ); - }); - test('it toggles file overview cards', async function (assert) { // Common server mocks this.server.get('/profiles/:id/unknown_analysis_status', (_, req) => { diff --git a/tests/integration/components/file-compare/index-test.js b/tests/integration/components/file-compare/index-test.js index f410fdb98..7229c762a 100644 --- a/tests/integration/components/file-compare/index-test.js +++ b/tests/integration/components/file-compare/index-test.js @@ -8,16 +8,6 @@ import { compareFiles, getFileComparisonCategories, } from 'irene/utils/compare-files'; -import Service from '@ember/service'; - -class RouterStub extends Service { - currentRouteName = 'authenticated.project.files'; - currentRoute = { queryParams: { referrer: 'all_uploads' } }; - - transitionTo(routeName) { - this.currentRouteName = routeName; - } -} module('Integration | Component | file-compare', function (hooks) { setupRenderingTest(hooks); @@ -227,30 +217,6 @@ module('Integration | Component | file-compare', function (hooks) { .doesNotExist(); }); - test('it renders all upload page breadcrumbs if page referrer is "all_uploads"', async function (assert) { - this.owner.register('service:router', RouterStub); - - const breadcrumbItems = [ - 't:allProjects:()', - this.file1?.project?.get('packageName'), - 't:compare:()', - ]; - - await render( - hbs`` - ); - - assert.dom('[data-test-fileCompare-header]').exists(); - assert.dom('[data-test-fileCompare-breadcrumbContainer]').exists(); - - breadcrumbItems.map((item) => - assert.dom(`[data-test-fileCompare-breadcrumbItem="${item}"]`).exists() - ); - }); - test('it toggles file overview header on show more or show less icon click', async function (assert) { await render( hbs`` - ); - - assert.dom('[data-test-fileCompare-header-compareFileEditIcon]').exists(); - - await click('[data-test-fileCompare-header-compareFileEditIcon]'); - - const router = this.owner.lookup('service:router'); - - assert.strictEqual(router.currentRouteName, 'authenticated.choose'); - }); - - test('it redirects to all uploads page if compare file edit icon is clicked and page referrer is "all_uploads"', async function (assert) { - this.owner.register('service:router', RouterStub); - - await render( - hbs`` - ); - - assert.dom('[data-test-fileCompare-header-compareFileEditIcon]').exists(); - - await click('[data-test-fileCompare-header-compareFileEditIcon]'); - - const router = this.owner.lookup('service:router'); - - assert.strictEqual(router.currentRouteName, 'authenticated.project.files'); - }); }); diff --git a/tests/integration/components/file-details/vulnerability-analysis-test.js b/tests/integration/components/file-details/vulnerability-analysis-test.js index cad55900d..27a44d14e 100644 --- a/tests/integration/components/file-details/vulnerability-analysis-test.js +++ b/tests/integration/components/file-details/vulnerability-analysis-test.js @@ -26,18 +26,6 @@ class NotificationsStub extends Service { } } -class RouterStub extends Service { - transitionToArgs = []; - - transitionTo() { - this.transitionToArgs = arguments; - } - - on() {} - - off() {} -} - const vulnerabilityTypeTextMap = { [ENUMS.VULNERABILITY_TYPE.STATIC]: 'static', [ENUMS.VULNERABILITY_TYPE.DYNAMIC]: 'dynamic', @@ -102,7 +90,6 @@ module( await this.owner.lookup('service:organization').load(); this.owner.register('service:notifications', NotificationsStub); - this.owner.register('service:router', RouterStub); }); test('it renders file-details/vulnerability-analysis', async function (assert) { @@ -280,43 +267,6 @@ module( .hasText('t:editAnalyses:()'); }); - test('test analysis row click', async function (assert) { - this.server.get('/v2/projects/:id', (schema, req) => { - return schema.projects.find(`${req.params.id}`)?.toJSON(); - }); - - this.server.get('/hudson-api/projects', () => { - return new Response(200); - }); - - await render(hbs` - - `); - - assert - .dom('[data-test-vulnerability-analysis-title]') - .hasText('t:vulnerabilityDetails:()'); - - const rows = findAll('[data-test-vulnerability-analysis-row]'); - - await click(rows[1]); - - const analyses = this.file.analyses - .toArray() - .sort((a, b) => b.computedRisk - a.computedRisk); // sort by computedRisk:desc - - const router = this.owner.lookup('service:router'); - const transitionToArgs = router.transitionToArgs; - - assert.true(transitionToArgs.length > 0); - assert.strictEqual( - transitionToArgs[0], - 'authenticated.dashboard.file.analysis' - ); - assert.strictEqual(transitionToArgs[1], this.file.id); - assert.strictEqual(transitionToArgs[2], analyses[1].id); - }); - test('test analysis sort by impact', async function (assert) { this.server.get('/v2/projects/:id', (schema, req) => { return schema.projects.find(`${req.params.id}`)?.toJSON(); diff --git a/tests/integration/components/file-list-test.js b/tests/integration/components/file-list-test.js index 8cef77ba6..d1b7e4b18 100644 --- a/tests/integration/components/file-list-test.js +++ b/tests/integration/components/file-list-test.js @@ -4,17 +4,6 @@ import { click, findAll, render, waitFor } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { setupIntl } from 'ember-intl/test-support'; import { setupMirage } from 'ember-cli-mirage/test-support'; -import Service from '@ember/service'; - -class RouterStub extends Service { - currentRouteName = 'authenticated.project.files'; - selectedFiles = ''; - - transitionTo(routeName, selectedFiles) { - this.currentRouteName = routeName; - this.selectedFiles = selectedFiles; - } -} module('Integration | Component | file-list', function (hooks) { setupRenderingTest(hooks); @@ -298,47 +287,6 @@ module('Integration | Component | file-list', function (hooks) { .doesNotExist(); }); - test('it compares two selected files', async function (assert) { - this.owner.register('service:router', RouterStub); - - await render( - hbs`` - ); - - const [baseFile, compareFile] = this.fileRecords; - - const baseFileSelector = `[data-test-fileList-fileOverview='${baseFile.id}']`; - const compareFileSelector = `[data-test-fileList-fileOverview='${compareFile.id}']`; - - // Selects base and compare files - await click( - `${baseFileSelector} [data-test-fileCompare-fileOverview-selectCheckBox]` - ); - - await click( - `${compareFileSelector} [data-test-fileCompare-fileOverview-selectCheckBox]` - ); - - assert - .dom('[data-test-fileList-projectOverview-header-compareBtn]') - .exists() - .hasText('t:compare:()'); - - await click('[data-test-fileList-projectOverview-header-compareBtn]'); - - const router = this.owner.lookup('service:router'); - - assert.strictEqual( - router.currentRouteName, - 'authenticated.dashboard.compare' - ); - - assert.strictEqual( - router.selectedFiles, - `${baseFile?.id}...${compareFile?.id}` - ); - }); - test('it should disable other files in list if two files have already been selected', async function (assert) { const [baseFile, compareFile, otherFile] = this.fileRecords; diff --git a/tests/integration/components/file/report-drawer/sbom-reports/index-test.js b/tests/integration/components/file/report-drawer/sbom-reports/index-test.js index 5930741e2..c05dc0538 100644 --- a/tests/integration/components/file/report-drawer/sbom-reports/index-test.js +++ b/tests/integration/components/file/report-drawer/sbom-reports/index-test.js @@ -2,7 +2,7 @@ import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; import { setupIntl } from 'ember-intl/test-support'; import { setupMirage } from 'ember-cli-mirage/test-support'; -import { click, findAll, render, waitFor } from '@ember/test-helpers'; +import { findAll, render, waitFor } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import Service from '@ember/service'; import { SbomReportStatus } from 'irene/models/sbom-report'; @@ -16,16 +16,6 @@ class OrganizationStub extends Service { }; } -class RouterStub extends Service { - currentRoute = { - parent: { - params: { - fileid: '1', - }, - }, - }; -} - module( 'Integration | Component | file/report-drawer/sbom-reports', function (hooks) { @@ -35,7 +25,6 @@ module( hooks.beforeEach(async function () { this.owner.register('service:organization', OrganizationStub); - this.owner.register('service:router', RouterStub); const store = this.owner.lookup('service:store'); @@ -338,69 +327,6 @@ module( ) .exists() .hasText('t:fileReport.noSbomReportAvailable:()'); - - assert - .dom('[data-test-fileReportDrawer-sbomReports-latestFileCTABtn]') - .exists(); - }); - - test('it renders and triggers go to latest file CTA button when current file is not latest and no sbom file exists', async function (assert) { - this.file = this.createFile(null); - - // Creates a new file with id of 2 - const latestFile = this.server.create('file'); - const latestFileNormalized = this.store.normalize( - 'file', - latestFile.toJSON() - ); - const latestFileRecord = this.store.push(latestFileNormalized); - - // Creates a new project that has a latest file of id 2 - const project = this.server.create('project'); - - const projectRecord = this.store.push( - this.store.normalize('project', project.toJSON()) - ); - - projectRecord.lastFile = latestFileRecord; - - // Updates file with id of 1 with project that has a latest file of id 2 - this.file.project = projectRecord; - - // Current file in route has an id of 1 - class RouterStub extends Service { - transitionToArgs = []; - - transitionTo() { - this.transitionToArgs = arguments; - } - - currentRoute = { - params: { - fileid: '1', - }, - }; - } - - this.owner.register('service:router', RouterStub); - - await render( - hbs`` - ); - - assert - .dom('[data-test-fileReportDrawer-sbomReports-latestFileCTABtn]') - .exists() - .hasText('t:fileReport.goToLatestFile:()'); - - await click('[data-test-fileReportDrawer-sbomReports-latestFileCTABtn]'); - - const router = this.owner.lookup('service:router'); - const transitionToArgs = router.transitionToArgs; - - assert.true(transitionToArgs.length > 0); - assert.strictEqual(transitionToArgs[0], 'authenticated.file'); - assert.strictEqual(transitionToArgs[1], projectRecord.lastFile.get('id')); }); } ); diff --git a/tests/integration/components/organization-details-test.js b/tests/integration/components/organization-details-test.js index b28225a2d..b256712a7 100644 --- a/tests/integration/components/organization-details-test.js +++ b/tests/integration/components/organization-details-test.js @@ -36,6 +36,9 @@ module('Integration | Component | organization-details', function (hooks) { await this.owner.lookup('service:organization').load(); this.owner.register('service:me', OrganizationMeStub); + + // unregister to override any lookup + this.owner.unregister('service:router'); this.owner.register('service:router', RouterStub); }); diff --git a/tests/integration/components/organization-invitation-list-test.js b/tests/integration/components/organization-invitation-list-test.js index f958469a0..7aefe75ee 100644 --- a/tests/integration/components/organization-invitation-list-test.js +++ b/tests/integration/components/organization-invitation-list-test.js @@ -1,4 +1,4 @@ -import { render, findAll, find, click, settled } from '@ember/test-helpers'; +import { render, findAll, find, click } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { setupMirage } from 'ember-cli-mirage/test-support'; import { setupIntl } from 'ember-intl/test-support'; @@ -8,20 +8,6 @@ import dayjs from 'dayjs'; import { Response } from 'miragejs'; import Service from '@ember/service'; -import { tracked } from '@glimmer/tracking'; - -class RouterStub extends Service { - currentRouteName = ''; - queryParams = null; - - transitionTo({ queryParams }) { - this.queryParams = queryParams; - } -} - -class RealtimeStub extends Service { - @tracked InvitationCounter = 0; -} class NotificationsStub extends Service { errorMsg = null; @@ -86,8 +72,6 @@ module( this.owner.register('service:me', OrganizationMeStub); this.owner.register('service:notifications', NotificationsStub); - this.owner.register('service:router', RouterStub); - this.owner.register('service:realtime', RealtimeStub); }); test('it renders organization user invitation list', async function (assert) { @@ -267,172 +251,5 @@ module( } } ); - - test.each( - 'test organization user invitation delete', - [{ fail: false }, { fail: true }], - async function (assert, { fail }) { - this.set('inviteDeleted', false); - - this.server.get('/organizations/:id/invitations', (schema) => { - const results = this.inviteDeleted - ? schema.organizationInvitations.all().models.slice(1) - : schema.organizationInvitations.all().models; - - return { count: results.length, next: null, previous: null, results }; - }); - - this.server.delete('/organizations/:id/invitations/:inviteId', () => { - return fail ? new Response(500) : {}; - }); - - this.server.get('/organizations/:id/users/:userId', (schema, req) => { - const user = schema.organizationUsers.find(req.params.userId); - - return user?.toJSON(); - }); - - this.server.get('/organizations/:id/teams/:teamId', (schema, req) => { - const user = schema.organizationTeams.find(req.params.teamId); - - return user?.toJSON(); - }); - - await render(hbs` - - `); - - assert.dom('[data-test-invitation-list]').exists(); - - const contentRows = findAll('[data-test-invitation-list-row]'); - - const firstRow = contentRows[0].querySelectorAll( - '[data-test-invitation-list-cell]' - ); - - assert - .dom('[data-test-invitation-delete-btn]', firstRow[4]) - .exists() - .isNotDisabled(); - - await click(`#${firstRow[4].id} [data-test-invitation-delete-btn]`); - - assert.dom('[data-test-ak-modal-header]').hasText('t:confirm:()'); - - assert - .dom('[data-test-confirmbox-description]') - .hasText('t:confirmBox.deleteInvitation:()'); - - assert - .dom('[data-test-confirmbox-confirmBtn]') - .exists() - .isNotDisabled() - .hasText('t:delete:()'); - - assert - .dom('[data-test-confirmbox-cancelBtn]') - .exists() - .isNotDisabled() - .hasText('t:cancel:()'); - - if (!fail) { - this.set('inviteDeleted', true); - } - - await click('[data-test-confirmbox-confirmBtn]'); - - const notify = this.owner.lookup('service:notifications'); - - if (fail) { - assert.strictEqual(notify.errorMsg, 't:pleaseTryAgain:()'); - - assert.strictEqual( - findAll('[data-test-invitation-list-row]').length, - this.organizationInvitations.length - ); - - assert.dom('[data-test-ak-modal-header]').exists(); - assert.dom('[data-test-confirmbox-confirmBtn]').exists(); - } else { - assert.strictEqual(notify.successMsg, 't:invitationDeleted:()'); - - assert.strictEqual( - findAll('[data-test-invitation-list-row]').length, - this.organizationInvitations.length - 1 - ); - - assert.dom('[data-test-ak-modal-header]').doesNotExist(); - assert.dom('[data-test-confirmbox-confirmBtn]').doesNotExist(); - } - } - ); - - test('test organization user invitation list reload', async function (assert) { - let apiCallCounter = 0; - - this.server.get('/organizations/:id/invitations', (schema) => { - const results = schema.organizationInvitations.all().models; - apiCallCounter++; - return { count: results.length, next: null, previous: null, results }; - }); - - this.server.get('/organizations/:id/users/:userId', (schema, req) => { - const user = schema.organizationUsers.find(req.params.userId); - - return user?.toJSON(); - }); - - this.server.get('/organizations/:id/teams/:teamId', (schema, req) => { - const user = schema.organizationTeams.find(req.params.teamId); - - return user?.toJSON(); - }); - - await render(hbs` - - <:headerContent> -
- {{t 'pendingInvitations'}} -
- -
- `); - - assert - .dom('[data-test-invitation-list-title]') - .exists() - .hasText('t:pendingInvitations:()'); - - assert.dom('[data-test-invitation-list]').exists(); - - const realtime = this.owner.lookup('service:realtime'); - realtime.incrementProperty('InvitationCounter'); - - await settled(); - - assert.strictEqual(apiCallCounter, 2); - - const contentRows = findAll('[data-test-invitation-list-row]'); - assert.strictEqual( - contentRows.length, - this.organizationInvitations.length - ); - - const firstRow = contentRows[0].querySelectorAll( - '[data-test-invitation-list-cell]' - ); - - assert.dom(firstRow[0]).hasText(this.organizationInvitations[0].email); - assert.dom(firstRow[1]).hasText('t:organization:()'); - - assert - .dom(firstRow[2]) - .hasText(dayjs(this.organizationInvitations[0].created_on).fromNow()); - - assert - .dom('[data-test-invitation-resend-btn]', firstRow[3]) - .exists() - .isNotDisabled(); - }); } ); diff --git a/tests/integration/components/organization-member/list-test.js b/tests/integration/components/organization-member/list-test.js index 0f795f469..48efe18d1 100644 --- a/tests/integration/components/organization-member/list-test.js +++ b/tests/integration/components/organization-member/list-test.js @@ -1,11 +1,4 @@ -import { - render, - findAll, - find, - click, - fillIn, - triggerEvent, -} from '@ember/test-helpers'; +import { render, findAll, find, click } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { setupMirage } from 'ember-cli-mirage/test-support'; import { setupIntl } from 'ember-intl/test-support'; @@ -17,15 +10,6 @@ import { Response } from 'miragejs'; import Service from '@ember/service'; import dayjs from 'dayjs'; -class RouterStub extends Service { - currentRouteName = ''; - queryParams = null; - - transitionTo({ queryParams }) { - this.queryParams = queryParams; - } -} - class NotificationsStub extends Service { errorMsg = null; successMsg = null; @@ -95,7 +79,6 @@ module('Integration | Component | organization-member/list', function (hooks) { this.owner.register('service:me', OrganizationMeStub); this.owner.register('service:notifications', NotificationsStub); - this.owner.register('service:router', RouterStub); }); test('it renders organization user list', async function (assert) { @@ -426,75 +409,4 @@ module('Integration | Component | organization-member/list', function (hooks) { assert.strictEqual(notify.errorMsg, 't:pleaseTryAgain:()'); }); - - test('test organization user inactive user checkbox', async function (assert) { - this.server.get('/organizations/:id/members', (schema, req) => { - this.set('is_active', req.queryParams.is_active); - - const results = schema.organizationMembers.all().models; - - return { count: results.length, next: null, previous: null, results }; - }); - - this.server.get('/organizations/:id/users/:userId', (schema, req) => { - const user = schema.organizationUsers.find(req.params.userId); - - return user?.toJSON(); - }); - - await render(hbs` - - `); - - const contentRows = findAll('[data-test-org-user-row]'); - - assert.strictEqual(contentRows.length, this.organizationMembers.length); - - assert.strictEqual(this.is_active, 'true'); - - await click('[data-test-inactive-user-label]'); - - assert.dom('[data-test-inactive-user-checkbox]').isChecked(); - - assert.strictEqual(typeof this.is_active, 'undefined'); - }); - - test('test organization user search', async function (assert) { - this.server.get('/organizations/:id/members', (schema, req) => { - this.set('query', req.queryParams.q); - - const results = schema.organizationMembers.all().models; - - return { count: results.length, next: null, previous: null, results }; - }); - - this.server.get('/organizations/:id/users/:userId', (schema, req) => { - const user = schema.organizationUsers.find(req.params.userId); - - return user?.toJSON(); - }); - - await render(hbs` - - `); - - const contentRows = findAll('[data-test-org-user-row]'); - - assert.strictEqual(contentRows.length, this.organizationMembers.length); - - assert - .dom('[data-test-user-search-input]') - .exists() - .isNotDisabled() - .hasNoValue(); - - assert.strictEqual(this.query, ''); - - await fillIn('[data-test-user-search-input]', 'test'); - await triggerEvent('[data-test-user-search-input]', 'keyup'); - - assert.dom('[data-test-user-search-input]').hasValue('test'); - - assert.strictEqual(this.query, 'test'); - }); }); diff --git a/tests/integration/components/organization-team/index-test.js b/tests/integration/components/organization-team/index-test.js index 44c039ea1..b16cc8220 100644 --- a/tests/integration/components/organization-team/index-test.js +++ b/tests/integration/components/organization-team/index-test.js @@ -1,28 +1,12 @@ import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; import { setupMirage } from 'ember-cli-mirage/test-support'; -import { - click, - render, - fillIn, - findAll, - triggerEvent, -} from '@ember/test-helpers'; +import { render, findAll } from '@ember/test-helpers'; import { setupIntl } from 'ember-intl/test-support'; import { hbs } from 'ember-cli-htmlbars'; -import { Response } from 'miragejs'; import Service from '@ember/service'; -class RouterStub extends Service { - currentRouteName = ''; - queryParams = null; - - transitionTo({ queryParams }) { - this.queryParams = queryParams; - } -} - class NotificationsStub extends Service { errorMsg = null; successMsg = null; @@ -65,7 +49,6 @@ module('Integration | Component | organization-team', function (hooks) { this.owner.register('service:me', OrganizationMeStub); this.owner.register('service:notifications', NotificationsStub); - this.owner.register('service:router', RouterStub); }); test.each( @@ -122,125 +105,4 @@ module('Integration | Component | organization-team', function (hooks) { .hasText(`t:projects:() ${this.organizationTeams[0].projects_count}`); } ); - - test('test organization-team search input & query', async function (assert) { - this.server.get('/organizations/:id/teams', (schema, req) => { - this.set('query', req.queryParams.q); - - const results = schema.organizationTeams.all().models; - - return { count: results.length, next: null, previous: null, results }; - }); - - await render( - hbs`` - ); - - assert.dom('[data-test-orgTeamSearch-input]').isNotDisabled().hasNoValue(); - assert.notOk(this.query); - - await fillIn('[data-test-orgTeamSearch-input]', 'test'); - await triggerEvent('[data-test-orgTeamSearch-input]', 'keyup'); - - assert.dom('[data-test-orgTeamSearch-input]').hasValue('test'); - assert.strictEqual(this.query, 'test'); - }); - - test.each( - 'test organization-team create team', - [{ fail: false }, { fail: true }], - async function (assert, { fail }) { - const server = this.server; - - this.server.get('/organizations/:id/teams', (schema) => { - const results = schema.organizationTeams - .all() - .models.sortBy('created_on'); - - return { count: results.length, next: null, previous: null, results }; - }); - - this.server.post('/organizations/:id/teams', (schema, req) => { - return fail - ? new Response(500) - : server.create('organization-team', { - name: JSON.parse(req.requestBody).name, - created_on: Date(), - }); - }); - - this.server.get('/organizations/:id', (schema, req) => - schema.organizations.find(`${req.params.id}`)?.toJSON() - ); - - await render( - hbs`` - ); - - assert - .dom('[data-test-orgCreateTeam-btn]') - .isNotDisabled() - .hasText('t:createTeam:()'); - - const teamList = findAll('[data-test-orgTeamOverview]'); - - assert.strictEqual(teamList.length, this.organizationTeams.length); - - await click('[data-test-orgCreateTeam-btn]'); - - assert.dom('[data-test-ak-modal-header]').hasText('t:createTeam:()'); - - assert.dom('[data-test-form-label]').hasText('t:createTeamInputLabel:()'); - - assert - .dom('[data-test-orgCreateTeam-input]') - .hasNoValue() - .isNotDisabled(); - - assert - .dom('[data-test-orgCreateTeam-submitBtn]') - .hasText('t:createTeam:()') - .isNotDisabled(); - - // empty input case - await click('[data-test-orgCreateTeam-submitBtn]'); - - const notify = this.owner.lookup('service:notifications'); - - assert.strictEqual(notify.errorMsg, 't:enterTeamName:()'); - - // fill value - await fillIn('[data-test-orgCreateTeam-input]', 'testTeam'); - - await click('[data-test-orgCreateTeam-submitBtn]'); - - if (fail) { - assert.strictEqual(notify.errorMsg, 't:pleaseTryAgain:()'); - - assert.dom('[data-test-ak-modal-header]').exists(); - assert.dom('[data-test-orgCreateTeam-submitBtn]').exists(); - - assert - .dom('[data-test-orgCreateTeam-input]') - .exists() - .hasValue('testTeam'); - - assert.strictEqual(teamList.length, this.organizationTeams.length); - } else { - assert.strictEqual(notify.successMsg, 't:teamCreated:()'); - - assert.dom('[data-test-ak-modal-header]').doesNotExist(); - assert.dom('[data-test-orgCreateTeam-submitBtn]').doesNotExist(); - assert.dom('[data-test-orgCreateTeam-input]').doesNotExist(); - - const teamList = findAll('[data-test-orgTeamOverview]'); - - assert.strictEqual(teamList.length, this.organizationTeams.length + 1); - - assert - .dom('[data-test-orgTeamOverview-name]', teamList[0]) - .hasText('testTeam'); - } - } - ); }); diff --git a/tests/integration/components/partner/clients-nav-test.js b/tests/integration/components/partner/clients-nav-test.js deleted file mode 100644 index 83012de12..000000000 --- a/tests/integration/components/partner/clients-nav-test.js +++ /dev/null @@ -1,84 +0,0 @@ -import { module, test } from 'qunit'; -import { setupRenderingTest } from 'ember-qunit'; -import { setupMirage } from 'ember-cli-mirage/test-support'; -import { setupIntl } from 'ember-intl/test-support'; -import { render } from '@ember/test-helpers'; -import { hbs } from 'ember-cli-htmlbars'; -import Service from '@ember/service'; -import styles from 'irene/components/partner/clients-nav/index.scss'; - -class RouterStub extends Service { - currentRoute = { - name: '', - }; -} - -class PartnerStub extends Service { - access = {}; -} - -module('Integration | Component | partner/clients-nav', function (hooks) { - setupRenderingTest(hooks); - setupMirage(hooks); - setupIntl(hooks); - - hooks.beforeEach(async function () { - this.owner.register('service:router', RouterStub); - this.owner.register('service:partner', PartnerStub); - }); - - test('it should render overview & invitations tabs always', async function (assert) { - await render(hbs``); - - assert.dom('[data-test-clients-nav]').exists(); - - assert.dom('[data-test-nav-tab="overview"]').exists(); - assert.dom('[data-test-nav-tab="invitations"]').exists(); - - assert.dom('[data-test-nav-tab="overview"]').hasText('t:overview:()'); - assert.dom('[data-test-nav-tab="invitations"]').hasText('t:invitations:()'); - }); - - test('it should not render registration requests tab if admin_registration privilege is false', async function (assert) { - const partner = this.owner.lookup('service:partner'); - partner.access.admin_registration = false; - - await render(hbs``); - assert.dom('[data-test-nav-tab="registration-requests"]').doesNotExist(); - }); - - test('it should render registration requests tab if admin_registration privilege is true', async function (assert) { - const partner = this.owner.lookup('service:partner'); - partner.access.admin_registration = true; - - await render(hbs``); - assert.dom('[data-test-nav-tab="registration-requests"]').exists(); - assert - .dom('[data-test-nav-tab="registration-requests"]') - .hasText('t:registrationRequests:()'); - }); - - test('it should activate tab of current route', async function (assert) { - const router = this.owner.lookup('service:router'); - - // current route: overview - router.currentRoute.name = 'authenticated.partner.clients.overview'; - await render(hbs``); - assert.dom('[data-test-nav-tab="overview"]').hasClass(styles['active']); - - // current route: invitations - router.currentRoute.name = 'authenticated.partner.clients.invitations'; - await render(hbs``); - assert.dom('[data-test-nav-tab="invitations"]').hasClass(styles['active']); - - // current route: registration-requests - const partner = this.owner.lookup('service:partner'); - partner.access.admin_registration = true; - router.currentRoute.name = - 'authenticated.partner.clients.registration-requests'; - await render(hbs``); - assert - .dom('[data-test-nav-tab="registration-requests"]') - .hasClass(styles['active']); - }); -}); diff --git a/tests/integration/components/partner/invitation-list-test.js b/tests/integration/components/partner/invitation-list-test.js index b55ec3c25..47f79db12 100644 --- a/tests/integration/components/partner/invitation-list-test.js +++ b/tests/integration/components/partner/invitation-list-test.js @@ -65,9 +65,9 @@ module('Integration | Component | partner/invitation-list', function (hooks) { test('it should add new entry in invitations list on successful client invite', async function (assert) { const rrCount = 2; const rrInvites = this.server.createList( - 'partner/registrationRequest', + 'partner/registration-request', rrCount, - { approvalStatus: 'approved', source: 'invitation' } + { approval_status: 'approved', source: 'invitation' } ); const rrItem = rrInvites[0]; @@ -77,8 +77,8 @@ module('Integration | Component | partner/invitation-list', function (hooks) { const is_activated = request.queryParams.is_activated; const status = request.queryParams.approval_status; const data = schema['partner/registrationRequests'].where({ - isActivated: is_activated, - approvalStatus: status, + is_activated: is_activated, + approval_status: status, }); return registrationRequestSerializer(data, true); } @@ -96,9 +96,9 @@ module('Integration | Component | partner/invitation-list', function (hooks) { first_name: body.first_name, last_name: body.last_name, }, - approvalStatus: 'approved', + approval_status: 'approved', source: 'invitation', - isActivated: false, + is_activated: false, }); const serData = registrationRequestSerializer(obj); return serData; diff --git a/tests/integration/components/partner/registration-request-pending-list-test.js b/tests/integration/components/partner/registration-request-pending-list-test.js index 6d5b78d67..5f36e79d2 100644 --- a/tests/integration/components/partner/registration-request-pending-list-test.js +++ b/tests/integration/components/partner/registration-request-pending-list-test.js @@ -24,34 +24,11 @@ function registrationRequestSerializer(data, many = false) { count: data.length, next: null, previous: null, - results: data.models.map((d) => { - return { - id: d.attrs.id, - email: d.attrs.email, - data: d.attrs.data, - created_on: d.attrs.createdOn, - updated_on: d.attrs.updatedOn, - valid_until: d.attrs.validUntil, - approval_status: d.attrs.approvalStatus, - source: d.attrs.source, - moderated_by: null, - is_activated: d.attrs.isActivated, - }; - }), + results: data.models.map((d) => d.toJSON()), }; } - return { - id: data.attrs.id, - email: data.attrs.email, - data: data.attrs.data, - created_on: data.attrs.createdOn, - updated_on: data.attrs.updatedOn, - valid_until: data.attrs.validUntil, - approval_status: data.attrs.approvalStatus, - source: data.attrs.source, - moderated_by: null, - is_activated: data.attrs.isActivated, - }; + + return data.toJSON(); } module( @@ -68,7 +45,9 @@ module( test('it renders translated section title', async function (assert) { await render(hbs``); + assert.dom('[data-test-pending-requests-title]').exists(); + assert .dom('[data-test-pending-requests-title]') .hasText('Pending Registration Requests'); @@ -78,7 +57,9 @@ module( this.server.get('v2/partners/1/registration_requests', () => { return new Response(500); }); + await render(hbs``); + assert.dom('[data-test-pending-requests-loading-error]').exists(); assert.dom('[data-test-pending-requests-loader]').doesNotExist(); assert.dom('[data-test-pending-requests-list]').doesNotExist(); @@ -93,11 +74,15 @@ module( results: [], }; }); + await render(hbs``); + assert.dom('[data-test-pending-requests-empty]').exists(); + assert .dom('[data-test-pending-requests-empty]') .hasText('No pending requests'); + assert.dom('[data-test-pending-requests-list]').doesNotExist(); }); @@ -110,26 +95,30 @@ module( results: [], }; }); + await render(hbs``); + assert.dom('[data-test-pending-requests-loader]').doesNotExist(); assert.dom('[data-test-pending-requests-loading-error]').doesNotExist(); assert.dom('[data-test-pending-requests-empty]').exists(); }); test('it renders table header for pending requests', async function (assert) { - this.server.createList('partner/registrationRequest', 1, { - approvalStatus: 'pending', + this.server.createList('partner/registration-request', 1, { + approval_status: 'pending', }); this.server.get( - 'v2/partners/1/registration_requests', + 'v2/partners/:id/registration_requests', (schema, request) => { const is_activated = request.queryParams.is_activated; const status = request.queryParams.approval_status; + const data = schema['partner/registrationRequests'].where({ - isActivated: is_activated, - approvalStatus: status, + is_activated: is_activated, + approval_status: status, }); + return registrationRequestSerializer(data, true); } ); @@ -137,9 +126,11 @@ module( await render(hbs``); assert.dom('[data-test-pending-requests-table-header]').exists(); + const header = this.element.querySelector( '[data-test-pending-requests-table-header]' ); + assert.equal(header.children[0].textContent, 'Requested by'); assert.equal(header.children[1].textContent, 'Company'); assert.equal(header.children[2].textContent, 'Requested'); @@ -163,18 +154,21 @@ module( }); test('it renders pending registrations requests list', async function (assert) { - this.server.createList('partner/registrationRequest', 5, { - approvalStatus: 'pending', + this.server.createList('partner/registration-request', 5, { + approval_status: 'pending', }); + this.server.get( 'v2/partners/1/registration_requests', (schema, request) => { const is_activated = request.queryParams.is_activated; const status = request.queryParams.approval_status; + const data = schema['partner/registrationRequests'].where({ - isActivated: is_activated, - approvalStatus: status, + is_activated: is_activated, + approval_status: status, }); + return registrationRequestSerializer(data, true); } ); @@ -182,9 +176,11 @@ module( await render(hbs``); assert.dom('[data-test-pending-requests-list]').exists(); + const rows = this.element.querySelectorAll( '[data-test-pending-request-row]' ); + assert.equal(rows.length, 5); assert.dom('[data-test-pending-requests-empty]').doesNotExist(); assert.dom('[data-test-pending-requests-list]').exists(); @@ -194,8 +190,9 @@ module( const rrsPending = this.server.createList( 'partner/registrationRequest', 5, - { approvalStatus: 'pending' } + { approval_status: 'pending' } ); + const rrPendingObj = rrsPending[0]; this.server.get( @@ -203,10 +200,12 @@ module( (schema, request) => { const is_activated = request.queryParams.is_activated; const status = request.queryParams.approval_status; + const data = schema['partner/registrationRequests'].where({ - isActivated: is_activated, - approvalStatus: status, + is_activated: is_activated, + approval_status: status, }); + return registrationRequestSerializer(data, true); } ); @@ -217,10 +216,13 @@ module( const obj = schema['partner/registrationRequests'].find( request.params.id ); + const body = JSON.parse(request.requestBody); + obj.update({ - approvalStatus: body.approval_status, + approval_status: body.approval_status, }); + return registrationRequestSerializer(obj); } ); @@ -231,11 +233,13 @@ module( const obj = schema['partner/registrationRequests'].find( request.params.id ); + return registrationRequestSerializer(obj); } ); await render(hbs``); + assert .dom(`[data-test-pending-request-id='${rrPendingObj.attrs.id}']`) .exists(); @@ -243,9 +247,11 @@ module( const selectedRequest = this.element.querySelector( `[data-test-pending-request-id='${rrPendingObj.attrs.id}']` ); + const selectedRequestRejectBtn = selectedRequest.querySelector( '[data-test-pending-request-reject-button]' ); + await click(selectedRequestRejectBtn); assert @@ -257,8 +263,9 @@ module( const rrsPending = this.server.createList( 'partner/registrationRequest', 5, - { approvalStatus: 'pending' } + { approval_status: 'pending' } ); + const rrPendingObj = rrsPending[0]; this.server.get( @@ -266,10 +273,12 @@ module( (schema, request) => { const is_activated = request.queryParams.is_activated; const status = request.queryParams.approval_status; + const data = schema['partner/registrationRequests'].where({ - isActivated: is_activated, - approvalStatus: status, + is_activated: is_activated, + approval_status: status, }); + return registrationRequestSerializer(data, true); } ); @@ -280,10 +289,13 @@ module( const obj = schema['partner/registrationRequests'].find( request.params.id ); + const body = JSON.parse(request.requestBody); + obj.update({ - approvalStatus: body.approval_status, + approval_status: body.approval_status, }); + return registrationRequestSerializer(obj); } ); @@ -294,11 +306,13 @@ module( const obj = schema['partner/registrationRequests'].find( request.params.id ); + return registrationRequestSerializer(obj); } ); await render(hbs``); + assert .dom(`[data-test-pending-request-id='${rrPendingObj.attrs.id}']`) .exists(); @@ -306,9 +320,11 @@ module( const selectedRequest = this.element.querySelector( `[data-test-pending-request-id='${rrPendingObj.attrs.id}']` ); + const selectedRequestApproveBtn = selectedRequest.querySelector( '[data-test-pending-request-approve-button]' ); + await click(selectedRequestApproveBtn); assert diff --git a/tests/integration/components/project-settings/general-settings/dynamicscan-automation-settings/scenario-test.js b/tests/integration/components/project-settings/general-settings/dynamicscan-automation-settings/scenario-test.js index 357bc56f4..a311bb317 100644 --- a/tests/integration/components/project-settings/general-settings/dynamicscan-automation-settings/scenario-test.js +++ b/tests/integration/components/project-settings/general-settings/dynamicscan-automation-settings/scenario-test.js @@ -29,16 +29,6 @@ class NotificationsStub extends Service { } } -class RouterStub extends Service { - currentRouteName = 'authenticated.project.settings'; - scenarioId = ''; - - transitionTo(routeName, scenarioId) { - this.currentRouteName = routeName; - this.scenarioId = scenarioId; - } -} - const selectors = { scenariosRoot: '[data-test-genSettings-dynScanAutoSettings-scenarios-root]', scenariosListEmpty: @@ -204,7 +194,6 @@ module( // Service registers this.owner.register('service:notifications', NotificationsStub); - this.owner.register('service:router', RouterStub); // Records const store = this.owner.lookup('service:store'); @@ -521,52 +510,5 @@ module( assert.ok(this.server.db.scanParameterGroups[0].is_active); }); - - test('it navigates to project scenario page on scenario click', async function (assert) { - const scenario1Name = 'New Scenario Name 1'; - - await render(hbs` - - `); - const router = this.owner.lookup('service:router'); - - // In Project settings route - assert.strictEqual( - router.currentRouteName, - 'authenticated.project.settings' - ); - - await click(selectors.addScenarioBtn); - - // Add first scenario with status of false - await fillIn(selectors.scenarioNameTextfield, scenario1Name); - await click(selectors.scenarioAddConfirmBtn); - - // Sanity Check for scenario items - const rows = findAll(selectors.scenarioTableRow); - - // assert first row - const firstRowCells = rows[0]; - - assert.dom(firstRowCells).containsText(scenario1Name); - assert.dom(selectors.scenarioStatusToggle, firstRowCells).isNotChecked(); - - // Click first row item - await click(firstRowCells); - - // In DAST Automation route - assert.strictEqual( - router.currentRouteName, - 'authenticated.project.settings.dast-automation-scenario' - ); - - assert.strictEqual( - router.scenarioId, - this.server.db.scanParameterGroups[0].id - ); - }); } ); diff --git a/tests/integration/components/project-settings/view-scenario/header-test.js b/tests/integration/components/project-settings/view-scenario/header-test.js index 4b504388e..18c60aa4f 100644 --- a/tests/integration/components/project-settings/view-scenario/header-test.js +++ b/tests/integration/components/project-settings/view-scenario/header-test.js @@ -1,9 +1,9 @@ import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; -import { click, find, render, triggerEvent } from '@ember/test-helpers'; +import { render } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; import { setupMirage } from 'ember-cli-mirage/test-support'; -import { setupIntl, t } from 'ember-intl/test-support'; +import { setupIntl } from 'ember-intl/test-support'; import Service from '@ember/service'; class NotificationsStub extends Service { @@ -19,16 +19,6 @@ class NotificationsStub extends Service { } } -class RouterStub extends Service { - currentRouteName = 'authenticated.project.settings.dast-automation-scenario'; - projectId = ''; - - transitionTo(routeName, projectId) { - this.currentRouteName = routeName; - this.projectId = projectId; - } -} - const selectors = { headerRoot: '[data-test-projectSettings-viewScenario-header-root]', headerScenarioName: @@ -58,7 +48,6 @@ module( hooks.beforeEach(async function () { this.owner.register('service:notifications', NotificationsStub); - this.owner.register('service:router', RouterStub); // Server mocks this.server.get('/organizations/:id/members', (schema) => { @@ -86,28 +75,6 @@ module( schema.scanParameterGroups.find(req.params.id).toJSON() ); - this.server.delete( - '/v2/projects/:projectId/scan_parameter_groups/:id', - function (schema, request) { - const scanParameterGroup = schema.scanParameterGroups.find( - request.params.id - ); - - if (!scanParameterGroup) { - return new Response( - 404, - {}, - { - detail: 'Not found.', - } - ); - } - - scanParameterGroup.destroy(); - return new Response(204, {}, ''); - } - ); - const store = this.owner.lookup('service:store'); // Project Model @@ -170,89 +137,5 @@ module( .exists() .hasAttribute('disabled'); }); - - test.each( - 'it deletes a scenario if not default', - [true, false], - async function (assert, is_default) { - this.scenario.set('isDefault', is_default); - - await render( - hbs`` - ); - - if (is_default) { - // Tootlip selector for default scenario - assert - .dom(selectors.deleteScenarioModalTrigger) - .exists() - .hasAttribute('disabled'); - - const deleteDefaultScenarioInfoTooltip = find( - selectors.deleteDefaultScenarioTooltip - ); - - await triggerEvent(deleteDefaultScenarioInfoTooltip, 'mouseenter'); - - assert - .dom('[data-test-ak-tooltip-content]') - .exists() - .containsText('t:dastAutomation.deleteDefaultScenarioInfo:()'); - } else { - const router = this.owner.lookup('service:router'); - - // In DAST Automation route - assert.strictEqual( - router.currentRouteName, - 'authenticated.project.settings.dast-automation-scenario' - ); - - assert - .dom(selectors.deleteScenarioModalTrigger) - .exists() - .doesNotHaveAttribute('disabled'); - - await click(selectors.deleteScenarioModalTrigger); - - assert - .dom(selectors.deleteConfirmTextSelector) - .exists() - .containsText( - t('dastAutomation.scenarioDeleteConfirm', { - scenarioName: this.scenario.name, - }) - ); - - assert - .dom(selectors.deleteCancelBtnSelector) - .exists() - .containsText(t('cancel')); - - assert - .dom(selectors.deleteBtnSelector) - .exists() - .containsText(t('yesDelete')); - - await click(selectors.deleteBtnSelector); - - const notify = this.owner.lookup('service:notifications'); - - assert.strictEqual( - notify.successMsg, - t('dastAutomation.scenarioDeleted', { - scenarioName: this.scenario.name, - }) - ); - - // Navigates to project settings after delete - assert.strictEqual( - router.currentRouteName, - 'authenticated.project.settings' - ); - - assert.strictEqual(router.projectId, this.project.get('id')); - } - } - ); } ); diff --git a/tests/integration/components/sbom/app-list-test.js b/tests/integration/components/sbom/app-list-test.js index bdddb08f7..e9d38a083 100644 --- a/tests/integration/components/sbom/app-list-test.js +++ b/tests/integration/components/sbom/app-list-test.js @@ -17,14 +17,6 @@ import dayjs from 'dayjs'; import { SbomScanStatus } from 'irene/models/sbom-file'; import Service from '@ember/service'; -class RouterStub extends Service { - transitionToArgs = []; - - transitionTo() { - this.transitionToArgs = arguments; - } -} - class NotificationsStub extends Service { errorMsg = null; successMsg = null; @@ -85,7 +77,6 @@ module('Integration | Component | sbom/app-list', function (hooks) { this.owner.register('service:me', OrganizationMeStub); this.owner.register('service:notifications', NotificationsStub); - this.owner.register('service:router', RouterStub); }); test.each( @@ -425,59 +416,6 @@ module('Integration | Component | sbom/app-list', function (hooks) { assert.strictEqual(this.query, this.queryParams.app_query); }); - test('test sbom app list row click', async function (assert) { - this.server.get('/v2/sb_projects', (schema, req) => { - this.set('query', req.queryParams.q); - - const results = schema.sbomProjects.all().models; - - return { count: results.length, next: null, previous: null, results }; - }); - - this.server.get('/v2/sb_files/:id', (schema, req) => { - const scan = schema.sbomFiles.find(`${req.params.id}`)?.toJSON(); - - if (scan && this.sbomProjects[1].latest_sb_file === req.params.id) { - scan.status = SbomScanStatus.COMPLETED; - } - - return scan; - }); - - this.server.get('/v2/projects/:id', (schema, req) => { - return schema.projects.find(`${req.params.id}`)?.toJSON(); - }); - - this.server.get('/v2/files/:id', (schema, req) => { - return schema.files.find(`${req.params.id}`)?.toJSON(); - }); - - await render(hbs` - - `); - - const contentRows = findAll('[data-test-sbomApp-row]'); - - assert.strictEqual(contentRows.length, this.sbomProjects.length); - - await click(contentRows[1]); - - const router = this.owner.lookup('service:router'); - const transitionToArgs = router.transitionToArgs; - - assert.true(transitionToArgs.length > 0); - assert.strictEqual( - transitionToArgs[0], - 'authenticated.dashboard.sbom.scan-details' - ); - assert.strictEqual(transitionToArgs[1], this.sbomProjects[1].id); - - assert.strictEqual( - transitionToArgs[2], - this.sbomProjects[1].latest_sb_file - ); - }); - test('it renders sbom app list loading & empty state', async function (assert) { this.server.get( '/v2/sb_projects', diff --git a/tests/integration/components/sbom/app-scan-test.js b/tests/integration/components/sbom/app-scan-test.js index 9847bc205..f49832a6c 100644 --- a/tests/integration/components/sbom/app-scan-test.js +++ b/tests/integration/components/sbom/app-scan-test.js @@ -6,6 +6,7 @@ import { waitFor, waitUntil, } from '@ember/test-helpers'; + import { hbs } from 'ember-cli-htmlbars'; import { setupMirage } from 'ember-cli-mirage/test-support'; import { setupIntl } from 'ember-intl/test-support'; @@ -16,14 +17,6 @@ import { SbomScanStatus } from 'irene/models/sbom-file'; import Service from '@ember/service'; import dayjs from 'dayjs'; -class RouterStub extends Service { - transitionToArgs = []; - - transitionTo() { - this.transitionToArgs = arguments; - } -} - class NotificationsStub extends Service { errorMsg = null; successMsg = null; @@ -92,7 +85,6 @@ module('Integration | Component | sbom/app-scan', function (hooks) { this.owner.register('service:me', OrganizationMeStub); this.owner.register('service:notifications', NotificationsStub); - this.owner.register('service:router', RouterStub); }); test.each( @@ -283,47 +275,6 @@ module('Integration | Component | sbom/app-scan', function (hooks) { .hasText('t:sbomModule.sbomDownloadReportDescription:()'); }); - test('test sbom scan list row click', async function (assert) { - this.server.get('/v2/sb_projects/:id/sb_files', (schema) => { - const results = schema.sbomFiles.all().models; - - return { count: results.length, next: null, previous: null, results }; - }); - - this.server.get('/v2/sb_files/:id', (schema, req) => { - return schema.sbomFiles.find(`${req.params.id}`)?.toJSON(); - }); - - this.server.get('/v2/projects/:id', (schema, req) => { - return schema.projects.find(`${req.params.id}`)?.toJSON(); - }); - - this.server.get('/v2/files/:id', (schema, req) => { - return schema.files.find(`${req.params.id}`)?.toJSON(); - }); - - await render(hbs` - - `); - - const contentRows = findAll('[data-test-sbomScan-row]'); - - assert.strictEqual(contentRows.length, this.sbomFiles.length); - - await click(contentRows[1]); - - const router = this.owner.lookup('service:router'); - const transitionToArgs = router.transitionToArgs; - - assert.true(transitionToArgs.length > 0); - assert.strictEqual( - transitionToArgs[0], - 'authenticated.dashboard.sbom.scan-details' - ); - assert.strictEqual(transitionToArgs[1], this.sbomProject.id); - assert.strictEqual(transitionToArgs[2], this.sbomFiles[1].id); - }); - test('test sbom app scans loading & empty state', async function (assert) { this.server.get( '/v2/sb_projects/:id/sb_files', diff --git a/tests/integration/components/sbom/scan-details/component-list-test.js b/tests/integration/components/sbom/scan-details/component-list-test.js index fb5396f9f..8a0eaba6a 100644 --- a/tests/integration/components/sbom/scan-details/component-list-test.js +++ b/tests/integration/components/sbom/scan-details/component-list-test.js @@ -1,12 +1,12 @@ import { render, - click, findAll, find, fillIn, triggerEvent, waitFor, } from '@ember/test-helpers'; + import { hbs } from 'ember-cli-htmlbars'; import { setupMirage } from 'ember-cli-mirage/test-support'; import { setupIntl } from 'ember-intl/test-support'; @@ -14,16 +14,6 @@ import { setupRenderingTest } from 'ember-qunit'; import { module, test } from 'qunit'; import { capitalize } from '@ember/string'; -import Service from '@ember/service'; - -class RouterStub extends Service { - transitionToArgs = []; - - transitionTo() { - this.transitionToArgs = arguments; - } -} - module( 'Integration | Component | sbom/scan-details/component-list', function (hooks) { @@ -79,8 +69,6 @@ module( }, store, }); - - this.owner.register('service:router', RouterStub); }); test('it renders sbom scan component list', async function (assert) { @@ -91,13 +79,13 @@ module( }); await render(hbs` - - `); + + `); assert.dom('[data-test-sbomComponent-table]').exists(); @@ -159,44 +147,6 @@ module( } }); - test('it triggers sbom scan component details route on row click', async function (assert) { - this.server.get('/v2/sb_files/:scan_id/sb_components', (schema) => { - const results = schema.sbomComponents.all().models; - - return { count: results.length, next: null, previous: null, results }; - }); - - await render(hbs` - - `); - - const contentRows = findAll('[data-test-sbomComponent-row]'); - - assert.strictEqual(contentRows.length, this.sbomComponents.length); - - await click(contentRows[2]); - - const router = this.owner.lookup('service:router'); - const transitionToArgs = router.transitionToArgs; - - assert.true(transitionToArgs.length > 0); - - assert.strictEqual( - transitionToArgs[0], - 'authenticated.dashboard.sbom.component-details' - ); - assert.strictEqual(transitionToArgs[1], this.sbomProject.id); - - assert.strictEqual(transitionToArgs[2], this.sbomFile.id); - - assert.strictEqual(transitionToArgs[3], this.sbomComponents[2].id); - }); - test.skip('test sbom scan component list search', async function (assert) { this.server.get('/v2/sb_files/:scan_id/sb_components', (schema, req) => { this.set('query', req.queryParams.q); @@ -207,13 +157,13 @@ module( }); await render(hbs` - - `); + + `); assert.dom('[data-test-sbomComponent-searchInput]').hasNoValue(); @@ -243,13 +193,13 @@ module( }); await render(hbs` - - `); + + `); const contentRows = findAll('[data-test-sbomComponent-row]'); @@ -298,13 +248,13 @@ module( ); render(hbs` - - `); + + `); await waitFor('[data-test-sbom-loadingSvg]', { timeout: 500 });