Skip to content

Commit

Permalink
fix: server test
Browse files Browse the repository at this point in the history
  • Loading branch information
OpportunityLiu committed Jun 20, 2022
1 parent fc08466 commit 2c6bfad
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 34 deletions.
1 change: 1 addition & 0 deletions angular.webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-check
import ResolveTypeScriptPlugin from 'resolve-typescript-plugin';

/**
Expand Down
1 change: 1 addition & 0 deletions scripts/info.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-check
import fs from 'fs-extra';
import { exportVariable } from '@actions/core';

Expand Down
1 change: 1 addition & 0 deletions scripts/server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-check
import fs from 'fs-extra';

const removedPackages = ['lazysizes', 'zone.js'];
Expand Down
5 changes: 3 additions & 2 deletions scripts/tool.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-check
import fs from 'fs-extra';

const removedPackages = ['lazysizes', 'zone.js'];
Expand All @@ -18,10 +19,10 @@ for (const key in packageJson.imports) {
packageJson.imports[key] = value.replace(/^.\/dist\//, './');
}
}
for (const key in packageJson.exports) {
for (const key in /** @type {object} */ (packageJson.exports)) {
const value = packageJson.exports[key];
if (typeof value == 'string') {
packageJson.imports[key] = value.replace(/^.\/dist\//, './');
packageJson.exports[key] = value.replace(/^.\/dist\//, './');
}
}
await fs.writeJSON('./dist/package.json', packageJson);
Expand Down
2 changes: 1 addition & 1 deletion src/server/database/database-badge.controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Controller, Get, Param } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { InjectableBase } from '../injectable-base.js';
import { NamespaceName } from '#shared/interfaces/ehtag.js';
import { NamespaceName } from '#shared/interfaces/ehtag';
import { DatabaseService } from './database.service.js';
import { NsParams } from './params.dto.js';
import { Badge } from './database-badge.dto.js';
Expand Down
4 changes: 2 additions & 2 deletions src/server/database/database.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import {
ApiConflictResponse,
ApiExcludeEndpoint,
} from '@nestjs/swagger';
import type { TagType } from '#shared/interfaces/ehtag.js';
import { Context } from '#shared/markdown/index.js';
import type { TagType } from '#shared/interfaces/ehtag';
import { Context } from '#shared/markdown/index';
import { InjectableBase } from '../injectable-base.js';
import { ApiIfMatchHeader, ApiIfNoneMatchHeader } from '../decorators/swagger.decoretor.js';
import { EtagInterceptor } from '../app/etag.interceptor.js';
Expand Down
10 changes: 5 additions & 5 deletions src/server/database/database.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import type { Octokit } from '@octokit/rest';
import type { AsyncReturnType } from 'type-fest';
import fs from 'fs-extra';
import path from 'path';
import { Database } from '#shared/database.js';
import { Sha1Value, NamespaceName, Commit } from '#shared/interfaces/ehtag.js';
import type { TagRecord } from '#shared/tag-record.js';
import type { RawTag } from '#shared/raw-tag.js';
import { Context } from '#shared/markdown/index.js';
import { Database } from '#shared/database';
import { Sha1Value, NamespaceName, Commit } from '#shared/interfaces/ehtag';
import type { TagRecord } from '#shared/tag-record';
import type { RawTag } from '#shared/raw-tag';
import { Context } from '#shared/markdown/index';
import { InjectableBase } from '../injectable-base.js';
import { OctokitService, UserInfo } from '../octokit/octokit.service.js';

Expand Down
4 changes: 2 additions & 2 deletions src/server/database/params.dto.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsIn, IsOptional } from 'class-validator';
import { NamespaceName, Sha1Value } from '#shared/interfaces/ehtag.js';
import { IsRawTag, RawTag } from '#shared/raw-tag.js';
import { NamespaceName, Sha1Value } from '#shared/interfaces/ehtag';
import { IsRawTag, RawTag } from '#shared/raw-tag';
export class NsParams {
@ApiProperty({
description: '命名空间名称',
Expand Down
2 changes: 1 addition & 1 deletion src/server/decorators/format.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createParamDecorator, ExecutionContext, BadRequestException, Header } f
import type { FastifyRequest } from 'fastify';
import { ApiQuery, ApiProduces } from '@nestjs/swagger';
import { __decorate } from 'tslib';
import type { TagType } from '#shared/interfaces/ehtag.js';
import type { TagType } from '#shared/interfaces/ehtag';

function getFromQuery(format: string): TagType {
format = format.trim().toLowerCase();
Expand Down
2 changes: 1 addition & 1 deletion src/server/dtos/repo-info.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
RepoData,
NamespaceData,
Tag,
} from '#shared/interfaces/ehtag.js';
} from '#shared/interfaces/ehtag';

export class SignatureDto implements Signature {
name!: string;
Expand Down
2 changes: 1 addition & 1 deletion src/server/octokit/octokit.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { OctokitOptions } from '@octokit/core/dist-types/types';
import { createAppAuth, StrategyOptions } from '@octokit/auth-app';
import { createOAuthAppAuth } from '@octokit/auth-oauth-app';
import { InjectableBase } from '../injectable-base.js';
import type { Sha1Value, Commit, Signature } from '#shared/interfaces/ehtag.js';
import type { Sha1Value, Commit, Signature } from '#shared/interfaces/ehtag';

export type AppInfo = NonNullable<Readonly<AsyncReturnType<Octokit['apps']['getAuthenticated']>['data']>>;
export type UserInfo = Readonly<AsyncReturnType<Octokit['users']['getByUsername']>['data']>;
Expand Down
8 changes: 4 additions & 4 deletions src/server/tools/tools.controller.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Controller, Post, Body, HttpCode, HttpStatus, Param, BadRequestException } from '@nestjs/common';
import { TagResponseDto, LooseTagDto } from '../dtos/repo-info.dto.js';
import { Format } from '../decorators/format.decorator.js';
import type { TagType } from '#shared/interfaces/ehtag.js';
import { TagRecord } from '#shared/tag-record.js';
import type { TagType } from '#shared/interfaces/ehtag';
import { TagRecord } from '#shared/tag-record';
import { InjectableBase } from '../injectable-base.js';
import { DatabaseService } from '../database/database.service.js';
import { RawTag } from '#shared/raw-tag.js';
import { RawTag } from '#shared/raw-tag';
import { ApiOperation, ApiConsumes, ApiTags, ApiProduces, ApiOkResponse, ApiBody } from '@nestjs/swagger';
import { TagParams, ParsedLine } from './tools.dto.js';
import { Context } from '#shared/markdown/index.js';
import { Context } from '#shared/markdown/index';

@ApiTags('Tools')
@Controller('tools')
Expand Down
10 changes: 6 additions & 4 deletions test/server/e2e.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
// @ts-check
import { jest } from '@jest/globals';
import { Test } from '@nestjs/testing';
import supertest from 'supertest';
import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';
import { FastifyAdapter } from '@nestjs/platform-fastify';
import { HttpStatus } from '@nestjs/common';
import { AppModule } from '#server/app/app.module.js';
import { setupSwagger, enableCors } from '#server/setup.js';
import { AppModule } from '#server/app/app.module';
import { setupSwagger, enableCors } from '#server/setup';

jest.setTimeout(30_000);

describe('AppController (e2e)', () => {
/** @type {NestFastifyApplication} */
/** @type {import('@nestjs/platform-fastify').NestFastifyApplication} */
let app;

beforeAll(async () => {
Expand Down
4 changes: 4 additions & 0 deletions test/server/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const config = {

collectCoverage: true,
coverageProvider: 'v8',

moduleNameMapper: {
'^#(.*)$': '<rootDir>/../../dist/$1.js',
},
};

export default config;
22 changes: 11 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3364,9 +3364,9 @@ camelcase@^6.2.0:
integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==

caniuse-lite@^1.0.30001335, caniuse-lite@^1.0.30001349:
version "1.0.30001356"
resolved "https://registry.npmmirror.com/caniuse-lite/-/caniuse-lite-1.0.30001356.tgz#cbf5fe7b33f90962bfbca532212ea478d4ec9de8"
integrity sha512-/30854bktMLhxtjieIxsrJBfs2gTM1pel6MXKF3K+RdIVJZcsn2A2QdhsuR4/p9+R204fZw0zCBBhktX8xWuyQ==
version "1.0.30001357"
resolved "https://registry.npmmirror.com/caniuse-lite/-/caniuse-lite-1.0.30001357.tgz#dec7fc4158ef6ad24690d0eec7b91f32b8cb1b5d"
integrity sha512-b+KbWHdHePp+ZpNj+RDHFChZmuN+J5EvuQUlee9jOQIUAdhv9uvAZeEtUeLAknXbkiu1uxjQ9NLp1ie894CuWg==

[email protected], chalk@^3.0.0:
version "3.0.0"
Expand Down Expand Up @@ -4968,7 +4968,7 @@ fs-minipass@^2.0.0, fs-minipass@^2.1.0:
dependencies:
minipass "^3.0.0"

[email protected]:
fs-monkey@^1.0.3:
version "1.0.3"
resolved "https://registry.npmmirror.com/fs-monkey/-/fs-monkey-1.0.3.tgz#ae3ac92d53bb328efe0e9a1d9541f6ad8d48e2d3"
integrity sha512-cybjIfiiE+pTWicSCLFHSrXZ6EilF30oh91FDP9S2B051prEa7QWfrVTQm10/dDpswBDXZugPa1Ogu8Yh+HV0Q==
Expand Down Expand Up @@ -6610,11 +6610,11 @@ [email protected]:
integrity sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==

memfs@^3.4.1, memfs@^3.4.3:
version "3.4.4"
resolved "https://registry.npmmirror.com/memfs/-/memfs-3.4.4.tgz#e8973cd8060548916adcca58a248e7805c715e89"
integrity sha512-W4gHNUE++1oSJVn8Y68jPXi+mkx3fXR5ITE/Ubz6EQ3xRpCN5k2CQ4AUR8094Z7211F876TyoBACGsIveqgiGA==
version "3.4.6"
resolved "https://registry.npmmirror.com/memfs/-/memfs-3.4.6.tgz#74097983d27c82b973665885dc75f27a65174510"
integrity sha512-rH9mjopto6Wkr7RFuH9l9dk3qb2XGOcYKr7xMhaYqfzuJqOqhRrcFvfD7JMuPj6SLmPreh5+6eAuv36NFAU+Mw==
dependencies:
fs-monkey "1.0.3"
fs-monkey "^1.0.3"

memoizee@^0.4.15:
version "0.4.15"
Expand Down Expand Up @@ -6791,9 +6791,9 @@ minipass-sized@^1.0.3:
minipass "^3.0.0"

minipass@^3.0.0, minipass@^3.1.0, minipass@^3.1.1, minipass@^3.1.3, minipass@^3.1.6:
version "3.1.6"
resolved "https://registry.npmmirror.com/minipass/-/minipass-3.1.6.tgz#3b8150aa688a711a1521af5e8779c1d3bb4f45ee"
integrity sha512-rty5kpw9/z8SX9dmxblFA6edItUmwJgMeYDZRrwlIVN27i8gysGbznJwUggw2V/FVqFSDdWy040ZPS811DYAqQ==
version "3.3.3"
resolved "https://registry.npmmirror.com/minipass/-/minipass-3.3.3.tgz#fd1f0e6c06449c10dadda72618b59c00f3d6378d"
integrity sha512-N0BOsdFAlNRfmwMhjAsLVWOk7Ljmeb39iqFlsV1At+jqRhSUP9yeof8FyJu4imaJiSUp8vQebWD/guZwGQC8iA==
dependencies:
yallist "^4.0.0"

Expand Down

0 comments on commit 2c6bfad

Please sign in to comment.