From 97f0b9db15cdbf28e0be2cbee7884556357fd142 Mon Sep 17 00:00:00 2001 From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> Date: Tue, 7 Jan 2025 11:12:26 +0000 Subject: [PATCH 1/2] Re-enable eslint `no-console` rule for log & debug levels --- .eslintrc.cjs | 8 +++++++- src/components/graphqlFormGenerator/components/vuetify.js | 1 - src/services/workflow.service.js | 4 +--- src/store/options.js | 1 + src/utils/aotf.js | 1 - src/views/Graph.vue | 1 - 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index e5a316339..064665526 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -40,6 +40,12 @@ module.exports = { functions: 'only-multiline', }, ], + 'no-console': [ + 'error', + { + allow: ['warn', 'error'] + } + ], 'template-curly-spacing': [ 'off' ], @@ -60,6 +66,6 @@ module.exports = { ], 'cypress/unsafe-to-chain-command': [ 'off' - ] + ], }, } diff --git a/src/components/graphqlFormGenerator/components/vuetify.js b/src/components/graphqlFormGenerator/components/vuetify.js index d98566726..757229f5f 100644 --- a/src/components/graphqlFormGenerator/components/vuetify.js +++ b/src/components/graphqlFormGenerator/components/vuetify.js @@ -206,7 +206,6 @@ export function getComponentProps (gqlType, namedTypes, kinds) { if (ret) { return ret } - // eslint-disable-next-line no-console console.warn(`Falling back to string for type: ${name}, kind: ${kind}`) return namedTypes.String } diff --git a/src/services/workflow.service.js b/src/services/workflow.service.js index 6ab115278..2f8314f96 100644 --- a/src/services/workflow.service.js +++ b/src/services/workflow.service.js @@ -167,6 +167,7 @@ class WorkflowService { }) } catch (err) { console.error(err) + // eslint-disable-next-line no-console console.log('retrying introspection query') await new Promise(resolve => setTimeout(resolve, 2000)) return this.loadTypes() @@ -242,7 +243,6 @@ class WorkflowService { callback.init(store, errors) for (const error of errors) { store.commit('SET_ALERT', new Alert(error[0], 'error'), { root: true }) - // eslint-disable-next-line no-console console.warn(...error) subscription.handleViewState(ViewState.ERROR, error('Error presetting view state')) } @@ -358,7 +358,6 @@ class WorkflowService { new Alert(error[0], 'error'), { root: true } ) - // eslint-disable-next-line no-console console.warn(...error) } }, @@ -423,7 +422,6 @@ class WorkflowService { unsubscribe (query, uid) { const subscription = this.subscriptions[query.name] if (!subscription) { - // eslint-disable-next-line no-console console.warn(`Could not unsubscribe [${query.name}]: Not Found`) return } diff --git a/src/store/options.js b/src/store/options.js index 892a8bd1f..b66e703b4 100644 --- a/src/store/options.js +++ b/src/store/options.js @@ -49,6 +49,7 @@ const actions = { if (alert?.color === 'error') { console.error(alert.err) } else if (alert) { + // eslint-disable-next-line no-console console.log(alert.err) } commit('SET_ALERT', alert) diff --git a/src/utils/aotf.js b/src/utils/aotf.js index ccf42a6ab..01fdcd084 100644 --- a/src/utils/aotf.js +++ b/src/utils/aotf.js @@ -908,7 +908,6 @@ function _mutateSuccess (message) { async function _mutateError (mutationName, err, response) { // log the response if (response) { - // eslint-disable-next-line no-console console.error('mutation response', response) } diff --git a/src/views/Graph.vue b/src/views/Graph.vue index 2c149952c..29055d689 100644 --- a/src/views/Graph.vue +++ b/src/views/Graph.vue @@ -705,7 +705,6 @@ export default { // something went wrong, allow the layout to retry later this.graphID = null this.updating = false - // eslint-disable-next-line no-console console.error(e) return } From 52eac3a1d19b4ddd09e7b49852b809632a8a4766 Mon Sep 17 00:00:00 2001 From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> Date: Tue, 7 Jan 2025 11:13:19 +0000 Subject: [PATCH 2/2] Move component tests to `tests/` --- .gitignore | 1 + README.md | 4 +-- cypress.config.cjs | 12 +++------ tests/component/.eslintrc.cjs | 25 +++++++++++++++++++ .../component}/fixtures/example.json | 0 .../component/specs}/boxPlot.cy.js | 0 .../component/specs}/copyBtn.cy.js | 0 .../component/specs}/cylc-graph-node.cy.js | 0 .../component/specs}/cylc-icons.cy.js | 0 .../component/specs}/ganttchart.cy.js | 0 .../component/specs}/info.cy.js | 0 .../component/specs}/utils/task.js | 0 .../component/specs}/viewToolbar.cy.js | 0 .../component}/support/commands.js | 0 .../component}/support/component-index.html | 0 .../component/support/index.js | 0 tests/e2e/.eslintrc.cjs | 5 +--- 17 files changed, 33 insertions(+), 14 deletions(-) create mode 100644 tests/component/.eslintrc.cjs rename {cypress => tests/component}/fixtures/example.json (100%) rename {cypress/component => tests/component/specs}/boxPlot.cy.js (100%) rename {cypress/component => tests/component/specs}/copyBtn.cy.js (100%) rename {cypress/component => tests/component/specs}/cylc-graph-node.cy.js (100%) rename {cypress/component => tests/component/specs}/cylc-icons.cy.js (100%) rename {cypress/component => tests/component/specs}/ganttchart.cy.js (100%) rename {cypress/component => tests/component/specs}/info.cy.js (100%) rename {cypress/component => tests/component/specs}/utils/task.js (100%) rename {cypress/component => tests/component/specs}/viewToolbar.cy.js (100%) rename {cypress => tests/component}/support/commands.js (100%) rename {cypress => tests/component}/support/component-index.html (100%) rename cypress/support/component.js => tests/component/support/index.js (100%) diff --git a/.gitignore b/.gitignore index 57d7eb1a4..6f9b1eb47 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ npm-debug.log* yarn-debug.log* yarn-error.log* selenium-debug.log* +vite.config.*.timestamp* # Coverage .nyc_output/ diff --git a/README.md b/README.md index 7e8f8211a..e35250c54 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ There are three groups of tests: * Unit tests * Simple unit tests for individual functions and classes. * **Framework:** [Vitest](https://vitest.dev/) - * **Assertions:** [Chai](https://www.chaijs.com/)/[Jest](https://jestjs.io/docs/expect) + * **Assertions:** [Chai](https://www.chaijs.com/)/[Vitest](https://vitest.dev/api/expect.html) * **Path:** `tests/unit` * **Command:** `yarn run test:unit` (watches by default, only re-runs changed file) * (To prevent watching, use `yarn vitest run`) @@ -77,7 +77,7 @@ There are three groups of tests: * In-browser tests which mount a single Vue component standalone. * **Framework:** [Cypress](https://docs.cypress.io/guides/overview/why-cypress) * **Assertions:** Chai - * **Path:** `cypress/component` + * **Path:** `tests/component` * **Command:** `yarn run test:component` * (For "headless" mode use `yarn cypress run --component --config video=false`) * End to end tests diff --git a/cypress.config.cjs b/cypress.config.cjs index d09185c4a..26285f80a 100644 --- a/cypress.config.cjs +++ b/cypress.config.cjs @@ -33,14 +33,7 @@ module.exports = defineConfig({ mode: 'development', }) ) - - return Object.assign({}, config, { - fixturesFolder: 'tests/e2e/fixtures', - specPattern: 'tests/e2e/specs', - screenshotsFolder: 'tests/e2e/screenshots', - videosFolder: 'tests/e2e/videos', - supportFile: 'tests/e2e/support/index.js' - }) + return config }, specPattern: 'tests/e2e/specs/**/*.cy.{js,jsx,ts,tsx}', supportFile: 'tests/e2e/support/index.js' @@ -56,6 +49,9 @@ module.exports = defineConfig({ require('@cypress/code-coverage/task')(on, config) return config }, + specPattern: 'tests/component/**/*.cy.{js,jsx,ts,tsx}', + supportFile: 'tests/component/support/index.js', + indexHtmlFile: 'tests/component/support/component-index.html' }, env: { diff --git a/tests/component/.eslintrc.cjs b/tests/component/.eslintrc.cjs new file mode 100644 index 000000000..0667e7b35 --- /dev/null +++ b/tests/component/.eslintrc.cjs @@ -0,0 +1,25 @@ +/* + * Copyright (C) NIWA & British Crown (Met Office) & Contributors. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +module.exports = { + plugins: [ + 'cypress' + ], + env: { + 'cypress/globals': true + }, +} diff --git a/cypress/fixtures/example.json b/tests/component/fixtures/example.json similarity index 100% rename from cypress/fixtures/example.json rename to tests/component/fixtures/example.json diff --git a/cypress/component/boxPlot.cy.js b/tests/component/specs/boxPlot.cy.js similarity index 100% rename from cypress/component/boxPlot.cy.js rename to tests/component/specs/boxPlot.cy.js diff --git a/cypress/component/copyBtn.cy.js b/tests/component/specs/copyBtn.cy.js similarity index 100% rename from cypress/component/copyBtn.cy.js rename to tests/component/specs/copyBtn.cy.js diff --git a/cypress/component/cylc-graph-node.cy.js b/tests/component/specs/cylc-graph-node.cy.js similarity index 100% rename from cypress/component/cylc-graph-node.cy.js rename to tests/component/specs/cylc-graph-node.cy.js diff --git a/cypress/component/cylc-icons.cy.js b/tests/component/specs/cylc-icons.cy.js similarity index 100% rename from cypress/component/cylc-icons.cy.js rename to tests/component/specs/cylc-icons.cy.js diff --git a/cypress/component/ganttchart.cy.js b/tests/component/specs/ganttchart.cy.js similarity index 100% rename from cypress/component/ganttchart.cy.js rename to tests/component/specs/ganttchart.cy.js diff --git a/cypress/component/info.cy.js b/tests/component/specs/info.cy.js similarity index 100% rename from cypress/component/info.cy.js rename to tests/component/specs/info.cy.js diff --git a/cypress/component/utils/task.js b/tests/component/specs/utils/task.js similarity index 100% rename from cypress/component/utils/task.js rename to tests/component/specs/utils/task.js diff --git a/cypress/component/viewToolbar.cy.js b/tests/component/specs/viewToolbar.cy.js similarity index 100% rename from cypress/component/viewToolbar.cy.js rename to tests/component/specs/viewToolbar.cy.js diff --git a/cypress/support/commands.js b/tests/component/support/commands.js similarity index 100% rename from cypress/support/commands.js rename to tests/component/support/commands.js diff --git a/cypress/support/component-index.html b/tests/component/support/component-index.html similarity index 100% rename from cypress/support/component-index.html rename to tests/component/support/component-index.html diff --git a/cypress/support/component.js b/tests/component/support/index.js similarity index 100% rename from cypress/support/component.js rename to tests/component/support/index.js diff --git a/tests/e2e/.eslintrc.cjs b/tests/e2e/.eslintrc.cjs index 61c8b001e..0667e7b35 100644 --- a/tests/e2e/.eslintrc.cjs +++ b/tests/e2e/.eslintrc.cjs @@ -1,4 +1,4 @@ -/** +/* * Copyright (C) NIWA & British Crown (Met Office) & Contributors. * * This program is free software: you can redistribute it and/or modify @@ -22,7 +22,4 @@ module.exports = { env: { 'cypress/globals': true }, - rules: { - strict: 'off' - } }