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

CBIIT / bento-icdc-frontend / 26530955228

27 May 2026 06:34PM UTC coverage: 17.321% (-8.4%) from 25.73%
26530955228

Pull #1607

github

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

306 of 2599 branches covered (11.77%)

Branch coverage included in aggregate %.

1 of 4346 new or added lines in 75 files covered. (0.02%)

2 existing lines in 2 files now uncovered.

2197 of 11852 relevant lines covered (18.54%)

0.41 hits per line

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

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

5
// Mock the GraphiQL CSS import to avoid style-related issues in Jest
NEW
6
jest.mock('graphiql/graphiql.css', () => ({}), { virtual: true });
×
7

8
// Capture the fetcher prop passed to GraphiQL
9
let capturedFetcher;
10

11
// Mock the GraphiQL component and capture the fetcher prop
NEW
12
jest.mock('graphiql', () => {
×
NEW
13
  const ReactActual = jest.requireActual('react');
×
14

NEW
15
  const MockGraphiQL = ({ fetcher }) => {
×
NEW
16
    capturedFetcher = fetcher;
×
NEW
17
    return ReactActual.createElement(
×
18
      'div',
19
      { 'data-testid': 'graphiql-mock' },
20
      'MockGraphiQL'
21
    );
22
  };
23

NEW
24
  MockGraphiQL.displayName = 'MockGraphiQL';
×
25

NEW
26
  return {
×
27
    __esModule: true,
28
    default: MockGraphiQL,
29
  };
30
});
31

32
// Mock @material-ui/styles withStyles HOC to inject deterministic class names
NEW
33
jest.mock('@material-ui/styles', () => {
×
NEW
34
  const ReactActual = jest.requireActual('react');
×
35

NEW
36
  const withStyles = stylesArg => Component => {
×
NEW
37
    const Wrapped = props => {
×
38
      const resolvedStyles =
NEW
39
        typeof stylesArg === 'function' ? stylesArg() : stylesArg || {};
×
NEW
40
      const classes = Object.keys(resolvedStyles).reduce((acc, key) => {
×
NEW
41
        acc[key] = key; // class name equals the style key for easy assertions
×
NEW
42
        return acc;
×
43
      }, {});
NEW
44
      return ReactActual.createElement(Component, { ...props, classes });
×
45
    };
NEW
46
    Wrapped.displayName = `withStyles(${(Component && (Component.displayName || Component.name)) || 'Component'})`;
×
NEW
47
    return Wrapped;
×
48
  };
49

NEW
50
  return {
×
51
    __esModule: true,
52
    withStyles,
53
  };
54
});
55

56
// Mock env to provide a deterministic backend URL
NEW
57
jest.mock('../../utils/env', () => ({
×
58
  __esModule: true,
59
  default: {
60
    REACT_APP_BACKEND_API: 'https://example.test/graphql',
61
  },
62
}));
63

64
import GraphQLView from './GraphQLView';
65

NEW
66
describe('GraphQLView', () => {
×
NEW
67
  beforeEach(() => {
×
NEW
68
    capturedFetcher = undefined;
×
NEW
69
    global.fetch = jest.fn();
×
70
  });
71

NEW
72
  afterEach(() => {
×
NEW
73
    jest.clearAllMocks();
×
NEW
74
    delete global.fetch;
×
75
  });
76

NEW
77
  it('renders the GraphiQL component', () => {
×
NEW
78
    render(<GraphQLView />);
×
79
    // Avoid custom matchers to keep environment-independent
NEW
80
    expect(screen.queryByTestId('graphiql-mock')).not.toBeNull();
×
81
  });
82

NEW
83
  it('applies the grapqhQlContainer class to the container div', () => {
×
NEW
84
    const { container } = render(<GraphQLView />);
×
NEW
85
    expect(container.querySelectorAll('div.grapqhQlContainer')).toHaveLength(1);
×
86
  });
87

NEW
88
  it('calls fetch with correct args and resolves parsed JSON', async () => {
×
NEW
89
    render(<GraphQLView />);
×
NEW
90
    expect(typeof capturedFetcher).toBe('function');
×
91

NEW
92
    const params = { query: '{ hello }', variables: { x: 1 } };
×
NEW
93
    const mockResponse = { data: { hello: 'world' } };
×
94

NEW
95
    global.fetch.mockResolvedValueOnce({
×
96
      json: jest.fn().mockResolvedValueOnce(mockResponse),
97
    });
98

NEW
99
    const result = await capturedFetcher(params);
×
100

NEW
101
    expect(global.fetch).toHaveBeenCalledTimes(1);
×
NEW
102
    expect(global.fetch).toHaveBeenCalledWith('https://example.test/graphql', {
×
103
      method: 'post',
104
      headers: { 'Content-Type': 'application/json' },
105
      body: JSON.stringify(params),
106
    });
NEW
107
    expect(result).toEqual(mockResponse);
×
108
  });
109

NEW
110
  it('rejects when response.json rejects', async () => {
×
NEW
111
    render(<GraphQLView />);
×
NEW
112
    expect(typeof capturedFetcher).toBe('function');
×
113

NEW
114
    const jsonError = new Error('bad json');
×
115

NEW
116
    global.fetch.mockResolvedValueOnce({
×
117
      json: jest.fn().mockRejectedValueOnce(jsonError),
118
    });
119

NEW
120
    await expect(capturedFetcher({ query: '{ broken }' })).rejects.toThrow(
×
121
      'bad json'
122
    );
NEW
123
    expect(global.fetch).toHaveBeenCalledTimes(1);
×
124
  });
125

NEW
126
  it('rejects when fetch rejects', async () => {
×
NEW
127
    render(<GraphQLView />);
×
NEW
128
    expect(typeof capturedFetcher).toBe('function');
×
129

NEW
130
    global.fetch.mockRejectedValueOnce(new Error('network down'));
×
131

NEW
132
    await expect(capturedFetcher({ query: '{ ping }' })).rejects.toThrow(
×
133
      'network down'
134
    );
NEW
135
    expect(global.fetch).toHaveBeenCalledTimes(1);
×
136
  });
137

NEW
138
  it('sends undefined body when graphQLParams is undefined', async () => {
×
NEW
139
    render(<GraphQLView />);
×
NEW
140
    expect(typeof capturedFetcher).toBe('function');
×
141

NEW
142
    const mockResponse = { data: { ok: true } };
×
143

NEW
144
    global.fetch.mockResolvedValueOnce({
×
145
      json: jest.fn().mockResolvedValueOnce(mockResponse),
146
    });
147

NEW
148
    const result = await capturedFetcher(undefined);
×
149

NEW
150
    expect(global.fetch).toHaveBeenCalledWith('https://example.test/graphql', {
×
151
      method: 'post',
152
      headers: { 'Content-Type': 'application/json' },
153
      body: undefined,
154
    });
NEW
155
    expect(result).toEqual(mockResponse);
×
156
  });
157
});
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