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

DLR-SC / ESID / 15845945232

24 Jun 2025 08:55AM UTC coverage: 51.517% (+0.5%) from 51.024%
15845945232

Pull #414

github

fifth-island
fix(tests): resolve test failures in CI

This commit fixes a series of cascading test failures that occurred after introducing the semantic search feature.

- Wraps test components in ArticleDataProvider to provide necessary context.

- Removes a duplicate data-testid that caused an ambiguous element error.
Pull Request #414: feat: Implement basic article search feature

418 of 539 branches covered (77.55%)

Branch coverage included in aggregate %.

353 of 582 new or added lines in 15 files covered. (60.65%)

102 existing lines in 6 files now uncovered.

4115 of 8260 relevant lines covered (49.82%)

4.48 hits per line

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

98.23
/src/components/ScenarioComponents/CardsComponents/DataCard.tsx
1
// SPDX-FileCopyrightText: 2024 German Aerospace Center (DLR)
2
// SPDX-License-Identifier: Apache-2.0
3

4
import Box from '@mui/material/Box';
1✔
5
import React, {Dispatch, useEffect, useMemo, useState} from 'react';
1✔
6
import MainCard from './MainCard/MainCard';
1✔
7
import FiltersContainer from './GroupFilter/FiltersContainer';
1✔
8
import {FilterValues} from 'types/card';
9
import {GroupFilter} from 'types/group';
10
import {Localization} from 'types/localization';
11

12
interface DataCardProps {
13
  /** A unique identifier for the card.*/
14
  id: string;
15

16
  /** A dictionary of compartment values associated with the card.*/
17
  compartmentValues: Record<string, number | null> | null;
18

19
  /** A dictionary of start values used for calculating the rate. This determines whether the values have increased, decreased, or remained the same. */
20
  referenceValues: Record<string, number> | null;
21

22
  /** The title of the card.*/
23
  title: string;
24

25
  /** A boolean indicating whether the compartments are expanded.*/
26
  compartmentsExpanded: boolean;
27

28
  /** The compartment that is currently selected.*/
29
  selectedCompartmentId: string | null;
30

31
  /** A boolean indicating whether the scenario is selected.*/
32
  isSelected: boolean;
33

34
  /** The color of the card.*/
35
  color: string;
36

37
  /** if this scenario is active.*/
38
  isActive: boolean;
39

40
  /** A dictionary of filter values. This is an array of objects, each containing a title and a dictionary of numbers representing
41
   * the filtered information to be displayed, it's used a disctionary because each card has to have the same amount of filter. */
42
  filterValues?: Record<string, FilterValues[]> | null;
43

44
  /** A function to set the selected scenario.*/
45
  setSelected: Dispatch<{id: string; state: boolean}>;
46

47
  /** A function to set the active scenario.*/
48
  setActive: Dispatch<{id: string; state: boolean}>;
49

50
  /** A function to notify the parent that this scenario wants to be removed. */
51
  remove: Dispatch<string>;
52

53
  /** The minimum number of compartment rows.*/
54
  minCompartmentsRows: number;
55

56
  /** The maximum number of compartment rows.*/
57
  maxCompartmentsRows: number;
58

59
  /** An object containing localization information (translation & number formattation).*/
60
  localization?: Localization;
61

62
  /** A dictionary of group filters.*/
63
  groupFilters: Record<string, GroupFilter> | undefined;
64

65
  /** Boolean to determine if the arrow is displayed */
66
  arrow?: boolean;
67
}
68

69
/**
70
 * This component renders a card for either the case data or the scenario cards. Each card contains a title, a list of
71
 * compartment values, and change rates relative to the simulation start. Additionally, the component includes a filter container.
72
 * The filter container renders a button and generates the necessary number of cards based on the presence of any filters.
73
 */
74
export default function DataCard({
22✔
75
  id,
22✔
76
  compartmentValues,
22✔
77
  referenceValues,
22✔
78
  title,
22✔
79
  compartmentsExpanded,
22✔
80
  selectedCompartmentId,
22✔
81
  filterValues,
22✔
82
  color,
22✔
83
  isActive,
22✔
84
  isSelected,
22✔
85
  minCompartmentsRows,
22✔
86
  maxCompartmentsRows,
22✔
87
  setSelected,
22✔
88
  setActive,
22✔
89
  remove,
22✔
90
  localization = {
22✔
91
    formatNumber: (value: number) => value.toString(),
22✔
92
    customLang: 'global',
22✔
93
    overrides: {},
22✔
94
  },
22✔
95
  groupFilters,
22✔
96
  arrow = true,
22✔
97
}: DataCardProps) {
22✔
98
  const [hover, setHover] = useState<boolean>(false);
22✔
99
  const [folded, setFolded] = useState<boolean>(false);
22✔
100
  const [visibility, setVisibility] = useState<boolean>(true);
22✔
101

102
  const filteredTitles: string[] = useMemo(() => {
22✔
103
    if (isActive && filterValues?.[id.toString()]) {
13✔
104
      return filterValues[id.toString()].map((filterValue: FilterValues) => filterValue.filteredTitle);
4✔
105
    }
4✔
106
    return [];
9✔
107
  }, [isActive, filterValues, id]);
22✔
108

109
  const filteredValues = useMemo(() => {
22✔
110
    if (isActive && filterValues?.[id.toString()]) {
13✔
111
      return filterValues[id.toString()].map((filterValue: FilterValues) => filterValue.filteredValues);
4✔
112
    }
4✔
113
    return [];
9✔
114
  }, [isActive, filterValues, id]);
22✔
115

116
  /*
117
   * This useEffect hook updates the visibility of the component based on groupFilters and filteredTitles.
118
   * It checks if the first title in filteredTitles matches any filter name in groupFilters and if that filter is visible.
119
   * If at least one matching filter is visible, the component becomes visible; otherwise, it remains hidden.
120
   */
121
  useEffect(() => {
22✔
122
    function checkVisibility(): boolean {
13✔
123
      if (groupFilters) {
13✔
124
        return Object.values(groupFilters)
13✔
125
          .map((filter) => (filter.name == filteredTitles[0] ? filter.isVisible : false))
13✔
126
          .includes(true);
13✔
127
      }
13!
UNCOV
128
      return false;
×
129
    }
13✔
130
    setVisibility(checkVisibility);
13✔
131
  }, [filteredTitles, groupFilters]);
22✔
132

133
  return (
22✔
134
    <Box
22✔
135
      id={`data-card-${id}`}
22✔
136
      sx={{
22✔
137
        display: 'flex',
22✔
138
        flexDirection: 'row',
22✔
139
        alignItems: 'flex-start',
22✔
140
      }}
22✔
141
    >
142
      <MainCard
22✔
143
        id={id}
22✔
144
        label={title}
22✔
145
        hover={hover}
22✔
146
        color={color}
22✔
147
        referenceValues={referenceValues}
22✔
148
        compartmentValues={compartmentValues}
22✔
149
        setHover={setHover}
22✔
150
        compartmentsExpanded={compartmentsExpanded}
22✔
151
        selectedCompartmentId={selectedCompartmentId}
22✔
152
        isSelected={isSelected}
22✔
153
        isActive={isActive}
22✔
154
        setSelected={setSelected}
22✔
155
        setActive={setActive}
22✔
156
        hide={remove}
22✔
157
        minCompartmentsRows={minCompartmentsRows}
22✔
158
        maxCompartmentsRows={maxCompartmentsRows}
22✔
159
        localization={localization}
22✔
160
        arrow={arrow}
22✔
161
      />
22✔
162
      {isActive && filterValues?.[id.toString()] && Object.keys(groupFilters || {}).length !== 0 && visibility && (
22✔
163
        <FiltersContainer
4✔
164
          id={id}
4✔
165
          color={color}
4✔
166
          filteredTitles={filteredTitles}
4✔
167
          folded={folded}
4✔
168
          setFolded={setFolded}
4✔
169
          compartmentsExpanded={compartmentsExpanded}
4✔
170
          selectedCompartmentId={selectedCompartmentId}
4✔
171
          filteredValues={filteredValues}
4✔
172
          minCompartmentsRows={minCompartmentsRows}
4✔
173
          maxCompartmentsRows={maxCompartmentsRows}
4✔
174
          localization={localization}
4✔
175
        />
4✔
176
      )}
177
    </Box>
22✔
178
  );
179
}
22✔
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