@@ -4,6 +4,7 @@ import flushPromises from "flush-promises";
44import { createPinia } from "pinia" ;
55import { getLocalVue } from "tests/jest/helpers" ;
66import { setupMockConfig } from "tests/jest/mockConfig" ;
7+ import VueRouter from "vue-router" ;
78
89import { useServerMock } from "@/api/client/__mocks__" ;
910import { useHistoryStore } from "@/stores/historyStore" ;
@@ -14,15 +15,12 @@ import ContentItem from "./Content/ContentItem.vue";
1415import HistoryView from "./HistoryView.vue" ;
1516
1617const localVue = getLocalVue ( ) ;
18+ localVue . use ( VueRouter ) ;
19+
1720jest . mock ( "stores/services/history.services" ) ;
1821
1922const { server, http } = useServerMock ( ) ;
2023
21- jest . mock ( "vue-router/composables" , ( ) => ( {
22- useRoute : jest . fn ( ( ) => ( { } ) ) ,
23- useRouter : jest . fn ( ( ) => ( { } ) ) ,
24- } ) ) ;
25-
2624function create_history ( historyId , userId , purged = false , archived = false ) {
2725 const historyName = `${ userId } 's History ${ historyId } ` ;
2826 return {
@@ -78,6 +76,9 @@ async function createWrapper(localVue, currentUserId, history) {
7876 } )
7977 ) ;
8078
79+ const router = new VueRouter ( ) ;
80+ router . push ( `/history/${ history . id } ` ) ;
81+
8182 const wrapper = mount ( HistoryView , {
8283 propsData : { id : history . id } ,
8384 localVue,
@@ -88,6 +89,7 @@ async function createWrapper(localVue, currentUserId, history) {
8889 } ,
8990 } ,
9091 pinia,
92+ router,
9193 } ) ;
9294 const userStore = useUserStore ( ) ;
9395 userStore . currentUser = getFakeRegisteredUser ( { id : currentUserId } ) ;
@@ -124,9 +126,9 @@ describe("History center panel View", () => {
124126 await historyStore . setCurrentHistory ( history . id ) ;
125127
126128 // switch/import buttons: current history, should be a disabled switch
127- const switchButton = wrapper . find ( "[data-description='switch to history button']" ) ;
129+ const switchButton = wrapper . find ( "[data-description='switch to history button']" ) . classes ( ) ;
128130 const importButton = wrapper . find ( "[data-description='import history button']" ) ;
129- expect ( switchButton . attributes ( " disabled") ) . toBeTruthy ( ) ;
131+ expect ( switchButton . includes ( "g- disabled") ) . toBeTruthy ( ) ;
130132 expect ( importButton . exists ( ) ) . toBe ( false ) ;
131133
132134 // parts of the layout that should be similar for all cases
@@ -169,9 +171,9 @@ describe("History center panel View", () => {
169171 expect ( wrapper . vm . history ) . toEqual ( history ) ;
170172
171173 // switch/import buttons: not current history, switchable
172- const switchButton = wrapper . find ( "[data-description='switch to history button']" ) ;
174+ const switchButton = wrapper . find ( "[data-description='switch to history button']" ) . classes ( ) ;
173175 const importButton = wrapper . find ( "[data-description='import history button']" ) ;
174- expect ( switchButton . attributes ( " disabled") ) . toBeFalsy ( ) ;
176+ expect ( switchButton . includes ( "g- disabled") ) . toBeFalsy ( ) ;
175177 expect ( importButton . exists ( ) ) . toBe ( false ) ;
176178
177179 // storage dashboard button should be enabled
@@ -187,9 +189,9 @@ describe("History center panel View", () => {
187189 expect ( wrapper . vm . history ) . toEqual ( history ) ;
188190
189191 // history purged, is switchable but not importable
190- const switchButton = wrapper . find ( "[data-description='switch to history button']" ) ;
192+ const switchButton = wrapper . find ( "[data-description='switch to history button']" ) . classes ( ) ;
191193 const importButton = wrapper . find ( "[data-description='import history button']" ) ;
192- expect ( switchButton . attributes ( " disabled") ) . toBeFalsy ( ) ;
194+ expect ( switchButton . includes ( "g- disabled") ) . toBeFalsy ( ) ;
193195 expect ( importButton . exists ( ) ) . toBe ( false ) ;
194196
195197 // storage dashboard button can be accessed
0 commit comments