enhance(backend): テストの高速化 (#12939)

* enhance(backend): テストの高速化

* add ls

* 自動的にマージされるようなので不要

* 起動方法を揃える

* fix test
This commit is contained in:
おさむのひと 2024-01-08 17:43:52 +09:00 committed by GitHub
parent 618e2ba1d2
commit 35ec41fc1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 563 additions and 283 deletions

View file

@ -11,13 +11,18 @@
process.env.NODE_ENV = 'test';
import * as assert from 'assert';
import { AuthorizationCode, ResourceOwnerPassword, type AuthorizationTokenConfig, ClientCredentials, ModuleOptions } from 'simple-oauth2';
import {
AuthorizationCode,
type AuthorizationTokenConfig,
ClientCredentials,
ModuleOptions,
ResourceOwnerPassword,
} from 'simple-oauth2';
import pkceChallenge from 'pkce-challenge';
import { JSDOM } from 'jsdom';
import Fastify, { type FastifyReply, type FastifyInstance } from 'fastify';
import { api, port, signup, startServer } from '../utils.js';
import Fastify, { type FastifyInstance, type FastifyReply } from 'fastify';
import { api, port, sendEnvUpdateRequest, signup } from '../utils.js';
import type * as misskey from 'misskey-js';
import type { INestApplicationContext } from '@nestjs/common';
const host = `http://127.0.0.1:${port}`;
@ -147,7 +152,6 @@ async function assertDirectError(response: Response, status: number, error: stri
}
describe('OAuth', () => {
let app: INestApplicationContext;
let fastify: FastifyInstance;
let alice: misskey.entities.SignupResponse;
@ -156,7 +160,6 @@ describe('OAuth', () => {
let sender: (reply: FastifyReply) => void;
beforeAll(async () => {
app = await startServer();
alice = await signup({ username: 'alice' });
bob = await signup({ username: 'bob' });
@ -168,7 +171,7 @@ describe('OAuth', () => {
}, 1000 * 60 * 2);
beforeEach(async () => {
process.env.MISSKEY_TEST_CHECK_IP_RANGE = '';
await sendEnvUpdateRequest({ key: 'MISSKEY_TEST_CHECK_IP_RANGE', value: '' });
sender = (reply): void => {
reply.send(`
<!DOCTYPE html>
@ -180,7 +183,6 @@ describe('OAuth', () => {
afterAll(async () => {
await fastify.close();
await app.close();
});
test('Full flow', async () => {
@ -881,7 +883,7 @@ describe('OAuth', () => {
});
test('Disallow loopback', async () => {
process.env.MISSKEY_TEST_CHECK_IP_RANGE = '1';
await sendEnvUpdateRequest({ key: 'MISSKEY_TEST_CHECK_IP_RANGE', value: '1' });
const client = new AuthorizationCode(clientConfig);
const response = await fetch(client.authorizeURL({