Skip to content

Commit

Permalink
Merge pull request #143 from reportportal/develop
Browse files Browse the repository at this point in the history
Release 5.0.7
  • Loading branch information
AmsterGet authored Dec 26, 2022
2 parents f537670 + 4cf4275 commit a5760e0
Show file tree
Hide file tree
Showing 22 changed files with 2,005 additions and 1,602 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
build
spec/**/*.json
26 changes: 24 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"extends": "airbnb-base",
"extends": [
"airbnb-base",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"plugins": ["prettier", "import"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"globals": {
"expectAsync": true
},
Expand All @@ -12,6 +22,18 @@
"indent": ["error", 2],
"max-len": ["error", 120],
"valid-jsdoc": ["error", { "requireReturn": false }],
"consistent-return": 0
"consistent-return": 0,
"@typescript-eslint/no-plusplus": 0,
"prettier/prettier": 2,
"class-methods-use-this": 0,
"no-else-return": 0,
"@typescript-eslint/lines-between-class-members": 0,
"import/no-extraneous-dependencies": 0,
"func-names": 0,
"import/prefer-default-export": 0,
"@typescript-eslint/naming-convention": 0,
"@typescript-eslint/dot-notation": 0,
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/no-var-requires": 0
}
}
2 changes: 2 additions & 0 deletions .github/workflows/CI-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ jobs:
node-version: ${{ matrix.node }}
- name: Clean install of node dependencies
run: npm ci
- name: Build the source code
run: npm run build
- name: Run lint
run: npm run lint
- name: Run tests
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ coverage.lcov
.nyc_output
coverage/
.npmrc
build
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"arrowParens": "always",
"singleQuote": true,
"trailingComma": "all",
"printWidth": 100,
"tabWidth": 2
}
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### Added
- The ability to see verbose logs in debug mode. To enable the debug mode, the `debug: true` flag should be specified in `params`.
### Security
- Updated versions of vulnerable packages (ajv, qs, follow-redirects, minimatch).

## [5.0.6] - 2022-01-13
### Fixed
Expand Down Expand Up @@ -39,6 +43,5 @@
## [5.0.0] - 2020-06-09
### Added
- Full compatibility with ReportPortal version 5.* (see [reportportal releases](https://github.com/reportportal/reportportal/releases))

### Deprecated
- Previous package version (`reportportal-client`) will no longer supported by reportportal.io
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,16 @@ rpClient.checkConnect().then((response) => {
## Settings
When creating a client instance, you need to specify the following parameters:

Parameter | Description
--------- | -----------
token | User's token Report Portal from which you want to send requests. It can be found on the profile page of this user.
endpoint | URL of your server. For example, if you visit the page at 'https://server:8080/ui', then endpoint will be equal to 'https://server:8080/api/v1'.
launch | Name of launch at creation.
project | The name of the project in which the launches will be created.
headers | (optional) The object with custom headers for internal http client.
restClientConfig | (optional) The object with `agent` property for configure [http(s)](https://nodejs.org/api/https.html#https_https_request_url_options_callback) client, may contain other client options eg. `timeout`.
| Parameter | Description |
|-----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| token | User's token Report Portal from which you want to send requests. It can be found on the profile page of this user. |
| endpoint | URL of your server. For example, if you visit the page at 'https://server:8080/ui', then endpoint will be equal to 'https://server:8080/api/v1'. |
| launch | Name of launch at creation. |
| project | The name of the project in which the launches will be created. |
| headers | (optional) The object with custom headers for internal http client. |
| debug | (optional) *Default: false.* This flag allows seeing the logs of the client. Useful for debugging. |
| isLaunchMergeRequired | (optional) *Default: false.* Allows client to merge launches into one at the end of the run via saving their UUIDs to the file system. At the end of the run launches can be merged using `mergeLaunches` method. |
| restClientConfig | (optional) The object with `agent` property for configure [http(s)](https://nodejs.org/api/https.html#https_https_request_url_options_callback) client, may contain other client options eg. `timeout`. |

## Asynchronous reporting
The client supports an asynchronous reporting.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.0.6
5.0.7-SNAPSHOT
3 changes: 2 additions & 1 deletion analytics/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const CLIENT_JAVASCRIPT_EVENTS = {
},
};

const getAgentEventLabel = (agentParams) => `Agent name "${agentParams.name}", version "${agentParams.version}"`;
const getAgentEventLabel = (agentParams) =>
`Agent name "${agentParams.name}", version "${agentParams.version}"`;

module.exports = {
CLIENT_JAVASCRIPT_EVENTS,
Expand Down
49 changes: 28 additions & 21 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ module.exports = {
formatName(name) {
const len = name.length;
// eslint-disable-next-line no-mixed-operators
return ((len < MIN) ? (name + new Array(MIN - len + 1).join('.')) : name).slice(-MAX);
return (len < MIN ? name + new Array(MIN - len + 1).join('.') : name).slice(-MAX);
},

now() {
return new Date().valueOf();
},

getServerResult(url, request, options, method) {
return RestClient
.request(method, url, request, options);
return RestClient.request(method, url, request, options);
},

readLaunchesFromFile() {
Expand All @@ -48,23 +47,28 @@ module.exports = {
const osArchitecture = os.arch();
const RAMSize = os.totalmem();
const nodeVersion = process.version;
const systemAttr = [{
key: 'client',
value: `${PJSON_NAME}|${PJSON_VERSION}`,
system: true,
}, {
key: 'os',
value: `${osType}|${osArchitecture}`,
system: true,
}, {
key: 'RAMSize',
value: RAMSize,
system: true,
}, {
key: 'nodeJS',
value: nodeVersion,
system: true,
}];
const systemAttr = [
{
key: 'client',
value: `${PJSON_NAME}|${PJSON_VERSION}`,
system: true,
},
{
key: 'os',
value: `${osType}|${osArchitecture}`,
system: true,
},
{
key: 'RAMSize',
value: RAMSize,
system: true,
},
{
key: 'nodeJS',
value: nodeVersion,
system: true,
},
];

return systemAttr;
},
Expand All @@ -78,7 +82,10 @@ module.exports = {
return codeRef;
}

const parameters = params.reduce((result, item) => (item.value ? result.concat(item.value) : result), []);
const parameters = params.reduce(
(result, item) => (item.value ? result.concat(item.value) : result),
[],
);

return `${codeRef}[${parameters}]`;
},
Expand Down
98 changes: 49 additions & 49 deletions lib/publicReportingAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,85 +5,85 @@ const { EVENTS } = require('./constants/events');
*/
class PublicReportingAPI {
/**
* Emit set description event.
* @param {String} text - description of current test/suite.
* @param {String} suite - suite description, optional.
*/
* Emit set description event.
* @param {String} text - description of current test/suite.
* @param {String} suite - suite description, optional.
*/
static setDescription(text, suite) {
process.emit(EVENTS.SET_DESCRIPTION, { text, suite });
}

/**
* Emit add attributes event.
* @param {Array} attributes - array of attributes, should looks like this:
* [{
* key: "attrKey",
* value: "attrValue",
* }]
*
* @param {String} suite - suite description, optional.
*/
* Emit add attributes event.
* @param {Array} attributes - array of attributes, should looks like this:
* [{
* key: "attrKey",
* value: "attrValue",
* }]
*
* @param {String} suite - suite description, optional.
*/
static addAttributes(attributes, suite) {
process.emit(EVENTS.ADD_ATTRIBUTES, { attributes, suite });
}

/**
* Emit send log to test item event.
* @param {Object} log - log object should looks like this:
* {
* level: "INFO",
* message: "log message",
* file: {
* name: "filename",
* type: "image/png", // media type
* content: data, // file content represented as 64base string
* },
* }
* @param {String} suite - suite description, optional.
*/
* Emit send log to test item event.
* @param {Object} log - log object should looks like this:
* {
* level: "INFO",
* message: "log message",
* file: {
* name: "filename",
* type: "image/png", // media type
* content: data, // file content represented as 64base string
* },
* }
* @param {String} suite - suite description, optional.
*/
static addLog(log, suite) {
process.emit(EVENTS.ADD_LOG, { log, suite });
}

/**
* Emit send log to current launch event.
* @param {Object} log - log object should looks like this:
* {
* level: "INFO",
* message: "log message",
* file: {
* name: "filename",
* type: "image/png", // media type
* content: data, // file content represented as 64base string
* },
* }
*/
* Emit send log to current launch event.
* @param {Object} log - log object should looks like this:
* {
* level: "INFO",
* message: "log message",
* file: {
* name: "filename",
* type: "image/png", // media type
* content: data, // file content represented as 64base string
* },
* }
*/
static addLaunchLog(log) {
process.emit(EVENTS.ADD_LAUNCH_LOG, log);
}

/**
* Emit set testCaseId event.
* @param {String} testCaseId - testCaseId of current test/suite.
* @param {String} suite - suite description, optional.
*/
* Emit set testCaseId event.
* @param {String} testCaseId - testCaseId of current test/suite.
* @param {String} suite - suite description, optional.
*/
static setTestCaseId(testCaseId, suite) {
process.emit(EVENTS.SET_TEST_CASE_ID, { testCaseId, suite });
}

/**
* Emit set status to current launch event.
* @param {String} status - status of current launch.
*/
* Emit set status to current launch event.
* @param {String} status - status of current launch.
*/
static setLaunchStatus(status) {
process.emit(EVENTS.SET_LAUNCH_STATUS, status);
}

/**
* Emit set status event.
* @param {String} status - status of current test/suite.
* @param {String} suite - suite description, optional.
*/
* Emit set status event.
* @param {String} status - status of current test/suite.
* @param {String} suite - suite description, optional.
*/
static setStatus(status, suite) {
process.emit(EVENTS.SET_STATUS, { status, suite });
}
Expand Down
Loading

0 comments on commit a5760e0

Please sign in to comment.