Skip to content

move test-support/index service container into other "modules" #4250

Description

@johncowen

Description

Why

We are gradually moving things out of the application and into separate modules, when we spot things that are not currently in a module (or "pseudo app-module") but probably should be, we are moving them over there.

What

We spotted

import { defaultKumaHtmlVars as htmlVars } from '@kumahq/config/vite'
import { config } from '@vue/test-utils'
import type { PluginDefinition, ComponentDefinition } from '@/app/vue'
import type { ServiceConfigurator } from '@kumahq/container'
import type { Component } from 'vue'
export const services: ServiceConfigurator = (app) => [
[app.app, {
service: (
components: ComponentDefinition[],
plugins: PluginDefinition[],
) => {
plugins.forEach(([...args]) => {
config.global.plugins.push([...args])
})
components.forEach(([name, component]: [string, Component]) => {
config.global.components[name] = component
})
return async () => {
throw new Error('You shouldn\'t be calling $.app during testing, just get(\'$.app\') is fine')
}
},
arguments: [
app.components,
app.plugins,
],
}],
[app.htmlVars, {
service: () => htmlVars,
}],
]

Which is currently in the application (@kumahq/kuma-gui) instead of in its own module.

We feel that the majority of this is very vue specific and therefore be moved to a test-support.ts or equivalant file under app/vue. That way when we make app/vueinto say@kumahq/vue-container` this code will then be in its own module. Note we don't need to make the module yet, jus move the file around.

Lastly, there is a htmlVars injection in that same file, ideally this belongs in app/kuma as its about kuma. At first glance to me this could probably go in a app/kuma/test-support.ts, but I could be wrong on that one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    dxkind/cleanupCleanup/refactor an existing component/codetriage/acceptedThe issue was reviewed and is complete enough to start working on ittriage/staleInactive for some time. It will be triaged again

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions