push
github
56 of 145 branches covered (38.62%)
48 of 50 new or added lines in 5 files covered. (96.0%)
3395 existing lines in 78 files now uncovered.8599 of 20189 relevant lines covered (42.59%)
701.76 hits per line
1 |
/** @format */
|
1✔ |
2 |
|
1✔ |
3 |
import { defineStore } from "pinia"; |
1✔ |
4 |
|
1✔ |
5 |
export const useSessionUserStore = defineStore("sessionUser", { |
1✔ |
6 |
state: () => {
|
|
7 |
return {
|
1✔ |
8 |
roles: [],
|
1✔ |
9 |
preferences: {}
|
1✔ |
10 |
}; |
1✔ |
11 |
}, |
1✔ |
12 |
actions: {
|
1✔ |
13 |
async initialize() { |
|
14 |
const response = await fetch("./erp/api/v0/session", {
|
1✔ |
15 |
method: "GET" |
1✔ |
16 |
}); |
1✔ |
17 |
|
1✔ |
18 |
if (response.ok) {
|
1✔ |
19 |
let data = await response.json(); |
1✔ |
20 |
this.$patch({ |
1✔ |
21 |
roles: data.roles,
|
1✔ |
22 |
preferences: data.preferences
|
1✔ |
23 |
}); |
1✔ |
24 |
} else {
|
|
25 |
throw new Error(`HTTP Error: ${response.status}`); |
× |
UNCOV
26
|
} |
× |
27 |
} |
1✔ |
28 |
}, |
1✔ |
29 |
getters: {
|
1✔ |
30 |
hasRole: (state) => {
|
|
31 |
return (role) => state.roles.find((r) => r === role) !== undefined; |
|
32 |
} |
1✔ |
33 |
} |
1✔ |
34 |
}); |
1✔ |