INSR-9520

scroll to top on mounted
add helper file for beforeEach for all jest tests.
This commit is contained in:
Bill Richardson 2026-05-06 10:23:00 -04:00
parent 5e01bcdf3d
commit 47d00e22af
3 changed files with 9 additions and 0 deletions

View file

@ -17,6 +17,7 @@ module.exports = {
'!src/helpers/unit-test-helper.js'
// END
], // ! means exclude from coverage.
setupFilesAfterEnv: ['<rootDir>/src/helpers/unit-test-setup-helper.js'],
testMatch: ['**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)'],
coverageThreshold: {
// global: {

View file

@ -0,0 +1,4 @@
beforeEach(() => {
// Your shared logic here
document.body.innerHTML = '<div id="app"></div>';
});

View file

@ -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) {