Welcome to mirror list, hosted at ThFree Co, Russian Federation.

mutations.js « store « grouped_test_report « reports « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2b88776815bd2e074f36aff49ba6ae95de1e69d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import * as types from './mutation_types';
import { countRecentlyFailedTests, formatFilePath } from './utils';

export default {
  [types.SET_PATHS](state, { endpoint, headBlobPath }) {
    state.endpoint = endpoint;
    state.headBlobPath = headBlobPath;
  },
  [types.REQUEST_REPORTS](state) {
    state.isLoading = true;
  },
  [types.RECEIVE_REPORTS_SUCCESS](state, response) {
    state.hasError = response.suites.some((suite) => suite.status === 'error');

    state.isLoading = false;

    state.summary.total = response.summary.total;
    state.summary.resolved = response.summary.resolved;
    state.summary.failed = response.summary.failed;
    state.summary.errored = response.summary.errored;
    state.summary.recentlyFailed = countRecentlyFailedTests(response.suites);

    state.status = response.status;
    state.reports = response.suites;

    state.reports.forEach((report, i) => {
      if (!state.reports[i].summary) return;
      state.reports[i].summary.recentlyFailed = countRecentlyFailedTests(report);
    });
  },
  [types.RECEIVE_REPORTS_ERROR](state) {
    state.isLoading = false;
    state.hasError = true;

    state.reports = [];
    state.summary = {
      total: 0,
      resolved: 0,
      failed: 0,
      errored: 0,
      recentlyFailed: 0,
    };
    state.status = null;
  },
  [types.SET_ISSUE_MODAL_DATA](state, payload) {
    const { issue } = payload;
    state.modal.title = issue.name;

    Object.keys(issue).forEach((key) => {
      if (Object.prototype.hasOwnProperty.call(state.modal.data, key)) {
        state.modal.data[key] = {
          ...state.modal.data[key],
          value: issue[key],
        };
      }
    });

    if (issue.file) {
      state.modal.data.filename.value = {
        text: issue.file,
        path: `${state.headBlobPath}/${formatFilePath(issue.file)}`,
      };
    }

    state.modal.open = true;
  },
  [types.RESET_ISSUE_MODAL_DATA](state) {
    state.modal.open = false;

    // Resetting modal data
    state.modal.title = null;
    Object.keys(state.modal.data).forEach((key) => {
      state.modal.data[key] = {
        ...state.modal.data[key],
        value: null,
      };
    });
  },
};