diff --git a/meshchatx/src/frontend/components/App.vue b/meshchatx/src/frontend/components/App.vue index a12a2ee..767521e 100644 --- a/meshchatx/src/frontend/components/App.vue +++ b/meshchatx/src/frontend/components/App.vue @@ -664,10 +664,10 @@ export default { }, }, watch: { - $route() { + $route(to, from) { this.isSidebarOpen = false; // Close tutorial modal if it's open and we navigate away - if (this.$refs.tutorialModal && this.$refs.tutorialModal.visible) { + if (from && from.name && this.$refs.tutorialModal && this.$refs.tutorialModal.visible) { this.$refs.tutorialModal.visible = false; } }, diff --git a/tests/frontend/AppModals.test.js b/tests/frontend/AppModals.test.js index 6d138bc..b0dce1d 100644 --- a/tests/frontend/AppModals.test.js +++ b/tests/frontend/AppModals.test.js @@ -32,28 +32,30 @@ const i18n = createI18n({ }, }); -const router = createRouter({ - history: createWebHashHistory(), - routes: [ - { path: "/", name: "messages", component: { template: "
Messages
" } }, - { path: "/nomadnetwork", name: "nomadnetwork", component: { template: "
Nomad
" } }, - { path: "/map", name: "map", component: { template: "
Map
" } }, - { path: "/archives", name: "archives", component: { template: "
Archives
" } }, - { path: "/call", name: "call", component: { template: "
Call
" } }, - { path: "/interfaces", name: "interfaces", component: { template: "
Interfaces
" } }, - { path: "/network-visualiser", name: "network-visualiser", component: { template: "
Network
" } }, - { path: "/tools", name: "tools", component: { template: "
Tools
" } }, - { path: "/settings", name: "settings", component: { template: "
Settings
" } }, - { path: "/identities", name: "identities", component: { template: "
Identities
" } }, - { path: "/about", name: "about", component: { template: "
About
" } }, - { path: "/profile/icon", name: "profile.icon", component: { template: "
Profile
" } }, - { path: "/changelog", name: "changelog", component: { template: "
Changelog
" } }, - { path: "/tutorial", name: "tutorial", component: { template: "
Tutorial
" } }, - ], -}); +const routes = [ + { path: "/", name: "messages", component: { template: "
Messages
" } }, + { path: "/nomadnetwork", name: "nomadnetwork", component: { template: "
Nomad
" } }, + { path: "/map", name: "map", component: { template: "
Map
" } }, + { path: "/archives", name: "archives", component: { template: "
Archives
" } }, + { path: "/call", name: "call", component: { template: "
Call
" } }, + { path: "/interfaces", name: "interfaces", component: { template: "
Interfaces
" } }, + { path: "/network-visualiser", name: "network-visualiser", component: { template: "
Network
" } }, + { path: "/tools", name: "tools", component: { template: "
Tools
" } }, + { path: "/settings", name: "settings", component: { template: "
Settings
" } }, + { path: "/identities", name: "identities", component: { template: "
Identities
" } }, + { path: "/about", name: "about", component: { template: "
About
" } }, + { path: "/profile/icon", name: "profile.icon", component: { template: "
Profile
" } }, + { path: "/changelog", name: "changelog", component: { template: "
Changelog
" } }, + { path: "/tutorial", name: "tutorial", component: { template: "
Tutorial
" } }, +]; describe("App.vue Modals", () => { + let router; beforeEach(() => { + router = createRouter({ + history: createWebHashHistory(), + routes, + }); vi.clearAllMocks(); axiosMock.get.mockImplementation((url) => { if (url === "/api/v1/app/info") { @@ -139,6 +141,7 @@ describe("App.vue Modals", () => { }, }); + await router.isReady(); await new Promise((resolve) => setTimeout(resolve, 200)); expect(wrapper.vm.$refs.tutorialModal.visible).toBe(true); @@ -197,6 +200,7 @@ describe("App.vue Modals", () => { }, }); + await router.isReady(); await new Promise((resolve) => setTimeout(resolve, 200)); expect(wrapper.vm.$refs.changelogModal.visible).toBe(true);