Add unit tests for role middleware
Some checks are pending
Docker Test / test (push) Waiting to run

This commit is contained in:
BibaBot 2026-03-17 07:07:36 +00:00
parent 7a9bf3199a
commit c294e2e9ae
5702 changed files with 465039 additions and 34 deletions

22
node_modules/jest-circus/LICENSE generated vendored Normal file
View file

@ -0,0 +1,22 @@
MIT License
Copyright (c) Meta Platforms, Inc. and affiliates.
Copyright Contributors to the Jest project.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

65
node_modules/jest-circus/README.md generated vendored Normal file
View file

@ -0,0 +1,65 @@
[type-definitions]: https://github.com/jestjs/jest/blob/main/packages/jest-types/src/Circus.ts
<h1 align="center">
<img src="https://jestjs.io/img/jest.png" height="150" width="150"/>
<img src="https://jestjs.io/img/circus.png" height="150" width="150"/>
<p align="center">jest-circus</p>
<p align="center">The next-gen test runner for Jest</p>
</h1>
## Overview
Circus is a flux-based test runner for Jest that is fast, maintainable, and simple to extend.
Circus allows you to bind to events via an optional event handler on any [custom environment](https://jestjs.io/docs/configuration#testenvironment-string). See the [type definitions][type-definitions] for more information on the events and state data currently available.
```ts
import type {Event, State} from 'jest-circus';
import {TestEnvironment as NodeEnvironment} from 'jest-environment-node';
class MyCustomEnvironment extends NodeEnvironment {
//...
async handleTestEvent(event: Event, state: State) {
if (event.name === 'test_start') {
// ...
}
}
}
```
Mutating event or state data is currently unsupported and may cause unexpected behavior or break in a future release without warning. New events, event data, and/or state data will not be considered a breaking change and may be added in any minor release.
Note, that `jest-circus` test runner would pause until a promise returned from `handleTestEvent` gets fulfilled. **However, there are a few events that do not conform to this rule, namely**: `start_describe_definition`, `finish_describe_definition`, `add_hook`, `add_test` or `error` (for the up-to-date list you can look at [SyncEvent type in the types definitions][type-definitions]). That is caused by backward compatibility reasons and `process.on('unhandledRejection', callback)` signature, but that usually should not be a problem for most of the use cases.
## Installation
> Note: As of Jest 27, `jest-circus` is the default test runner, so you do not have to install it to use it.
Install `jest-circus` using yarn:
```bash
yarn add --dev jest-circus
```
Or via npm:
```bash
npm install --save-dev jest-circus
```
## Configure
Configure Jest to use `jest-circus` via the [`testRunner`](https://jestjs.io/docs/configuration#testrunner-string) option:
```json
{
"testRunner": "jest-circus/runner"
}
```
Or via CLI:
```bash
jest --testRunner='jest-circus/runner'
```

76
node_modules/jest-circus/build/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,76 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import {Circus, Global as Global_2} from '@jest/types';
export declare const addEventHandler: (handler: Circus.EventHandler) => void;
export declare const afterAll: THook;
export declare const afterEach: THook;
export declare const beforeAll: THook;
export declare const beforeEach: THook;
declare const _default: {
afterAll: THook;
afterEach: THook;
beforeAll: THook;
beforeEach: THook;
describe: {
(blockName: Circus.BlockNameLike, blockFn: Circus.BlockFn): void;
each: Global_2.EachTestFn<any>;
only: {
(blockName: Circus.BlockNameLike, blockFn: Circus.BlockFn): void;
each: Global_2.EachTestFn<any>;
};
skip: {
(blockName: Circus.BlockNameLike, blockFn: Circus.BlockFn): void;
each: Global_2.EachTestFn<any>;
};
};
it: Global_2.It;
test: Global_2.It;
};
export default _default;
export declare const describe: {
(blockName: Circus.BlockNameLike, blockFn: Circus.BlockFn): void;
each: Global_2.EachTestFn<any>;
only: {
(blockName: Circus.BlockNameLike, blockFn: Circus.BlockFn): void;
each: Global_2.EachTestFn<any>;
};
skip: {
(blockName: Circus.BlockNameLike, blockFn: Circus.BlockFn): void;
each: Global_2.EachTestFn<any>;
};
};
declare type Event_2 = Circus.Event;
export {Event_2 as Event};
export declare const getState: () => Circus.State;
export declare const it: Global_2.It;
export declare const removeEventHandler: (handler: Circus.EventHandler) => void;
export declare const resetState: () => void;
export declare const run: () => Promise<Circus.RunResult>;
export declare const setState: (state: Circus.State) => Circus.State;
export declare type State = Circus.State;
export declare const test: Global_2.It;
declare type THook = (fn: Circus.HookFn, timeout?: number) => void;
export {};

1670
node_modules/jest-circus/build/index.js generated vendored Normal file

File diff suppressed because it is too large Load diff

16
node_modules/jest-circus/build/index.mjs generated vendored Normal file
View file

@ -0,0 +1,16 @@
import cjsModule from './index.js';
export const addEventHandler = cjsModule.addEventHandler;
export const afterAll = cjsModule.afterAll;
export const afterEach = cjsModule.afterEach;
export const beforeAll = cjsModule.beforeAll;
export const beforeEach = cjsModule.beforeEach;
export const describe = cjsModule.describe;
export const getState = cjsModule.getState;
export const it = cjsModule.it;
export const removeEventHandler = cjsModule.removeEventHandler;
export const resetState = cjsModule.resetState;
export const run = cjsModule.run;
export const setState = cjsModule.setState;
export const test = cjsModule.test;
export default cjsModule.default;

2049
node_modules/jest-circus/build/jestAdapterInit.js generated vendored Normal file

File diff suppressed because it is too large Load diff

200
node_modules/jest-circus/build/runner.js generated vendored Normal file
View file

@ -0,0 +1,200 @@
/*!
* /**
* * Copyright (c) Meta Platforms, Inc. and affiliates.
* *
* * This source code is licensed under the MIT license found in the
* * LICENSE file in the root directory of this source tree.
* * /
*/
/******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ "./src/legacy-code-todo-rewrite/jestAdapter.ts"
(__unused_webpack_module, exports) {
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports["default"] = void 0;
var _jestUtil = require("jest-util");
var Symbol = globalThis['jest-symbol-do-not-touch'] || globalThis.Symbol;
var Symbol = globalThis['jest-symbol-do-not-touch'] || globalThis.Symbol;
var jestNow = globalThis[Symbol.for('jest-native-now')] || globalThis.Date.now;
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const FRAMEWORK_INITIALIZER = require.resolve('./jestAdapterInit');
const jestAdapter = async (globalConfig, config, environment, runtime, testPath, sendMessageToJest) => {
const {
initialize,
runAndTransformResultsToJestFormat
} = runtime.requireInternalModule(FRAMEWORK_INITIALIZER);
const {
globals,
snapshotState
} = await initialize({
config,
environment,
globalConfig,
localRequire: runtime.requireModule.bind(runtime),
parentProcess: process,
runtime,
sendMessageToJest,
setGlobalsForRuntime: runtime.setGlobalsForRuntime.bind(runtime),
testPath
});
if (config.fakeTimers.enableGlobally) {
if (config.fakeTimers.legacyFakeTimers) {
// during setup, this cannot be null (and it's fine to explode if it is)
environment.fakeTimers.useFakeTimers();
} else {
environment.fakeTimersModern.useFakeTimers();
}
}
globals.beforeEach(() => {
if (config.resetModules) {
runtime.resetModules();
}
if (config.clearMocks) {
runtime.clearAllMocks();
}
if (config.resetMocks) {
runtime.resetAllMocks();
if (config.fakeTimers.enableGlobally && config.fakeTimers.legacyFakeTimers) {
// during setup, this cannot be null (and it's fine to explode if it is)
environment.fakeTimers.useFakeTimers();
}
}
if (config.restoreMocks) {
runtime.restoreAllMocks();
}
});
const setupAfterEnvStart = jestNow();
for (const path of config.setupFilesAfterEnv) {
const esm = runtime.unstable_shouldLoadAsEsm(path);
if (esm) {
await runtime.unstable_importModule(path);
} else {
const setupFile = runtime.requireModule(path);
if (typeof setupFile === 'function') {
await setupFile();
}
}
}
const setupAfterEnvEnd = jestNow();
const esm = runtime.unstable_shouldLoadAsEsm(testPath);
if (esm) {
await runtime.unstable_importModule(testPath);
} else {
runtime.requireModule(testPath);
}
const setupAfterEnvPerfStats = {
setupAfterEnvEnd,
setupAfterEnvStart
};
const results = await runAndTransformResultsToJestFormat({
config,
globalConfig,
setupAfterEnvPerfStats,
testPath
});
_addSnapshotData(results, snapshotState);
// We need to copy the results object to ensure we don't leaks the prototypes
// from the VM. Jasmine creates the result objects in the parent process, we
// should consider doing that for circus as well.
return (0, _jestUtil.deepCyclicCopy)(results, {
keepPrototype: false
});
};
const _addSnapshotData = (results, snapshotState) => {
for (const {
fullName,
status,
failing
} of results.testResults) {
if (status === 'pending' || status === 'failed' || failing && status === 'passed') {
// If test is skipped or failed, we don't want to mark
// its snapshots as obsolete.
// When tests called with test.failing pass, they've thrown an exception,
// so maintain any snapshots after the error.
snapshotState.markSnapshotsAsCheckedForTest(fullName);
}
}
const uncheckedCount = snapshotState.getUncheckedCount();
const uncheckedKeys = snapshotState.getUncheckedKeys();
if (uncheckedCount) {
snapshotState.removeUncheckedKeys();
}
const status = snapshotState.save();
results.snapshot.fileDeleted = status.deleted;
results.snapshot.added = snapshotState.added;
results.snapshot.matched = snapshotState.matched;
results.snapshot.unmatched = snapshotState.unmatched;
results.snapshot.updated = snapshotState.updated;
results.snapshot.unchecked = status.deleted ? 0 : uncheckedCount;
// Copy the array to prevent memory leaks
results.snapshot.uncheckedKeys = [...uncheckedKeys];
};
var _default = exports["default"] = jestAdapter;
/***/ }
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry needs to be wrapped in an IIFE because it uses a non-standard name for the exports (exports).
(() => {
var exports = __webpack_exports__;
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports["default"] = void 0;
var _jestAdapter = _interopRequireDefault(__webpack_require__("./src/legacy-code-todo-rewrite/jestAdapter.ts"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// Allow people to use `jest-circus/runner` as a runner.
var _default = exports["default"] = _jestAdapter.default;
})();
module.exports = __webpack_exports__;
/******/ })()
;

61
node_modules/jest-circus/package.json generated vendored Normal file
View file

@ -0,0 +1,61 @@
{
"name": "jest-circus",
"version": "30.3.0",
"repository": {
"type": "git",
"url": "https://github.com/jestjs/jest.git",
"directory": "packages/jest-circus"
},
"license": "MIT",
"main": "./build/index.js",
"types": "./build/index.d.ts",
"exports": {
".": {
"types": "./build/index.d.ts",
"require": "./build/index.js",
"import": "./build/index.mjs",
"default": "./build/index.js"
},
"./package.json": "./package.json",
"./runner": "./build/runner.js"
},
"dependencies": {
"@jest/environment": "30.3.0",
"@jest/expect": "30.3.0",
"@jest/test-result": "30.3.0",
"@jest/types": "30.3.0",
"@types/node": "*",
"chalk": "^4.1.2",
"co": "^4.6.0",
"dedent": "^1.6.0",
"is-generator-fn": "^2.1.0",
"jest-each": "30.3.0",
"jest-matcher-utils": "30.3.0",
"jest-message-util": "30.3.0",
"jest-runtime": "30.3.0",
"jest-snapshot": "30.3.0",
"jest-util": "30.3.0",
"p-limit": "^3.1.0",
"pretty-format": "30.3.0",
"pure-rand": "^7.0.0",
"slash": "^3.0.0",
"stack-utils": "^2.0.6"
},
"devDependencies": {
"@babel/core": "^7.27.4",
"@babel/register": "^7.27.1",
"@types/co": "^4.6.6",
"@types/graceful-fs": "^4.1.9",
"@types/stack-utils": "^2.0.3",
"execa": "^5.1.1",
"graceful-fs": "^4.2.11",
"tempy": "^1.0.1"
},
"engines": {
"node": "^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0"
},
"publishConfig": {
"access": "public"
},
"gitHead": "efb59c2e81083f8dc941f20d6d20a3af2dc8d068"
}