From 33b5b01401587315a28141e4500f87c81da992cd Mon Sep 17 00:00:00 2001 From: Steffen Ohrendorf Date: Sat, 15 Feb 2025 11:44:48 +0100 Subject: [PATCH 1/8] switch to vite Signed-off-by: Steffen Ohrendorf --- .eslintrc.js | 18 - .postcssrc.js | 5 - babel.config.js | 7 - eslint.config.js | 12 + public/index.html => index.html | 1 + package-lock.json | 41083 +++++----------- package.json | 17 +- src/App.vue | 12 +- src/assets/scss/style.scss | 6 +- src/i18n/index.js | 21 +- src/main.js | 11 + src/views/pages/Login.vue | 8 +- src/views/pages/PasswordForceChange.vue | 6 +- .../projects/ProjectDependencyGraph.vue | 4 +- vite.config.js | 16 + vue.config.js | 5 +- 16 files changed, 12941 insertions(+), 28291 deletions(-) delete mode 100644 .eslintrc.js delete mode 100644 .postcssrc.js create mode 100644 eslint.config.js rename public/index.html => index.html (96%) create mode 100644 vite.config.js diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index b1b87779f..000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,18 +0,0 @@ -module.exports = { - root: true, - env: { - node: true, - }, - parserOptions: { - parser: '@babel/eslint-parser', - }, - extends: [ - 'eslint:recommended', - 'plugin:vue/essential', - 'plugin:prettier/recommended', - ], - rules: { - 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', - 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', - }, -}; diff --git a/.postcssrc.js b/.postcssrc.js deleted file mode 100644 index a47ef4f95..000000000 --- a/.postcssrc.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - plugins: { - autoprefixer: {}, - }, -}; diff --git a/babel.config.js b/babel.config.js index bcdde9806..24bae9893 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,12 +1,5 @@ module.exports = { presets: [ ['@vue/babel-preset-jsx'], - [ - '@babel/preset-env', - { - useBuiltIns: 'entry', - corejs: '3.33', - }, - ], ], }; diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 000000000..27f42ded3 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,12 @@ +import pluginVue from 'eslint-plugin-vue'; +import recommendedConfig from 'eslint-plugin-prettier/recommended'; + +export default [ + { + name: 'app/files-to-lint', + files: ['src/**/*.{js,vue,md,yaml}'], + }, + + recommendedConfig, + ...pluginVue.configs['flat/vue2-essential'], +]; diff --git a/public/index.html b/index.html similarity index 96% rename from public/index.html rename to index.html index 6a576e19c..ab14067cd 100644 --- a/public/index.html +++ b/index.html @@ -15,6 +15,7 @@ >
+ diff --git a/src/assets/scss/style.scss b/src/assets/scss/style.scss index f1c68e7eb..7949b4512 100644 --- a/src/assets/scss/style.scss +++ b/src/assets/scss/style.scss @@ -2,9 +2,9 @@ @import "variables"; // Import styles -@import "~@coreui/coreui/scss/coreui"; +@import "@coreui/coreui/scss/coreui"; -@import '~vue-easy-pie-chart/dist/vue-easy-pie-chart.css'; +@import 'vue-easy-pie-chart/dist/vue-easy-pie-chart.css'; @import "code"; @@ -14,4 +14,4 @@ // ie fixes @import "ie-fix"; -@import "~vue-multiselect/dist/vue-multiselect.min.css"; +@import "vue-multiselect/dist/vue-multiselect.min.css"; diff --git a/src/i18n/index.js b/src/i18n/index.js index 7112c298d..3ad25deed 100644 --- a/src/i18n/index.js +++ b/src/i18n/index.js @@ -2,6 +2,7 @@ import Vue from 'vue'; import VueI18n from 'vue-i18n'; import axios from 'axios'; import api from '../shared/api.json'; +import $ from 'jquery'; Vue.use(VueI18n); @@ -17,19 +18,19 @@ async function getDefaultLanguage() { } function loadLocaleMessages() { - const locales = require.context( - './locales', - true, - /[A-Za-z0-9-_,\s]+\.json$/i, - ); + const locales = import.meta.glob('./locales/*.json'); + const messages = {}; - locales.keys().forEach((key) => { - const matched = key.match(/([A-Za-z0-9-_]+)\./i); + for (const path in locales) { + const matched = path.match(/([A-Za-z0-9-_]+)\./i); if (matched && matched.length > 1) { const locale = matched[1]; - messages[locale] = locales(key); + locales[path]().then((data) => { + messages[locale] = data; + }); } - }); + } + return messages; } @@ -69,7 +70,7 @@ function matchLocale(requestedLocale) { } const i18n = new VueI18n({ locale: 'en', - fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE || 'en', + fallbackLocale: import.meta.env.VUE_APP_I18N_FALLBACK_LOCALE || 'en', messages: localeMessages, }); diff --git a/src/main.js b/src/main.js index 1fdfa468c..11bb1484a 100644 --- a/src/main.js +++ b/src/main.js @@ -34,10 +34,14 @@ Vue.use(VuePageTitle, { prefix: 'Dependency-Track -', router }); Vue.prototype.$api = api; Vue.prototype.$oidc = oidc; + +console.log('Loading DT...'); + const contextPath = getContextPath(); axios .get(contextPath + '/static/config.json') .then((response) => { + console.log('Loaded config.json', response); if (response.data.API_BASE_URL && response.data.API_BASE_URL !== '') { Vue.prototype.$api.BASE_URL = response.data.API_BASE_URL; } else { @@ -67,6 +71,9 @@ axios 'Cannot retrieve static/config.json from host. This is expected behavior in development environments.', ); createVueApp(); + }) + .catch((error) => { + console.error('Failed to load config.json', error); }); /** @@ -74,6 +81,7 @@ axios * https://github.com/DependencyTrack/frontend/issues/34 */ function createVueApp() { + console.log('Creating Vue App'); /* Register global $dtrack variable which will be the response body from /api/version. $dtrack can then be used anywhere in the app to get information about the server, @@ -83,6 +91,9 @@ function createVueApp() { .get(`${Vue.prototype.$api.BASE_URL}/${Vue.prototype.$api.URL_ABOUT}`) .then((result) => { Vue.prototype.$dtrack = result.data; + }) + .catch((error) => { + console.error('Failed to load about URL', error); }); Vue.prototype.$version = version; diff --git a/src/views/pages/Login.vue b/src/views/pages/Login.vue index 1455c0bf0..e85d14df7 100644 --- a/src/views/pages/Login.vue +++ b/src/views/pages/Login.vue @@ -108,8 +108,8 @@ import { ValidationObserver } from 'vee-validate'; import BValidatedInputGroupFormInput from '../../forms/BValidatedInputGroupFormInput'; import InformationalModal from '../modals/InformationalModal'; import EventBus from '../../shared/eventbus'; -import { getRedirectUrl, getContextPath } from '../../shared/utils'; -const qs = require('querystring'); +import { getRedirectUrl, getContextPath } from '@/shared/utils'; +import queryString from 'query-string'; import common from '../../shared/common'; export default { @@ -178,7 +178,7 @@ export default { // redirect to url from query param but only if it is save for redirection const redirectTo = getRedirectUrl(this.$router); axios - .post(url, qs.stringify(requestBody), config) + .post(url, queryString.stringify(requestBody), config) .then((result) => { if (result.status === 200) { EventBus.$emit('authenticated', result.data); @@ -280,7 +280,7 @@ export default { }; this.axios - .post(url, qs.stringify(requestBody), config) + .post(url, queryString.stringify(requestBody), config) .then((result) => { if (result.status === 200) { EventBus.$emit('authenticated', result.data); diff --git a/src/views/pages/PasswordForceChange.vue b/src/views/pages/PasswordForceChange.vue index f4d987cb5..4f8b81ac5 100644 --- a/src/views/pages/PasswordForceChange.vue +++ b/src/views/pages/PasswordForceChange.vue @@ -94,8 +94,8 @@ import axios from 'axios'; import { ValidationObserver } from 'vee-validate'; import InformationalModal from '../modals/InformationalModal'; import BValidatedInputGroupFormInput from '../../forms/BValidatedInputGroupFormInput'; -import { getRedirectUrl } from '../../shared/utils'; -const qs = require('querystring'); +import { getRedirectUrl } from '@/shared/utils'; +import queryString from 'query-string'; export default { name: 'PasswordForceChange', @@ -130,7 +130,7 @@ export default { }, }; axios - .post(url, qs.stringify(requestBody), config) + .post(url, queryString.stringify(requestBody), config) .then((result) => { if (result.status === 200) { this.$toastr.s(this.$t('message.password_change_success')); diff --git a/src/views/portfolio/projects/ProjectDependencyGraph.vue b/src/views/portfolio/projects/ProjectDependencyGraph.vue index d54c04f33..0733214eb 100644 --- a/src/views/portfolio/projects/ProjectDependencyGraph.vue +++ b/src/views/portfolio/projects/ProjectDependencyGraph.vue @@ -56,7 +56,7 @@ - diff --git a/src/views/administration/configuration/Email.cy.js b/src/views/administration/configuration/Email.cy.js new file mode 100644 index 000000000..16b95cb87 --- /dev/null +++ b/src/views/administration/configuration/Email.cy.js @@ -0,0 +1,34 @@ +import Email from './Email.vue'; +import { genAxiosResponse } from '../../../../cypress/support/utils'; + +describe('Email', () => { + it('mounts successfully', () => { + cy.mount(Email, { + prototypeMocks: { + axios: { + get: genAxiosResponse({ + '/api/v1/configProperty/': [ + { + groupName: 'artifact', + propertyName: 'cyclonedx.enabled', + propertyValue: 'false', + }, + { + groupName: 'artifact', + propertyName: 'bom.validation.mode', + propertyValue: 'ENABLED', + }, + { + groupName: 'artifact', + propertyName: 'bom.validation.tags.inclusive', + propertyValue: '[]', + }, + ], + }), + }, + }, + }); + + cy.get('div.card').should('be.visible'); + }); +}); diff --git a/src/views/administration/configuration/Email.vue b/src/views/administration/configuration/Email.vue index 58d06fd1a..bc82ca513 100644 --- a/src/views/administration/configuration/Email.vue +++ b/src/views/administration/configuration/Email.vue @@ -98,20 +98,25 @@ diff --git a/src/views/administration/configuration/EmailTestConfigurationModal.cy.js b/src/views/administration/configuration/EmailTestConfigurationModal.cy.js new file mode 100644 index 000000000..36cc6e0bf --- /dev/null +++ b/src/views/administration/configuration/EmailTestConfigurationModal.cy.js @@ -0,0 +1,16 @@ +import { shouldShowModal } from '../../../../cypress/support/utils'; + +import EmailTestConfigurationModal from './EmailTestConfigurationModal.vue'; + +describe('EmailTestConfigurationModal', () => { + it('mounts successfully', () => { + cy.mount(EmailTestConfigurationModal, { + attachTo: document.body, + stubs: { + transition: false, + }, + }); + + shouldShowModal('emailTestConfigurationModal'); + }); +}); diff --git a/src/views/administration/configuration/EmailTestConfigurationModal.vue b/src/views/administration/configuration/EmailTestConfigurationModal.vue index 605e5df3f..16f1c5f32 100644 --- a/src/views/administration/configuration/EmailTestConfigurationModal.vue +++ b/src/views/administration/configuration/EmailTestConfigurationModal.vue @@ -17,7 +17,7 @@ tooltip="Enter an email address you control to test your send configuration." lazy="true" /> - diff --git a/src/views/administration/configuration/JiraConfig.cy.js b/src/views/administration/configuration/JiraConfig.cy.js new file mode 100644 index 000000000..72a30bb56 --- /dev/null +++ b/src/views/administration/configuration/JiraConfig.cy.js @@ -0,0 +1,18 @@ +import JiraConfig from './JiraConfig.vue'; +import { genAxiosResponse } from '../../../../cypress/support/utils'; + +describe('JiraConfig', () => { + it('mounts successfully', () => { + cy.mount(JiraConfig, { + prototypeMocks: { + axios: { + get: genAxiosResponse({ + '/api/v1/configProperty/': [], + }), + }, + }, + }); + + cy.get('div.card').should('be.visible'); + }); +}); diff --git a/src/views/administration/configuration/JiraConfig.vue b/src/views/administration/configuration/JiraConfig.vue index 95cbaecfb..c26a11ea9 100644 --- a/src/views/administration/configuration/JiraConfig.vue +++ b/src/views/administration/configuration/JiraConfig.vue @@ -59,17 +59,23 @@ diff --git a/src/views/administration/configuration/Search.cy.js b/src/views/administration/configuration/Search.cy.js new file mode 100644 index 000000000..a1304329a --- /dev/null +++ b/src/views/administration/configuration/Search.cy.js @@ -0,0 +1,18 @@ +import Search from './Search.vue'; +import { genAxiosResponse } from '../../../../cypress/support/utils'; + +describe('Search', () => { + it('mounts successfully', () => { + cy.mount(Search, { + prototypeMocks: { + axios: { + get: genAxiosResponse({ + '/api/v1/configProperty/': [], + }), + }, + }, + }); + + cy.get('div').should('be.visible'); + }); +}); diff --git a/src/views/administration/configuration/Search.vue b/src/views/administration/configuration/Search.vue index 810b7a4d9..4a700f829 100644 --- a/src/views/administration/configuration/Search.vue +++ b/src/views/administration/configuration/Search.vue @@ -118,18 +118,23 @@ diff --git a/src/views/administration/configuration/Telemetry.cy.js b/src/views/administration/configuration/Telemetry.cy.js new file mode 100644 index 000000000..af27944f5 --- /dev/null +++ b/src/views/administration/configuration/Telemetry.cy.js @@ -0,0 +1,18 @@ +import Telemetry from './Telemetry.vue'; +import { genAxiosResponse } from '../../../../cypress/support/utils'; + +describe('Telemetry', () => { + it('mounts successfully', () => { + cy.mount(Telemetry, { + prototypeMocks: { + axios: { + get: genAxiosResponse({ + '/api/v1/configProperty/': [], + }), + }, + }, + }); + + cy.get('div.card').should('be.visible'); + }); +}); diff --git a/src/views/administration/configuration/Telemetry.vue b/src/views/administration/configuration/Telemetry.vue index b1e09703f..2dfe923c0 100644 --- a/src/views/administration/configuration/Telemetry.vue +++ b/src/views/administration/configuration/Telemetry.vue @@ -44,11 +44,38 @@ diff --git a/src/views/administration/configuration/WelcomeMessage.cy.js b/src/views/administration/configuration/WelcomeMessage.cy.js new file mode 100644 index 000000000..a54fe0193 --- /dev/null +++ b/src/views/administration/configuration/WelcomeMessage.cy.js @@ -0,0 +1,18 @@ +import WelcomeMessage from './WelcomeMessage.vue'; +import { genAxiosResponse } from '../../../../cypress/support/utils'; + +describe('WelcomeMessage', () => { + it('mounts successfully', () => { + cy.mount(WelcomeMessage, { + prototypeMocks: { + axios: { + get: genAxiosResponse({ + '/api/v1/configProperty/': [], + }), + }, + }, + }); + + cy.get('div.card').should('be.visible'); + }); +}); diff --git a/src/views/administration/configuration/WelcomeMessage.vue b/src/views/administration/configuration/WelcomeMessage.vue index ba732c2c7..828781c5b 100644 --- a/src/views/administration/configuration/WelcomeMessage.vue +++ b/src/views/administration/configuration/WelcomeMessage.vue @@ -54,36 +54,53 @@ diff --git a/src/views/administration/integrations/FortifySsc.cy.js b/src/views/administration/integrations/FortifySsc.cy.js new file mode 100644 index 000000000..8c0e7c74e --- /dev/null +++ b/src/views/administration/integrations/FortifySsc.cy.js @@ -0,0 +1,18 @@ +import FortifySsc from './FortifySsc.vue'; +import { genAxiosResponse } from '../../../../cypress/support/utils'; + +describe('FortifySsc', () => { + it('mounts successfully', () => { + cy.mount(FortifySsc, { + prototypeMocks: { + axios: { + get: genAxiosResponse({ + '/api/v1/configProperty/': [], + }), + }, + }, + }); + + cy.get('div.card').should('be.visible'); + }); +}); diff --git a/src/views/administration/integrations/FortifySsc.vue b/src/views/administration/integrations/FortifySsc.vue index 9ef3c058b..618fe1f2c 100644 --- a/src/views/administration/integrations/FortifySsc.vue +++ b/src/views/administration/integrations/FortifySsc.vue @@ -49,18 +49,23 @@ diff --git a/src/views/administration/integrations/KennaSecurity.cy.js b/src/views/administration/integrations/KennaSecurity.cy.js new file mode 100644 index 000000000..2bfc8b62c --- /dev/null +++ b/src/views/administration/integrations/KennaSecurity.cy.js @@ -0,0 +1,18 @@ +import KennaSecurity from './KennaSecurity.vue'; +import { genAxiosResponse } from '../../../../cypress/support/utils'; + +describe('KennaSecurity', () => { + it('mounts successfully', () => { + cy.mount(KennaSecurity, { + prototypeMocks: { + axios: { + get: genAxiosResponse({ + '/api/v1/configProperty/': [], + }), + }, + }, + }); + + cy.get('div.card').should('be.visible'); + }); +}); diff --git a/src/views/administration/integrations/KennaSecurity.vue b/src/views/administration/integrations/KennaSecurity.vue index 4c1618a62..8162bc7c9 100644 --- a/src/views/administration/integrations/KennaSecurity.vue +++ b/src/views/administration/integrations/KennaSecurity.vue @@ -49,18 +49,23 @@ diff --git a/src/views/administration/mixins/configPropertyMixin.js b/src/views/administration/mixins/configPropertyMixin.js index 350cbb162..a930e11f1 100644 --- a/src/views/administration/mixins/configPropertyMixin.js +++ b/src/views/administration/mixins/configPropertyMixin.js @@ -1,6 +1,4 @@ -import Vue from 'vue'; -import axios from 'axios'; -import common from '../../../shared/common'; +import common from '@/shared/common'; export default { data() { diff --git a/src/views/administration/notifications/Alerts.vue b/src/views/administration/notifications/Alerts.vue index cdbcbf762..c1ebd5486 100644 --- a/src/views/administration/notifications/Alerts.vue +++ b/src/views/administration/notifications/Alerts.vue @@ -18,46 +18,39 @@ > - + diff --git a/src/views/administration/notifications/CreateAlertModal.cy.js b/src/views/administration/notifications/CreateAlertModal.cy.js new file mode 100644 index 000000000..0252976fe --- /dev/null +++ b/src/views/administration/notifications/CreateAlertModal.cy.js @@ -0,0 +1,26 @@ +import { + genAxiosResponse, + shouldShowModal, +} from '../../../../cypress/support/utils'; + +import CreateAlertModal from './CreateAlertModal.vue'; + +describe('CreateAlertModal', () => { + it('mounts successfully', () => { + cy.mount(CreateAlertModal, { + attachTo: document.body, + stubs: { + transition: false, + }, + prototypeMocks: { + axios: { + get: genAxiosResponse({ + '/api/v1/notification/publisher': [], + }), + }, + }, + }); + + shouldShowModal('createAlertModal'); + }); +}); diff --git a/src/views/administration/notifications/CreateAlertModal.vue b/src/views/administration/notifications/CreateAlertModal.vue index cddfac151..10627c441 100644 --- a/src/views/administration/notifications/CreateAlertModal.vue +++ b/src/views/administration/notifications/CreateAlertModal.vue @@ -69,7 +69,7 @@ buttons /> - @@ -28,46 +28,27 @@ diff --git a/src/views/administration/repositories/RepositoryCreateRepositoryModal.cy.js b/src/views/administration/repositories/RepositoryCreateRepositoryModal.cy.js new file mode 100644 index 000000000..d73b5cc38 --- /dev/null +++ b/src/views/administration/repositories/RepositoryCreateRepositoryModal.cy.js @@ -0,0 +1,16 @@ +import { shouldShowModal } from '../../../../cypress/support/utils'; + +import RepositoryCreateRepositoryModal from './RepositoryCreateRepositoryModal.vue'; + +describe('RepositoryCreateRepositoryModal', () => { + it('mounts successfully', () => { + cy.mount(RepositoryCreateRepositoryModal, { + attachTo: document.body, + stubs: { + transition: false, + }, + }); + + shouldShowModal('repositoryCreateRepositoryModal'); + }); +}); diff --git a/src/views/administration/repositories/RepositoryCreateRepositoryModal.vue b/src/views/administration/repositories/RepositoryCreateRepositoryModal.vue index 23a759e5d..79986e0ce 100644 --- a/src/views/administration/repositories/RepositoryCreateRepositoryModal.vue +++ b/src/views/administration/repositories/RepositoryCreateRepositoryModal.vue @@ -67,7 +67,7 @@ $t('admin.enabled') }} - diff --git a/src/views/dashboard/ChartAuditingFindingsProgress.cy.js b/src/views/dashboard/ChartAuditingFindingsProgress.cy.js new file mode 100644 index 000000000..fe9471ff6 --- /dev/null +++ b/src/views/dashboard/ChartAuditingFindingsProgress.cy.js @@ -0,0 +1,11 @@ +import ChartAuditingFindingsProgress from '@/views/dashboard/ChartAuditingFindingsProgress.vue'; + +describe('ChartAuditingFindingsProgress', () => { + it('mounts successfully', () => { + cy.mount(ChartAuditingFindingsProgress, { + propsData: { + height: 300, + }, + }); + }); +}); diff --git a/src/views/dashboard/ChartAuditingFindingsProgress.vue b/src/views/dashboard/ChartAuditingFindingsProgress.vue index 971aa6a03..0d37e9ca6 100644 --- a/src/views/dashboard/ChartAuditingFindingsProgress.vue +++ b/src/views/dashboard/ChartAuditingFindingsProgress.vue @@ -1,5 +1,5 @@ diff --git a/src/views/globalAudit/VulnerabilityAuditByOccurrence.cy.js b/src/views/globalAudit/VulnerabilityAuditByOccurrence.cy.js new file mode 100644 index 000000000..84d2d9235 --- /dev/null +++ b/src/views/globalAudit/VulnerabilityAuditByOccurrence.cy.js @@ -0,0 +1,20 @@ +import VulnerabilityAuditByOccurrence from './VulnerabilityAuditByOccurrence.vue'; + +describe('VulnerabilityAuditByOccurrence', () => { + it('mounts successfully', () => { + const mockCommon = { + formatSeverityLabel: cy.stub().returns(''), + formatAnalyzerLabel: cy.stub().returns(''), + formatTimestamp: cy.stub().returns(''), + formatSourceLabel: cy.stub().returns(''), + concatenateComponentName: cy.stub().returns(''), + valueWithDefault: cy.stub().returns(''), + capitalize: cy.stub().returns(''), + makeAnalysisStateLabelFormatter: cy.stub().returns(() => ''), + }; + + cy.mount(VulnerabilityAuditByOccurrence); + + cy.get('div').should('exist'); + }); +}); diff --git a/src/views/globalAudit/VulnerabilityAuditByOccurrence.vue b/src/views/globalAudit/VulnerabilityAuditByOccurrence.vue index 8942f65b9..2fcc2693b 100644 --- a/src/views/globalAudit/VulnerabilityAuditByOccurrence.vue +++ b/src/views/globalAudit/VulnerabilityAuditByOccurrence.vue @@ -79,35 +79,35 @@ id="publish-date-form-group" :label="this.$t('message.published')" > - - + + > - - + + > option.value, - ); - }, - methods: { - initializeWatchers: function () { - this.simpleWatcher = this.$watch('watchers', () => this.refreshTable()); - this.textSearchSelectedWatcher = this.$watch('textSearchSelected', () => { - if (this.textSearchInput.trim().length !== 0) { - this.refreshTable(); - } - }); - this.textSearchInputWatcher = this.$watch( - 'textSearchInput', - (newInput, oldInput) => { - if (!(newInput.trim().length === 0 && oldInput.trim().length === 0)) { - this.refreshTable(); - } - }, - ); - this.cvssv2FromWatcher = this.$watch('cvssv2From', () => { - if (this.cvssv2FromState() !== false) { - this.refreshTable(); - } - }); - this.cvssv2ToWatcher = this.$watch('cvssv2To', () => { - if (this.cvssv2ToState() !== false) { - this.refreshTable(); - } - }); - this.cvssv3FromWatcher = this.$watch('cvssv3From', () => { - if (this.cvssv3FromState() !== false) { - this.refreshTable(); - } - }); - this.cvssv3ToWatcher = this.$watch('cvssv3To', () => { - if (this.cvssv3ToState() !== false) { - this.refreshTable(); - } - }); - }, - apiUrl: function () { - let url = `${this.$api.BASE_URL}/${this.$api.URL_FINDING}`; - url += - '?showInactive=' + - (this.showInactive === 'true') + - '&showSuppressed=' + - (this.showSuppressed === 'true'); - if (this.severitySelected && this.severitySelected.length > 0) { - url += '&severity=' + this.severitySelected; - } - if ( - this.analysisStatusSelected && - this.analysisStatusSelected.length > 0 - ) { - url += '&analysisStatus=' + this.analysisStatusSelected; - } - if ( - this.vendorResponseSelected && - this.vendorResponseSelected.length > 0 - ) { - url += '&vendorResponse=' + this.vendorResponseSelected; - } - if (this.publishDateFrom && this.publishDateFrom.length > 0) { - url += '&publishDateFrom=' + this.publishDateFrom; - } - if (this.publishDateTo && this.publishDateTo.length > 0) { - url += '&publishDateTo=' + this.publishDateTo; - } - if (this.attributedOnDateFrom && this.attributedOnDateFrom.length > 0) { - url += '&attributedOnDateFrom=' + this.attributedOnDateFrom; - } - if (this.attributedOnDateTo && this.attributedOnDateTo.length > 0) { - url += '&attributedOnDateTo=' + this.attributedOnDateTo; - } - if (this.textSearchInput && this.textSearchInput.trim().length > 0) { - url += - '&textSearchField=' + - this.textSearchSelected + - '&textSearchInput=' + - this.textSearchInput.trim(); - } - if (this.cvssv2From && this.cvssv2From.trim().length > 0) { - url += '&cvssv2From=' + this.cvssv2From; - } - if (this.cvssv2To && this.cvssv2To.trim().length > 0) { - url += '&cvssv2To=' + this.cvssv2To; - } - if (this.cvssv3From && this.cvssv3From.trim().length > 0) { - url += '&cvssv3From=' + this.cvssv3From; - } - if (this.cvssv3To && this.cvssv3To.trim().length > 0) { - url += '&cvssv3To=' + this.cvssv3To; - } - return url; - }, - clearAllFilters: function () { - this.simpleWatcher(); - this.textSearchSelectedWatcher(); - this.textSearchInputWatcher(); - this.cvssv2FromWatcher(); - this.cvssv2ToWatcher(); - this.cvssv3FromWatcher(); - this.cvssv3ToWatcher(); - this.showInactive = false; - this.showSuppressed = false; - this.severitySelected = []; - this.analysisStatusSelected = []; - this.vendorResponseSelected = []; - this.publishDateFrom = ''; - this.publishDateTo = ''; - this.attributedOnDateFrom = ''; - this.attributedOnDateTo = ''; - this.textSearchInput = ''; - this.textSearchSelected = this.textSearchOptions.map( - (option) => option.value, - ); - this.cvssv2From = ''; - this.cvssv2To = ''; - this.cvssv3From = ''; - this.cvssv3To = ''; - this.refreshTable(); - this.initializeWatchers(); - }, - refreshTable: function () { - this.$refs.table.refresh({ - url: this.apiUrl(), - silent: true, - pageNumber: 1, - }); - }, - initializeTooltips: function () { - $('[data-toggle="tooltip"]').tooltip({ - trigger: 'hover', - }); - }, - cvssv2UpperLimit: function () { - return this.cvssv2To ? this.cvssv2To : 10; - }, - cvssv2LowerLimit: function () { - return this.cvssv2From ? this.cvssv2From : 0; - }, - cvssv2FromState() { - return this.cvssv2From - ? !isNaN(this.cvssv2From) && - (!this.cvssv2To || - !isNaN(this.cvssv2To) || - this.cvssv2From <= this.cvssv2To) && - this.cvssv2From <= 10 && - this.cvssv2From >= 0 - : null; - }, - cvssv2ToState() { - return this.cvssv2To - ? !isNaN(this.cvssv2To) && - (!this.cvssv2From || - !isNaN(this.cvssv2From) || - this.cvssv2To >= this.cvssv2From) && - this.cvssv2To <= 10 && - this.cvssv2To >= 0 - : null; - }, - cvssv3UpperLimit: function () { - return this.cvssv3To ? this.cvssv3To : 10; - }, - cvssv3LowerLimit: function () { - return this.cvssv3From ? this.cvssv3From : 0; - }, - cvssv3FromState() { - return this.cvssv3From - ? !isNaN(this.cvssv3From) && - (!this.cvssv3To || - !isNaN(this.cvssv3To) || - this.cvssv3From <= this.cvssv3To) && - this.cvssv3From <= 10 && - this.cvssv3From >= 0 - : null; - }, - cvssv3ToState() { - return this.cvssv3To - ? !isNaN(this.cvssv3To) && - (!this.cvssv3From || - !isNaN(this.cvssv3From) || - this.cvssv3To >= this.cvssv3From) && - this.cvssv3To <= 10 && - this.cvssv3To >= 0 - : null; - }, - onLoadSuccess: function () { - loadUserPreferencesForBootstrapTable( - this, - 'VulnerabilityAuditByOccurrence', - this.$refs.table.columns, - ); - }, + components: { + BRow, + BCol, + BButton, + BFormGroup, + BFormCheckbox, + BFormCheckboxGroup, + BFormInput, + BFormRow, + BFormDatepicker, + BootstrapTable, }, data() { return { @@ -743,5 +554,218 @@ export default { }, }; }, + computed: { + watchers() { + return [ + this.showInactive, + this.showSuppressed, + this.severitySelected, + this.analysisStatusSelected, + this.vendorResponseSelected, + this.publishDateFrom, + this.publishDateTo, + this.attributedOnDateFrom, + this.attributedOnDateTo, + ]; + }, + }, + beforeMount() { + this.initializeWatchers(); + this.textSearchSelected = this.textSearchOptions.map( + (option) => option.value, + ); + }, + methods: { + initializeWatchers: function () { + this.simpleWatcher = this.$watch('watchers', () => this.refreshTable()); + this.textSearchSelectedWatcher = this.$watch('textSearchSelected', () => { + if (this.textSearchInput.trim().length !== 0) { + this.refreshTable(); + } + }); + this.textSearchInputWatcher = this.$watch( + 'textSearchInput', + (newInput, oldInput) => { + if (!(newInput.trim().length === 0 && oldInput.trim().length === 0)) { + this.refreshTable(); + } + }, + ); + this.cvssv2FromWatcher = this.$watch('cvssv2From', () => { + if (this.cvssv2FromState() !== false) { + this.refreshTable(); + } + }); + this.cvssv2ToWatcher = this.$watch('cvssv2To', () => { + if (this.cvssv2ToState() !== false) { + this.refreshTable(); + } + }); + this.cvssv3FromWatcher = this.$watch('cvssv3From', () => { + if (this.cvssv3FromState() !== false) { + this.refreshTable(); + } + }); + this.cvssv3ToWatcher = this.$watch('cvssv3To', () => { + if (this.cvssv3ToState() !== false) { + this.refreshTable(); + } + }); + }, + apiUrl: function () { + let url = `${this.$api.BASE_URL}/${this.$api.URL_FINDING}`; + url += + '?showInactive=' + + (this.showInactive === 'true') + + '&showSuppressed=' + + (this.showSuppressed === 'true'); + if (this.severitySelected && this.severitySelected.length > 0) { + url += '&severity=' + this.severitySelected; + } + if ( + this.analysisStatusSelected && + this.analysisStatusSelected.length > 0 + ) { + url += '&analysisStatus=' + this.analysisStatusSelected; + } + if ( + this.vendorResponseSelected && + this.vendorResponseSelected.length > 0 + ) { + url += '&vendorResponse=' + this.vendorResponseSelected; + } + if (this.publishDateFrom && this.publishDateFrom.length > 0) { + url += '&publishDateFrom=' + this.publishDateFrom; + } + if (this.publishDateTo && this.publishDateTo.length > 0) { + url += '&publishDateTo=' + this.publishDateTo; + } + if (this.attributedOnDateFrom && this.attributedOnDateFrom.length > 0) { + url += '&attributedOnDateFrom=' + this.attributedOnDateFrom; + } + if (this.attributedOnDateTo && this.attributedOnDateTo.length > 0) { + url += '&attributedOnDateTo=' + this.attributedOnDateTo; + } + if (this.textSearchInput && this.textSearchInput.trim().length > 0) { + url += + '&textSearchField=' + + this.textSearchSelected + + '&textSearchInput=' + + this.textSearchInput.trim(); + } + if (this.cvssv2From && this.cvssv2From.trim().length > 0) { + url += '&cvssv2From=' + this.cvssv2From; + } + if (this.cvssv2To && this.cvssv2To.trim().length > 0) { + url += '&cvssv2To=' + this.cvssv2To; + } + if (this.cvssv3From && this.cvssv3From.trim().length > 0) { + url += '&cvssv3From=' + this.cvssv3From; + } + if (this.cvssv3To && this.cvssv3To.trim().length > 0) { + url += '&cvssv3To=' + this.cvssv3To; + } + return url; + }, + clearAllFilters: function () { + this.simpleWatcher(); + this.textSearchSelectedWatcher(); + this.textSearchInputWatcher(); + this.cvssv2FromWatcher(); + this.cvssv2ToWatcher(); + this.cvssv3FromWatcher(); + this.cvssv3ToWatcher(); + this.showInactive = false; + this.showSuppressed = false; + this.severitySelected = []; + this.analysisStatusSelected = []; + this.vendorResponseSelected = []; + this.publishDateFrom = ''; + this.publishDateTo = ''; + this.attributedOnDateFrom = ''; + this.attributedOnDateTo = ''; + this.textSearchInput = ''; + this.textSearchSelected = this.textSearchOptions.map( + (option) => option.value, + ); + this.cvssv2From = ''; + this.cvssv2To = ''; + this.cvssv3From = ''; + this.cvssv3To = ''; + this.refreshTable(); + this.initializeWatchers(); + }, + refreshTable: function () { + this.$refs.table.refresh({ + url: this.apiUrl(), + silent: true, + pageNumber: 1, + }); + }, + initializeTooltips: function () { + $('[data-toggle="tooltip"]').tooltip({ + trigger: 'hover', + }); + }, + cvssv2UpperLimit: function () { + return this.cvssv2To ? this.cvssv2To : 10; + }, + cvssv2LowerLimit: function () { + return this.cvssv2From ? this.cvssv2From : 0; + }, + cvssv2FromState() { + return this.cvssv2From + ? !isNaN(this.cvssv2From) && + (!this.cvssv2To || + !isNaN(this.cvssv2To) || + this.cvssv2From <= this.cvssv2To) && + this.cvssv2From <= 10 && + this.cvssv2From >= 0 + : null; + }, + cvssv2ToState() { + return this.cvssv2To + ? !isNaN(this.cvssv2To) && + (!this.cvssv2From || + !isNaN(this.cvssv2From) || + this.cvssv2To >= this.cvssv2From) && + this.cvssv2To <= 10 && + this.cvssv2To >= 0 + : null; + }, + cvssv3UpperLimit: function () { + return this.cvssv3To ? this.cvssv3To : 10; + }, + cvssv3LowerLimit: function () { + return this.cvssv3From ? this.cvssv3From : 0; + }, + cvssv3FromState() { + return this.cvssv3From + ? !isNaN(this.cvssv3From) && + (!this.cvssv3To || + !isNaN(this.cvssv3To) || + this.cvssv3From <= this.cvssv3To) && + this.cvssv3From <= 10 && + this.cvssv3From >= 0 + : null; + }, + cvssv3ToState() { + return this.cvssv3To + ? !isNaN(this.cvssv3To) && + (!this.cvssv3From || + !isNaN(this.cvssv3From) || + this.cvssv3To >= this.cvssv3From) && + this.cvssv3To <= 10 && + this.cvssv3To >= 0 + : null; + }, + onLoadSuccess: function () { + loadUserPreferencesForBootstrapTable( + this, + 'VulnerabilityAuditByOccurrence', + this.$refs.table.columns, + ); + }, + }, }; diff --git a/src/views/globalAudit/VulnerabilityAuditGroupedByVulnerability.cy.js b/src/views/globalAudit/VulnerabilityAuditGroupedByVulnerability.cy.js new file mode 100644 index 000000000..c1d8e55f1 --- /dev/null +++ b/src/views/globalAudit/VulnerabilityAuditGroupedByVulnerability.cy.js @@ -0,0 +1,17 @@ +import VulnerabilityAuditGroupedByVulnerability from './VulnerabilityAuditGroupedByVulnerability.vue'; + +describe('VulnerabilityAuditGroupedByVulnerability', () => { + it('mounts successfully', () => { + const mockCommon = { + formatSeverityLabel: cy.stub().returns(''), + formatAnalyzerLabel: cy.stub().returns(''), + formatTimestamp: cy.stub().returns(''), + formatSourceLabel: cy.stub().returns(''), + capitalize: cy.stub().returns(''), + }; + + cy.mount(VulnerabilityAuditGroupedByVulnerability); + + cy.get('div').should('exist'); + }); +}); diff --git a/src/views/globalAudit/VulnerabilityAuditGroupedByVulnerability.vue b/src/views/globalAudit/VulnerabilityAuditGroupedByVulnerability.vue index 5deb43191..22b31c6d7 100644 --- a/src/views/globalAudit/VulnerabilityAuditGroupedByVulnerability.vue +++ b/src/views/globalAudit/VulnerabilityAuditGroupedByVulnerability.vue @@ -41,18 +41,18 @@ id="grouped-publish-date-form-group" :label="this.$t('message.published')" > - - + + > option.value, - ); - }, - methods: { - initializeWatchers: function () { - this.simpleWatcher = this.$watch('watchers', () => this.refreshTable()); - this.textSearchSelectedWatcher = this.$watch('textSearchSelected', () => { - if (this.textSearchInput.trim().length !== 0) { - this.refreshTable(); - } - }); - this.textSearchInputWatcher = this.$watch( - 'textSearchInput', - (newInput, oldInput) => { - if (!(newInput.trim().length === 0 && oldInput.trim().length === 0)) { - this.refreshTable(); - } - }, - ); - this.cvssv2FromWatcher = this.$watch('cvssv2From', () => { - if (this.cvssv2FromState() !== false) { - this.refreshTable(); - } - }); - this.cvssv2ToWatcher = this.$watch('cvssv2To', () => { - if (this.cvssv2ToState() !== false) { - this.refreshTable(); - } - }); - this.cvssv3FromWatcher = this.$watch('cvssv3From', () => { - if (this.cvssv3FromState() !== false) { - this.refreshTable(); - } - }); - this.cvssv3ToWatcher = this.$watch('cvssv3To', () => { - if (this.cvssv3ToState() !== false) { - this.refreshTable(); - } - }); - this.occurrencesFromWatcher = this.$watch('occurrencesFrom', () => { - if (this.occurrencesFromState() !== false) { - this.refreshTable(); - } - }); - this.occurrencesToWatcher = this.$watch('occurrencesTo', () => { - if (this.occurrencesToState() !== false) { - this.refreshTable(); - } - }); - }, - apiUrl: function () { - let url = `${this.$api.BASE_URL}/${this.$api.URL_FINDING}/grouped`; - url += - '?showInactive=' + - (this.showInactive === 'true') + - '&showSuppressed=' + - (this.showSuppressed === 'true'); - if (this.severitySelected && this.severitySelected.length > 0) { - url += '&severity=' + this.severitySelected; - } - if (this.publishDateFrom && this.publishDateFrom.length > 0) { - url += '&publishDateFrom=' + this.publishDateFrom; - } - if (this.publishDateTo && this.publishDateTo.length > 0) { - url += '&publishDateTo=' + this.publishDateTo; - } - if (this.textSearchInput && this.textSearchInput.trim().length > 0) { - url += - '&textSearchField=' + - this.textSearchSelected + - '&textSearchInput=' + - this.textSearchInput.trim(); - } - if (this.cvssv2From && this.cvssv2From.trim().length > 0) { - url += '&cvssv2From=' + this.cvssv2From; - } - if (this.cvssv2To && this.cvssv2To.trim().length > 0) { - url += '&cvssv2To=' + this.cvssv2To; - } - if (this.cvssv3From && this.cvssv3From.trim().length > 0) { - url += '&cvssv3From=' + this.cvssv3From; - } - if (this.cvssv3To && this.cvssv3To.trim().length > 0) { - url += '&cvssv3To=' + this.cvssv3To; - } - if (this.occurrencesFrom && this.occurrencesFrom.trim().length > 0) { - url += '&occurrencesFrom=' + this.occurrencesFrom; - } - if (this.occurrencesTo && this.occurrencesTo.trim().length > 0) { - url += '&occurrencesTo=' + this.occurrencesTo; - } - return url; - }, - clearAllFilters: function () { - this.simpleWatcher(); - this.textSearchSelectedWatcher(); - this.textSearchInputWatcher(); - this.cvssv2FromWatcher(); - this.cvssv2ToWatcher(); - this.cvssv3FromWatcher(); - this.cvssv3ToWatcher(); - this.occurrencesFromWatcher(); - this.occurrencesToWatcher(); - this.showInactive = false; - this.severitySelected = []; - this.publishDateFrom = ''; - this.publishDateTo = ''; - this.textSearchInput = ''; - this.textSearchSelected = this.textSearchOptions.map( - (option) => option.value, - ); - this.cvssv2From = ''; - this.cvssv2To = ''; - this.cvssv3From = ''; - this.cvssv3To = ''; - this.occurrencesFrom = ''; - this.occurrencesTo = ''; - this.refreshTable(); - this.initializeWatchers(); - }, - refreshTable: function () { - this.$refs.table.refresh({ - url: this.apiUrl(), - silent: true, - pageNumber: 1, - }); - }, - cvssv2UpperLimit: function () { - return this.cvssv2To ? this.cvssv2To : 10; - }, - cvssv2LowerLimit: function () { - return this.cvssv2From ? this.cvssv2From : 0; - }, - cvssv2FromState() { - return this.cvssv2From - ? !isNaN(this.cvssv2From) && - (!this.cvssv2To || - !isNaN(this.cvssv2To) || - this.cvssv2From <= this.cvssv2To) && - this.cvssv2From <= 10 - : null; - }, - cvssv2ToState() { - return this.cvssv2To - ? !isNaN(this.cvssv2To) && - (!this.cvssv2From || - !isNaN(this.cvssv2From) || - this.cvssv2To >= this.cvssv2From) && - this.cvssv2To >= 0 - : null; - }, - cvssv3UpperLimit: function () { - return this.cvssv3To ? this.cvssv3To : 10; - }, - cvssv3LowerLimit: function () { - return this.cvssv3From ? this.cvssv3From : 0; - }, - cvssv3FromState() { - return this.cvssv3From - ? !isNaN(this.cvssv3From) && - (!this.cvssv3To || - !isNaN(this.cvssv3To) || - this.cvssv3From <= this.cvssv3To) && - this.cvssv3From <= 10 - : null; - }, - cvssv3ToState() { - return this.cvssv3To - ? !isNaN(this.cvssv3To) && - (!this.cvssv3From || - !isNaN(this.cvssv3From) || - this.cvssv3To >= this.cvssv3From) && - this.cvssv3To >= 0 - : null; - }, - occurrencesUpperLimit: function () { - return this.occurrencesTo ? this.occurrencesTo : null; - }, - occurrencesLowerLimit: function () { - return this.occurrencesFrom ? this.occurrencesFrom : 0; - }, - occurrencesFromState: function () { - return this.occurrencesFrom - ? !isNaN(this.occurrencesFrom) && - (!this.occurrencesTo || - !isNaN(this.occurrencesTo) || - this.occurrencesFrom <= this.occurrencesTo) && - this.cvssv3From >= 0 - : null; - }, - occurrencesToState: function () { - return this.occurrencesTo - ? !isNaN(this.occurrencesTo) && - (!this.occurrencesFrom || - !isNaN(this.occurrencesFrom) || - this.occurrencesTo >= this.occurrencesFrom) && - this.cvssv3To >= 0 - : null; - }, - onLoadSuccess: function () { - loadUserPreferencesForBootstrapTable( - this, - 'VulnerabilityAuditGroupedByVulnerability', - this.$refs.table.columns, - ); - }, + components: { + BRow, + BCol, + BFormCheckbox, + BButton, + BFormInput, + BFormGroup, + BFormCheckboxGroup, + BFormDatepicker, + BFormRow, + BootstrapTable, }, data() { return { @@ -634,5 +438,225 @@ export default { }, }; }, + computed: { + watchers() { + return [ + this.showInactive, + this.severitySelected, + this.publishDateFrom, + this.publishDateTo, + ]; + }, + }, + beforeMount() { + this.initializeWatchers(); + this.textSearchSelected = this.textSearchOptions.map( + (option) => option.value, + ); + }, + methods: { + initializeWatchers: function () { + this.simpleWatcher = this.$watch('watchers', () => this.refreshTable()); + this.textSearchSelectedWatcher = this.$watch('textSearchSelected', () => { + if (this.textSearchInput.trim().length !== 0) { + this.refreshTable(); + } + }); + this.textSearchInputWatcher = this.$watch( + 'textSearchInput', + (newInput, oldInput) => { + if (!(newInput.trim().length === 0 && oldInput.trim().length === 0)) { + this.refreshTable(); + } + }, + ); + this.cvssv2FromWatcher = this.$watch('cvssv2From', () => { + if (this.cvssv2FromState() !== false) { + this.refreshTable(); + } + }); + this.cvssv2ToWatcher = this.$watch('cvssv2To', () => { + if (this.cvssv2ToState() !== false) { + this.refreshTable(); + } + }); + this.cvssv3FromWatcher = this.$watch('cvssv3From', () => { + if (this.cvssv3FromState() !== false) { + this.refreshTable(); + } + }); + this.cvssv3ToWatcher = this.$watch('cvssv3To', () => { + if (this.cvssv3ToState() !== false) { + this.refreshTable(); + } + }); + this.occurrencesFromWatcher = this.$watch('occurrencesFrom', () => { + if (this.occurrencesFromState() !== false) { + this.refreshTable(); + } + }); + this.occurrencesToWatcher = this.$watch('occurrencesTo', () => { + if (this.occurrencesToState() !== false) { + this.refreshTable(); + } + }); + }, + apiUrl: function () { + let url = `${this.$api.BASE_URL}/${this.$api.URL_FINDING}/grouped`; + url += + '?showInactive=' + + (this.showInactive === 'true') + + '&showSuppressed=' + + (this.showSuppressed === 'true'); + if (this.severitySelected && this.severitySelected.length > 0) { + url += '&severity=' + this.severitySelected; + } + if (this.publishDateFrom && this.publishDateFrom.length > 0) { + url += '&publishDateFrom=' + this.publishDateFrom; + } + if (this.publishDateTo && this.publishDateTo.length > 0) { + url += '&publishDateTo=' + this.publishDateTo; + } + if (this.textSearchInput && this.textSearchInput.trim().length > 0) { + url += + '&textSearchField=' + + this.textSearchSelected + + '&textSearchInput=' + + this.textSearchInput.trim(); + } + if (this.cvssv2From && this.cvssv2From.trim().length > 0) { + url += '&cvssv2From=' + this.cvssv2From; + } + if (this.cvssv2To && this.cvssv2To.trim().length > 0) { + url += '&cvssv2To=' + this.cvssv2To; + } + if (this.cvssv3From && this.cvssv3From.trim().length > 0) { + url += '&cvssv3From=' + this.cvssv3From; + } + if (this.cvssv3To && this.cvssv3To.trim().length > 0) { + url += '&cvssv3To=' + this.cvssv3To; + } + if (this.occurrencesFrom && this.occurrencesFrom.trim().length > 0) { + url += '&occurrencesFrom=' + this.occurrencesFrom; + } + if (this.occurrencesTo && this.occurrencesTo.trim().length > 0) { + url += '&occurrencesTo=' + this.occurrencesTo; + } + return url; + }, + clearAllFilters: function () { + this.simpleWatcher(); + this.textSearchSelectedWatcher(); + this.textSearchInputWatcher(); + this.cvssv2FromWatcher(); + this.cvssv2ToWatcher(); + this.cvssv3FromWatcher(); + this.cvssv3ToWatcher(); + this.occurrencesFromWatcher(); + this.occurrencesToWatcher(); + this.showInactive = false; + this.severitySelected = []; + this.publishDateFrom = ''; + this.publishDateTo = ''; + this.textSearchInput = ''; + this.textSearchSelected = this.textSearchOptions.map( + (option) => option.value, + ); + this.cvssv2From = ''; + this.cvssv2To = ''; + this.cvssv3From = ''; + this.cvssv3To = ''; + this.occurrencesFrom = ''; + this.occurrencesTo = ''; + this.refreshTable(); + this.initializeWatchers(); + }, + refreshTable: function () { + this.$refs.table.refresh({ + url: this.apiUrl(), + silent: true, + pageNumber: 1, + }); + }, + cvssv2UpperLimit: function () { + return this.cvssv2To ? this.cvssv2To : 10; + }, + cvssv2LowerLimit: function () { + return this.cvssv2From ? this.cvssv2From : 0; + }, + cvssv2FromState() { + return this.cvssv2From + ? !isNaN(this.cvssv2From) && + (!this.cvssv2To || + !isNaN(this.cvssv2To) || + this.cvssv2From <= this.cvssv2To) && + this.cvssv2From <= 10 + : null; + }, + cvssv2ToState() { + return this.cvssv2To + ? !isNaN(this.cvssv2To) && + (!this.cvssv2From || + !isNaN(this.cvssv2From) || + this.cvssv2To >= this.cvssv2From) && + this.cvssv2To >= 0 + : null; + }, + cvssv3UpperLimit: function () { + return this.cvssv3To ? this.cvssv3To : 10; + }, + cvssv3LowerLimit: function () { + return this.cvssv3From ? this.cvssv3From : 0; + }, + cvssv3FromState() { + return this.cvssv3From + ? !isNaN(this.cvssv3From) && + (!this.cvssv3To || + !isNaN(this.cvssv3To) || + this.cvssv3From <= this.cvssv3To) && + this.cvssv3From <= 10 + : null; + }, + cvssv3ToState() { + return this.cvssv3To + ? !isNaN(this.cvssv3To) && + (!this.cvssv3From || + !isNaN(this.cvssv3From) || + this.cvssv3To >= this.cvssv3From) && + this.cvssv3To >= 0 + : null; + }, + occurrencesUpperLimit: function () { + return this.occurrencesTo ? this.occurrencesTo : null; + }, + occurrencesLowerLimit: function () { + return this.occurrencesFrom ? this.occurrencesFrom : 0; + }, + occurrencesFromState: function () { + return this.occurrencesFrom + ? !isNaN(this.occurrencesFrom) && + (!this.occurrencesTo || + !isNaN(this.occurrencesTo) || + this.occurrencesFrom <= this.occurrencesTo) && + this.cvssv3From >= 0 + : null; + }, + occurrencesToState: function () { + return this.occurrencesTo + ? !isNaN(this.occurrencesTo) && + (!this.occurrencesFrom || + !isNaN(this.occurrencesFrom) || + this.occurrencesTo >= this.occurrencesFrom) && + this.cvssv3To >= 0 + : null; + }, + onLoadSuccess: function () { + loadUserPreferencesForBootstrapTable( + this, + 'VulnerabilityAuditGroupedByVulnerability', + this.$refs.table.columns, + ); + }, + }, }; diff --git a/src/views/modals/InformationalModal.cy.js b/src/views/modals/InformationalModal.cy.js new file mode 100644 index 000000000..9a6bbe4d9 --- /dev/null +++ b/src/views/modals/InformationalModal.cy.js @@ -0,0 +1,31 @@ +import InformationalModal from '@/views/modals/InformationalModal.vue'; +import { shouldShowModal } from '../../../cypress/support/utils'; + +describe('InformationalModal', () => { + it('contains the message', () => { + cy.setToken(); + + cy.mount(InformationalModal, { + attachTo: document.body, + stubs: { + transition: false, + }, + propsData: { + message: 'Foo', + }, + }); + + shouldShowModal('modal-informational'); + + cy.get('#modal-informational').invoke('css', 'display', 'block'); + cy.get('#modal-informational').invoke('css', 'opacity', '1'); + cy.get('#modal-informational').invoke('addClass', 'show'); + + cy.get('#modal-informational').should('be.visible'); + + cy.get('#modal-informational .modal-content').should('be.visible'); + cy.get('#modal-informational .modal-content p') + .should('be.visible') + .should('contain.text', 'Foo'); + }); +}); diff --git a/src/views/modals/InformationalModal.vue b/src/views/modals/InformationalModal.vue index a91936428..424e7280b 100644 --- a/src/views/modals/InformationalModal.vue +++ b/src/views/modals/InformationalModal.vue @@ -1,6 +1,6 @@ diff --git a/src/views/pages/PasswordForceChange.cy.js b/src/views/pages/PasswordForceChange.cy.js new file mode 100644 index 000000000..39a95be0b --- /dev/null +++ b/src/views/pages/PasswordForceChange.cy.js @@ -0,0 +1,13 @@ +import PasswordForceChange from './PasswordForceChange.vue'; + +describe('PasswordForceChange', () => { + it('mounts successfully', () => { + cy.mount(PasswordForceChange, { + mocks: { + $toastr: { + s: cy.stub(), + }, + }, + }); + }); +}); diff --git a/src/views/pages/PasswordForceChange.vue b/src/views/pages/PasswordForceChange.vue index 4f8b81ac5..deb91135b 100644 --- a/src/views/pages/PasswordForceChange.vue +++ b/src/views/pages/PasswordForceChange.vue @@ -59,8 +59,8 @@ variant="primary" class="px-4" type="submit" - >{{ $t('message.password_change') }} + >{{ $t('message.password_change') }} + @@ -85,24 +85,38 @@ - + diff --git a/src/views/policy/PolicyCondition.cy.js b/src/views/policy/PolicyCondition.cy.js new file mode 100644 index 000000000..3d0bd879f --- /dev/null +++ b/src/views/policy/PolicyCondition.cy.js @@ -0,0 +1,9 @@ +import PolicyCondition from './PolicyCondition.vue'; + +describe('PolicyCondition', () => { + it('mounts successfully', () => { + cy.mount(PolicyCondition); + + cy.get('li.list-group-item.align-middle').should('be.visible'); + }); +}); diff --git a/src/views/policy/PolicyCondition.vue b/src/views/policy/PolicyCondition.vue index 559c5e046..856d849a8 100644 --- a/src/views/policy/PolicyCondition.vue +++ b/src/views/policy/PolicyCondition.vue @@ -1,14 +1,14 @@ diff --git a/src/views/policy/PolicyManagement.cy.js b/src/views/policy/PolicyManagement.cy.js new file mode 100644 index 000000000..6c5fcc178 --- /dev/null +++ b/src/views/policy/PolicyManagement.cy.js @@ -0,0 +1,23 @@ +import PolicyManagement from './PolicyManagement.vue'; + +describe('PolicyManagement', () => { + it('mounts successfully', () => { + cy.setToken(['POLICY_MANAGEMENT']); + + cy.mount(PolicyManagement, { + prototypeMocks: { + $route: { + fullPath: '/policy', + query: { + searchText: '', + }, + }, + $router: { + push: cy.stub(), + }, + }, + }); + + cy.get('div.animated.fadeIn').should('be.visible'); + }); +}); diff --git a/src/views/policy/PolicyManagement.vue b/src/views/policy/PolicyManagement.vue index 3cc1cd92b..83cab1b29 100644 --- a/src/views/policy/PolicyManagement.vue +++ b/src/views/policy/PolicyManagement.vue @@ -11,43 +11,55 @@ active @click="routeTo()" > - - + - - + diff --git a/src/views/policy/SelectLicenseModal.cy.js b/src/views/policy/SelectLicenseModal.cy.js new file mode 100644 index 000000000..02d14671b --- /dev/null +++ b/src/views/policy/SelectLicenseModal.cy.js @@ -0,0 +1,16 @@ +import { shouldShowModal } from '../../../cypress/support/utils'; + +import SelectLicenseModal from './SelectLicenseModal.vue'; + +describe('SelectLicenseModal', () => { + it('mounts successfully', () => { + cy.mount(SelectLicenseModal, { + attachTo: document.body, + stubs: { + transition: false, + }, + }); + + shouldShowModal('selectLicenseModal'); + }); +}); diff --git a/src/views/policy/SelectLicenseModal.vue b/src/views/policy/SelectLicenseModal.vue index a61d9fcf7..378974c41 100644 --- a/src/views/policy/SelectLicenseModal.vue +++ b/src/views/policy/SelectLicenseModal.vue @@ -13,7 +13,7 @@ :options="options" > -