mirror of
https://github.com/portainer/portainer.git
synced 2025-08-04 21:35:23 +02:00
chore(deps): upgrade to msw v2 [EE-6489] (#10911)
This commit is contained in:
parent
ecd603db8c
commit
400a80c07d
19 changed files with 2602 additions and 1669 deletions
|
@ -1,76 +1,70 @@
|
|||
import { rest } from 'msw';
|
||||
import { http, HttpResponse } from 'msw';
|
||||
|
||||
export const azureHandlers = [
|
||||
rest.get('/api/endpoints/:endpointId/azure/subscriptions', (req, res, ctx) =>
|
||||
res(
|
||||
ctx.json({
|
||||
value: [
|
||||
http.get('/api/endpoints/:endpointId/azure/subscriptions', () =>
|
||||
HttpResponse.json({
|
||||
value: [
|
||||
{
|
||||
id: '/subscriptions/sub1',
|
||||
authorizationSource: 'RoleBased',
|
||||
subscriptionId: 'sub1',
|
||||
displayName: 'Portainer',
|
||||
state: 'Enabled',
|
||||
},
|
||||
],
|
||||
})
|
||||
),
|
||||
http.get(
|
||||
'/api/endpoints/:endpointId/azure/subscriptions/:subscriptionId/providers/Microsoft.ContainerInstance',
|
||||
({ params }) =>
|
||||
HttpResponse.json({
|
||||
id: `/subscriptions/${params.subscriptionId}/providers/Microsoft.ContainerInstance`,
|
||||
namespace: 'Microsoft.ContainerInstance',
|
||||
resourceTypes: [
|
||||
{
|
||||
id: '/subscriptions/sub1',
|
||||
authorizationSource: 'RoleBased',
|
||||
subscriptionId: 'sub1',
|
||||
displayName: 'Portainer',
|
||||
state: 'Enabled',
|
||||
resourceType: 'containerGroups',
|
||||
locations: [
|
||||
'Australia East',
|
||||
'Australia Southeast',
|
||||
'Brazil South',
|
||||
],
|
||||
},
|
||||
{
|
||||
resourceType: 'serviceAssociationLinks',
|
||||
locations: [
|
||||
'Korea Central',
|
||||
'North Central US',
|
||||
'North Europe',
|
||||
'Norway East',
|
||||
'South Africa North',
|
||||
'South Central US',
|
||||
],
|
||||
},
|
||||
{
|
||||
resourceType: 'locations',
|
||||
locations: [],
|
||||
},
|
||||
],
|
||||
})
|
||||
)
|
||||
),
|
||||
rest.get(
|
||||
'/api/endpoints/:endpointId/azure/subscriptions/:subscriptionId/providers/Microsoft.ContainerInstance',
|
||||
(req, res, ctx) =>
|
||||
res(
|
||||
ctx.json({
|
||||
id: `/subscriptions/${req.params.subscriptionId}/providers/Microsoft.ContainerInstance`,
|
||||
namespace: 'Microsoft.ContainerInstance',
|
||||
resourceTypes: [
|
||||
{
|
||||
resourceType: 'containerGroups',
|
||||
locations: [
|
||||
'Australia East',
|
||||
'Australia Southeast',
|
||||
'Brazil South',
|
||||
],
|
||||
},
|
||||
{
|
||||
resourceType: 'serviceAssociationLinks',
|
||||
locations: [
|
||||
'Korea Central',
|
||||
'North Central US',
|
||||
'North Europe',
|
||||
'Norway East',
|
||||
'South Africa North',
|
||||
'South Central US',
|
||||
],
|
||||
},
|
||||
{
|
||||
resourceType: 'locations',
|
||||
locations: [],
|
||||
},
|
||||
],
|
||||
})
|
||||
)
|
||||
),
|
||||
rest.get(
|
||||
http.get(
|
||||
'/api/endpoints/:endpointId/azure/subscriptions/:subsriptionId/resourcegroups',
|
||||
(res, req, ctx) =>
|
||||
req(
|
||||
ctx.json({
|
||||
value: [
|
||||
{
|
||||
id: `/subscriptions/${res.params.subscriptionId}/resourceGroups/rg1`,
|
||||
name: 'rg1',
|
||||
location: 'southcentralus',
|
||||
properties: { provisioningState: 'Succeeded' },
|
||||
},
|
||||
{
|
||||
id: `/subscriptions/${res.params.subscriptionId}/resourceGroups/rg2`,
|
||||
name: 'rg2',
|
||||
location: 'southcentralus',
|
||||
properties: { provisioningState: 'Succeeded' },
|
||||
},
|
||||
],
|
||||
})
|
||||
)
|
||||
({ params }) =>
|
||||
HttpResponse.json({
|
||||
value: [
|
||||
{
|
||||
id: `/subscriptions/${params.subscriptionId}/resourceGroups/rg1`,
|
||||
name: 'rg1',
|
||||
location: 'southcentralus',
|
||||
properties: { provisioningState: 'Succeeded' },
|
||||
},
|
||||
{
|
||||
id: `/subscriptions/${params.subscriptionId}/resourceGroups/rg2`,
|
||||
name: 'rg2',
|
||||
location: 'southcentralus',
|
||||
properties: { provisioningState: 'Succeeded' },
|
||||
},
|
||||
],
|
||||
})
|
||||
),
|
||||
];
|
||||
|
|
|
@ -1,21 +1,19 @@
|
|||
import { DefaultBodyType, PathParams, rest } from 'msw';
|
||||
import { http, HttpResponse } from 'msw';
|
||||
import { SystemInfo, SystemVersion } from 'docker-types/generated/1.41';
|
||||
|
||||
export const dockerHandlers = [
|
||||
rest.get<DefaultBodyType, PathParams, SystemInfo>(
|
||||
http.get<never, never, SystemInfo>(
|
||||
'/api/endpoints/:endpointId/docker/info',
|
||||
(req, res, ctx) =>
|
||||
res(
|
||||
ctx.json({
|
||||
Plugins: { Authorization: [], Log: [], Network: [], Volume: [] },
|
||||
MemTotal: 0,
|
||||
NCPU: 0,
|
||||
Runtimes: { runc: { path: 'runc' } },
|
||||
})
|
||||
)
|
||||
() =>
|
||||
HttpResponse.json({
|
||||
Plugins: { Authorization: [], Log: [], Network: [], Volume: [] },
|
||||
MemTotal: 0,
|
||||
NCPU: 0,
|
||||
Runtimes: { runc: { path: 'runc' } },
|
||||
})
|
||||
),
|
||||
rest.get<DefaultBodyType, PathParams, SystemVersion>(
|
||||
http.get<never, never, SystemVersion>(
|
||||
'/api/endpoints/:endpointId/docker/version',
|
||||
(req, res, ctx) => res(ctx.json({ ApiVersion: '1.24' }))
|
||||
() => HttpResponse.json({ ApiVersion: '1.24' })
|
||||
),
|
||||
];
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
import { DefaultBodyType, PathParams, rest } from 'msw';
|
||||
import { http, HttpResponse } from 'msw';
|
||||
|
||||
import { TeamMembership } from '@/react/portainer/users/teams/types';
|
||||
import { createMockUsers } from '@/react-tools/test-mocks';
|
||||
|
||||
export const userHandlers = [
|
||||
rest.get('/api/users', async (req, res, ctx) =>
|
||||
res(ctx.json(createMockUsers(10)))
|
||||
),
|
||||
rest.get<DefaultBodyType, PathParams, TeamMembership[]>(
|
||||
http.get('/api/users', async () => HttpResponse.json(createMockUsers(10))),
|
||||
http.get<never, never, TeamMembership[]>(
|
||||
'/api/users/:userId/memberships',
|
||||
(req, res, ctx) => res(ctx.json([]))
|
||||
() => HttpResponse.json([])
|
||||
),
|
||||
];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue