@@ -16,11 +16,10 @@
|
||||
|
||||
import { setupRequestMockHandlers } from '@backstage/backend-test-utils';
|
||||
import { GroupEntity, UserEntity } from '@backstage/catalog-model';
|
||||
import { graphql } from '@octokit/graphql';
|
||||
import { graphql as graphqlOctokit } from '@octokit/graphql';
|
||||
import { graphql as graphqlMsw } from 'msw';
|
||||
import { setupServer } from 'msw/node';
|
||||
import { TeamTransformer, UserTransformer } from './defaultTransformers';
|
||||
|
||||
import {
|
||||
getOrganizationTeams,
|
||||
getOrganizationUsers,
|
||||
@@ -35,11 +34,9 @@ import {
|
||||
} from './github';
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
// Workaround for Node.js 18, where native fetch is available, but not yet picked up by msw
|
||||
// TODO(Rugvip): remove once https://github.com/mswjs/msw/issues/1388 is resolved
|
||||
(global as any).fetch = fetch;
|
||||
|
||||
describe('github', () => {
|
||||
const graphql = graphqlOctokit.defaults({ request: { fetch } });
|
||||
|
||||
const server = setupServer();
|
||||
setupRequestMockHandlers(server);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import { setupRequestMockHandlers } from '@backstage/backend-test-utils';
|
||||
import { readGitLabIntegrationConfig } from '@backstage/integration';
|
||||
import { getVoidLogger } from '@backstage/backend-common';
|
||||
import { graphql, rest } from 'msw';
|
||||
import { setupServer, SetupServerApi } from 'msw/node';
|
||||
import { setupServer, SetupServer } from 'msw/node';
|
||||
import { GitLabClient, paginated } from './client';
|
||||
import { GitLabGroup, GitLabUser } from './types';
|
||||
|
||||
@@ -37,7 +37,7 @@ const MOCK_CONFIG = readGitLabIntegrationConfig(
|
||||
const FAKE_PAGED_ENDPOINT = `/some-endpoint`;
|
||||
const FAKE_PAGED_URL = `${MOCK_CONFIG.apiBaseUrl}${FAKE_PAGED_ENDPOINT}`;
|
||||
|
||||
function setupFakeFourPageURL(srv: SetupServerApi, url: string) {
|
||||
function setupFakeFourPageURL(srv: SetupServer, url: string) {
|
||||
srv.use(
|
||||
rest.get(url, (req, res, ctx) => {
|
||||
const page = req.url.searchParams.get('page');
|
||||
@@ -57,7 +57,7 @@ function setupFakeFourPageURL(srv: SetupServerApi, url: string) {
|
||||
}
|
||||
|
||||
function setupFakeGroupProjectsEndpoint(
|
||||
srv: SetupServerApi,
|
||||
srv: SetupServer,
|
||||
apiBaseUrl: string,
|
||||
groupID: string,
|
||||
) {
|
||||
@@ -79,7 +79,7 @@ function setupFakeGroupProjectsEndpoint(
|
||||
}
|
||||
|
||||
function setupFakeInstanceProjectsEndpoint(
|
||||
srv: SetupServerApi,
|
||||
srv: SetupServer,
|
||||
apiBaseUrl: string,
|
||||
) {
|
||||
srv.use(
|
||||
@@ -105,7 +105,7 @@ function setupFakeInstanceProjectsEndpoint(
|
||||
);
|
||||
}
|
||||
|
||||
function setupFakeHasFileEndpoint(srv: SetupServerApi, apiBaseUrl: string) {
|
||||
function setupFakeHasFileEndpoint(srv: SetupServer, apiBaseUrl: string) {
|
||||
srv.use(
|
||||
rest.head(
|
||||
`${apiBaseUrl}/projects/group%2Frepo/repository/files/catalog-info.yaml`,
|
||||
|
||||
@@ -18,7 +18,7 @@ import { AddressInfo } from 'net';
|
||||
import { Server } from 'http';
|
||||
import express, { Router, RequestHandler } from 'express';
|
||||
import { RestContext, rest } from 'msw';
|
||||
import { setupServer, SetupServerApi } from 'msw/node';
|
||||
import { setupServer, SetupServer } from 'msw/node';
|
||||
import { PluginEndpointDiscovery } from '@backstage/backend-common';
|
||||
import {
|
||||
AuthorizeResult,
|
||||
@@ -34,7 +34,7 @@ import { z } from 'zod';
|
||||
|
||||
describe('PermissionIntegrationClient', () => {
|
||||
describe('applyConditions', () => {
|
||||
let server: SetupServerApi;
|
||||
let server: SetupServer;
|
||||
|
||||
const mockConditions: PermissionCriteria<PermissionCondition> = {
|
||||
not: {
|
||||
|
||||
@@ -30498,8 +30498,8 @@ __metadata:
|
||||
linkType: hard
|
||||
|
||||
"msw@npm:^1.0.0, msw@npm:^1.0.1":
|
||||
version: 1.0.1
|
||||
resolution: "msw@npm:1.0.1"
|
||||
version: 1.2.0
|
||||
resolution: "msw@npm:1.2.0"
|
||||
dependencies:
|
||||
"@mswjs/cookies": ^0.2.2
|
||||
"@mswjs/interceptors": ^0.17.5
|
||||
@@ -30521,13 +30521,13 @@ __metadata:
|
||||
type-fest: ^2.19.0
|
||||
yargs: ^17.3.1
|
||||
peerDependencies:
|
||||
typescript: ">= 4.4.x <= 4.9.x"
|
||||
typescript: ">= 4.4.x <= 5.0.x"
|
||||
peerDependenciesMeta:
|
||||
typescript:
|
||||
optional: true
|
||||
bin:
|
||||
msw: cli/index.js
|
||||
checksum: e5d6cbe67067ca46f42aaa33011f53a4e5a873abcf81c52a6996536b3c41a88f522821d3a4cf589658252581506afddb58fd8c3dfd79a5cbf06e26e14f9570b6
|
||||
checksum: 2cea7fe0f2ebb59b11534896cbaa91dca65f4fb2272402549079cc4190847fc42f5367f331c552d576d59a3521f498da0384d53cf4960beaebd6165bbc44593b
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
||||
Reference in New Issue
Block a user