Skip to content

Commit

Permalink
Merge 8bc1508 into 8f89d2f
Browse files Browse the repository at this point in the history
  • Loading branch information
flops committed Jan 15, 2019
2 parents 8f89d2f + 8bc1508 commit e5b5074
Show file tree
Hide file tree
Showing 22 changed files with 40 additions and 55 deletions.
2 changes: 0 additions & 2 deletions packages/browser-proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
"@testring/transport": "0.4.49",
"@testring/types": "0.4.49",
"@testring/utils": "0.4.49",
"@types/nanoid": "1.0.0",
"@types/node": "10.5.6",
"@types/yargs": "12.0.0",
"nanoid": "1.1.0",
"yargs": "12.0.1"
},
"devDependencies": {
Expand Down
9 changes: 4 additions & 5 deletions packages/browser-proxy/src/browser-proxy-worker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChildProcess } from 'child_process';

import {
BrowserProxyActions,
BrowserProxyMessageTypes,
Expand All @@ -8,11 +9,9 @@ import {
IBrowserProxyWorker,
ITransport,
} from '@testring/types';

import { generateUniqId } from '@testring/utils';
import { loggerClient } from '@testring/logger';

const nanoid = require('nanoid');

export class BrowserProxyWorker implements IBrowserProxyWorker {
private pendingCommandsQueue: Set<IBrowserProxyPendingCommand> = new Set();

Expand All @@ -29,7 +28,7 @@ export class BrowserProxyWorker implements IBrowserProxyWorker {
constructor(
private transport: ITransport,
private workerCreator: (onActionPluginPath: string, config: any) => ChildProcess | Promise<ChildProcess>,
private spawnConfig: { plugin: string, config: any },
private spawnConfig: { plugin: string; config: any },
) {
this.registerResponseListener();
}
Expand Down Expand Up @@ -162,7 +161,7 @@ export class BrowserProxyWorker implements IBrowserProxyWorker {
}

return new Promise((resolve, reject) => {
const uid = nanoid();
const uid = generateUniqId();
const item: IBrowserProxyPendingCommand = {
uid,
resolve,
Expand Down
2 changes: 0 additions & 2 deletions packages/http-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
"@testring/transport": "0.4.49",
"@testring/types": "0.4.49",
"@testring/utils": "0.4.49",
"@types/nanoid": "1.0.0",
"@types/node": "10.5.6",
"@types/request-promise": "4.1.42",
"@types/tough-cookie": "2.3.3",
"nanoid": "1.1.0",
"request-promise": "4.2.2",
"tough-cookie": "2.4.3"
}
Expand Down
6 changes: 2 additions & 4 deletions packages/http-api/src/abstract-http-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ import {
HttpClientParams,
} from '@testring/types';
import { LoggerClient, loggerClient } from '@testring/logger';
import { Queue } from '@testring/utils';
import { Queue, generateUniqId } from '@testring/utils';
import { HttpCookieJar } from './cookie-jar';

const nanoid = require('nanoid');

const toString = c => c.toString();

export abstract class AbstractHttpClient implements IHttpClient {
Expand Down Expand Up @@ -104,7 +102,7 @@ export abstract class AbstractHttpClient implements IHttpClient {
throw new Error('request is not valid');
}

const requestUID = nanoid();
const requestUID = generateUniqId();

return new Promise((resolve, reject) => {
const removeResponseHandler = this.transportInstance.on(
Expand Down
4 changes: 1 addition & 3 deletions packages/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
"@testring/types": "0.4.49",
"@testring/utils": "0.4.49",
"@types/bytes": "3.0.0",
"@types/nanoid": "1.0.0",
"@types/node": "10.5.6",
"bytes": "3.0.0",
"chalk": "2.4.1",
"nanoid": "1.1.0"
"chalk": "2.4.1"
},
"devDependencies": {
"@testring/test-utils": "0.4.49"
Expand Down
6 changes: 2 additions & 4 deletions packages/logger/src/abstract-logger-client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Stack } from '@testring/utils';
import { Stack, generateUniqId } from '@testring/utils';
import { transport } from '@testring/transport';
import {
ILogEntity,
Expand All @@ -12,8 +12,6 @@ import {
LogEntityMarkerType,
} from '@testring/types';

const nanoid = require('nanoid');


type stepEntity = {
stepID: string;
Expand Down Expand Up @@ -43,7 +41,7 @@ export abstract class AbstractLoggerClient implements AbstractLoggerType {

protected generateStepEntity(message: string): stepEntity {
return {
stepID: nanoid(),
stepID: generateUniqId(),
message,
};
}
Expand Down
2 changes: 1 addition & 1 deletion packages/recorder-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@testring/recorder-frontend": "0.4.49",
"@testring/transport": "0.4.49",
"@testring/types": "0.4.49",
"@testring/utils": "0.4.49",
"@types/babel-traverse": "6.25.4",
"@types/koa": "2.0.46",
"@types/koa-static": "4.0.0",
Expand All @@ -31,7 +32,6 @@
"koa": "2.5.2",
"koa-static": "5.0.0",
"koa-views": "6.1.4",
"nanoid": "1.1.0",
"ws": "6.0.0"
},
"devDependencies": {
Expand Down
5 changes: 2 additions & 3 deletions packages/recorder-backend/src/recorder-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as WebSocket from 'ws';
import { launch, LaunchedChrome } from 'chrome-launcher';
import { loggerClient } from '@testring/logger';
import { transport } from '@testring/transport';
import { generateUniqId } from '@testring/utils';
import {
RecorderServerEvents,
RecorderServerMessageTypes,
Expand All @@ -22,8 +23,6 @@ import {
import { RecorderHttpServer } from './http-server';
import { RecorderWebSocketServer, RecorderWsEvents } from './ws-server';

const nanoid = require('nanoid');

const extensionPath = path.dirname(require.resolve('@testring/recorder-extension'));
const frontendPath = path.dirname(require.resolve('@testring/recorder-frontend'));
const templatesPath = path.resolve(__dirname, '../templates/');
Expand Down Expand Up @@ -73,7 +72,7 @@ export class RecorderServer implements IRecorderServer {
);

private registerConnection(ws: WebSocket): void {
const conId = nanoid();
const conId = generateUniqId();

this.connections.set(conId, ws);

Expand Down
1 change: 0 additions & 1 deletion packages/recorder-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"@types/chrome": "0.0.69",
"@types/webpack": "4.4.22",
"mkdirp": "0.5.1",
"nanoid": "1.1.0",
"ncp": "2.0.0",
"nodemon": "1.18.9",
"ts-loader": "5.3.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/// <reference types="chrome" />

import * as EventEmitter from 'events';
import { generateUniqId } from '@testring/utils';
import { IMessagingTransportMessage, MessagingTransportEvents } from '@testring/types';

import Port = chrome.runtime.Port;

const nanoid = require('nanoid');

export class MessagingTransportServer extends EventEmitter {
constructor() {
super();
Expand All @@ -23,7 +22,7 @@ export class MessagingTransportServer extends EventEmitter {
}

private registerConnection(port: Port): void {
const conId = nanoid();
const conId = generateUniqId();

port.onMessage.addListener((message) => {
this.handleMessage(message);
Expand Down
4 changes: 1 addition & 3 deletions packages/test-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
"@testring/transport": "0.4.49",
"@testring/types": "0.4.49",
"@testring/utils": "0.4.49",
"@types/nanoid": "1.0.0",
"@types/node": "10.5.6",
"nanoid": "1.1.0"
"@types/node": "10.5.6"
},
"devDependencies": {
"@testring/test-utils": "0.4.49"
Expand Down
5 changes: 2 additions & 3 deletions packages/test-worker/src/test-worker-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as path from 'path';
import { loggerClient } from '@testring/logger';
import { FSReader } from '@testring/fs-reader';
import { fork } from '@testring/child-process';
import { generateUniqId } from '@testring/utils';
import { TestWorkerLocal } from './test-worker-local';
import {
buildDependencyDictionary,
Expand All @@ -20,8 +21,6 @@ import {
IWorkerEmitter,
} from '@testring/types';

const nanoid = require('nanoid');

const WORKER_ROOT = require.resolve(
path.resolve(__dirname, 'worker')
);
Expand Down Expand Up @@ -55,7 +54,7 @@ export class TestWorkerInstance implements ITestWorkerInstance {

private queuedWorker: Promise<IWorkerEmitter> | null = null;

private workerID = `worker/${nanoid()}`;
private workerID = `worker/${generateUniqId()}`;

private logger = loggerClient;

Expand Down
5 changes: 2 additions & 3 deletions packages/transport/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
"dependencies": {
"@testring/child-process": "0.4.49",
"@testring/types": "0.4.49",
"@types/nanoid": "1.0.0",
"@types/node": "10.5.6",
"nanoid": "1.1.0"
"@testring/utils": "0.4.49",
"@types/node": "10.5.6"
}
}
4 changes: 2 additions & 2 deletions packages/transport/src/direct-transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import {
ITransportDirectMessage,
ITransportMessage,
} from '@testring/types';
import { generateUniqId } from '@testring/utils';
import { serialize, deserialize } from './serialize';

const nanoid = require('nanoid');

class DirectTransport {

private static createMessageUID(processID: string) {
return `${processID}|${nanoid()}`;
return `${processID}|${generateUniqId()}`;
}

private static isMessageFromProcess(processID: string, messageUID: string) {
Expand Down
2 changes: 2 additions & 0 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
"dependencies": {
"@testring/types": "0.4.49",
"@types/bytes": "3.0.0",
"@types/nanoid": "1.2.0",
"@types/node": "10.5.6",
"@types/resolve": "0.0.8",
"bytes": "3.0.0",
"nanoid": "2.0.1",
"resolve": "1.8.1"
}
}
5 changes: 5 additions & 0 deletions packages/utils/src/generate-uniq-id.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const nanoid = require('nanoid');

export function generateUniqId(size?: number) {
return nanoid(size);
}
1 change: 1 addition & 0 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export { requirePlugin } from './plugin-require';
export { Queue } from './queue';
export { Stack } from './stack';

export { generateUniqId } from './generate-uniq-id';

export {
getMemoryReport,
Expand Down
5 changes: 2 additions & 3 deletions packages/web-application/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
"@testring/pluggable-module": "0.4.49",
"@testring/transport": "0.4.49",
"@testring/types": "0.4.49",
"@types/nanoid": "1.0.0",
"@testring/utils": "0.4.49",
"@types/node": "10.5.6",
"chai": "4.2.0",
"nanoid": "1.1.0"
"chai": "4.2.0"
},
"devDependencies": {
"@testring/child-process": "0.4.49",
Expand Down
7 changes: 3 additions & 4 deletions packages/web-application/src/web-application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ import {
WindowFeaturesConfig,
} from '@testring/types';
import { loggerClient, LoggerClient } from '@testring/logger';
import { generateUniqId } from '@testring/utils';
import { PluggableModule } from '@testring/pluggable-module';
import { createElementPath, ElementPath } from '@testring/element-path';
import { createAssertion } from './assert';
import { WebClient } from './web-client';
import * as utils from './utils';

const nanoid = require('nanoid');

type valueType = string | number | null | undefined;

export class WebApplication extends PluggableModule {
Expand Down Expand Up @@ -286,7 +285,7 @@ export class WebApplication extends PluggableModule {
}

public get client(): WebClient {
const applicationID = `${this.testUID}-${nanoid()}`;
const applicationID = `${this.testUID}-${generateUniqId()}`;
const value = new WebClient(applicationID, this.transport);

Object.defineProperty(this, 'client', {
Expand Down Expand Up @@ -1185,7 +1184,7 @@ export class WebApplication extends PluggableModule {
.replace(/\s+/g, '_');

this.logger.media(
`${this.testUID}-${formattedDate}-${nanoid(5)}.png`,
`${this.testUID}-${formattedDate}-${generateUniqId(5)}.png`,
screenshoot
);
}
Expand Down
5 changes: 2 additions & 3 deletions packages/web-application/src/web-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import {
WebApplicationMessageType,
WindowFeaturesConfig,
} from '@testring/types';

const nanoid = require('nanoid');
import { generateUniqId } from '@testring/utils';

export class WebClient implements IWebApplicationClient {

Expand All @@ -20,7 +19,7 @@ export class WebClient implements IWebApplicationClient {
const transport = this.transport;

return new Promise((resolve, reject) => {
const uid = nanoid();
const uid = generateUniqId();
const request: IWebApplicationExecuteMessage = {
uid: uid,
applicant: this.applicant,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ import { fork } from '@testring/child-process';
import { Transport } from '@testring/transport';
import { WebApplicationControllerEventType } from '@testring/types';
import { BrowserProxyControllerMock } from '@testring/test-utils';
import { generateUniqId } from '@testring/utils';
import { WebApplicationController } from '../src/web-application-controller';
import { ELEMENT_NAME, TEST_NAME } from './fixtures/constants';

const nanoid = require('nanoid');

const testProcessPath = path.resolve(__dirname, './fixtures/test-process.ts');

// TODO add more tests
describe('WebApplicationController functional', () => {
it('should get messages from', (callback) => {
const processID = nanoid();
const processID = generateUniqId();

const transport = new Transport();
const browserProxyMock = new BrowserProxyControllerMock();
Expand Down
5 changes: 2 additions & 3 deletions packages/web-application/test/web-application.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
import * as chai from 'chai';

import { TransportMock } from '@testring/test-utils';
import { generateUniqId } from '@testring/utils';
import { WebApplication } from '../src/web-application';

const nanoid = require('nanoid');

// TODO add more tests
describe('WebApplication functional', () => {
it('should extend current instance', () => {
const workerId = nanoid();
const workerId = generateUniqId();
const transport = new TransportMock();

const webApplication = new WebApplication(workerId, transport);
Expand Down

0 comments on commit e5b5074

Please sign in to comment.