add tests and move type support presets to app store
This commit is contained in:
parent
914beb890f
commit
a95941b1e2
|
@ -16,7 +16,7 @@
|
|||
DateAsNumber,
|
||||
} from "./lines"
|
||||
import subjects from "./subjects"
|
||||
import { componentStore } from "stores/builder"
|
||||
import { appStore } from "stores/builder"
|
||||
|
||||
export let explanation
|
||||
export let columnIcon
|
||||
|
@ -29,7 +29,7 @@
|
|||
|
||||
$: explanationWithPresets = getExplanationWithPresets(
|
||||
explanation,
|
||||
$componentStore.typeSupportPresets
|
||||
$appStore.typeSupportPresets
|
||||
)
|
||||
let support
|
||||
let messages = []
|
||||
|
|
|
@ -19,6 +19,7 @@ export const INITIAL_APP_META_STATE = {
|
|||
showNotificationAction: false,
|
||||
sidePanel: false,
|
||||
},
|
||||
typeSupportPresets: {},
|
||||
features: {
|
||||
componentValidation: false,
|
||||
disableUserMetadata: false,
|
||||
|
@ -79,6 +80,13 @@ export class AppMetaStore extends BudiStore {
|
|||
}))
|
||||
}
|
||||
|
||||
syncClientTypeSupportPresets(typeSupportPresets) {
|
||||
this.update(state => ({
|
||||
...state,
|
||||
typeSupportPresets
|
||||
}))
|
||||
}
|
||||
|
||||
async syncAppRoutes() {
|
||||
const resp = await API.fetchAppRoutes()
|
||||
this.update(state => ({
|
||||
|
|
|
@ -103,12 +103,12 @@ export class ComponentStore extends BudiStore {
|
|||
this.update(state => ({
|
||||
...state,
|
||||
components,
|
||||
customComponents,
|
||||
typeSupportPresets: components?.typeSupportPresets ?? {},
|
||||
customComponents
|
||||
}))
|
||||
|
||||
// Sync client features to app store
|
||||
appStore.syncClientFeatures(components.features)
|
||||
appStore.syncClientTypeSupportPresets(components?.typeSupportPresets ?? {})
|
||||
|
||||
return components
|
||||
}
|
||||
|
|
|
@ -91,6 +91,12 @@ describe("Application Meta Store", () => {
|
|||
})
|
||||
})
|
||||
|
||||
it("Sync type support information to state", async ctx => {
|
||||
ctx.test.appStore.syncClientTypeSupportPresets({ preset: "information" })
|
||||
|
||||
expect(ctx.test.store.typeSupportPresets).toStrictEqual({ preset: "information" })
|
||||
})
|
||||
|
||||
it("Sync component feature flags to state", async ctx => {
|
||||
ctx.test.appStore.syncClientFeatures(clientFeaturesResp)
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ vi.mock("stores/builder", async () => {
|
|||
update: mockAppStore.update,
|
||||
set: mockAppStore.set,
|
||||
syncClientFeatures: vi.fn(),
|
||||
syncClientTypeSupportPresets: vi.fn(),
|
||||
}
|
||||
const mockTableStore = writable()
|
||||
const tables = {
|
||||
|
|
Loading…
Reference in New Issue