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

CBIIT / bento-icdc-frontend / 26521483403

27 May 2026 03:36PM UTC coverage: 17.458% (-8.3%) from 25.73%
26521483403

Pull #1607

github

web-flow
Merge 2f30510ff into bc935f39c
Pull Request #1607: Feature/ai test studio - ICDC-4165 & ICDC-4171

306 of 2587 branches covered (11.83%)

Branch coverage included in aggregate %.

1 of 4244 new or added lines in 74 files covered. (0.02%)

2 existing lines in 2 files now uncovered.

2197 of 11750 relevant lines covered (18.7%)

0.41 hits per line

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

0.0
/src/components/DocumentDownload/DocumentDownloadView.generated.test.jsx
1
import React from 'react';
2
import { fireEvent, render, screen, act } from '@testing-library/react';
3
import DocumentDownloadView from './DocumentDownloadView';
4

NEW
5
jest.mock('react-router-dom', () => ({
×
6
  __esModule: true,
7
  Link: ({ children, to, onClick, ...rest }) => {
NEW
8
    const href = typeof to === 'string' ? to : to?.pathname || '#';
×
NEW
9
    return (
×
10
      <a href={href} onClick={onClick} {...rest}>
11
        {children}
12
      </a>
13
    );
14
  },
15
}));
16

NEW
17
jest.mock(
×
18
  '../../assets/icons/JbrowseViewIcon.svg',
NEW
19
  () => 'mock-jbrowse-logo.svg'
×
20
);
21

NEW
22
jest.mock('../../utils/env', () => ({
×
23
  __esModule: true,
24
  default: {
25
    REACT_APP_FILE_SERVICE_API: 'https://files.example.com/',
26
  },
27
}));
28

NEW
29
jest.mock('../../bento-core', () => ({
×
30
  __esModule: true,
31
  ToolTip: ({ title, children }) => (
NEW
32
    <span data-testid="tooltip" data-title={title}>
×
33
      {children}
34
    </span>
35
  ),
36
}));
37

NEW
38
jest.mock('../CustomIcon', () => ({
×
39
  __esModule: true,
40
  default: ({ imgSrc }) => (
NEW
41
    <img
×
42
      data-testid="custom-icon"
43
      alt="custom-icon"
44
      src={imgSrc}
45
      data-src={imgSrc}
46
    />
47
  ),
48
}));
49

NEW
50
jest.mock('../../bento/JBrowseData', () => ({
×
51
  __esModule: true,
52
  jBrowseOptions: { jBrowse: true },
53
  JbrowserFiles: ['bam', 'bai', 'vcf', 'tbi'],
54
  SINGLE_FILE_VIEW: 'single',
55
}));
56

NEW
57
const mockSetSelectedFiles = jest.fn(files => files);
×
NEW
58
const mockSetJBrowseSelectedFiles = jest.fn();
×
59

NEW
60
jest.mock('../../pages/JbrowseDetail/util', () => ({
×
61
  __esModule: true,
NEW
62
  setSelectedFiles: (...args) => mockSetSelectedFiles(...args),
×
63
}));
64

NEW
65
jest.mock('../../pages/JbrowseDetail/store/jborwse.reducer', () => ({
×
66
  __esModule: true,
NEW
67
  setJborwseSelectedFiles: (...args) => mockSetJBrowseSelectedFiles(...args),
×
68
}));
69

NEW
70
describe('DocumentDownloadView', () => {
×
NEW
71
  beforeEach(() => {
×
NEW
72
    jest.clearAllMocks();
×
NEW
73
    global.fetch = jest.fn();
×
74
  });
75

NEW
76
  afterEach(() => {
×
NEW
77
    jest.restoreAllMocks();
×
78
  });
79

NEW
80
  it('renders the JBrowse link and updates selected files when supported file format is used', () => {
×
NEW
81
    render(
×
82
      <DocumentDownloadView
83
        fileFormat="bam"
84
        caseId="CASE-123"
85
        toolTipTextFileViewer="View in JBrowse"
86
      />
87
    );
88

NEW
89
    const link = screen.getByRole('link');
×
NEW
90
    expect(link).toBeTruthy();
×
NEW
91
    expect(link.getAttribute('target')).toBe('_blank');
×
NEW
92
    expect(link.getAttribute('rel')).toBe('noreferrer');
×
NEW
93
    expect(link.getAttribute('href')).toBe('/jBrowse/single');
×
94

NEW
95
    const logoImg = screen.getByAltText('jBrowse');
×
NEW
96
    expect(logoImg).toBeTruthy();
×
NEW
97
    expect(logoImg.getAttribute('src')).toBe('mock-jbrowse-logo.svg');
×
98

NEW
99
    const tooltip = screen.getByTestId('tooltip');
×
NEW
100
    expect(tooltip.getAttribute('data-title')).toBe('View in JBrowse');
×
101

NEW
102
    fireEvent.click(link);
×
103

NEW
104
    expect(mockSetSelectedFiles).toHaveBeenCalledTimes(1);
×
NEW
105
    expect(mockSetSelectedFiles).toHaveBeenCalledWith(['CASE-123']);
×
NEW
106
    expect(mockSetJBrowseSelectedFiles).toHaveBeenCalledTimes(1);
×
NEW
107
    expect(mockSetJBrowseSelectedFiles).toHaveBeenCalledWith(['CASE-123']);
×
108
  });
109

NEW
110
  it('renders download icon and fetches the file when file size is under max size', async () => {
×
NEW
111
    global.fetch = jest.fn().mockResolvedValue({
×
112
      text: jest
113
        .fn()
114
        .mockResolvedValue('https://files.example.com/downloads/file.pdf'),
115
    });
116

NEW
117
    render(
×
118
      <DocumentDownloadView
119
        fileSize={100}
120
        maxFileSize={2000}
121
        fileLocation="files/abc-123"
122
        iconFileDownload="download-icon.png"
123
        toolTipTextFileDownload="Download a copy of this file"
124
      />
125
    );
126

NEW
127
    const icon = screen.getByTestId('custom-icon');
×
NEW
128
    expect(icon).toBeTruthy();
×
NEW
129
    expect(icon.getAttribute('data-src')).toBe('download-icon.png');
×
130

NEW
131
    const tooltip = screen.getByTestId('tooltip');
×
NEW
132
    expect(tooltip.getAttribute('data-title')).toBe(
×
133
      'Download a copy of this file'
134
    );
135

NEW
136
    await act(async () => {
×
NEW
137
      fireEvent.click(icon.parentElement);
×
NEW
138
      await Promise.resolve();
×
139
    });
140

NEW
141
    expect(global.fetch).toHaveBeenCalledTimes(1);
×
NEW
142
    expect(global.fetch).toHaveBeenCalledWith(
×
143
      'https://files.example.com/files/abc-123',
144
      {
145
        method: 'GET',
146
        headers: { 'Content-Type': 'application/pdf' },
147
      }
148
    );
149
  });
150

NEW
151
  it('renders preview icon and tooltip when file is too large for download', () => {
×
NEW
152
    render(
×
153
      <DocumentDownloadView
154
        fileSize={5000}
155
        maxFileSize={2000}
156
        iconFilePreview="preview-icon.png"
157
        toolTipTextFilePreview="Unavailable for download; use My Files"
158
      />
159
    );
160

NEW
161
    const icon = screen.getByTestId('custom-icon');
×
NEW
162
    expect(icon).toBeTruthy();
×
NEW
163
    expect(icon.getAttribute('data-src')).toBe('preview-icon.png');
×
164

NEW
165
    const tooltip = screen.getByTestId('tooltip');
×
NEW
166
    expect(tooltip.getAttribute('data-title')).toBe(
×
167
      'Unavailable for download; use My Files'
168
    );
169

NEW
170
    expect(screen.queryByRole('link')).toBeNull();
×
171
  });
172

NEW
173
  it('uses the download branch by default when format is unsupported and size is within download range', () => {
×
NEW
174
    render(<DocumentDownloadView iconFileDownload="dl.png" />);
×
175

NEW
176
    const icon = screen.getByTestId('custom-icon');
×
NEW
177
    expect(icon).toBeTruthy();
×
NEW
178
    expect(icon.getAttribute('data-src')).toBe('dl.png');
×
179
  });
180
});
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