• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

FAIRsharing / fairsharing.github.io / 24769584990

22 Apr 2026 08:57AM UTC coverage: 95.892% (-4.1%) from 100.0%
24769584990

push

github

web-flow
Merge pull request #2746 from FAIRsharing/dev

Dev

3653 of 3813 branches covered (95.8%)

Branch coverage included in aggregate %.

17344 of 18229 new or added lines in 282 files covered. (95.15%)

766 existing lines in 50 files now uncovered.

38617 of 40268 relevant lines covered (95.9%)

5.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.86
/src/store/AdvancedSearchComponents/advancedSearch.js
1
import { jsonToGraphQLQuery } from "json-to-graphql-query";
1✔
2
import { isBoolean } from "lodash";
1✔
3

4
import GraphClient from "@/lib/GraphClient/GraphClient.js";
1✔
5
import advancedQuery from "@/lib/GraphClient/queries/getAdvancedSearch.json";
1✔
6
import { uniqueValues } from "@/utils/advancedSearchUtils";
1✔
7

8
const CLIENT = new GraphClient(),
1✔
9
  ADVANCED_TAGS = JSON.parse(JSON.stringify(advancedQuery));
1✔
10

11
const state = {
1✔
12
  advancedSearchText: "",
1✔
13
  advancedSearch: {},
1✔
14
  editAdvancedSearch: {},
1✔
15
  advancedSearchQuery: {
1✔
16
    operator: "",
1✔
17
    fields: [],
1✔
18
  },
1✔
19
  advancedSearchResponse: [],
1✔
20
  loadingStatus: false,
1✔
21
  errorStatus: false,
1✔
22
  editDialogStatus: false,
1✔
23
  advancedSearchDialogStatus: false,
1✔
24
};
1✔
25

26
const actions = {
1✔
27
  async fetchAdvancedSearchResults({ commit }, advancedSearchTerm) {
1✔
28
    state.advancedSearchQuery["fields"] = [];
3✔
29
    commit("setLoadingStatus", true);
3✔
30
    state.advancedSearchQuery["operator"] =
3✔
31
      state.advancedSearch["operatorIdentifier"];
3✔
32
    /* istanbul ignore next */
3✔
33
    if (
3✔
34
      state.advancedSearch["children"] &&
3!
UNCOV
35
      state.advancedSearch["children"].length
×
36
    ) {
3!
UNCOV
37
      state.advancedSearch["children"].forEach((item) => {
×
UNCOV
38
        if (item["children"] && item["children"].length) {
×
UNCOV
39
          let fieldsObj = {};
×
UNCOV
40
          let fieldValue = [] || Boolean;
×
UNCOV
41
          let fieldTypeValue = [];
×
UNCOV
42
          fieldsObj["operator"] = item["operatorIdentifier"];
×
UNCOV
43
          const mergedValues = uniqueValues(item["children"]);
×
44

UNCOV
45
          mergedValues.forEach((params) => {
×
UNCOV
46
            let fieldKey = params["identifier"];
×
UNCOV
47
            //Changing databasetype/standardtype/policytype keyname to 'type'
×
UNCOV
48
            //to pass as a required key for advancedSearch query
×
UNCOV
49
            if (
×
UNCOV
50
              fieldKey === "databasetype" ||
×
UNCOV
51
              fieldKey === "standardtype" ||
×
UNCOV
52
              fieldKey === "policytype" ||
×
UNCOV
53
              fieldKey === "fairassisttype"
×
UNCOV
54
            ) {
×
UNCOV
55
              fieldKey = "type";
×
UNCOV
56
              fieldTypeValue.push(params["value"]);
×
UNCOV
57
              fieldTypeValue = fieldTypeValue.flatMap((value) => value);
×
UNCOV
58
              fieldValue = fieldTypeValue;
×
UNCOV
59
            } else {
×
UNCOV
60
              if (Array.isArray(params["value"])) {
×
UNCOV
61
                fieldValue = params["value"];
×
NEW
62
              } else if (isBoolean(params["value"])) {
×
UNCOV
63
                fieldValue = params["value"];
×
NEW
64
              } else if (params["value"]) {
×
UNCOV
65
                //When string is boolean value, convert to boolean format
×
NEW
66
                if (params["value"] === "true" || params["value"] === "false") {
×
UNCOV
67
                  fieldValue = JSON.parse(params["value"]);
×
UNCOV
68
                } else {
×
UNCOV
69
                  fieldValue = [params["value"]];
×
UNCOV
70
                }
×
UNCOV
71
              }
×
UNCOV
72
            }
×
UNCOV
73
            if (fieldValue && fieldValue.length) {
×
UNCOV
74
              fieldValue = fieldValue.map((e) => e.toLowerCase());
×
NEW
75
              fieldsObj[fieldKey] = fieldValue;
×
NEW
76
            } else if (isBoolean(fieldValue)) {
×
NEW
77
              fieldsObj[fieldKey] = fieldValue;
×
UNCOV
78
            }
×
UNCOV
79
          });
×
80

UNCOV
81
          state.advancedSearchQuery["fields"].push(fieldsObj);
×
UNCOV
82
        }
×
UNCOV
83
      });
×
UNCOV
84
    }
×
85

86
    commit("setAdvancedSearchQuery", state.advancedSearchQuery);
3✔
87

88
    //Below is the format required for jsonToGraphQlQuery
3✔
89
    let parentQuery = {};
3✔
90
    parentQuery["query"] = {};
3✔
91
    parentQuery["__args"] = state.advancedSearchQuery;
3✔
92
    parentQuery.query["__args"] = {
3✔
93
      where: state.advancedSearchQuery,
3✔
94
    };
3✔
95
    let graphqlQuery = jsonToGraphQLQuery(parentQuery, {
3✔
96
      pretty: true,
3✔
97
    });
3✔
98
    graphqlQuery = graphqlQuery.replace("query", "").trim();
3✔
99
    graphqlQuery = graphqlQuery.match(/^\((.*)\)$/)[1];
3✔
100
    let whereObj = graphqlQuery.replace("where:", "");
3✔
101

102
    if (advancedSearchTerm) {
3✔
103
      commit("setAdvancedSearchText", advancedSearchTerm);
1✔
104
      ADVANCED_TAGS.queryParam = {
1✔
105
        q: state.advancedSearchText,
1✔
106
        where: whereObj,
1✔
107
      };
1✔
108
    } else {
3✔
109
      commit("setAdvancedSearchText", "");
2✔
110
      ADVANCED_TAGS.queryParam = {
2✔
111
        where: whereObj,
2✔
112
      };
2✔
113
    }
2✔
114

115
    try {
3✔
116
      let response = await CLIENT.executeQuery(ADVANCED_TAGS);
3✔
117
      commit("setAdvancedSearchResponse", response["advancedSearch"]);
3✔
118
      if (!response["error"]) {
3✔
119
        commit("setError", false);
2✔
120
        commit("setAdvancedSearchResponse", response["advancedSearch"]);
2✔
121
      } else {
3✔
122
        commit("setError", true);
1✔
123
      }
1✔
124
    } catch (error) {
3!
UNCOV
125
      /* istanbul ignore next */
×
UNCOV
126
      commit("setError", true);
×
UNCOV
127
    }
×
128
    commit("setLoadingStatus", false);
3✔
129
  },
1✔
130

131
  resetAdvancedSearchResponse({ commit }) {
1✔
132
    commit("resetAdvancedSearch");
1✔
133
  },
1✔
134
};
1✔
135

136
const mutations = {
1✔
137
  setAdvancedSearchText(state, advancedSearchText) {
1✔
138
    state.advancedSearchText = advancedSearchText;
1✔
139
  },
1✔
140
  setAdvancedSearch(state, advancedSearch) {
1✔
141
    state.advancedSearch = advancedSearch;
1✔
142
  },
1✔
143
  setEditAdvancedSearch(state, editAdvancedSearch) {
1✔
144
    state.editAdvancedSearch = editAdvancedSearch;
1✔
145
  },
1✔
146
  setAdvancedSearchResponse(state, advancedSearchResponse) {
1✔
147
    state.advancedSearchResponse = advancedSearchResponse;
1✔
148
  },
1✔
149
  setLoadingStatus(state, loadingStatus) {
1✔
150
    state.loadingStatus = loadingStatus;
1✔
151
  },
1✔
152
  resetAdvancedSearch(state) {
1✔
153
    state.advancedSearch = {};
1✔
154
    state.editAdvancedSearch = {};
1✔
155
    state.advancedSearchQuery = {
1✔
156
      operator: "",
1✔
157
      fields: [],
1✔
158
    };
1✔
159
    state.advancedSearchResponse = [];
1✔
160
  },
1✔
161
  setError(state, errorStatus) {
1✔
162
    state.errorStatus = errorStatus;
1✔
163
  },
1✔
164
  setAdvancedSearchQuery(state, advancedSearchQuery) {
1✔
165
    state.advancedSearchQuery = {
1✔
166
      operator: advancedSearchQuery["operator"],
1✔
167
      fields: advancedSearchQuery["fields"],
1✔
168
    };
1✔
169
  },
1✔
170

171
  setEditDialogStatus(state, editDialogStatus) {
1✔
172
    state.editDialogStatus = editDialogStatus;
1✔
173
  },
1✔
174
  setAdvancedSearchDialogStatus(state, advancedSearchDialogStatus) {
1✔
175
    state.advancedSearchDialogStatus = advancedSearchDialogStatus;
1✔
176
  },
1✔
177
};
1✔
178

179
const getters = {
1✔
180
  getAdvancedSearchText(state) {
1✔
181
    return state.advancedSearchText;
1✔
182
  },
1✔
183
  getAdvancedSearch(state) {
1✔
184
    return state.advancedSearch;
1✔
185
  },
1✔
186
  getEditAdvancedSearch(state) {
1✔
187
    return state.editAdvancedSearch;
1✔
188
  },
1✔
189

190
  getAdvancedSearchResponse(state) {
1✔
191
    return state.advancedSearchResponse;
1✔
192
  },
1✔
193
  getLoadingStatus(state) {
1✔
194
    return state.loadingStatus;
1✔
195
  },
1✔
196
  getErrorStatus(state) {
1✔
197
    return state.errorStatus;
1✔
198
  },
1✔
199
  getAdvancedSearchQuery(state) {
1✔
200
    return state.advancedSearchQuery;
1✔
201
  },
1✔
202
  getEditDialogStatus(state) {
1✔
203
    return state.editDialogStatus;
1✔
204
  },
1✔
205
  getAdvancedSearchDialogStatus(state) {
1✔
206
    return state.advancedSearchDialogStatus;
1✔
207
  },
1✔
208
};
1✔
209
const advancedSearch = {
1✔
210
  namespaced: true,
1✔
211
  state,
1✔
212
  actions,
1✔
213
  mutations,
1✔
214
  getters,
1✔
215
};
1✔
216

217
export default advancedSearch;
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc