@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user