From 47d00e22af391a688aa9b588fc8fc0360e5c4018 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Wed, 6 May 2026 10:23:00 -0400 Subject: [PATCH 1/2] INSR-9520 scroll to top on mounted add helper file for beforeEach for all jest tests. --- jest.config.js | 1 + src/helpers/unit-test-setup-helper.js | 4 ++++ src/mixins/base-form-mixin.js | 4 ++++ 3 files changed, 9 insertions(+) create mode 100644 src/helpers/unit-test-setup-helper.js diff --git a/jest.config.js b/jest.config.js index a8f63af6..4f503f85 100644 --- a/jest.config.js +++ b/jest.config.js @@ -17,6 +17,7 @@ module.exports = { '!src/helpers/unit-test-helper.js' // END ], // ! means exclude from coverage. + setupFilesAfterEnv: ['/src/helpers/unit-test-setup-helper.js'], testMatch: ['**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)'], coverageThreshold: { // global: { diff --git a/src/helpers/unit-test-setup-helper.js b/src/helpers/unit-test-setup-helper.js new file mode 100644 index 00000000..2d6818c0 --- /dev/null +++ b/src/helpers/unit-test-setup-helper.js @@ -0,0 +1,4 @@ +beforeEach(() => { + // Your shared logic here + document.body.innerHTML = '
'; +}); diff --git a/src/mixins/base-form-mixin.js b/src/mixins/base-form-mixin.js index 314a1dd8..41b1d45a 100644 --- a/src/mixins/base-form-mixin.js +++ b/src/mixins/base-form-mixin.js @@ -2,6 +2,9 @@ import showIssLoadingModal from '@/helpers/loading-modal-helper'; export default { mounted() { + // The router scroll behavior happens before transitioning to the new page, so we need to manually scroll to top here + // to ensure that we are at the top of the page when the new page is loaded. + document.getElementById("app").scrollTop = 0; showIssLoadingModal(false); }, methods: { @@ -17,6 +20,7 @@ export default { * Identify the first error field and put focus on it * get error names array */ + console.log('Form submission prevented due to validation errors. Attempting to focus on the first invalid field.'); const errorNames = errors ? Object.keys(errors) : []; const firstErrorEl = errorNames[0]; if (firstErrorEl) { From df0f41e5606d54d8be182d2f254c69b881b4ffd0 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Wed, 6 May 2026 10:40:09 -0400 Subject: [PATCH 2/2] remove console log --- src/mixins/base-form-mixin.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mixins/base-form-mixin.js b/src/mixins/base-form-mixin.js index 41b1d45a..e806dc0f 100644 --- a/src/mixins/base-form-mixin.js +++ b/src/mixins/base-form-mixin.js @@ -20,7 +20,6 @@ export default { * Identify the first error field and put focus on it * get error names array */ - console.log('Form submission prevented due to validation errors. Attempting to focus on the first invalid field.'); const errorNames = errors ? Object.keys(errors) : []; const firstErrorEl = errorNames[0]; if (firstErrorEl) {