0
  /   ˆ{‹„„-i[D<†ªoZƒ›Ù«Â443_‘I|¥‰ÓMdœv ©ƒ†ü+=ÂÁ »    ‹      �“Qo›0…ßû+îü°·pC’J[k˜:ˆ´Hi¥LU5M“ƒXÙÎÒî×Ï„LÍªFkûdà~÷øœkLß¥Ë$»[MáKv=‡Õ×ÏóYd€x;NÓ,í“`"NHå\{�¸Ûí‚Ý8Ð¦Äl�•kê	Zgdîî8‰Ïh÷->Z	Æý
ÔIW‹x¦¸¸] ê­³’‹	n­A[1#Pi.~4šokaQµ6LùÅ¾×«áAŽn4èv	ß¨è÷¦Øf/Ü=š˜º
~±Z–*"N·$¦²)Áš<"(s­,nj¦~¥,°ÚEäÛ,Y~÷ºªëŽ)ƒÊˆ""Ÿ’hq¹Œ®H¼`� Èžg®{fÎ¬oSRð“ðMßÈß§ÓžI…Í�l�ÔêEñ8j®kÛ2ŸõÜ'¨Ì1Õ#üÓ`ù?ÃX]­§‹,�­û‘ðNâÑÝ‹Ï‡Ä+_SRiDî´y8dèß«�m/ÿ¾ÂÁ¡‘eåH0€gÉWÄ*tÍ…9v*’wz»ûåØãS£áh<~Œ>@x~ŽÞäþ…G‡‡Ÿšâþ’Pì¯â»±!œí    J   ˆl–Ãa¾”ªi?u8 ¸Û71hß�þB'„³Ž˜ÆB…×gùÅƒiÖ^Ä_“I|¥ŽõHºl=$¤�zTÖ™	ÄÃ ‚    // Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/

// Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/

import { useApolloClient } from '@vue/apollo-composable/compat'
import { random } from 'lodash-es'

// import authenticationGuard from '#shared/router/guards/before/authentication.ts'
// import permissionGuard from '#shared/router/guards/before/permission.ts'

import { useNotifications } from '#shared/components/CommonNotifications/useNotifications.ts'
import { useLocaleStore } from '#shared/stores/locale.ts'

import { initializeBetaUiFeedbackConsentDialog } from '#desktop/components/BetaUi/composables/useBetaUiFeedbackConsent.ts'

import mockApolloClient from '../mock-apollo-client.ts'

import LayoutTestDesktopView from './LayoutTestDesktopView.vue'
import LayoutTestMobileView from './LayoutTestMobileView.vue'
import renderComponent, {
  getHistory,
  getTestRouter,
  type ExtendedMountingOptions,
} from './renderComponent.ts'

import type { NavigationGuard, RouteRecordRaw } from 'vue-router'

const isDesktop = await vi.hoisted(async () => {
  const { getTestAppName } = await import('./app.ts')
  return getTestAppName() === 'desktop'
})

vi.mock('#shared/server/apollo/client.ts', async (importOriginal) => {
  // The desktop specs get the automocked client through `setApolloClient`. Importing the mocker
  //   here instead would wait on it while it is still importing this very module.
  if (isDesktop) return importOriginal()
  return {
    clearApolloClientStore: () => {
      return Promise.resolve()
    },
    getApolloClient: () => {
      return {
        cache: {
          gc: () => [],
        },
      }
    },
  }
})

Object.defineProperty(window, 'fetch', {
  value: (path: string) => {
    throw new Error(`calling fetch on ${path}`)
  },
  writable: true,
  configurable: true,
})

const html = String.raw

interface VisitViewOptions extends ExtendedMountingOptions<unknown> {
  mockApollo?: boolean
  setLocale?: boolean
}

const { routes } = isDesktop
  ? await import('#desktop/router/index.ts')
  : await import('#mobile/router/index.ts')

// remove LayoutMain layout, keep only actual content
if (routes.at(-1)?.name === 'Main') {
  const [mainRoutes] = routes.splice(routes.length - 1, 1)

  routes.push(...(mainRoutes.children as RouteRecordRaw[]), {
    path: '/testing-environment',
    component: {
      template: '<div></div>',
    },
  })
}

// Always reset again before each renderComponent call. With this we
// have an initial route for each test.
const routerBeforeGuards: NavigationGuard[] = []

// TODO: disable some stuff for now, because it will break a lot of test.
// const routerBeforeGuards = [authenticationGuard, permissionGuard]
if (isDesktop) {
  // Always reset again before each renderComponent call. With this we
  // have an initial route for each test.

  //   const { default: systemSetupInfo } = await import(
  //     '#desktop/router/guards/before/systemSetupInfo.ts'
  //   )
  //   routerBeforeGuards.push(systemSetupInfo)
  const { default: activeTaskbarTab } =
    await import('#desktop/router/guards/before/activeTaskbarTab.ts')
  routerBeforeGuards.push(activeTaskbarTab)
}

export const visitView = async (
  href: string,
  // rely on new way to mock apollo in desktop by default
  options: VisitViewOptions = { mockApollo: !isDesktop, setLocale: isDesktop },
) => {
  if (options.mockApollo) {
    mockApolloClient([])
  } else if (isDesktop) {
    // au