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:
parent
710883cff5
commit
ace7ae9855
3 changed files with 11 additions and 18 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { ref, computed } from "vue";
|
import { ref } from "vue";
|
||||||
|
|
||||||
function getOriginFromLocation() {
|
function getOriginFromLocation() {
|
||||||
// This will default to the same origin that's serving
|
// This will default to the same origin that's serving
|
||||||
|
|
@ -13,8 +13,8 @@ export const useSettingsStore = defineStore(
|
||||||
"settings",
|
"settings",
|
||||||
() => {
|
() => {
|
||||||
// State
|
// State
|
||||||
const origin = ref(getOriginFromLocation());
|
const baseUri = ref(getOriginFromLocation());
|
||||||
const available = ref(false);
|
const ready = ref(false);
|
||||||
const waiting = ref(false);
|
const waiting = ref(false);
|
||||||
const error = ref("");
|
const error = ref("");
|
||||||
const trackWindow = ref(true);
|
const trackWindow = ref(true);
|
||||||
|
|
@ -43,14 +43,14 @@ export const useSettingsStore = defineStore(
|
||||||
// Actions
|
// Actions
|
||||||
function resetState() {
|
function resetState() {
|
||||||
waiting.value = false;
|
waiting.value = false;
|
||||||
available.value = false;
|
ready.value = false;
|
||||||
// On resetState there is no connection.
|
// On resetState there is no connection.
|
||||||
error.value = "Microscope is not connected.";
|
error.value = "Microscope is not connected.";
|
||||||
}
|
}
|
||||||
|
|
||||||
function setConnected() {
|
function setConnected() {
|
||||||
waiting.value = false;
|
waiting.value = false;
|
||||||
available.value = true;
|
ready.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addStream(id) {
|
function addStream(id) {
|
||||||
|
|
@ -59,15 +59,12 @@ export const useSettingsStore = defineStore(
|
||||||
function removeStream(id) {
|
function removeStream(id) {
|
||||||
activeStreams.value[id] = false;
|
activeStreams.value[id] = false;
|
||||||
}
|
}
|
||||||
// Getters
|
|
||||||
const baseUri = computed(() => origin.value);
|
|
||||||
const ready = computed(() => available.value);
|
|
||||||
|
|
||||||
// Export
|
// Export
|
||||||
return {
|
return {
|
||||||
//State
|
// State
|
||||||
origin,
|
baseUri,
|
||||||
available,
|
ready,
|
||||||
waiting,
|
waiting,
|
||||||
error,
|
error,
|
||||||
trackWindow,
|
trackWindow,
|
||||||
|
|
@ -79,11 +76,7 @@ export const useSettingsStore = defineStore(
|
||||||
navigationStepSize,
|
navigationStepSize,
|
||||||
navigationInvert,
|
navigationInvert,
|
||||||
|
|
||||||
//Getters
|
// Actions
|
||||||
baseUri,
|
|
||||||
ready,
|
|
||||||
|
|
||||||
//Actions
|
|
||||||
resetState,
|
resetState,
|
||||||
setConnected,
|
setConnected,
|
||||||
addStream,
|
addStream,
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ describe("Test LoggingContent.vue", () => {
|
||||||
createTestingPinia({
|
createTestingPinia({
|
||||||
createSpy: vi.fn,
|
createSpy: vi.fn,
|
||||||
initialState: {
|
initialState: {
|
||||||
settings: { origin: "http://microscope.local:5000/api/v3" },
|
settings: { baseUri: "http://microscope.local:5000/api/v3" },
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ export default defineConfig({
|
||||||
thresholds: {
|
thresholds: {
|
||||||
lines: 4,
|
lines: 4,
|
||||||
statements: 3,
|
statements: 3,
|
||||||
functions: 3,
|
functions: 2,
|
||||||
branches: 1,
|
branches: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue