From 58c9cf904bd41a49aa7a31c3ce3e8361af36efb4 Mon Sep 17 00:00:00 2001 From: Avi Shah Date: Fri, 17 Jan 2025 10:28:48 +0530 Subject: [PATCH] --wip-- fix failing tests ember v5 --- app/adapters/jira-repo.ts | 2 +- app/components/ak-drawer/index.ts | 34 ++-- .../ak-select/before-option/index.ts | 8 +- app/components/ak-select/index.ts | 4 +- app/components/ak-tooltip/index.ts | 36 ++-- .../override-edit-drawer/index.ts | 4 +- .../app-monitoring/settings/index.ts | 4 +- .../appknox-wrapper/onboarding-guide/index.ts | 4 +- app/components/file-compare/table/index.ts | 8 +- .../dynamic-scan/action/expiry/index.ts | 5 +- app/components/github-account/index.js | 8 +- .../list/add-to-team/index.ts | 6 +- .../organization-member/list/index.ts | 6 +- .../list/member-details/index.ts | 6 +- .../add-team-member/index.ts | 6 +- .../add-team-project/index.ts | 6 +- app/components/organization-team/index.ts | 6 +- .../invitation-list/index.ts | 6 +- .../organization-team/member-list/index.ts | 6 +- .../organization-team/project-list/index.ts | 6 +- .../service-account/add-project/list/index.ts | 6 +- .../service-account/create/index.ts | 4 +- .../section/access-token/index.ts | 6 +- .../section/select-project/list/index.ts | 6 +- .../partner/client-report-download/index.js | 2 +- .../client-uploads-stat-chart/index.js | 18 +- .../add-project-collaborator/table/index.ts | 4 +- .../add-project-team/table/index.ts | 5 +- .../general-settings/jira-project/index.ts | 1 - app/components/sbom/app-list/index.ts | 4 +- .../sbom/scan-details/component-list/index.ts | 4 +- .../security/project-search-list/index.ts | 4 +- .../discover/requested-apps/index.ts | 2 +- app/components/system-status/index.ts | 4 +- .../app-monitoring/monitoring-details.ts | 2 +- .../monitoring-details/history.ts | 4 +- .../monitoring-details/index.ts | 4 +- app/services/ajax.ts | 10 ++ app/services/body-class.js | 4 +- app/services/websocket.ts | 4 +- package-lock.json | 5 +- tests/acceptance/file-compare-test.js | 7 +- tests/helpers/destroy-app.js | 6 +- tests/helpers/start-app.js | 13 +- .../index-test.js | 36 ++-- .../components/plus-n-list-test.js | 2 +- tests/unit/initializers/irene-test.js | 10 +- tests/unit/models/analysis-test.js | 158 +++++++++++++----- .../models/analytics/recent-issue-test.js | 12 +- tests/unit/models/api-scan-options-test.js | 20 ++- tests/unit/models/attachment-test.js | 11 +- tests/unit/models/available-device-test.js | 12 +- tests/unit/models/capturedapi-test.js | 12 +- tests/unit/models/coupon-test.js | 9 +- tests/unit/models/device-preference-test.js | 29 ++-- tests/unit/models/device-test.js | 9 +- tests/unit/models/file-test.js | 90 +++++----- tests/unit/models/invoice-test.js | 36 ++-- tests/unit/models/manualscan-test.js | 61 +++---- tests/unit/models/mfa-test.js | 10 +- tests/unit/models/organization-mfa-test.js | 12 +- .../models/organization-namespace-test.js | 11 +- tests/unit/models/organization-user-test.js | 11 +- tests/unit/models/owasp-test.js | 6 +- tests/unit/models/owaspmobile2024-test.js | 8 +- tests/unit/models/personaltoken-test.js | 24 ++- tests/unit/models/plan-test.js | 11 +- tests/unit/models/pricing-test.js | 11 +- tests/unit/models/profile-test.js | 10 +- tests/unit/models/project-team-test.js | 9 +- tests/unit/models/project-test.js | 60 +++++-- tests/unit/models/proxy-settings-test.js | 12 +- tests/unit/models/security/analysis-test.js | 12 +- tests/unit/models/security/attachment-test.js | 12 +- tests/unit/models/security/file-test.js | 12 +- tests/unit/models/security/project-test.js | 12 +- .../models/security/vulnerability-test.js | 12 +- tests/unit/models/submission-test.js | 13 +- tests/unit/models/subscription-test.js | 89 +++++----- tests/unit/models/tag-test.js | 10 +- tests/unit/models/team-invitation-test.js | 12 +- tests/unit/models/team-member-test.js | 10 +- tests/unit/models/team-project-test.js | 10 +- .../models/unknown-analysis-status-test.js | 12 +- tests/unit/models/user-test.js | 63 +++---- .../models/vulnerability-preference-test.js | 94 ++++++++--- tests/unit/models/vulnerability-test.js | 22 ++- .../authenticated/security/file-test.js | 5 +- tests/unit/serializers/mfa-test.js | 9 +- 89 files changed, 802 insertions(+), 609 deletions(-) diff --git a/app/adapters/jira-repo.ts b/app/adapters/jira-repo.ts index 1dd549b7b..b141fab61 100644 --- a/app/adapters/jira-repo.ts +++ b/app/adapters/jira-repo.ts @@ -14,7 +14,7 @@ export default class JiraRepoAdapter extends commondrf { modelName: string | number, snapshot: Snapshot ) { - return this._buildURL(modelName, snapshot.id); + return this._buildURL(modelName, snapshot.record.project.get('id')); } } diff --git a/app/components/ak-drawer/index.ts b/app/components/ak-drawer/index.ts index e30b311e9..74c36a227 100644 --- a/app/components/ak-drawer/index.ts +++ b/app/components/ak-drawer/index.ts @@ -1,6 +1,6 @@ import Component from '@glimmer/component'; import { action } from '@ember/object'; -import { later } from '@ember/runloop'; +import { runTask } from 'ember-lifeline'; export interface DrawerSignature { Element: HTMLDivElement; @@ -38,9 +38,7 @@ export default class DrawerComponent extends Component { @action handleDrawerClose() { - later(() => { - this.args.onClose(); - }, 300); + runTask(this, () => this.args.onClose(), 300); if (this.backdropElement) { this.backdropElement.style.opacity = '0'; @@ -55,22 +53,30 @@ export default class DrawerComponent extends Component { @action backdropInserted(element: HTMLElement) { - later(() => { - this.backdropElement = element; + runTask( + this, + () => { + this.backdropElement = element; - element.style.opacity = '1'; - element.style.transition = 'opacity 225ms ease-in-out 0ms'; - }, 0); + element.style.opacity = '1'; + element.style.transition = 'opacity 225ms ease-in-out 0ms'; + }, + 0 + ); } @action drawerInserted(element: HTMLElement) { - later(() => { - this.drawerElement = element; + runTask( + this, + () => { + this.drawerElement = element; - element.style.transform = 'none'; - element.style.transition = 'transform 225ms ease-out 0ms'; - }, 0); + element.style.transform = 'none'; + element.style.transition = 'transform 225ms ease-out 0ms'; + }, + 0 + ); } } diff --git a/app/components/ak-select/before-option/index.ts b/app/components/ak-select/before-option/index.ts index 5727fcbf7..67245d149 100644 --- a/app/components/ak-select/before-option/index.ts +++ b/app/components/ak-select/before-option/index.ts @@ -1,7 +1,7 @@ import { action } from '@ember/object'; import Component from '@glimmer/component'; import { Select } from 'ember-power-select/components/power-select'; -import { later, scheduleOnce } from '@ember/runloop'; +import { runTask, scheduleTask } from 'ember-lifeline'; interface AkSelectBeforeOptionArgs { select: Select; @@ -22,16 +22,16 @@ export default class AkSelectBeforeOptionComponent extends Component this.args.select.actions.search('')); } @action focusInput(el: HTMLElement) { - later(() => { + runTask(this, () => { if (this.args.autofocus !== false) { el.focus(); } - }, 0); + }); } @action diff --git a/app/components/ak-select/index.ts b/app/components/ak-select/index.ts index 16247fa93..8dedcfbe6 100644 --- a/app/components/ak-select/index.ts +++ b/app/components/ak-select/index.ts @@ -1,7 +1,7 @@ import { guidFor } from '@ember/object/internals'; import Component from '@glimmer/component'; import { action } from '@ember/object'; -import { next } from '@ember/runloop'; +import { runTask } from 'ember-lifeline'; import type { PowerSelectArgs, @@ -70,7 +70,7 @@ export default class AkSelectComponent extends Component< @action onOpen(select: Select, event: Event) { // Reposition the dropdown to make sure it's properly aligned - next(this, () => select.actions.reposition()); + runTask(this, () => select.actions.reposition()); this.args.onOpen?.(select, event); } diff --git a/app/components/ak-tooltip/index.ts b/app/components/ak-tooltip/index.ts index 43a74c7a3..b835365f1 100644 --- a/app/components/ak-tooltip/index.ts +++ b/app/components/ak-tooltip/index.ts @@ -1,7 +1,7 @@ import Component from '@glimmer/component'; import { action } from '@ember/object'; import { tracked } from '@glimmer/tracking'; -import { later, cancel } from '@ember/runloop'; +import { runTask, cancelTask } from 'ember-lifeline'; import { Placement } from '@popperjs/core'; import { EmberRunTimer } from '@ember/runloop/types'; @@ -27,14 +27,19 @@ export interface AkTooltipSignature { export default class AkTooltipComponent extends Component { @tracked anchorRef: HTMLElement | null = null; - @tracked runShowToolipLater?: EmberRunTimer; - @tracked runHideToolipLater?: EmberRunTimer; + @tracked runShowToolipLater?: EmberRunTimer | number; + @tracked runHideToolipLater?: EmberRunTimer | number; willDestroy() { super.willDestroy(); - cancel(this.runShowToolipLater); - cancel(this.runHideToolipLater); + if (this.runShowToolipLater) { + cancelTask(this, this.runShowToolipLater as EmberRunTimer); + } + + if (this.runHideToolipLater) { + cancelTask(this, this.runHideToolipLater as EmberRunTimer); + } } @action @@ -44,9 +49,11 @@ export default class AkTooltipComponent extends Component { } if (this.args.enterDelay) { - this.runShowToolipLater = later(() => { - this.showTooltip(event, event.target as HTMLElement); - }, this.args.enterDelay); + this.runShowToolipLater = runTask( + this, + () => this.showTooltip(event, event.target as HTMLElement), + this.args.enterDelay + ); } else { this.showTooltip(event, event.currentTarget as HTMLElement); } @@ -67,7 +74,10 @@ export default class AkTooltipComponent extends Component { } // cancel if mouse leaves before timeout - const cancelled = cancel(this.runShowToolipLater); + const cancelled = cancelTask( + this, + this.runShowToolipLater as EmberRunTimer + ); // tooltip never appeared so onClose should not be called if (cancelled) { @@ -75,9 +85,11 @@ export default class AkTooltipComponent extends Component { } if (this.args.leaveDelay) { - this.runHideToolipLater = later(() => { - this.hideTooltip(event); - }, this.args.leaveDelay); + this.runHideToolipLater = runTask( + this, + () => this.hideTooltip(event), + this.args.leaveDelay + ); } else { this.hideTooltip(event); } diff --git a/app/components/analysis-risk/override-edit-drawer/index.ts b/app/components/analysis-risk/override-edit-drawer/index.ts index f395789a9..f615dc7be 100644 --- a/app/components/analysis-risk/override-edit-drawer/index.ts +++ b/app/components/analysis-risk/override-edit-drawer/index.ts @@ -3,7 +3,7 @@ import { service } from '@ember/service'; import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; import IntlService from 'ember-intl/services/intl'; -import { next } from '@ember/runloop'; +import { runTask } from 'ember-lifeline'; import { ComponentLike } from '@glint/template'; import AnalysisModel from 'irene/models/analysis'; @@ -65,7 +65,7 @@ export default class AnalysisRiskOverrideEditDrawerComponent extends Component { + runTask(this, () => { this.appBarData = appBarData; }); } diff --git a/app/components/app-monitoring/settings/index.ts b/app/components/app-monitoring/settings/index.ts index 25a8f5444..574aea82e 100644 --- a/app/components/app-monitoring/settings/index.ts +++ b/app/components/app-monitoring/settings/index.ts @@ -4,7 +4,7 @@ import { task } from 'ember-concurrency'; import IntlService from 'ember-intl/services/intl'; import { action } from '@ember/object'; import RouterService from '@ember/routing/router-service'; -import { debounce } from '@ember/runloop'; +import { debounceTask } from 'ember-lifeline'; import AmConfigurationModel from 'irene/models/amconfiguration'; import MeService from 'irene/services/me'; @@ -96,7 +96,7 @@ export default class AppMonitoringSettingsComponent extends Component { + runTask(this, () => { this.mountIFrame = true; }); } diff --git a/app/components/file-compare/table/index.ts b/app/components/file-compare/table/index.ts index f66e34646..572ab1e12 100644 --- a/app/components/file-compare/table/index.ts +++ b/app/components/file-compare/table/index.ts @@ -2,7 +2,7 @@ import { action } from '@ember/object'; import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; import { inject as service } from '@ember/service'; -import { later } from '@ember/runloop'; +import { runTask } from 'ember-lifeline'; import RouterService from '@ember/routing/router-service'; import IntlService from 'ember-intl/services/intl'; @@ -150,7 +150,11 @@ export default class FileCompareTableComponent extends Component scrollDashboardMainContainerTo({ top: 0, left: 0 }), 150); + runTask( + this, + () => scrollDashboardMainContainerTo({ top: 0, left: 0 }), + 150 + ); } } diff --git a/app/components/file-details/dynamic-scan/action/expiry/index.ts b/app/components/file-details/dynamic-scan/action/expiry/index.ts index f60dc9bff..a3fb1743b 100644 --- a/app/components/file-details/dynamic-scan/action/expiry/index.ts +++ b/app/components/file-details/dynamic-scan/action/expiry/index.ts @@ -4,7 +4,7 @@ import { tracked } from '@glimmer/tracking'; import { task } from 'ember-concurrency'; import { action } from '@ember/object'; import { inject as service } from '@ember/service'; -import { later } from '@ember/runloop'; +import { runTask } from 'ember-lifeline'; import { EmberRunTimer } from '@ember/runloop/types'; import { addObserver, removeObserver } from '@ember/object/observers'; import type Store from '@ember-data/store'; @@ -121,7 +121,8 @@ export default class DynamicScanExpiryComponent extends Component this.clock(), 1000); } updateDurationRemaining() { diff --git a/app/components/github-account/index.js b/app/components/github-account/index.js index 786968cda..ad43b7783 100644 --- a/app/components/github-account/index.js +++ b/app/components/github-account/index.js @@ -13,11 +13,17 @@ export default class GithubAccountComponent extends Component { @service organization; @tracked showRevokeGithubConfirmBox = false; - @tracked integratedUser = this.args.integratedUser; + @tracked integratedUser; tGithubWillBeRevoked = this.intl.t('githubWillBeRevoked'); tGithubErrorIntegration = this.intl.t('githubErrorIntegration'); + constructor() { + super(...arguments); + + this.integratedUser = this.args.integratedUser; + } + redirectAPI = task(async () => { return await this.ajax.request( `/api/organizations/${this.organization.selected.id}/github/redirect` diff --git a/app/components/organization-member/list/add-to-team/index.ts b/app/components/organization-member/list/add-to-team/index.ts index 65df3e03b..822f3b466 100644 --- a/app/components/organization-member/list/add-to-team/index.ts +++ b/app/components/organization-member/list/add-to-team/index.ts @@ -3,7 +3,7 @@ import { action } from '@ember/object'; import { tracked } from '@glimmer/tracking'; import { inject as service } from '@ember/service'; import { task } from 'ember-concurrency'; -import { debounce } from '@ember/runloop'; +import { debounceTask } from 'ember-lifeline'; import Store from '@ember-data/store'; import IntlService from 'ember-intl/services/intl'; // eslint-disable-next-line ember/use-ember-data-rfc-395-imports @@ -65,9 +65,9 @@ export default class AddToTeamComponent extends Component { + runTask(this, () => { this.changeset = mergedChangeset; }); diff --git a/app/components/organization/service-account/section/access-token/index.ts b/app/components/organization/service-account/section/access-token/index.ts index bf0e45691..f0b3e9930 100644 --- a/app/components/organization/service-account/section/access-token/index.ts +++ b/app/components/organization/service-account/section/access-token/index.ts @@ -5,7 +5,7 @@ import { tracked } from '@glimmer/tracking'; import dayjs from 'dayjs'; import { task } from 'ember-concurrency'; import { waitForPromise } from '@ember/test-waiters'; -import { next } from '@ember/runloop'; +import { runTask } from 'ember-lifeline'; import type IntlService from 'ember-intl/services/intl'; import parseError from 'irene/utils/parse-error'; @@ -39,9 +39,7 @@ export default class OrganizationServiceAccountSectionAccessTokenComponent exten this.doesNotExpire = this.args.serviceAccount.expiry === null; // sets the expiry in create mode - next(() => { - this.setCreateServiceAccountExpiry(); - }); + runTask(this, () => this.setCreateServiceAccountExpiry()); } get renderType() { diff --git a/app/components/organization/service-account/section/select-project/list/index.ts b/app/components/organization/service-account/section/select-project/list/index.ts index b476f0586..9c02b07af 100644 --- a/app/components/organization/service-account/section/select-project/list/index.ts +++ b/app/components/organization/service-account/section/select-project/list/index.ts @@ -3,7 +3,7 @@ import { service } from '@ember/service'; import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; import { task } from 'ember-concurrency'; -import { debounce } from '@ember/runloop'; +import { debounceTask } from 'ember-lifeline'; // eslint-disable-next-line ember/use-ember-data-rfc-395-imports import type DS from 'ember-data'; @@ -117,9 +117,9 @@ export default class OrganizationServiceAccountSectionSelectProjectListComponent @action handleSearchQueryChange(event: Event) { - debounce( + debounceTask( this, - this.setSearchQuery, + 'setSearchQuery', (event.target as HTMLInputElement).value, 500 ); diff --git a/app/components/partner/client-report-download/index.js b/app/components/partner/client-report-download/index.js index e056e7546..316c9b487 100644 --- a/app/components/partner/client-report-download/index.js +++ b/app/components/partner/client-report-download/index.js @@ -92,7 +92,7 @@ export default class PartnerClientReportDownloadComponent extends Component { 'partner/partnerclient-report', { clientId: this.args.clientId, - id: this.reports.firstObject.id, + id: this.reports[0].id, } ); diff --git a/app/components/partner/client-uploads-stat-chart/index.js b/app/components/partner/client-uploads-stat-chart/index.js index aaf6916ae..7b63918af 100644 --- a/app/components/partner/client-uploads-stat-chart/index.js +++ b/app/components/partner/client-uploads-stat-chart/index.js @@ -22,13 +22,6 @@ export default class PartnerClientUploadsStatChartComponent extends Component { @service intl; @service partner; - constructor() { - super(...arguments); - dayjs.extend(advancedFormat); - dayjs.extend(weekOfYear); - dayjs.extend(weekday); - } - // Properties datepickerOptions = [ 'last7Days', @@ -79,7 +72,7 @@ export default class PartnerClientUploadsStatChartComponent extends Component { }, ]; - @tracked currentTimeline = this.timelinePlaceholders.objectAt(0); + @tracked currentTimeline; @tracked chartContainer = null; @@ -87,6 +80,15 @@ export default class PartnerClientUploadsStatChartComponent extends Component { maxDate = dayjs(Date.now()).toDate(); + constructor() { + super(...arguments); + dayjs.extend(advancedFormat); + dayjs.extend(weekOfYear); + dayjs.extend(weekday); + + this.currentTimeline = this.timelinePlaceholders.objectAt(0); + } + get startDate() { return this.dateRange.objectAt(0); } diff --git a/app/components/project-settings/general-settings/add-project-collaborator/table/index.ts b/app/components/project-settings/general-settings/add-project-collaborator/table/index.ts index bc4afe713..def086598 100644 --- a/app/components/project-settings/general-settings/add-project-collaborator/table/index.ts +++ b/app/components/project-settings/general-settings/add-project-collaborator/table/index.ts @@ -8,7 +8,7 @@ import IntlService from 'ember-intl/services/intl'; import Store from '@ember-data/store'; import { action } from '@ember/object'; import ProjectModel from 'irene/models/project'; -import { debounce } from '@ember/runloop'; +import { debounceTask } from 'ember-lifeline'; import OrganizationMemberModel from 'irene/models/organization-member'; import parseError from 'irene/utils/parse-error'; @@ -84,7 +84,7 @@ export default class ProjectSettingsGeneralSettingsAddProjectCollaboratorTableCo } @action setSearchQuery() { - debounce(this, this.updateSearchQuery, 500); + debounceTask(this, 'updateSearchQuery', 500); } @action diff --git a/app/components/project-settings/general-settings/add-project-team/table/index.ts b/app/components/project-settings/general-settings/add-project-team/table/index.ts index 0cc033f6c..2fe2cf135 100644 --- a/app/components/project-settings/general-settings/add-project-team/table/index.ts +++ b/app/components/project-settings/general-settings/add-project-team/table/index.ts @@ -7,9 +7,10 @@ import { task } from 'ember-concurrency'; import IntlService from 'ember-intl/services/intl'; import Store from '@ember-data/store'; import { action } from '@ember/object'; +import { debounceTask } from 'ember-lifeline'; + import OrganizationTeamModel from 'irene/models/organization-team'; import ProjectModel from 'irene/models/project'; -import { debounce } from '@ember/runloop'; import parseError from 'irene/utils/parse-error'; interface LimitOffset { @@ -84,7 +85,7 @@ export default class ProjectSettingsGeneralSettingsAddProjectTeamTableComponent } @action setSearchQuery() { - debounce(this, this.updateSearchQuery, 500); + debounceTask(this, 'updateSearchQuery', 500); } @action diff --git a/app/components/project-settings/general-settings/jira-project/index.ts b/app/components/project-settings/general-settings/jira-project/index.ts index 2617ec5bc..e9977bbb7 100644 --- a/app/components/project-settings/general-settings/jira-project/index.ts +++ b/app/components/project-settings/general-settings/jira-project/index.ts @@ -239,7 +239,6 @@ export default class ProjectSettingsGeneralSettingsJiraProjectComponent extends jiraProject.setProperties(projectDetails); } else { jiraProject = this.store.createRecord('jira-repo', { - id: this.project?.id, project: this.project, ...projectDetails, }); diff --git a/app/components/sbom/app-list/index.ts b/app/components/sbom/app-list/index.ts index f20c0189a..3d30dbef1 100644 --- a/app/components/sbom/app-list/index.ts +++ b/app/components/sbom/app-list/index.ts @@ -4,7 +4,7 @@ import IntlService from 'ember-intl/services/intl'; import { task } from 'ember-concurrency'; import { tracked } from '@glimmer/tracking'; import { action } from '@ember/object'; -import { debounce } from '@ember/runloop'; +import { debounceTask } from 'ember-lifeline'; // eslint-disable-next-line ember/use-ember-data-rfc-395-imports import { DS } from 'ember-data'; @@ -165,7 +165,7 @@ export default class SbomAppListComponent extends Component this.getWebsocketHealthStatus.perform()); + runTask(this, () => this.getWebsocketHealthStatus.perform()); } } diff --git a/app/routes/authenticated/dashboard/app-monitoring/monitoring-details.ts b/app/routes/authenticated/dashboard/app-monitoring/monitoring-details.ts index eb3e7ffa0..eb5d74e32 100644 --- a/app/routes/authenticated/dashboard/app-monitoring/monitoring-details.ts +++ b/app/routes/authenticated/dashboard/app-monitoring/monitoring-details.ts @@ -19,7 +19,7 @@ export default class AuthenticatedDashboardAppMonitoringMonitoringDetailsRoute e beforeModel() { if (!this.organization.selected?.features.app_monitoring) { - this.transitionTo('authenticated.dashboard.projects'); + this.router.transitionTo('authenticated.dashboard.projects'); } } diff --git a/app/routes/authenticated/dashboard/app-monitoring/monitoring-details/history.ts b/app/routes/authenticated/dashboard/app-monitoring/monitoring-details/history.ts index 1d6cf67ba..a3936186b 100644 --- a/app/routes/authenticated/dashboard/app-monitoring/monitoring-details/history.ts +++ b/app/routes/authenticated/dashboard/app-monitoring/monitoring-details/history.ts @@ -1,5 +1,6 @@ import { service } from '@ember/service'; import type Store from '@ember-data/store'; +import type RouterService from '@ember/routing/router-service'; import AkBreadcrumbsRoute from 'irene/utils/ak-breadcrumbs-route'; import type OrganizationService from 'irene/services/organization'; @@ -8,12 +9,13 @@ import type { AppMonitoringDetailsQueryParams } from 'irene/routes/authenticated export default class AuthenticatedDashboardAppMonitoringMonitoringDetailsHistoryRoute extends AkBreadcrumbsRoute { @service declare organization: OrganizationService; @service declare store: Store; + @service declare router: RouterService; parentRoute = 'authenticated.dashboard.app-monitoring.monitoring-details'; beforeModel() { if (!this.organization.selected?.features.app_monitoring) { - this.transitionTo('authenticated.dashboard.projects'); + this.router.transitionTo('authenticated.dashboard.projects'); } } diff --git a/app/routes/authenticated/dashboard/app-monitoring/monitoring-details/index.ts b/app/routes/authenticated/dashboard/app-monitoring/monitoring-details/index.ts index 718783903..61b42da05 100644 --- a/app/routes/authenticated/dashboard/app-monitoring/monitoring-details/index.ts +++ b/app/routes/authenticated/dashboard/app-monitoring/monitoring-details/index.ts @@ -1,5 +1,6 @@ import Store from '@ember-data/store'; import { service } from '@ember/service'; +import type RouterService from '@ember/routing/router-service'; import AkBreadcrumbsRoute from 'irene/utils/ak-breadcrumbs-route'; import type OrganizationService from 'irene/services/organization'; @@ -8,12 +9,13 @@ import type { AppMonitoringDetailsQueryParams } from 'irene/routes/authenticated export default class AuthenticatedDashboardAppMonitoringMonitoringDetailsIndexRoute extends AkBreadcrumbsRoute { @service declare organization: OrganizationService; @service declare store: Store; + @service declare router: RouterService; parentRoute = 'authenticated.dashboard.app-monitoring.monitoring-details'; beforeModel() { if (!this.organization.selected?.features.app_monitoring) { - this.transitionTo('authenticated.dashboard.projects'); + this.router.transitionTo('authenticated.dashboard.projects'); } } diff --git a/app/services/ajax.ts b/app/services/ajax.ts index 5f8a3c210..a930a8023 100644 --- a/app/services/ajax.ts +++ b/app/services/ajax.ts @@ -30,6 +30,16 @@ interface DefaultHeaders { 'X-Product': string; } +export interface AjaxError { + type: string; + status: number; + ok: boolean; + statusText: string; + url: string; + message: string; + payload: any; +} + const completeUrlRegex = /^(http|https)/; function isFullURL(url: string): boolean { diff --git a/app/services/body-class.js b/app/services/body-class.js index 455425979..56739bbdb 100644 --- a/app/services/body-class.js +++ b/app/services/body-class.js @@ -1,6 +1,6 @@ import Service from '@ember/service'; import { inject as service } from '@ember/service'; -import { scheduleOnce } from '@ember/runloop'; +import { scheduleTask } from 'ember-lifeline'; export default class BodyClassService extends Service { // https://github.com/ember-cli/ember-page-title/blob/a886af4d83c7a3a3c716372e8a322258a4f92991/addon/services/page-title-list.js#L27 @@ -61,7 +61,7 @@ export default class BodyClassService extends Service { } scheduleUpdate() { - scheduleOnce('afterRender', this, this._updateClass); + scheduleTask(this, 'render', () => this._updateClass()); } applyTokenDefaults(token) { diff --git a/app/services/websocket.ts b/app/services/websocket.ts index ff7379e6e..72aa9f8a1 100644 --- a/app/services/websocket.ts +++ b/app/services/websocket.ts @@ -2,7 +2,7 @@ import { inject as service } from '@ember/service'; import { singularize } from 'ember-inflector'; import Service from '@ember/service'; import { task } from 'ember-concurrency'; -import { debounce } from '@ember/runloop'; +import { debounceTask } from 'ember-lifeline'; import type Store from '@ember-data/store'; import ENUMS from 'irene/enums'; @@ -235,7 +235,7 @@ export default class WebsocketService extends Service { this.modelNameIdMapper[`${modelName}-${id}`] = { modelName, id }; // debounce and pass copy of mapper object - debounce(this, this.handlePullModel, { ...this.modelNameIdMapper }, 300); + debounceTask(this, 'handlePullModel', { ...this.modelNameIdMapper }, 300); } ); diff --git a/package-lock.json b/package-lock.json index 661c2dd24..e0163779d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25766,6 +25766,7 @@ "integrity": "sha512-p7D6wJ5EJFFq1CcF2lu1XeqKFLBob8jRQGNAvFLTsV3CbSKBl3VtliAVlUIGz2i9H6kEFnI2Amaft5ZopIG2Fw==", "dev": true, "license": "MIT", + "optional": true, "dependencies": { "find": "^0.2.4" } @@ -54112,6 +54113,7 @@ "integrity": "sha512-7a4/LCiInB9xYMnAUEjLilL9FKclwbwK7VlXw+h5jMvT2TDFeYFCHM24O1XdnC/on/hx8mxVO3FTQkyHZnOghQ==", "dev": true, "license": "MIT", + "optional": true, "dependencies": { "traverse-chain": "~0.1.0" } @@ -84121,7 +84123,8 @@ "resolved": "https://registry.npmjs.org/traverse-chain/-/traverse-chain-0.1.0.tgz", "integrity": "sha512-up6Yvai4PYKhpNp5PkYtx50m3KbwQrqDwbuZP/ItyL64YEWHAvH6Md83LFLV/GRSk/BoUVwwgUzX6SOQSbsfAg==", "dev": true, - "license": "MIT" + "license": "MIT", + "optional": true }, "node_modules/tree-kill": { "version": "1.2.2", diff --git a/tests/acceptance/file-compare-test.js b/tests/acceptance/file-compare-test.js index 99f30bfdb..c8d4a89f4 100644 --- a/tests/acceptance/file-compare-test.js +++ b/tests/acceptance/file-compare-test.js @@ -30,20 +30,15 @@ module('Acceptance | file compare', function (hooks) { setupMirage(hooks); hooks.beforeEach(async function () { - const { vulnerabilities } = await setupRequiredEndpoints(this.server); + 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 diff --git a/tests/helpers/destroy-app.js b/tests/helpers/destroy-app.js index 24dd14def..6f760e7a5 100644 --- a/tests/helpers/destroy-app.js +++ b/tests/helpers/destroy-app.js @@ -1,10 +1,10 @@ -import { run } from '@ember/runloop'; - export default function destroyApp(application) { - run(application, 'destroy'); + application.destroy(); + if (window.server) { window.server.shutdown(); } + // eslint-disable-next-line server.shutdown(); } diff --git a/tests/helpers/start-app.js b/tests/helpers/start-app.js index 838532d59..05b120d5d 100644 --- a/tests/helpers/start-app.js +++ b/tests/helpers/start-app.js @@ -1,16 +1,17 @@ import Application from '../../app'; import config from '../../config/environment'; import { merge } from '@ember/polyfills'; -import { run } from '@ember/runloop'; export default function startApp(attrs) { let attributes = merge({}, config.APP); attributes.autoboot = true; + attributes = merge(attributes, attrs); // use defaults, but you can override; - return run(() => { - let application = Application.create(attributes); - application.setupForTesting(); - application.injectTestHelpers(); - }); + let application = Application.create(attributes); + + application.setupForTesting(); + application.injectTestHelpers(); + + return application; } diff --git a/tests/integration/components/file-details/vulnerability-analysis-details/index-test.js b/tests/integration/components/file-details/vulnerability-analysis-details/index-test.js index 8cb914c0b..45ee4d637 100644 --- a/tests/integration/components/file-details/vulnerability-analysis-details/index-test.js +++ b/tests/integration/components/file-details/vulnerability-analysis-details/index-test.js @@ -251,7 +251,7 @@ module( assert, { risk, computedRisk, overriddenRisk, findings } ) { - const analysis = this.file.analyses.lastObject; + const analysis = this.file.analyses.at(-1); analysis.risk = risk; analysis.computedRisk = computedRisk; analysis.overriddenRisk = overriddenRisk ?? null; @@ -335,7 +335,7 @@ module( assert, { risk, computedRisk, overriddenRisk, businessImplication } ) { - const analysis = this.file.analyses.lastObject; + const analysis = this.file.analyses.at(-1); analysis.risk = risk; analysis.computedRisk = computedRisk; analysis.overriddenRisk = overriddenRisk ?? null; @@ -417,7 +417,7 @@ module( assert, { risk, computedRisk, overriddenRisk, compliantSolution } ) { - const analysis = this.file.analyses.lastObject; + const analysis = this.file.analyses.at(-1); analysis.risk = risk; analysis.computedRisk = computedRisk; analysis.overriddenRisk = overriddenRisk ?? null; @@ -499,7 +499,7 @@ module( assert, { risk, computedRisk, overriddenRisk, nonCompliantCodeExample } ) { - const analysis = this.file.analyses.lastObject; + const analysis = this.file.analyses.at(-1); analysis.risk = risk; analysis.computedRisk = computedRisk; analysis.overriddenRisk = overriddenRisk ?? null; @@ -567,7 +567,7 @@ module( assert, { risk, computedRisk, overriddenRisk, doesNotHaveFindings } ) { - const analysis = this.file.analyses.lastObject; + const analysis = this.file.analyses.at(-1); analysis.risk = risk; analysis.computedRisk = computedRisk; analysis.overriddenRisk = overriddenRisk ?? null; @@ -623,7 +623,7 @@ module( ); test('it renders analysis details with vulnerable api findings', async function (assert) { - const analysis = this.file.analyses.lastObject; + const analysis = this.file.analyses.at(-1); analysis.risk = ENUMS.RISK.MEDIUM; analysis.computedRisk = ENUMS.RISK.MEDIUM; analysis.overriddenRisk = null; @@ -798,7 +798,7 @@ module( ) ); - const analysis = this.file.analyses.lastObject; + const analysis = this.file.analyses.at(-1); this.set('analysis', analysis); @@ -842,7 +842,7 @@ module( 'it does not render regulatories for (system passed, untested) risk', [ENUMS.RISK.NONE, ENUMS.RISK.UNKNOWN], async function (assert, computedRisk) { - const analysis = this.file.analyses.firstObject; + const analysis = this.file.analyses[0]; analysis.computedRisk = computedRisk; analysis.overriddenRisk = null; @@ -898,7 +898,7 @@ module( 'it does not render regulatories if analysis is not completed', [ENUMS.ANALYSIS.WAITING, ENUMS.ANALYSIS.RUNNING, ENUMS.ANALYSIS.ERROR], async function (assert, status) { - const analysis = this.file.analyses.firstObject; + const analysis = this.file.analyses[0]; analysis.computedRisk = ENUMS.RISK.UNKNOWN; analysis.status = status; @@ -961,7 +961,7 @@ module( }, ], async function (assert, { risk, computedRisk, overriddenRisk }) { - const analysis = this.file.analyses.firstObject; + const analysis = this.file.analyses[0]; analysis.risk = risk; analysis.computedRisk = computedRisk; @@ -1078,7 +1078,7 @@ module( ); test('it renders optional regulatories based in profile regulatory preference', async function (assert) { - const analysis = this.file.analyses.firstObject; + const analysis = this.file.analyses[0]; analysis.computedRisk = ENUMS.RISK.CRITICAL; analysis.risk = ENUMS.RISK.CRITICAL; @@ -1209,7 +1209,7 @@ module( }, ], async function (assert, { risk, computedRisk, overriddenRisk }) { - const analysis = this.file.analyses.lastObject; + const analysis = this.file.analyses.at(-1); analysis.risk = risk; analysis.computedRisk = computedRisk; @@ -1400,7 +1400,11 @@ module( '[data-test-analysisDetail-regulatoryContent-listItem]' ); - const regulatorContent = analysis[modelKey].toArray(); + const relationshipReference = this.analysis.hasMany(modelKey); + + const value = relationshipReference.value(); + + const regulatorContent = value.toArray(); contents.forEach((ctnt, i) => { assert @@ -1805,7 +1809,11 @@ module( '[data-test-analysisDetail-regulatoryContent-listItem]' ); - const regulatorContent = analysis[modelKey].toArray(); + const relationshipReference = this.analysis.hasMany(modelKey); + + const value = relationshipReference.value(); + + const regulatorContent = value.toArray(); for (let i = 0; i < contents.length; i++) { assert diff --git a/tests/integration/components/plus-n-list-test.js b/tests/integration/components/plus-n-list-test.js index b683f96be..5d99fcd05 100644 --- a/tests/integration/components/plus-n-list-test.js +++ b/tests/integration/components/plus-n-list-test.js @@ -26,7 +26,7 @@ module('Integration | Component | plus-n-list', function (hooks) { } this.set('emails', emails); await render(hbs``); - assert.dom('[data-test-default-items]').hasText(this.emails.firstObject); + assert.dom('[data-test-default-items]').hasText(this.emails[0]); }); test('it renders 3 default items', async function (assert) { diff --git a/tests/unit/initializers/irene-test.js b/tests/unit/initializers/irene-test.js index e03d0de79..4434eb948 100644 --- a/tests/unit/initializers/irene-test.js +++ b/tests/unit/initializers/irene-test.js @@ -1,18 +1,16 @@ import Application from '@ember/application'; import Resolver from 'ember-resolver'; import { module, test } from 'qunit'; -import { run } from '@ember/runloop'; let application = null; module('Unit | Initializer | irene', function (hooks) { hooks.beforeEach(function () { - run(() => { - application = Application.create({ - Resolver, - }); - application.deferReadiness(); + application = Application.create({ + Resolver, }); + + application.deferReadiness(); }); test('it works', function (assert) { diff --git a/tests/unit/models/analysis-test.js b/tests/unit/models/analysis-test.js index fb6afb960..d1c531af9 100644 --- a/tests/unit/models/analysis-test.js +++ b/tests/unit/models/analysis-test.js @@ -2,54 +2,128 @@ import ENUMS from 'irene/enums'; import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; -module('Unit | Model | analysis', function(hooks) { +module('Unit | Model | analysis', function (hooks) { setupTest(hooks); - hooks.beforeEach(function() { + hooks.beforeEach(function () { // set the locale and the config this.owner.lookup('service:intl').setLocale('en'); }); - test('it exists', function(assert) { - const analysis = run(() => this.owner.lookup('service:store').createRecord('analysis')); - let store = this.owner.lookup('service:store'); - run(function() { - assert.equal(analysis.get('isScanning'), 0, "Unknown"); - - assert.equal(analysis.hasType(), false, "No type"); - analysis.set('vulnerability', store.createRecord('vulnerability', { - types: [1,2,3] - }) - ); - assert.equal(analysis.hasType(1), true, "Has Type"); - analysis.set('risk', ENUMS.RISK.UNKNOWN); - assert.equal(analysis.iconClass(ENUMS.RISK.UNKNOWN), "fa-spinner fa-spin", "Loading"); - analysis.set('risk', ENUMS.RISK.NONE); - assert.equal(analysis.iconClass(ENUMS.RISK.NONE), "fa-check", "Check"); - analysis.set('risk', ENUMS.RISK.CRITICAL); - assert.equal(analysis.iconClass(ENUMS.RISK.CRITICAL), "fa-warning", "Warning"); - assert.equal(analysis.get("riskIconClass"), "fa-warning", "Risk Icon Class"); - const cls = 'tag'; - analysis.set('risk', ENUMS.RISK.UNKNOWN); - assert.equal(analysis.labelClass(ENUMS.RISK.UNKNOWN), cls + " " + "is-progress", "Progress"); - analysis.set('risk', ENUMS.RISK.NONE); - assert.equal(analysis.labelClass(ENUMS.RISK.NONE), cls + " " + "is-success", "Success"); - analysis.set('risk', ENUMS.RISK.LOW); - assert.equal(analysis.labelClass(ENUMS.RISK.LOW), cls + " " + "is-info", "Info"); - analysis.set('risk', ENUMS.RISK.MEDIUM); - assert.equal(analysis.labelClass(ENUMS.RISK.MEDIUM), cls + " " + "is-warning", "Warning"); - analysis.set('risk', ENUMS.RISK.HIGH); - assert.equal(analysis.labelClass(ENUMS.RISK.HIGH), cls + " " + "is-danger", "Danger"); - analysis.set('risk', ENUMS.RISK.CRITICAL); - assert.equal(analysis.labelClass(ENUMS.RISK.CRITICAL), cls + " " + "is-critical", "Critical"); - assert.equal(analysis.get('isRisky'), true, "Is Risky"); - assert.equal(analysis.get('riskLabelClass'), "tag is-critical", "Risk Label Class"); - - analysis.set('overriddenRisk', ENUMS.RISK.CRITICAL); - assert.equal(analysis.get("overriddenRiskIconClass"), "fa-warning", "Overridden Risk Icon Class"); - assert.equal(analysis.get("overriddenRiskLabelClass"), cls + " " + "is-critical", "Overridden Risk Icon Class"); - }); + test('it exists', function (assert) { + const store = this.owner.lookup('service:store'); + const analysis = store.createRecord('analysis'); + + assert.equal(analysis.get('isScanning'), 0, 'Unknown'); + + assert.equal(analysis.hasType(), false, 'No type'); + + analysis.set( + 'vulnerability', + store.createRecord('vulnerability', { + types: [1, 2, 3], + }) + ); + + assert.equal(analysis.hasType(1), true, 'Has Type'); + + analysis.set('risk', ENUMS.RISK.UNKNOWN); + + assert.equal( + analysis.iconClass(ENUMS.RISK.UNKNOWN), + 'fa-spinner fa-spin', + 'Loading' + ); + + analysis.set('risk', ENUMS.RISK.NONE); + + assert.equal(analysis.iconClass(ENUMS.RISK.NONE), 'fa-check', 'Check'); + + analysis.set('risk', ENUMS.RISK.CRITICAL); + + assert.equal( + analysis.iconClass(ENUMS.RISK.CRITICAL), + 'fa-warning', + 'Warning' + ); + + assert.equal( + analysis.get('riskIconClass'), + 'fa-warning', + 'Risk Icon Class' + ); + + const cls = 'tag'; + + analysis.set('risk', ENUMS.RISK.UNKNOWN); + + assert.equal( + analysis.labelClass(ENUMS.RISK.UNKNOWN), + cls + ' ' + 'is-progress', + 'Progress' + ); + + analysis.set('risk', ENUMS.RISK.NONE); + + assert.equal( + analysis.labelClass(ENUMS.RISK.NONE), + cls + ' ' + 'is-success', + 'Success' + ); + + analysis.set('risk', ENUMS.RISK.LOW); + + assert.equal( + analysis.labelClass(ENUMS.RISK.LOW), + cls + ' ' + 'is-info', + 'Info' + ); + + analysis.set('risk', ENUMS.RISK.MEDIUM); + + assert.equal( + analysis.labelClass(ENUMS.RISK.MEDIUM), + cls + ' ' + 'is-warning', + 'Warning' + ); + + analysis.set('risk', ENUMS.RISK.HIGH); + + assert.equal( + analysis.labelClass(ENUMS.RISK.HIGH), + cls + ' ' + 'is-danger', + 'Danger' + ); + + analysis.set('risk', ENUMS.RISK.CRITICAL); + + assert.equal( + analysis.labelClass(ENUMS.RISK.CRITICAL), + cls + ' ' + 'is-critical', + 'Critical' + ); + + assert.equal(analysis.get('isRisky'), true, 'Is Risky'); + + assert.equal( + analysis.get('riskLabelClass'), + 'tag is-critical', + 'Risk Label Class' + ); + + analysis.set('overriddenRisk', ENUMS.RISK.CRITICAL); + + assert.equal( + analysis.get('overriddenRiskIconClass'), + 'fa-warning', + 'Overridden Risk Icon Class' + ); + + assert.equal( + analysis.get('overriddenRiskLabelClass'), + cls + ' ' + 'is-critical', + 'Overridden Risk Icon Class' + ); }); }); diff --git a/tests/unit/models/analytics/recent-issue-test.js b/tests/unit/models/analytics/recent-issue-test.js index 9e00b43a1..d2967cd0f 100644 --- a/tests/unit/models/analytics/recent-issue-test.js +++ b/tests/unit/models/analytics/recent-issue-test.js @@ -2,14 +2,14 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Model | analytics/recent issue', function(hooks) { +module('Unit | Model | analytics/recent issue', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - let model = run(() => this.owner.lookup('service:store').createRecord('analytics/recent-issue')); - // let store = this.store(); + test('it exists', function (assert) { + let model = this.owner + .lookup('service:store') + .createRecord('analytics/recent-issue'); + assert.ok(!!model); }); }); diff --git a/tests/unit/models/api-scan-options-test.js b/tests/unit/models/api-scan-options-test.js index 03bb69ab2..c9824baf8 100644 --- a/tests/unit/models/api-scan-options-test.js +++ b/tests/unit/models/api-scan-options-test.js @@ -1,16 +1,20 @@ /* eslint-disable prettier/prettier, qunit/require-expect, qunit/no-assert-equal */ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; -module('Unit | Model | api scan options', function(hooks) { +module('Unit | Model | api scan options', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - const apiScanOptions = run(() => this.owner.lookup('service:store').createRecord('api-scan-options')); - run(function() { - apiScanOptions.set('apiUrlFilters', "test.com"); - assert.equal(apiScanOptions.get('apiUrlFilterItems'), "test.com", "No role"); - }); + test('it exists', function (assert) { + const store = this.owner.lookup('service:store'); + const apiScanOptions = store.createRecord('api-scan-options'); + + apiScanOptions.set('apiUrlFilters', 'test.com'); + + assert.equal( + apiScanOptions.get('apiUrlFilterItems'), + 'test.com', + 'No role' + ); }); }); diff --git a/tests/unit/models/attachment-test.js b/tests/unit/models/attachment-test.js index 8a1b10413..a38704421 100644 --- a/tests/unit/models/attachment-test.js +++ b/tests/unit/models/attachment-test.js @@ -2,13 +2,12 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Model | attachment', function(hooks) { +module('Unit | Model | attachment', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - const model = run(() => this.owner.lookup('service:store').createRecord('attachment')); - return assert.ok(!!model); + test('it exists', function (assert) { + const model = this.owner.lookup('service:store').createRecord('attachment'); + + assert.ok(!!model); }); }); diff --git a/tests/unit/models/available-device-test.js b/tests/unit/models/available-device-test.js index 10ec9b16e..29578387a 100644 --- a/tests/unit/models/available-device-test.js +++ b/tests/unit/models/available-device-test.js @@ -2,14 +2,14 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Model | available device', function(hooks) { +module('Unit | Model | available device', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - let model = run(() => this.owner.lookup('service:store').createRecord('available-device')); - // let store = this.store(); + test('it exists', function (assert) { + const model = this.owner + .lookup('service:store') + .createRecord('available-device'); + assert.ok(!!model); }); }); diff --git a/tests/unit/models/capturedapi-test.js b/tests/unit/models/capturedapi-test.js index 4cc117ab3..9dcb3c3cb 100644 --- a/tests/unit/models/capturedapi-test.js +++ b/tests/unit/models/capturedapi-test.js @@ -2,14 +2,14 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Model | capturedapi', function(hooks) { +module('Unit | Model | capturedapi', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - let model = run(() => this.owner.lookup('service:store').createRecord('capturedapi')); - // let store = this.store(); + test('it exists', function (assert) { + const model = this.owner + .lookup('service:store') + .createRecord('capturedapi'); + assert.ok(!!model); }); }); diff --git a/tests/unit/models/coupon-test.js b/tests/unit/models/coupon-test.js index 5cef8a840..82aee0576 100644 --- a/tests/unit/models/coupon-test.js +++ b/tests/unit/models/coupon-test.js @@ -2,13 +2,12 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Model | coupon', function(hooks) { +module('Unit | Model | coupon', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - const model = run(() => this.owner.lookup('service:store').createRecord('coupon')); + test('it exists', function (assert) { + const model = this.owner.lookup('service:store').createRecord('coupon'); + assert.ok(!!model); }); }); diff --git a/tests/unit/models/device-preference-test.js b/tests/unit/models/device-preference-test.js index 5a8045e21..a168a4ade 100644 --- a/tests/unit/models/device-preference-test.js +++ b/tests/unit/models/device-preference-test.js @@ -1,23 +1,30 @@ /* eslint-disable prettier/prettier, qunit/require-expect, qunit/no-assert-equal */ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; -module('Unit | Model | device preference', function(hooks) { +module('Unit | Model | device preference', function (hooks) { setupTest(hooks); - hooks.beforeEach(function() { + hooks.beforeEach(function () { // set the locale and the config this.owner.lookup('service:intl').setLocale('en'); }); - test('it exists', function(assert) { - const devicePreference = run(() => this.owner.lookup('service:store').createRecord('device-preference')); - run(function() { - devicePreference.set('platformVersion', "1"); - assert.equal(devicePreference.get('versionText'), "1", "Version Text"); - devicePreference.set('platformVersion', "0"); - assert.equal(devicePreference.get('versionText'), "Any Version", "Version Text"); - }); + test('it exists', function (assert) { + const devicePreference = this.owner + .lookup('service:store') + .createRecord('device-preference'); + + devicePreference.set('platformVersion', '1'); + + assert.equal(devicePreference.get('versionText'), '1', 'Version Text'); + + devicePreference.set('platformVersion', '0'); + + assert.equal( + devicePreference.get('versionText'), + 'Any Version', + 'Version Text' + ); }); }); diff --git a/tests/unit/models/device-test.js b/tests/unit/models/device-test.js index 51804a78a..7c09984b6 100644 --- a/tests/unit/models/device-test.js +++ b/tests/unit/models/device-test.js @@ -2,13 +2,12 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Model | device', function(hooks) { +module('Unit | Model | device', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - const model = run(() => this.owner.lookup('service:store').createRecord('device')); + test('it exists', function (assert) { + const model = this.owner.lookup('service:store').createRecord('device'); + assert.ok(!!model); }); }); diff --git a/tests/unit/models/file-test.js b/tests/unit/models/file-test.js index 1b8893ee2..dec4b9f3a 100644 --- a/tests/unit/models/file-test.js +++ b/tests/unit/models/file-test.js @@ -2,62 +2,76 @@ import ENUMS from 'irene/enums'; import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; -module('Unit | Model | file', function(hooks) { +module('Unit | Model | file', function (hooks) { setupTest(hooks); - hooks.beforeEach(function() { + hooks.beforeEach(function () { // set the locale and the config this.owner.lookup('service:intl').setLocale('en'); }); - test('it passes', function(assert) { - run(() => { - const file = this.owner.lookup( - 'service:store' - ).createRecord('file', { - 'id': 1 - }); - assert.equal(file.get('isManualRequested'), true, "Manual Requested"); + test('it passes', function (assert) { + const file = this.owner.lookup('service:store').createRecord('file', { + id: 1, + }); - assert.equal(file.get('isRunningApiScan'), false, "API Scan"); - file.set('apiScanProgress', 100); - assert.equal(file.get('isRunningApiScan'), false, "API Scan not done"); + assert.equal(file.get('isManualRequested'), true, 'Manual Requested'); - assert.equal(file.scanProgressClass(), false, "Scan Progress Class"); - assert.equal(file.scanProgressClass(true), true, "Scan Progress Class"); + assert.equal(file.get('isRunningApiScan'), false, 'API Scan'); - assert.equal(file.get('isStaticCompleted'), false, "Static Scan"); + file.set('apiScanProgress', 100); - assert.equal(file.get('isNoneStatus'), false, "None Status"); + assert.equal(file.get('isRunningApiScan'), false, 'API Scan not done'); - assert.equal(file.get('isReady'), false, "Is Ready"); + assert.equal(file.scanProgressClass(), false, 'Scan Progress Class'); - assert.equal(file.get('isNeitherNoneNorReady'), true, "Is Not None Nor Ready"); + assert.equal(file.scanProgressClass(true), true, 'Scan Progress Class'); - assert.equal(file.get('statusText'), "Unknown Status", 'Unknown Status'); - file.set('dynamicStatus', ENUMS.DYNAMIC_STATUS.BOOTING); - assert.equal(file.get('statusText'), "Booting", 'Booting'); - file.set('dynamicStatus', ENUMS.DYNAMIC_STATUS.DOWNLOADING); - assert.equal(file.get('statusText'), "Downloading", 'Downloading'); - file.set('dynamicStatus', ENUMS.DYNAMIC_STATUS.INSTALLING); - assert.equal(file.get('statusText'), "Installing", 'Installing'); - file.set('dynamicStatus', ENUMS.DYNAMIC_STATUS.LAUNCHING); - assert.equal(file.get('statusText'), "Launching", 'Launching'); - file.set('dynamicStatus', ENUMS.DYNAMIC_STATUS.HOOKING); - assert.equal(file.get('statusText'), "Starting", 'Hooking'); - file.set('dynamicStatus', ENUMS.DYNAMIC_STATUS.SHUTTING_DOWN); - assert.equal(file.get('statusText'), "Stopping", 'Shutting Down'); + assert.equal(file.get('isStaticCompleted'), false, 'Static Scan'); - assert.equal(file.setBootingStatus(), undefined, "Set Booting Status"); + assert.equal(file.get('isNoneStatus'), false, 'None Status'); - assert.equal(file.setShuttingDown(), undefined, "Set Booting Status"); + assert.equal(file.get('isReady'), false, 'Is Ready'); - assert.equal(file.setNone(), undefined, "Set Booting Status"); + assert.equal( + file.get('isNeitherNoneNorReady'), + true, + 'Is Not None Nor Ready' + ); - assert.equal(file.setReady(), undefined, "Set Booting Status"); + assert.equal(file.get('statusText'), 'Unknown Status', 'Unknown Status'); - }); + file.set('dynamicStatus', ENUMS.DYNAMIC_STATUS.BOOTING); + + assert.equal(file.get('statusText'), 'Booting', 'Booting'); + + file.set('dynamicStatus', ENUMS.DYNAMIC_STATUS.DOWNLOADING); + + assert.equal(file.get('statusText'), 'Downloading', 'Downloading'); + + file.set('dynamicStatus', ENUMS.DYNAMIC_STATUS.INSTALLING); + + assert.equal(file.get('statusText'), 'Installing', 'Installing'); + + file.set('dynamicStatus', ENUMS.DYNAMIC_STATUS.LAUNCHING); + + assert.equal(file.get('statusText'), 'Launching', 'Launching'); + + file.set('dynamicStatus', ENUMS.DYNAMIC_STATUS.HOOKING); + + assert.equal(file.get('statusText'), 'Starting', 'Hooking'); + + file.set('dynamicStatus', ENUMS.DYNAMIC_STATUS.SHUTTING_DOWN); + + assert.equal(file.get('statusText'), 'Stopping', 'Shutting Down'); + + assert.equal(file.setBootingStatus(), undefined, 'Set Booting Status'); + + assert.equal(file.setShuttingDown(), undefined, 'Set Booting Status'); + + assert.equal(file.setNone(), undefined, 'Set Booting Status'); + + assert.equal(file.setReady(), undefined, 'Set Booting Status'); }); }); diff --git a/tests/unit/models/invoice-test.js b/tests/unit/models/invoice-test.js index 41ed97fe5..ece934e9c 100644 --- a/tests/unit/models/invoice-test.js +++ b/tests/unit/models/invoice-test.js @@ -1,29 +1,35 @@ /* eslint-disable prettier/prettier, qunit/require-expect, qunit/no-assert-equal */ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; -module('Unit | Model | invoice', function(hooks) { +module('Unit | Model | invoice', function (hooks) { setupTest(hooks); - hooks.beforeEach(function() { + hooks.beforeEach(function () { // set the locale and the config this.owner.lookup('service:intl').setLocale('en'); }); - test('it exists', function(assert) { - const invoice = run(() => this.owner.lookup('service:store').createRecord('invoice')); - run(function() { - const d = new Date("25 March 2015"); - invoice.set('paidOn', d); - assert.equal(invoice.get('paidOnHumanized'), d.toLocaleDateString(), "Paid On"); + test('it exists', function (assert) { + const invoice = this.owner.lookup('service:store').createRecord('invoice'); + const d = new Date('25 March 2015'); - assert.equal(invoice.get('paidDate'), "Pending", "Paid Date Pending"); - assert.equal(invoice.get('paidStatus'), "Unpaid", "Unpaid"); - invoice.set('isPaid', true); - assert.equal(invoice.get('paidDate'), d.toLocaleDateString(), "Paid Date"); - assert.equal(invoice.get('paidStatus'), "Paid", "Paid"); - }); + invoice.set('paidOn', d); + assert.equal( + invoice.get('paidOnHumanized'), + d.toLocaleDateString(), + 'Paid On' + ); + + assert.equal(invoice.get('paidDate'), 'Pending', 'Paid Date Pending'); + + assert.equal(invoice.get('paidStatus'), 'Unpaid', 'Unpaid'); + + invoice.set('isPaid', true); + + assert.equal(invoice.get('paidDate'), d.toLocaleDateString(), 'Paid Date'); + + assert.equal(invoice.get('paidStatus'), 'Paid', 'Paid'); }); }); diff --git a/tests/unit/models/manualscan-test.js b/tests/unit/models/manualscan-test.js index 689b88645..11fa43e62 100644 --- a/tests/unit/models/manualscan-test.js +++ b/tests/unit/models/manualscan-test.js @@ -1,6 +1,5 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; module('Unit | Model | manualscan', function (hooks) { setupTest(hooks); @@ -8,54 +7,42 @@ module('Unit | Model | manualscan', function (hooks) { test('it exists', function (assert) { assert.expect(10); - const manualscan = run(() => - this.owner.lookup('service:store').createRecord('manualscan') - ); + const manualscan = this.owner + .lookup('service:store') + .createRecord('manualscan'); + + assert.strictEqual(manualscan.get('filteredAppEnv'), 0, 'App Env/0'); - run(function () { - assert.strictEqual(manualscan.get('filteredAppEnv'), 0, 'App Env/0'); - manualscan.set('appEnv', 1); - assert.strictEqual(manualscan.get('filteredAppEnv'), 1, 'App Env/1'); + manualscan.set('appEnv', 1); - assert.strictEqual( - manualscan.get('filteredAppAction'), - 0, - 'App Action/0' - ); + assert.strictEqual(manualscan.get('filteredAppEnv'), 1, 'App Env/1'); - manualscan.set('appAction', 1); + assert.strictEqual(manualscan.get('filteredAppAction'), 0, 'App Action/0'); - assert.strictEqual( - manualscan.get('filteredAppAction'), - 1, - 'App Action/1' - ); + manualscan.set('appAction', 1); - assert.false(manualscan.get('showProceedText'), 'Proceed Text/False'); + assert.strictEqual(manualscan.get('filteredAppAction'), 1, 'App Action/1'); - manualscan.set('appAction', 2); + assert.false(manualscan.get('showProceedText'), 'Proceed Text/False'); - assert.true(manualscan.get('showProceedText'), 'Proceed Text/True'); + manualscan.set('appAction', 2); - assert.strictEqual( - manualscan.get('loginStatus'), - 'no', - 'Login Status/No' - ); + assert.true(manualscan.get('showProceedText'), 'Proceed Text/True'); - manualscan.set('loginRequired', true); + assert.strictEqual(manualscan.get('loginStatus'), 'no', 'Login Status/No'); - assert.strictEqual( - manualscan.get('loginStatus'), - 'yes', - 'Login Status/Yes' - ); + manualscan.set('loginRequired', true); + + assert.strictEqual( + manualscan.get('loginStatus'), + 'yes', + 'Login Status/Yes' + ); - assert.strictEqual(manualscan.get('vpnStatus'), 'no', 'VPN Status/No'); + assert.strictEqual(manualscan.get('vpnStatus'), 'no', 'VPN Status/No'); - manualscan.set('vpnRequired', true); + manualscan.set('vpnRequired', true); - assert.strictEqual(manualscan.get('vpnStatus'), 'yes', 'VPN Status/Yes'); - }); + assert.strictEqual(manualscan.get('vpnStatus'), 'yes', 'VPN Status/Yes'); }); }); diff --git a/tests/unit/models/mfa-test.js b/tests/unit/models/mfa-test.js index 4d21b25c7..0c80f3514 100644 --- a/tests/unit/models/mfa-test.js +++ b/tests/unit/models/mfa-test.js @@ -2,14 +2,12 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Model | mfa', function(hooks) { +module('Unit | Model | mfa', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - let model = run(() => this.owner.lookup('service:store').createRecord('mfa')); - // let store = this.store(); + test('it exists', function (assert) { + const model = this.owner.lookup('service:store').createRecord('mfa'); + assert.ok(!!model); }); }); diff --git a/tests/unit/models/organization-mfa-test.js b/tests/unit/models/organization-mfa-test.js index e2edf7201..10d991f8e 100644 --- a/tests/unit/models/organization-mfa-test.js +++ b/tests/unit/models/organization-mfa-test.js @@ -2,14 +2,14 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Model | organization mfa', function(hooks) { +module('Unit | Model | organization mfa', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - let model = run(() => this.owner.lookup('service:store').createRecord('organization-mfa')); - // let store = this.store(); + test('it exists', function (assert) { + const model = this.owner + .lookup('service:store') + .createRecord('organization-mfa'); + assert.ok(!!model); }); }); diff --git a/tests/unit/models/organization-namespace-test.js b/tests/unit/models/organization-namespace-test.js index 8eefcb42d..d7ebcdeae 100644 --- a/tests/unit/models/organization-namespace-test.js +++ b/tests/unit/models/organization-namespace-test.js @@ -2,13 +2,14 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Model | organization namespace', function(hooks) { +module('Unit | Model | organization namespace', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - const model = run(() => this.owner.lookup('service:store').createRecord('organization-namespace')); + test('it exists', function (assert) { + const model = this.owner + .lookup('service:store') + .createRecord('organization-namespace'); + assert.ok(!!model); }); }); diff --git a/tests/unit/models/organization-user-test.js b/tests/unit/models/organization-user-test.js index 988df1e6a..b84587a8a 100644 --- a/tests/unit/models/organization-user-test.js +++ b/tests/unit/models/organization-user-test.js @@ -2,13 +2,14 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Model | organization user', function(hooks) { +module('Unit | Model | organization user', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - const model = run(() => this.owner.lookup('service:store').createRecord('organization-user')); + test('it exists', function (assert) { + const model = this.owner + .lookup('service:store') + .createRecord('organization-user'); + assert.ok(!!model); }); }); diff --git a/tests/unit/models/owasp-test.js b/tests/unit/models/owasp-test.js index 56d9795b0..4083ce373 100644 --- a/tests/unit/models/owasp-test.js +++ b/tests/unit/models/owasp-test.js @@ -2,15 +2,11 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - module('Unit | Model | owasp', function (hooks) { setupTest(hooks); test('it exists', function (assert) { - const model = run(() => - this.owner.lookup('service:store').createRecord('owasp') - ); + const model = this.owner.lookup('service:store').createRecord('owasp'); assert.ok(!!model); }); diff --git a/tests/unit/models/owaspmobile2024-test.js b/tests/unit/models/owaspmobile2024-test.js index 1d97b6dba..ccd7bf67f 100644 --- a/tests/unit/models/owaspmobile2024-test.js +++ b/tests/unit/models/owaspmobile2024-test.js @@ -2,15 +2,13 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - module('Unit | Model | owaspmobile2024', function (hooks) { setupTest(hooks); test('it exists', function (assert) { - const model = run(() => - this.owner.lookup('service:store').createRecord('owaspmobile2024') - ); + const model = this.owner + .lookup('service:store') + .createRecord('owaspmobile2024'); assert.ok(!!model); }); diff --git a/tests/unit/models/personaltoken-test.js b/tests/unit/models/personaltoken-test.js index a8dd3d4e7..c601659e1 100644 --- a/tests/unit/models/personaltoken-test.js +++ b/tests/unit/models/personaltoken-test.js @@ -1,17 +1,23 @@ /* eslint-disable prettier/prettier, qunit/require-expect, qunit/no-assert-equal */ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; -module('Unit | Model | personaltoken', function(hooks) { +module('Unit | Model | personaltoken', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - const personaltoken = run(() => this.owner.lookup('service:store').createRecord('personaltoken')); - run(function() { - const d = new Date("25 March 2015"); - personaltoken.set('created', d); - assert.equal(personaltoken.get('createdDateOnHumanized'), d.toLocaleDateString(), "Date Created"); - }); + test('it exists', function (assert) { + const personaltoken = this.owner + .lookup('service:store') + .createRecord('personaltoken'); + + const d = new Date('25 March 2015'); + + personaltoken.set('created', d); + + assert.equal( + personaltoken.get('createdDateOnHumanized'), + d.toLocaleDateString(), + 'Date Created' + ); }); }); diff --git a/tests/unit/models/plan-test.js b/tests/unit/models/plan-test.js index 7bd7dd925..9fd924404 100644 --- a/tests/unit/models/plan-test.js +++ b/tests/unit/models/plan-test.js @@ -2,13 +2,12 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Model | plan', function(hooks) { +module('Unit | Model | plan', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - const plan = run(() => this.owner.lookup('service:store').createRecord('plan')); - assert.equal(plan.get('descriptionItems'), undefined, "Description"); + test('it exists', function (assert) { + const plan = this.owner.lookup('service:store').createRecord('plan'); + + assert.equal(plan.get('descriptionItems'), undefined, 'Description'); }); }); diff --git a/tests/unit/models/pricing-test.js b/tests/unit/models/pricing-test.js index c4c6ce9f5..ba606bfc4 100644 --- a/tests/unit/models/pricing-test.js +++ b/tests/unit/models/pricing-test.js @@ -2,13 +2,12 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Model | pricing', function(hooks) { +module('Unit | Model | pricing', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - const pricing = run(() => this.owner.lookup('service:store').createRecord('pricing')); - assert.equal(pricing.get('descriptionItems'), undefined, "Description"); + test('it exists', function (assert) { + const pricing = this.owner.lookup('service:store').createRecord('pricing'); + + assert.equal(pricing.get('descriptionItems'), undefined, 'Description'); }); }); diff --git a/tests/unit/models/profile-test.js b/tests/unit/models/profile-test.js index ba2a92c58..db366454f 100644 --- a/tests/unit/models/profile-test.js +++ b/tests/unit/models/profile-test.js @@ -2,14 +2,12 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Model | profile', function(hooks) { +module('Unit | Model | profile', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - let model = run(() => this.owner.lookup('service:store').createRecord('profile')); - // let store = this.store(); + test('it exists', function (assert) { + let model = this.owner.lookup('service:store').createRecord('profile'); + assert.ok(!!model); }); }); diff --git a/tests/unit/models/project-team-test.js b/tests/unit/models/project-team-test.js index c56e67a5c..6943e5644 100644 --- a/tests/unit/models/project-team-test.js +++ b/tests/unit/models/project-team-test.js @@ -2,13 +2,12 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Model | project team', function(hooks) { +module('Unit | Model | project team', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - let model = run(() => this.owner.lookup('service:store').createRecord('project-team')); + test('it exists', function (assert) { + let model = this.owner.lookup('service:store').createRecord('project-team'); + assert.ok(!!model); }); }); diff --git a/tests/unit/models/project-test.js b/tests/unit/models/project-test.js index 0f17cc1e1..c17dbc4fe 100644 --- a/tests/unit/models/project-test.js +++ b/tests/unit/models/project-test.js @@ -2,34 +2,58 @@ import ENUMS from 'irene/enums'; import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; -module('Unit | Model | project', function(hooks) { +module('Unit | Model | project', function (hooks) { setupTest(hooks); - hooks.beforeEach(function() { + hooks.beforeEach(function () { // set the locale and the config this.owner.lookup('service:intl').setLocale('en'); }); - test('it exists', function(assert) { - const project = run(() => this.owner.lookup('service:store').createRecord('project')); - run(function() { + test('it exists', function (assert) { + const project = this.owner.lookup('service:store').createRecord('project'); - assert.equal(project.get('pdfPassword'), "Unknown!", "PDF Password/Unknown"); - project.set('uuid', "abceghi-jklm-opqr-stuv-wxyz100"); - assert.equal(project.get('pdfPassword'), "wxyz100", "PDF Password"); + assert.equal( + project.get('pdfPassword'), + 'Unknown!', + 'PDF Password/Unknown' + ); - assert.equal(project.get('platformIconClass'), "mobile", "Platform Icon Class/mobile"); - project.set('platform', ENUMS.PLATFORM.ANDROID); - assert.equal(project.get('platformIconClass'), "android", "Platform Icon Class/android"); - project.set('platform', ENUMS.PLATFORM.IOS); - assert.equal(project.get('platformIconClass'), "apple", "Platform Icon Class/apple"); - project.set('platform', ENUMS.PLATFORM.WINDOWS); - assert.equal(project.get('platformIconClass'), "windows", "Platform Icon Class/windows"); + project.set('uuid', 'abceghi-jklm-opqr-stuv-wxyz100'); + assert.equal(project.get('pdfPassword'), 'wxyz100', 'PDF Password'); - assert.equal(project.get('isAPIScanEnabled'), false, "API Scan Enabled"); - }); + assert.equal( + project.get('platformIconClass'), + 'mobile', + 'Platform Icon Class/mobile' + ); + + project.set('platform', ENUMS.PLATFORM.ANDROID); + + assert.equal( + project.get('platformIconClass'), + 'android', + 'Platform Icon Class/android' + ); + + project.set('platform', ENUMS.PLATFORM.IOS); + + assert.equal( + project.get('platformIconClass'), + 'apple', + 'Platform Icon Class/apple' + ); + + project.set('platform', ENUMS.PLATFORM.WINDOWS); + + assert.equal( + project.get('platformIconClass'), + 'windows', + 'Platform Icon Class/windows' + ); + + assert.equal(project.get('isAPIScanEnabled'), false, 'API Scan Enabled'); }); }); diff --git a/tests/unit/models/proxy-settings-test.js b/tests/unit/models/proxy-settings-test.js index 9c18b8fc3..96988ba8a 100644 --- a/tests/unit/models/proxy-settings-test.js +++ b/tests/unit/models/proxy-settings-test.js @@ -2,14 +2,14 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Model | proxy setting', function(hooks) { +module('Unit | Model | proxy setting', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - let model = run(() => this.owner.lookup('service:store').createRecord('proxy-setting')); - // let store = this.store(); + test('it exists', function (assert) { + const model = this.owner + .lookup('service:store') + .createRecord('proxy-setting'); + assert.ok(!!model); }); }); diff --git a/tests/unit/models/security/analysis-test.js b/tests/unit/models/security/analysis-test.js index b1c2ac8bc..f6e5e3a2f 100644 --- a/tests/unit/models/security/analysis-test.js +++ b/tests/unit/models/security/analysis-test.js @@ -2,14 +2,14 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Model | security/analysis', function(hooks) { +module('Unit | Model | security/analysis', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - let model = run(() => this.owner.lookup('service:store').createRecord('security/analysis')); - // let store = this.store(); + test('it exists', function (assert) { + let model = this.owner + .lookup('service:store') + .createRecord('security/analysis'); + assert.ok(!!model); }); }); diff --git a/tests/unit/models/security/attachment-test.js b/tests/unit/models/security/attachment-test.js index 34621a10c..71d49ec74 100644 --- a/tests/unit/models/security/attachment-test.js +++ b/tests/unit/models/security/attachment-test.js @@ -2,14 +2,14 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Model | security/attachment', function(hooks) { +module('Unit | Model | security/attachment', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - let model = run(() => this.owner.lookup('service:store').createRecord('security/attachment')); - // let store = this.store(); + test('it exists', function (assert) { + let model = this.owner + .lookup('service:store') + .createRecord('security/attachment'); + assert.ok(!!model); }); }); diff --git a/tests/unit/models/security/file-test.js b/tests/unit/models/security/file-test.js index 4a344de3c..6d22b7d9a 100644 --- a/tests/unit/models/security/file-test.js +++ b/tests/unit/models/security/file-test.js @@ -2,14 +2,14 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Model | security/file', function(hooks) { +module('Unit | Model | security/file', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - let model = run(() => this.owner.lookup('service:store').createRecord('security/file')); - // let store = this.store(); + test('it exists', function (assert) { + let model = this.owner + .lookup('service:store') + .createRecord('security/file'); + assert.ok(!!model); }); }); diff --git a/tests/unit/models/security/project-test.js b/tests/unit/models/security/project-test.js index bc55280a2..1dd8e2dff 100644 --- a/tests/unit/models/security/project-test.js +++ b/tests/unit/models/security/project-test.js @@ -2,14 +2,14 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Model | security/project', function(hooks) { +module('Unit | Model | security/project', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - let model = run(() => this.owner.lookup('service:store').createRecord('security/project')); - // let store = this.store(); + test('it exists', function (assert) { + let model = this.owner + .lookup('service:store') + .createRecord('security/project'); + assert.ok(!!model); }); }); diff --git a/tests/unit/models/security/vulnerability-test.js b/tests/unit/models/security/vulnerability-test.js index 87a867aba..ecfecf9ee 100644 --- a/tests/unit/models/security/vulnerability-test.js +++ b/tests/unit/models/security/vulnerability-test.js @@ -2,14 +2,14 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Model | security/vulnerability', function(hooks) { +module('Unit | Model | security/vulnerability', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - let model = run(() => this.owner.lookup('service:store').createRecord('security/vulnerability')); - // let store = this.store(); + test('it exists', function (assert) { + let model = this.owner + .lookup('service:store') + .createRecord('security/vulnerability'); + assert.ok(!!model); }); }); diff --git a/tests/unit/models/submission-test.js b/tests/unit/models/submission-test.js index d08a085c6..e151bd8af 100644 --- a/tests/unit/models/submission-test.js +++ b/tests/unit/models/submission-test.js @@ -2,13 +2,14 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Model | submission', function(hooks) { +module('Unit | Model | submission', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - const submission = run(() => this.owner.lookup('service:store').createRecord('submission')); - assert.equal(submission.get('hasReason'), false, "Reason"); + test('it exists', function (assert) { + const submission = this.owner + .lookup('service:store') + .createRecord('submission'); + + assert.equal(submission.get('hasReason'), false, 'Reason'); }); }); diff --git a/tests/unit/models/subscription-test.js b/tests/unit/models/subscription-test.js index 385adde1f..8df33d7db 100644 --- a/tests/unit/models/subscription-test.js +++ b/tests/unit/models/subscription-test.js @@ -1,7 +1,6 @@ /* eslint-disable qunit/require-expect, qunit/no-assert-equal */ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; module('Unit | Model | subscription', function (hooks) { setupTest(hooks); @@ -12,46 +11,54 @@ module('Unit | Model | subscription', function (hooks) { }); test('it exists', function (assert) { - const subscription = run(() => - this.owner.lookup('service:store').createRecord('subscription') + const subscription = this.owner + .lookup('service:store') + .createRecord('subscription'); + + const d = new Date('25 March 2015'); + + subscription.set('expiryDate', d); + + assert.equal( + subscription.get('expiryDateOnHumanized'), + d.toLocaleDateString(), + 'Expiry Date' + ); + + subscription.set('isTrial', true); + subscription.set('isCancelled', true); + + assert.equal( + subscription.get('subscriptionText'), + 'Your trial will expire on', + 'Expiry Text' + ); + + subscription.set('isTrial', true); + subscription.set('isCancelled', false); + + assert.equal( + subscription.get('subscriptionText'), + 'Your free trial will be converted into paid subscription on', + 'Expiry Text' + ); + + subscription.set('isTrial', false); + subscription.set('isCancelled', true); + + assert.equal( + subscription.get('subscriptionText'), + 'Subscription will expire on', + 'Expiry Text' + ); + + subscription.set('isTrial', false); + subscription.set('isCancelled', false); + + assert.equal( + subscription.get('subscriptionText'), + 'You will be charged on', + 'Expiry Text' ); - run(function () { - const d = new Date('25 March 2015'); - subscription.set('expiryDate', d); - assert.equal( - subscription.get('expiryDateOnHumanized'), - d.toLocaleDateString(), - 'Expiry Date' - ); - - subscription.set('isTrial', true); - subscription.set('isCancelled', true); - assert.equal( - subscription.get('subscriptionText'), - 'Your trial will expire on', - 'Expiry Text' - ); - subscription.set('isTrial', true); - subscription.set('isCancelled', false); - assert.equal( - subscription.get('subscriptionText'), - 'Your free trial will be converted into paid subscription on', - 'Expiry Text' - ); - subscription.set('isTrial', false); - subscription.set('isCancelled', true); - assert.equal( - subscription.get('subscriptionText'), - 'Subscription will expire on', - 'Expiry Text' - ); - subscription.set('isTrial', false); - subscription.set('isCancelled', false); - assert.equal( - subscription.get('subscriptionText'), - 'You will be charged on', - 'Expiry Text' - ); - }); }); }); diff --git a/tests/unit/models/tag-test.js b/tests/unit/models/tag-test.js index eedfc4b46..ebbf82a53 100644 --- a/tests/unit/models/tag-test.js +++ b/tests/unit/models/tag-test.js @@ -2,14 +2,12 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Model | tag', function(hooks) { +module('Unit | Model | tag', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - let model = run(() => this.owner.lookup('service:store').createRecord('tag')); - // let store = this.store(); + test('it exists', function (assert) { + let model = this.owner.lookup('service:store').createRecord('tag'); + assert.ok(!!model); }); }); diff --git a/tests/unit/models/team-invitation-test.js b/tests/unit/models/team-invitation-test.js index 37a2294ba..2720fa0ae 100644 --- a/tests/unit/models/team-invitation-test.js +++ b/tests/unit/models/team-invitation-test.js @@ -2,14 +2,14 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Model | team invitation', function(hooks) { +module('Unit | Model | team invitation', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - let model = run(() => this.owner.lookup('service:store').createRecord('team-invitation')); - // let store = this.store(); + test('it exists', function (assert) { + let model = this.owner + .lookup('service:store') + .createRecord('team-invitation'); + assert.ok(!!model); }); }); diff --git a/tests/unit/models/team-member-test.js b/tests/unit/models/team-member-test.js index bdc95927d..735bdcd04 100644 --- a/tests/unit/models/team-member-test.js +++ b/tests/unit/models/team-member-test.js @@ -2,14 +2,12 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Model | team member', function(hooks) { +module('Unit | Model | team member', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - let model = run(() => this.owner.lookup('service:store').createRecord('team-member')); - // let store = this.store(); + test('it exists', function (assert) { + let model = this.owner.lookup('service:store').createRecord('team-member'); + assert.ok(!!model); }); }); diff --git a/tests/unit/models/team-project-test.js b/tests/unit/models/team-project-test.js index 15831a10b..0732a051e 100644 --- a/tests/unit/models/team-project-test.js +++ b/tests/unit/models/team-project-test.js @@ -2,14 +2,12 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Model | team project', function(hooks) { +module('Unit | Model | team project', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - let model = run(() => this.owner.lookup('service:store').createRecord('team-project')); - // let store = this.store(); + test('it exists', function (assert) { + let model = this.owner.lookup('service:store').createRecord('team-project'); + assert.ok(!!model); }); }); diff --git a/tests/unit/models/unknown-analysis-status-test.js b/tests/unit/models/unknown-analysis-status-test.js index ad2cc4aea..2dab9fc54 100644 --- a/tests/unit/models/unknown-analysis-status-test.js +++ b/tests/unit/models/unknown-analysis-status-test.js @@ -2,14 +2,14 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Model | unknown analysis status', function(hooks) { +module('Unit | Model | unknown analysis status', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - let model = run(() => this.owner.lookup('service:store').createRecord('unknown-analysis-status')); - // let store = this.store(); + test('it exists', function (assert) { + let model = this.owner + .lookup('service:store') + .createRecord('unknown-analysis-status'); + assert.ok(!!model); }); }); diff --git a/tests/unit/models/user-test.js b/tests/unit/models/user-test.js index 06c4a8911..069f82d8f 100644 --- a/tests/unit/models/user-test.js +++ b/tests/unit/models/user-test.js @@ -1,7 +1,6 @@ /* eslint-disable prettier/prettier, qunit/require-expect, qunit/no-assert-equal, qunit/no-assert-equal-boolean */ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; module('Unit | Model | user', function (hooks) { setupTest(hooks); @@ -12,62 +11,50 @@ module('Unit | Model | user', function (hooks) { }); test('it exists', function (assert) { - const user = run(() => - this.owner.lookup('service:store').createRecord('user') + const user = this.owner.lookup('service:store').createRecord('user'); + + assert.equal( + user.get('provisioningURL'), + 'otpauth://totp/Appknox:undefined?secret=undefined&issuer=Appknox', + 'ProvisioningURL' ); - run(function () { - assert.equal( - user.get('provisioningURL'), - 'otpauth://totp/Appknox:undefined?secret=undefined&issuer=Appknox', - 'ProvisioningURL' - ); + assert.equal(user.get('mfaEnabled'), false, 'MFA Disabled'); - assert.equal(user.get('mfaEnabled'), false, 'MFA Disabled'); - - user.set('mfaMethod', 1); + user.set('mfaMethod', 1); - assert.equal(user.get('mfaEnabled'), true, 'MFA Enabled'); + assert.equal(user.get('mfaEnabled'), true, 'MFA Enabled'); - user.set('projectCount', 2); + user.set('projectCount', 2); - assert.equal(user.get('totalProjects'), '2 projects', 'Many Projects'); + assert.equal(user.get('totalProjects'), '2 projects', 'Many Projects'); - user.set('projectCount', 1); + user.set('projectCount', 1); - assert.equal(user.get('totalProjects'), '1 project', '1 Project'); + assert.equal(user.get('totalProjects'), '1 project', '1 Project'); - user.set('projectCount', 0); + user.set('projectCount', 0); - assert.equal(user.get('totalProjects'), 'No projects', 'No Project'); + assert.equal(user.get('totalProjects'), 'No projects', 'No Project'); - assert.equal(user.get('ifBillingIsNotHidden'), true, 'Billing Hidden'); + assert.equal(user.get('ifBillingIsNotHidden'), true, 'Billing Hidden'); - user.set('expiryDate', new Date('25 March 2015')); + user.set('expiryDate', new Date('25 March 2015')); - user.set('devknoxExpiry', new Date('25 March 2015')); + user.set('devknoxExpiry', new Date('25 March 2015')); - assert.equal(user.get('hasExpiryDate'), true, 'Has Expiry Date'); + assert.equal(user.get('hasExpiryDate'), true, 'Has Expiry Date'); - user.set('expiryDate', ''); + user.set('expiryDate', ''); - assert.equal(user.get('hasExpiryDate'), false, 'No Expiry Date'); + assert.equal(user.get('hasExpiryDate'), false, 'No Expiry Date'); - assert.equal( - user.get('expiryText'), - 'subscriptionExpired', - 'Expiry Text' - ); + assert.equal(user.get('expiryText'), 'subscriptionExpired', 'Expiry Text'); - user.set('expiryDate', new Date('25 March 2019')); + user.set('expiryDate', new Date('25 March 2019')); - assert.equal( - user.get('expiryText'), - 'subscriptionExpired', - 'Expiry Text' - ); + assert.equal(user.get('expiryText'), 'subscriptionExpired', 'Expiry Text'); - assert.equal(user.get('namespaceItems'), undefined, 'Namespace Items'); - }); + assert.equal(user.get('namespaceItems'), undefined, 'Namespace Items'); }); }); diff --git a/tests/unit/models/vulnerability-preference-test.js b/tests/unit/models/vulnerability-preference-test.js index 381769911..10a2931a2 100644 --- a/tests/unit/models/vulnerability-preference-test.js +++ b/tests/unit/models/vulnerability-preference-test.js @@ -2,27 +2,83 @@ import ENUMS from 'irene/enums'; import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; -module('Unit | Model | vulnerability preference', function(hooks) { +module('Unit | Model | vulnerability preference', function (hooks) { setupTest(hooks); - test('it exists', function(assert) { - const submission = run(() => this.owner.lookup('service:store').createRecord('vulnerability-preference')); - run(function() { - submission.set("risk", 1); - assert.equal(submission.get('riskOverridden'), true, "Risk Overridden"); - assert.equal(submission.iconClass(ENUMS.RISK.UNKNOWN), "fa-spinner fa-spin", 'Icon Class'); - assert.equal(submission.iconClass(ENUMS.RISK.NONE), "fa-check", 'Icon Class'); - assert.equal(submission.iconClass(ENUMS.RISK.CRITICAL), "fa-warning", 'Icon Class'); - assert.equal(submission.get("riskIconClass"), "fa-warning", 'Risk Icon Class'); - assert.equal(submission.labelClass(ENUMS.RISK.UNKNOWN), "tag is-progress", 'Label Class'); - assert.equal(submission.labelClass(ENUMS.RISK.NONE), "tag is-success", 'Label Class'); - assert.equal(submission.labelClass(ENUMS.RISK.LOW), "tag is-info", 'Label Class'); - assert.equal(submission.labelClass(ENUMS.RISK.MEDIUM), "tag is-warning", 'Label Class'); - assert.equal(submission.labelClass(ENUMS.RISK.HIGH), "tag is-danger", 'Label Class'); - assert.equal(submission.labelClass(ENUMS.RISK.CRITICAL), "tag is-critical", 'Label Class'); - assert.equal(submission.get("riskLabelClass"), "tag is-info", 'Risk Label Class'); - }); + test('it exists', function (assert) { + const submission = this.owner + .lookup('service:store') + .createRecord('vulnerability-preference'); + + submission.set('risk', 1); + + assert.equal(submission.get('riskOverridden'), true, 'Risk Overridden'); + + assert.equal( + submission.iconClass(ENUMS.RISK.UNKNOWN), + 'fa-spinner fa-spin', + 'Icon Class' + ); + + assert.equal( + submission.iconClass(ENUMS.RISK.NONE), + 'fa-check', + 'Icon Class' + ); + + assert.equal( + submission.iconClass(ENUMS.RISK.CRITICAL), + 'fa-warning', + 'Icon Class' + ); + + assert.equal( + submission.get('riskIconClass'), + 'fa-warning', + 'Risk Icon Class' + ); + + assert.equal( + submission.labelClass(ENUMS.RISK.UNKNOWN), + 'tag is-progress', + 'Label Class' + ); + + assert.equal( + submission.labelClass(ENUMS.RISK.NONE), + 'tag is-success', + 'Label Class' + ); + + assert.equal( + submission.labelClass(ENUMS.RISK.LOW), + 'tag is-info', + 'Label Class' + ); + + assert.equal( + submission.labelClass(ENUMS.RISK.MEDIUM), + 'tag is-warning', + 'Label Class' + ); + + assert.equal( + submission.labelClass(ENUMS.RISK.HIGH), + 'tag is-danger', + 'Label Class' + ); + + assert.equal( + submission.labelClass(ENUMS.RISK.CRITICAL), + 'tag is-critical', + 'Label Class' + ); + + assert.equal( + submission.get('riskLabelClass'), + 'tag is-info', + 'Risk Label Class' + ); }); }); diff --git a/tests/unit/models/vulnerability-test.js b/tests/unit/models/vulnerability-test.js index 9cdd00319..ac36a3c8a 100644 --- a/tests/unit/models/vulnerability-test.js +++ b/tests/unit/models/vulnerability-test.js @@ -1,7 +1,6 @@ /* eslint-disable prettier/prettier, qunit/require-expect, qunit/no-assert-equal */ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; module('Unit | Model | vulnerability', function (hooks) { setupTest(hooks); @@ -12,17 +11,16 @@ module('Unit | Model | vulnerability', function (hooks) { }); test('it exists', function (assert) { - const vulnerability = run(() => - this.owner.lookup('service:store').createRecord('vulnerability') - ); + const vulnerability = this.owner + .lookup('service:store') + .createRecord('vulnerability'); + + vulnerability.set('description', '

Hello World

'); - run(function () { - vulnerability.set('description', '

Hello World

'); - assert.equal( - vulnerability.get('descriptionUnescapedd'), - '

Hello World

', - 'Description' - ); - }); + assert.equal( + vulnerability.get('descriptionUnescapedd'), + '

Hello World

', + 'Description' + ); }); }); diff --git a/tests/unit/routes/authenticated/security/file-test.js b/tests/unit/routes/authenticated/security/file-test.js index 1c937ccbd..a79f00732 100644 --- a/tests/unit/routes/authenticated/security/file-test.js +++ b/tests/unit/routes/authenticated/security/file-test.js @@ -1,4 +1,3 @@ -import { run } from '@ember/runloop'; import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; @@ -10,8 +9,6 @@ module('Unit | Route | authenticated/security/file', function (hooks) { let route = this.owner.lookup('route:authenticated/security/file'); - run(function () { - assert.ok(route); - }); + assert.ok(route); }); }); diff --git a/tests/unit/serializers/mfa-test.js b/tests/unit/serializers/mfa-test.js index 8e4db63ca..61345cb41 100644 --- a/tests/unit/serializers/mfa-test.js +++ b/tests/unit/serializers/mfa-test.js @@ -1,15 +1,12 @@ -/* eslint-disable prettier/prettier */ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { run } from '@ember/runloop'; - -module('Unit | Serializer | mfa', function(hooks) { +module('Unit | Serializer | mfa', function (hooks) { setupTest(hooks); // Replace this with your real tests. - test('it serializes records', function(assert) { - let record = run(() => this.owner.lookup('service:store').createRecord('mfa')); + test('it serializes records', function (assert) { + let record = this.owner.lookup('service:store').createRecord('mfa'); let serializedRecord = record.serialize();