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

FAIRsharing / fairsharing.github.io / 27561447601

15 Jun 2026 04:40PM UTC coverage: 96.026% (-0.2%) from 96.234%
27561447601

Pull #2784

github

prakhyatox
applying fix for doi urls
Pull Request #2784: Replacing prerender 2754

3702 of 3882 branches covered (95.36%)

Branch coverage included in aggregate %.

794 of 897 new or added lines in 73 files covered. (88.52%)

18 existing lines in 3 files now uncovered.

39217 of 40813 relevant lines covered (96.09%)

5.08 hits per line

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

70.2
/src/store/AdvancedSearchComponents/advancedSearch.js
1
import { jsonToGraphQLQuery } from "json-to-graphql-query";
1✔
2
import { isBoolean, isObject } from "lodash-es";
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!
35
      state.advancedSearch["children"].length
×
36
    ) {
3!
37
      state.advancedSearch["children"].forEach((item) => {
×
38
        if (item["children"] && item["children"].length) {
×
39
          let fieldsObj = {};
×
40
          let fieldValue = [] || Boolean;
×
41
          let fieldTypeValue = [];
×
42
          fieldsObj["operator"] = item["operatorIdentifier"];
×
43
          const mergedValues = uniqueValues(item["children"]);
×
44

45
          mergedValues.forEach((params) => {
×
46
            let fieldKey = params["identifier"];
×
47
            //Changing databasetype/standardtype/policytype keyname to 'type'
×
48
            //to pass as a required key for advancedSearch query
×
49
            if (
×
50
              fieldKey === "databasetype" ||
×
51
              fieldKey === "standardtype" ||
×
52
              fieldKey === "policytype" ||
×
53
              fieldKey === "fairassisttype"
×
54
            ) {
×
55
              fieldKey = "type";
×
56
              let valuesArr = [];
×
57
              params["value"].forEach((item) => {
×
58
                if (isObject(item)) {
×
59
                  valuesArr.push(item.value);
×
NEW
60
                }
×
NEW
61
                else {
×
62
                  valuesArr.push(item);
×
63
                }
×
64
              });
×
65
              fieldTypeValue.push(valuesArr);
×
66
              fieldTypeValue = fieldTypeValue.flatMap((value) => value);
×
67
              fieldValue = fieldTypeValue;
×
NEW
68
            }
×
NEW
69
            else {
×
70
              if (Array.isArray(params["value"])) {
×
71
                let valuesArr = [];
×
72
                params["value"].forEach((item) => {
×
73
                  if (isObject(item)) {
×
74
                    valuesArr.push(item.value);
×
NEW
75
                  }
×
NEW
76
                  else {
×
77
                    valuesArr.push(item);
×
78
                  }
×
79
                });
×
80
                fieldValue = valuesArr;
×
NEW
81
              }
×
NEW
82
              else if (isBoolean(params["value"])) {
×
83
                fieldValue = params["value"];
×
NEW
84
              }
×
NEW
85
              else if (params["value"]) {
×
86
                //When string is boolean value, convert to boolean format
×
87
                if (params["value"] === "true" || params["value"] === "false") {
×
88
                  fieldValue = JSON.parse(params["value"]);
×
NEW
89
                }
×
NEW
90
                else {
×
91
                  fieldValue = [params["value"]];
×
92
                }
×
93
              }
×
94
            }
×
95
            if (fieldValue && fieldValue.length) {
×
96
              fieldValue = fieldValue.map((e) => e.toLowerCase());
×
97
              fieldsObj[fieldKey] = fieldValue;
×
NEW
98
            }
×
NEW
99
            else if (isBoolean(fieldValue)) {
×
100
              fieldsObj[fieldKey] = fieldValue;
×
101
            }
×
102
          });
×
103

104
          state.advancedSearchQuery["fields"].push(fieldsObj);
×
105
        }
×
106
      });
×
107
    }
×
108

109
    commit("setAdvancedSearchQuery", state.advancedSearchQuery);
3✔
110

111
    //Below is the format required for jsonToGraphQlQuery
3✔
112
    let parentQuery = {};
3✔
113
    parentQuery["query"] = {};
3✔
114
    parentQuery["__args"] = state.advancedSearchQuery;
3✔
115
    parentQuery.query["__args"] = {
3✔
116
      where: state.advancedSearchQuery,
3✔
117
    };
3✔
118
    let graphqlQuery = jsonToGraphQLQuery(parentQuery, {
3✔
119
      pretty: true,
3✔
120
    });
3✔
121
    graphqlQuery = graphqlQuery.replace("query", "").trim();
3✔
122
    graphqlQuery = graphqlQuery.match(/^\((.*)\)$/)[1];
3✔
123
    let whereObj = graphqlQuery.replace("where:", "");
3✔
124

125
    if (advancedSearchTerm) {
3✔
126
      commit("setAdvancedSearchText", advancedSearchTerm);
1✔
127
      ADVANCED_TAGS.queryParam = {
1✔
128
        q: state.advancedSearchText,
1✔
129
        where: whereObj,
1✔
130
      };
1✔
131
    }
1✔
132
    else {
2✔
133
      commit("setAdvancedSearchText", "");
2✔
134
      ADVANCED_TAGS.queryParam = {
2✔
135
        where: whereObj,
2✔
136
      };
2✔
137
    }
2✔
138

139
    try {
3✔
140
      let response = await CLIENT.executeQuery(ADVANCED_TAGS);
3✔
141
      commit("setAdvancedSearchResponse", response["advancedSearch"]);
3✔
142
      if (!response["error"]) {
3✔
143
        commit("setError", false);
2✔
144
        commit("setAdvancedSearchResponse", response["advancedSearch"]);
2✔
145
      }
2✔
146
      else {
1✔
147
        commit("setError", true);
1✔
148
      }
1✔
149
    }
3✔
150
    catch (error) {
3!
151
      /* istanbul ignore next */
×
152
      commit("setError", true);
×
153
    }
×
154
    commit("setLoadingStatus", false);
3✔
155
  },
1✔
156

157
  resetAdvancedSearchResponse({ commit }) {
1✔
158
    commit("resetAdvancedSearch");
1✔
159
  },
1✔
160
};
1✔
161

162
const mutations = {
1✔
163
  setAdvancedSearchText(state, advancedSearchText) {
1✔
164
    state.advancedSearchText = advancedSearchText;
1✔
165
  },
1✔
166
  setAdvancedSearch(state, advancedSearch) {
1✔
167
    state.advancedSearch = advancedSearch;
1✔
168
  },
1✔
169
  setEditAdvancedSearch(state, editAdvancedSearch) {
1✔
170
    state.editAdvancedSearch = editAdvancedSearch;
1✔
171
  },
1✔
172
  setAdvancedSearchResponse(state, advancedSearchResponse) {
1✔
173
    state.advancedSearchResponse = advancedSearchResponse;
1✔
174
  },
1✔
175
  setLoadingStatus(state, loadingStatus) {
1✔
176
    state.loadingStatus = loadingStatus;
1✔
177
  },
1✔
178
  resetAdvancedSearch(state) {
1✔
179
    state.advancedSearch = {};
1✔
180
    state.editAdvancedSearch = {};
1✔
181
    state.advancedSearchQuery = {
1✔
182
      operator: "",
1✔
183
      fields: [],
1✔
184
    };
1✔
185
    state.advancedSearchResponse = [];
1✔
186
  },
1✔
187
  setError(state, errorStatus) {
1✔
188
    state.errorStatus = errorStatus;
1✔
189
  },
1✔
190
  setAdvancedSearchQuery(state, advancedSearchQuery) {
1✔
191
    state.advancedSearchQuery = {
1✔
192
      operator: advancedSearchQuery["operator"],
1✔
193
      fields: advancedSearchQuery["fields"],
1✔
194
    };
1✔
195
  },
1✔
196

197
  setEditDialogStatus(state, editDialogStatus) {
1✔
198
    state.editDialogStatus = editDialogStatus;
1✔
199
  },
1✔
200
  setAdvancedSearchDialogStatus(state, advancedSearchDialogStatus) {
1✔
201
    state.advancedSearchDialogStatus = advancedSearchDialogStatus;
1✔
202
  },
1✔
203
};
1✔
204

205
const getters = {
1✔
206
  getAdvancedSearchText(state) {
1✔
207
    return state.advancedSearchText;
1✔
208
  },
1✔
209
  getAdvancedSearch(state) {
1✔
210
    return state.advancedSearch;
1✔
211
  },
1✔
212
  getEditAdvancedSearch(state) {
1✔
213
    return state.editAdvancedSearch;
1✔
214
  },
1✔
215

216
  getAdvancedSearchResponse(state) {
1✔
217
    return state.advancedSearchResponse;
1✔
218
  },
1✔
219
  getLoadingStatus(state) {
1✔
220
    return state.loadingStatus;
1✔
221
  },
1✔
222
  getErrorStatus(state) {
1✔
223
    return state.errorStatus;
1✔
224
  },
1✔
225
  getAdvancedSearchQuery(state) {
1✔
226
    return state.advancedSearchQuery;
1✔
227
  },
1✔
228
  getEditDialogStatus(state) {
1✔
229
    return state.editDialogStatus;
1✔
230
  },
1✔
231
  getAdvancedSearchDialogStatus(state) {
1✔
232
    return state.advancedSearchDialogStatus;
1✔
233
  },
1✔
234
};
1✔
235
const advancedSearch = {
1✔
236
  namespaced: true,
1✔
237
  state,
1✔
238
  actions,
1✔
239
  mutations,
1✔
240
  getters,
1✔
241
};
1✔
242

243
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