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

stacklok / codegate-ui / 13808282424

12 Mar 2025 09:43AM UTC coverage: 66.452% (+0.1%) from 66.347%
13808282424

Pull #379

github

web-flow
Merge d1ad42c49 into 0fb0ba74f
Pull Request #379: feat: shareable workspaces MVP (frontend)

428 of 707 branches covered (60.54%)

Branch coverage included in aggregate %.

36 of 72 new or added lines in 14 files covered. (50.0%)

1 existing line in 1 file now uncovered.

913 of 1311 relevant lines covered (69.64%)

40.19 hits per line

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

75.0
/src/mocks/msw/handlers.ts
1
import { http, HttpResponse } from 'msw'
2
import mockedAlerts from '@/mocks/msw/fixtures/GET_ALERTS.json'
3
import mockedWorkspaces from '@/mocks/msw/fixtures/GET_WORKSPACES.json'
4
import mockedProviders from '@/mocks/msw/fixtures/GET_PROVIDERS.json'
5
import mockedProvidersModels from '@/mocks/msw/fixtures/GET_PROVIDERS_MODELS.json'
6
import { AlertSummary, ProviderType } from '@/api/generated'
7
import { mswEndpoint } from '@/test/msw-endpoint'
8
import { buildFilterablePaginatedMessagesHandler } from './mockers/paginated-messages-response.mock'
9

10
export const handlers = [
33✔
11
  http.get(mswEndpoint('/health'), () =>
12
    HttpResponse.json({
3✔
13
      current_version: 'foo',
14
      latest_version: 'bar',
15
      is_latest: false,
16
      error: null,
17
    })
18
  ),
19
  http.get(mswEndpoint('/api/v1/version'), () =>
20
    HttpResponse.json({ status: 'healthy' })
6✔
21
  ),
22
  http.get(mswEndpoint('/api/v1/workspaces/active'), () =>
23
    HttpResponse.json({
90✔
24
      workspaces: [
25
        {
26
          name: 'my-awesome-workspace',
27
          is_active: true,
28
          last_updated: new Date(Date.now()).toISOString(),
29
        },
30
      ],
31
    })
32
  ),
33
  http.get(
34
    mswEndpoint('/api/v1/workspaces/:workspace_name/messages'),
35
    buildFilterablePaginatedMessagesHandler()
36
  ),
37
  http.get(mswEndpoint('/api/v1/workspaces/:workspace_name/alerts'), () => {
38
    return HttpResponse.json(mockedAlerts)
×
39
  }),
40
  http.get(
41
    mswEndpoint('/api/v1/workspaces/:workspace_name/alerts-summary'),
42
    () => {
43
      const response: AlertSummary = {
18✔
44
        malicious_packages: 13,
45
        pii: 9,
46
        secrets: 10,
47
        total_alerts: 32,
48
      }
49
      return HttpResponse.json(response)
18✔
50
    }
51
  ),
52
  http.get(mswEndpoint('/api/v1/workspaces'), () => {
53
    return HttpResponse.json(mockedWorkspaces)
36✔
54
  }),
55
  http.get(mswEndpoint('/api/v1/workspaces/archive'), () => {
56
    return HttpResponse.json({
45✔
57
      workspaces: [
58
        {
59
          name: 'archived_workspace',
60
          is_active: false,
61
        },
62
      ],
63
    })
64
  }),
65
  http.post(mswEndpoint('/api/v1/workspaces'), () => {
66
    return HttpResponse.json(mockedWorkspaces)
2✔
67
  }),
68
  http.post(
69
    mswEndpoint('/api/v1/workspaces/active'),
70
    () => new HttpResponse(null, { status: 204 })
3✔
71
  ),
72
  http.put(mswEndpoint('/api/v1/workspaces/:workspace_name'), () =>
73
    HttpResponse.json(
2✔
74
      {
75
        name: 'foo',
76
        config: {
77
          custom_instructions: '',
78
          muxing_rules: [],
79
        },
80
      },
81
      { status: 201 }
82
    )
83
  ),
84
  http.get(mswEndpoint('/api/v1/workspaces/:workspace_name'), () =>
85
    HttpResponse.json({
9✔
86
      name: 'foo',
87
      config: {
88
        custom_instructions: '',
89
        muxing_rules: [],
90
      },
91
    })
92
  ),
93
  http.post(
94
    mswEndpoint('/api/v1/workspaces/archive/:workspace_name/recover'),
95
    () => new HttpResponse(null, { status: 204 })
2✔
96
  ),
97
  http.delete(
98
    mswEndpoint('/api/v1/workspaces/:workspace_name'),
99
    () => new HttpResponse(null, { status: 204 })
2✔
100
  ),
101
  http.delete(
102
    mswEndpoint('/api/v1/workspaces/archive/:workspace_name'),
103
    () => new HttpResponse(null, { status: 204 })
2✔
104
  ),
105
  http.get(
106
    mswEndpoint('/api/v1/workspaces/:workspace_name/custom-instructions'),
107
    () => {
108
      return HttpResponse.json({ prompt: 'foo' })
9✔
109
    }
110
  ),
111
  http.get(
112
    mswEndpoint('/api/v1/workspaces/:workspace_name/token-usage'),
113
    () => {
114
      return HttpResponse.json({
12✔
115
        tokens_by_model: {
116
          'claude-3-5-sonnet-latest': {
117
            provider_type: ProviderType.ANTHROPIC,
118
            model: 'claude-3-5-sonnet-latest',
119
            token_usage: {
120
              input_tokens: 1183,
121
              output_tokens: 433,
122
              input_cost: 0.003549,
123
              output_cost: 0.006495,
124
            },
125
          },
126
        },
127
        token_usage: {
128
          input_tokens: 1183,
129
          output_tokens: 433,
130
          input_cost: 0.003549,
131
          output_cost: 0.006495,
132
        },
133
      })
134
    }
135
  ),
136
  http.put(
137
    mswEndpoint('/api/v1/workspaces/:workspace_name/custom-instructions'),
138
    () => new HttpResponse(null, { status: 204 })
1✔
139
  ),
140
  http.get(mswEndpoint('/api/v1/workspaces/:workspace_name/muxes'), () =>
141
    HttpResponse.json([])
13✔
142
  ),
143
  http.put(
144
    mswEndpoint('/api/v1/workspaces/:workspace_name/muxes'),
145
    () => new HttpResponse(null, { status: 204 })
1✔
146
  ),
147
  http.get(
148
    mswEndpoint('/api/v1/provider-endpoints/:provider_name/models'),
NEW
149
    () => HttpResponse.json(mockedProvidersModels)
×
150
  ),
151
  http.get(mswEndpoint('/api/v1/provider-endpoints/models'), () =>
152
    HttpResponse.json(mockedProvidersModels)
12✔
153
  ),
154
  http.get(mswEndpoint('/api/v1/provider-endpoints/:provider_name'), () =>
155
    HttpResponse.json(mockedProviders[0])
×
156
  ),
157
  http.get(mswEndpoint('/api/v1/provider-endpoints'), () =>
158
    HttpResponse.json(mockedProviders)
×
159
  ),
160
  http.post(
161
    mswEndpoint('/api/v1/provider-endpoints'),
162
    () => new HttpResponse(null, { status: 204 })
×
163
  ),
164
  http.put(
165
    mswEndpoint('/api/v1/provider-endpoints'),
166
    () => new HttpResponse(null, { status: 204 })
×
167
  ),
168
  http.delete(
169
    mswEndpoint('/api/v1/provider-endpoints'),
170
    () => new HttpResponse(null, { status: 204 })
×
171
  ),
172
]
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

© 2025 Coveralls, Inc