Skip to content

Commit

Permalink
fix e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandrMov committed Sep 18, 2023
1 parent 9c158bc commit 0f19704
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 11 deletions.
35 changes: 35 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,41 @@
"sourceMaps": true,
"stopOnEntry": false,
"console": "integratedTerminal",
},
{
"type": "node",
"request": "launch",
"name": "Debug Jest e2e",
"runtimeExecutable": "yarn",
"runtimeArgs": [
"test:e2e",
],
"cwd": "${workspaceFolder}/src",
"autoAttachChildProcesses": true,
"restart": true,
"sourceMaps": true,
"stopOnEntry": false,
"console": "integratedTerminal",
},
{
"name": "Jest file",
"type": "node",
"request": "launch",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/jest",
"args": [
"${fileBasenameNoExtension}",
"--runInBand",
"--watch",
"--coverage=false",
"--no-cache"
],
"cwd": "${workspaceRoot}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"sourceMaps": true,
"windows": {
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
}
}
]
}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
"@nestjs/testing": "^8.2.5",
"@types/cache-manager": "^3.4.2",
"@types/jest": "^27.4.0",
"@types/jsonstream": "^0.8.31",
"@types/node": "^17.0.9",
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^5.10.0",
Expand Down
2 changes: 1 addition & 1 deletion src/http/keys/keys.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class KeysController {
try {
for (const keysGenerator of keysGenerators) {
for await (const keysBatch of keysGenerator) {
jsonStream.write(JSON.stringify(keysBatch));
jsonStream.write(keysBatch);
}
}
} finally {
Expand Down
14 changes: 13 additions & 1 deletion src/http/keys/keys.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { Test } from '@nestjs/testing';
import { Global, INestApplication, Module, ValidationPipe, VersioningType } from '@nestjs/common';
import {
KeyRegistryService,
RegistryKey,
RegistryKeyStorageService,
RegistryStorageModule,
RegistryStorageService,
} from '../../common/registry';
import { MikroORM } from '@mikro-orm/core';
import { FilterQuery, MikroORM } from '@mikro-orm/core';
import { MikroOrmModule } from '@mikro-orm/nestjs';
import { KeysController } from './keys.controller';
import { StakingRouterModule } from '../../staking-router-modules/staking-router.module';
Expand Down Expand Up @@ -131,6 +132,15 @@ describe('KeyController (e2e)', () => {
}
}

class RegistryKeyStorageServiceMock extends RegistryKeyStorageService {
async *findStream(where: FilterQuery<RegistryKey>, fields?: string[] | undefined): AsyncIterable<RegistryKey> {
const result = await this.find(where);
for (const key of result) {
yield key;
}
}
}

beforeAll(async () => {
const imports = [
// sqlite3 only supports serializable transactions, ignoring the isolation level param
Expand All @@ -151,6 +161,8 @@ describe('KeyController (e2e)', () => {
const moduleRef = await Test.createTestingModule({ imports, controllers, providers })
.overrideProvider(KeyRegistryService)
.useClass(KeysRegistryServiceMock)
.overrideProvider(RegistryKeyStorageService)
.useClass(RegistryKeyStorageServiceMock)
.compile();

elMetaStorageService = moduleRef.get(ElMetaStorageService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class SRModulesOperatorsKeysController {
reply.type('application/json').send(jsonStream);

for await (const keysBatch of keysGenerator) {
jsonStream.write(JSON.stringify(keysBatch));
jsonStream.write(keysBatch);
}

jsonStream.end();
Expand Down
7 changes: 0 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1612,13 +1612,6 @@
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==

"@types/jsonstream@^0.8.31":
version "0.8.31"
resolved "https://registry.yarnpkg.com/@types/jsonstream/-/jsonstream-0.8.31.tgz#8df1c36c80dbb36e40794217d782022455d1e89a"
integrity sha512-32nJ7wl+q0lebxHo8iXqpmgLmkj6lYNHKp97+h8qteQ6O6IKnY+GyD/Eitqi4ul2Bbw3MScfRKtaHxt8gpC98w==
dependencies:
"@types/node" "*"

"@types/node-fetch@^2.5.12":
version "2.6.2"
resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.2.tgz#d1a9c5fd049d9415dce61571557104dec3ec81da"
Expand Down

0 comments on commit 0f19704

Please sign in to comment.