INSR-9520
scroll to top on mounted add helper file for beforeEach for all jest tests.
This commit is contained in:
parent
5e01bcdf3d
commit
47d00e22af
3 changed files with 9 additions and 0 deletions
|
|
@ -17,6 +17,7 @@ module.exports = {
|
||||||
'!src/helpers/unit-test-helper.js'
|
'!src/helpers/unit-test-helper.js'
|
||||||
// END
|
// END
|
||||||
], // ! means exclude from coverage.
|
], // ! means exclude from coverage.
|
||||||
|
setupFilesAfterEnv: ['<rootDir>/src/helpers/unit-test-setup-helper.js'],
|
||||||
testMatch: ['**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)'],
|
testMatch: ['**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)'],
|
||||||
coverageThreshold: {
|
coverageThreshold: {
|
||||||
// global: {
|
// global: {
|
||||||
|
|
|
||||||
4
src/helpers/unit-test-setup-helper.js
Normal file
4
src/helpers/unit-test-setup-helper.js
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
beforeEach(() => {
|
||||||
|
// Your shared logic here
|
||||||
|
document.body.innerHTML = '<div id="app"></div>';
|
||||||
|
});
|
||||||
|
|
@ -2,6 +2,9 @@ import showIssLoadingModal from '@/helpers/loading-modal-helper';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mounted() {
|
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);
|
showIssLoadingModal(false);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -17,6 +20,7 @@ export default {
|
||||||
* Identify the first error field and put focus on it
|
* Identify the first error field and put focus on it
|
||||||
* get error names array
|
* 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 errorNames = errors ? Object.keys(errors) : [];
|
||||||
const firstErrorEl = errorNames[0];
|
const firstErrorEl = errorNames[0];
|
||||||
if (firstErrorEl) {
|
if (firstErrorEl) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue