All files / app/assets/javascripts/reports/accessibility_report/store getters.js

100% Statements 24/24
100% Branches 16/16
100% Functions 7/7
100% Lines 20/20

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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      4x 16x 2x     14x 2x     12x 12x 8x     4x             4x 12x 2x     10x 3x     7x     4x 12x         4x 4x 4x  
import { s__, n__ } from '~/locale';
import { LOADING, ERROR, SUCCESS, STATUS_FAILED } from '../../constants';
 
export const groupedSummaryText = (state) => {
  if (state.isLoading) {
    return s__('Reports|Accessibility scanning results are being parsed');
  }
 
  if (state.hasError) {
    return s__('Reports|Accessibility scanning failed loading results');
  }
 
  const numberOfResults = state.report?.summary?.errored || 0;
  if (numberOfResults === 0) {
    return s__('Reports|Accessibility scanning detected no issues for the source branch only');
  }
 
  return n__(
    'Reports|Accessibility scanning detected %d issue for the source branch only',
    'Reports|Accessibility scanning detected %d issues for the source branch only',
    numberOfResults,
  );
};
 
export const summaryStatus = (state) => {
  if (state.isLoading) {
    return LOADING;
  }
 
  if (state.hasError || state.status === STATUS_FAILED) {
    return ERROR;
  }
 
  return SUCCESS;
};
 
export const shouldRenderIssuesList = (state) =>
  Object.values(state.report).some((x) => Array.isArray(x) && x.length > 0);
 
// We could just map state, but we're going to iterate in the future
// to add notes and warnings to these issue lists, so I'm going to
// keep these as getters
export const unresolvedIssues = (state) => state.report.existing_errors;
export const resolvedIssues = (state) => state.report.resolved_errors;
export const newIssues = (state) => state.report.new_errors;