ui_migration refactor(store) Remove lingering getters for origin and available at settings.js pinia store, fixed unit test and thresholds accordingly.

This commit is contained in:
Antonio Anaya 2026-05-24 16:50:53 -06:00
parent 710883cff5
commit ace7ae9855
3 changed files with 11 additions and 18 deletions

View file

@ -1,5 +1,5 @@
import { defineStore } from "pinia";
import { ref, computed } from "vue";
import { ref } from "vue";
function getOriginFromLocation() {
// This will default to the same origin that's serving
@ -13,8 +13,8 @@ export const useSettingsStore = defineStore(
"settings",
() => {
// State
const origin = ref(getOriginFromLocation());
const available = ref(false);
const baseUri = ref(getOriginFromLocation());
const ready = ref(false);
const waiting = ref(false);
const error = ref("");
const trackWindow = ref(true);
@ -43,14 +43,14 @@ export const useSettingsStore = defineStore(
// Actions
function resetState() {
waiting.value = false;
available.value = false;
ready.value = false;
// On resetState there is no connection.
error.value = "Microscope is not connected.";
}
function setConnected() {
waiting.value = false;
available.value = true;
ready.value = true;
}
function addStream(id) {
@ -59,15 +59,12 @@ export const useSettingsStore = defineStore(
function removeStream(id) {
activeStreams.value[id] = false;
}
// Getters
const baseUri = computed(() => origin.value);
const ready = computed(() => available.value);
// Export
return {
//State
origin,
available,
// State
baseUri,
ready,
waiting,
error,
trackWindow,
@ -79,11 +76,7 @@ export const useSettingsStore = defineStore(
navigationStepSize,
navigationInvert,
//Getters
baseUri,
ready,
//Actions
// Actions
resetState,
setConnected,
addStream,

View file

@ -53,7 +53,7 @@ describe("Test LoggingContent.vue", () => {
createTestingPinia({
createSpy: vi.fn,
initialState: {
settings: { origin: "http://microscope.local:5000/api/v3" },
settings: { baseUri: "http://microscope.local:5000/api/v3" },
},
}),
],

View file

@ -50,7 +50,7 @@ export default defineConfig({
thresholds: {
lines: 4,
statements: 3,
functions: 3,
functions: 2,
branches: 1,
},
},