This repository was archived by the owner on Sep 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Rewrite package on typescript #108
Open
OldSkyTree
wants to merge
22
commits into
master
Choose a base branch
from
FEI-17919
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
5a26826
build: add infrastructure for typescript
cd1b349
chore: rename files from *.js to *.ts
80b76f8
test: fix tests paths
ca93773
chore(index): rewrite index.js to TS
cc35e28
chore(base-stats): rewrite module base-stats to TS
e9a5162
chore(image): rewrite module image on TS
1488913
chore(coverage): rewrite module coverage on TS
ba47642
chore(browser/camera): rewrite module browser/camera on TS
3c6c1cf
chore(browser-pool): rewrite module browser-pool on TS
2f7000b
chore(browser-agent): rewrite module browser-agent on TS
05303d2
chore(promise-utils): rewrite module promise-utils on TS
582132e
chore(events): rewrite module events on TS
9fb40f6
chore(calibrator): rewrite module calibrator on TS
00d41db
chore(client-bridge): rewrite module client-bridge on TS
bd5a301
chore(config): rewrite module config on TS
5c2da1f
chore(errors): rewrite module errors on TS
55eb61d
chore(screen-shooter): rewrite module screen-shooter on TS
6ac4811
chore(sets-builder): rewrite module sets-builder on TS
c69932c
chore(temp): rewrite module temp on TS
1e97892
chore(utils): rewrite module utils on TS
18c0e75
chore(browser/client-scripts): rewrite module browser/client-scripts …
96bc669
test: fix tests
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| /lib/browser/client-scripts/calibrate.min.js | ||
| /build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| node_modules | ||
| build | ||
| *.log | ||
| /lib/browser/client-scripts/calibrate.min.js |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| export { default as BaseStats } from "./lib/base-stats"; | ||
| export { default as SetsBuilder } from "./lib/sets-builder"; | ||
|
|
||
| import options from "./lib/config/options"; | ||
| export const config = { options }; | ||
|
|
||
| export { default as Calibrator } from "./lib/calibrator"; | ||
| export * as BrowserPool from "./lib/browser-pool"; | ||
| export { default as BrowserAgent } from "./lib/browser-agent"; | ||
| export { default as Image } from "./lib/image"; | ||
| export * as temp from "./lib/temp"; | ||
| export * as errors from "./lib/errors"; | ||
| export * as events from "./lib/events"; | ||
| export * as promiseUtils from "./lib/promise-utils"; | ||
| export * as clientBridge from "./lib/client-bridge"; | ||
|
|
||
| import * as coverageLevel from "./lib/coverage/coverage-level"; | ||
| export const coverage = { coverageLevel }; | ||
|
|
||
| import Camera from "./lib/browser/camera"; | ||
| export const browser = { Camera }; | ||
| export { Camera }; | ||
|
|
||
| export { default as ScreenShooter } from "./lib/screen-shooter"; | ||
| export { default as Viewport } from "./lib/screen-shooter/viewport"; | ||
| export { default as CoordValidator } from "./lib/screen-shooter/viewport/coord-validator"; | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import _ from "lodash"; | ||
|
|
||
| type StatNames<T extends string = 'passed' | 'failed' | 'skipped'> = Record<Uppercase<T>, Lowercase<T>>; | ||
|
|
||
| type Stats = { [StatName in StatNames[keyof StatNames]]: number }; | ||
| type StatsResult = Stats & { | ||
| total: number; | ||
| retries: number; | ||
| }; | ||
|
|
||
| export default class BaseStats { | ||
| private _tests: Set<string>; | ||
| private _retries: number; | ||
| private _statNames: StatNames; | ||
| private _stats: Stats; | ||
|
|
||
| public static create(statNames: StatNames): BaseStats { | ||
| return new this(statNames); | ||
| } | ||
|
|
||
| constructor(statNames: StatNames) { | ||
| this._tests = new Set(); | ||
| this._retries = 0; | ||
| this._statNames = statNames; | ||
|
|
||
| this._stats = this._fillEmptyStats(); | ||
| } | ||
|
|
||
| public addPassed(test: unknown) { | ||
| this._addStat(this._statNames.PASSED, test); | ||
| } | ||
|
|
||
| public addFailed(test: unknown) { | ||
| this._addStat(this._statNames.FAILED, test); | ||
| } | ||
|
|
||
| public addSkipped(test: unknown) { | ||
| this._addStat(this._statNames.SKIPPED, test); | ||
| } | ||
|
|
||
| public addRetries() { | ||
| this._retries++; | ||
| } | ||
|
|
||
| private _addStat(stat: StatNames[keyof StatNames], test: unknown, statsStorage = this._stats, testsStorage = this._tests) { | ||
| const key = `${this._buildSuiteKey(test)} ${this._buildStateKey(test)}`; | ||
|
|
||
| statsStorage[stat]++; | ||
| testsStorage.add(key); | ||
| } | ||
|
|
||
| private _fillEmptyStats(): Stats { | ||
| const statValues = _.values(this._statNames); | ||
|
|
||
| return _.zipObject(statValues, Array(statValues.length).fill(0)) as Stats; | ||
| } | ||
|
|
||
| private _buildStateKey(_test: unknown): string { | ||
| throw new Error('Method must be implemented in child classes'); | ||
| } | ||
|
|
||
| private _buildSuiteKey(_test: unknown): string { | ||
| throw new Error('Method must be implemented in child classes'); | ||
| } | ||
|
|
||
| public getResult(): StatsResult { | ||
| return _.extend(this._stats, { | ||
| total: this._tests.size, | ||
| retries: this._retries | ||
| }); | ||
| } | ||
| }; |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import _ from 'lodash'; | ||
|
|
||
| import type { Pool } from '../types/pool'; | ||
| import type { NewBrowser } from '../types/new-browser'; | ||
|
|
||
| export default class BrowserAgent { | ||
| private _sessions: Array<string>; | ||
|
|
||
| public static create(browserId: string, pool: Pool): BrowserAgent { | ||
| return new BrowserAgent(browserId, pool); | ||
| } | ||
|
|
||
| constructor(public browserId: string, private _pool: Pool) { | ||
| this._sessions = []; | ||
| } | ||
|
|
||
| public async getBrowser(opts: any): Promise<NewBrowser> { | ||
| const browser = await this._pool.getBrowser(this.browserId, opts); | ||
|
|
||
| if (_.includes(this._sessions, browser.sessionId)) { | ||
| await this.freeBrowser(browser, {force: true}); | ||
|
|
||
| return this.getBrowser(opts); | ||
| } | ||
|
|
||
| this._sessions.push(browser.sessionId); | ||
|
|
||
| return browser; | ||
| } | ||
|
|
||
| public async freeBrowser(browser: NewBrowser, opts: any): Promise<void> { | ||
| return this._pool.freeBrowser(browser, opts); | ||
| } | ||
| } |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Такая махинация нужна, чтобы сохранить API, но понял, что можно сделать лучше так:
./lib/config/index.tsс содержимымexport * as options from "./options";export * as config from "./lib/config";