Skip to content

Commit

Permalink
v0.0.3 - Fixed dotenv issue and added ACCESS_TOKEN to reporter config
Browse files Browse the repository at this point in the history
  • Loading branch information
asukhodolova committed Jul 18, 2023
1 parent c5072e0 commit f9819cc
Show file tree
Hide file tree
Showing 8 changed files with 674 additions and 416 deletions.
268 changes: 167 additions & 101 deletions README.md

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zebrunner/javascript-agent-playwright",
"version": "0.0.2",
"version": "0.0.3",
"main": "build/src/lib/index.js",
"license": "MIT",
"description": "Zebrunner Agent for Playwright",
Expand All @@ -10,16 +10,17 @@
},
"devDependencies": {
"@playwright/test": "^1.18.1",
"dotenv": "^14.3.2",
"playwright": "^1.18.1",
"prettier": "^2.5.1",
"rimraf": "^5.0.1",
"typescript": "^4.5.5"
},
"dependencies": {
"@ffmpeg-installer/ffmpeg": "^1.1.0",
"@slack/web-api": "^6.6.0",
"@supercharge/promise-pool": "^2.1.0",
"axios": "^0.25.0",
"dotenv": "^16.3.1",
"fluent-ffmpeg": "^2.1.2",
"form-data": "^4.0.0",
"ua-parser-js": "^1.0.2",
Expand Down
1 change: 1 addition & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const config: PlaywrightTestConfig = {
{
enabled: true,
reportingServerHostname: 'https://webdriver.zebrunner.com',
reportingServerAccessToken: 'somesecretaccesstoken',
reportingProjectKey: 'DEF',
reportingRunDisplayName: 'PW-tests',
reportingRunBuild: 'alpha-1',
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ZebAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class ZebAgent {
private readonly _maximumConcurrentTask = 20;

constructor(config: zebrunnerConfig) {
this._accessToken = process.env.REPORTING_SERVER_ACCESS_TOKEN;
this._accessToken = config.reportingServerAccessToken || process.env.REPORTING_SERVER_ACCESS_TOKEN;
this._projectKey = config.reportingProjectKey || 'DEF';
this._reportBaseUrl = config.reportingServerHostname;

Expand Down
1 change: 1 addition & 0 deletions src/lib/ZebrunnerReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ let parser = new UAParser();
export type zebrunnerConfig = {
enabled: boolean;
reportingServerHostname: string;
reportingServerAccessToken: string;
reportingProjectKey?: string;
reportingRunDisplayName?: string;
reportingRunBuild?: string;
Expand Down
16 changes: 12 additions & 4 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ const parsePwConfig = (config) => {
const pwConfig = {
enabled: process.env.REPORTING_ENABLED ? JSON.parse(process.env.REPORTING_ENABLED) : false,
reportingServerHostname: process.env.REPORTING_SERVER_HOSTNAME,
reportingServerAccessToken: process.env.REPORTING_SERVER_ACCESS_TOKEN,
reportingProjectKey: process.env.REPORTING_PROJECT_KEY,
reportingRunDisplayName: process.env.REPORTING_RUN_DISPLAY_NAME,
reportingRunBuild: process.env.REPORTING_RUN_BUILD,
Expand All @@ -288,19 +289,26 @@ const parsePwConfig = (config) => {
: 10,
};

const regExp = /zebr/i;
const configObject = config.reporter.find((el) => regExp.test(el[0]) || regExp.test(el[1]))[1];

const zbrName = 'javascript-agent-playwright';
const zbrReporter = config.reporter.find((el) => el[0].includes(zbrName));
const configObject = zbrReporter.length > 1 ? zbrReporter[1] : {};

Object.keys(configObject).forEach((key) => {
if (key === 'enabled') {
pwConfig.enabled = _getConfigVar('ENABLED', configObject[key]);
pwConfig.enabled = _getConfigVar('REPORTING_ENABLED', configObject[key]);
}
if (key === 'reportingServerHostname') {
pwConfig.reportingServerHostname = _getConfigVar(
'REPORTING_SERVER_HOSTNAME',
configObject[key]
);
}
if (key === 'reportingServerAccessToken') {
pwConfig.reportingServerAccessToken = _getConfigVar(
'REPORTING_SERVER_ACCESS_TOKEN',
configObject[key]
);
}
if (key === 'reportingProjectKey') {
pwConfig.reportingProjectKey = _getConfigVar('REPORTING_PROJECT_KEY', configObject[key]);
}
Expand Down
1 change: 1 addition & 0 deletions tests/testData/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type ParserFixture = {
const config = {
enabled: true,
reportingServerHostname: 'https://webdriver.zebrunner.com',
reportingServerAccessToken: 'somesecrettokenhere',
reportingProjectKey: 'DEF',
reportingRunDisplayName: 'PW-tests conf',
reportingRunBuild: 'alpha-1 conf',
Expand Down
796 changes: 488 additions & 308 deletions yarn.lock

Large diffs are not rendered by default.

0 comments on commit f9819cc

Please sign in to comment.