Skip to content

Commit

Permalink
Convert session details property to a stringified value
Browse files Browse the repository at this point in the history
  • Loading branch information
rconner46 committed Jul 30, 2024
1 parent 25b95c7 commit 6b731ee
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 120 deletions.
56 changes: 25 additions & 31 deletions dist/index.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.cjs.map

Large diffs are not rendered by default.

31 changes: 21 additions & 10 deletions dist/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.min.js.map

Large diffs are not rendered by default.

56 changes: 25 additions & 31 deletions dist/index.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.mjs.map

Large diffs are not rendered by default.

44 changes: 1 addition & 43 deletions src/auto-api/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import { TestRunHeartbeatService } from './heartbeat.ts';
import { join as pathJoin } from 'path';
import { AutoApiConfig } from './auto-api-config.ts';
import { parseTestCaseName } from '../shared/test-case.ts';

export class ApplauseReporter {
private autoApi: AutoApi;
Expand Down Expand Up @@ -173,46 +174,3 @@ export class RunReporter {
}
}
}
export const TEST_RAIL_CASE_ID_PREFIX: string = 'TestRail-';
export const APPLAUSE_CASE_ID_PREFIX: string = 'Applause-';

export function parseTestCaseName(testCaseName: string): ParsedTestCaseName {
// Split the name on spaces. We will reassemble after parsing out the other ids
const tokens = testCaseName.split(' ');
let testRailTestCaseId: string | undefined;
let applauseTestCaseId: string | undefined;
tokens.forEach(token => {
if (token?.startsWith(TEST_RAIL_CASE_ID_PREFIX)) {
if (testRailTestCaseId !== undefined) {
console.warn('Multiple TestRail case ids detected in testCase name');
}
testRailTestCaseId = token.substring(TEST_RAIL_CASE_ID_PREFIX.length);
} else if (token?.startsWith(APPLAUSE_CASE_ID_PREFIX)) {
if (applauseTestCaseId !== undefined) {
console.warn('Multiple Applause case ids detected in testCase name');
}
applauseTestCaseId = token.substring(APPLAUSE_CASE_ID_PREFIX.length);
}
});
return {
applauseTestCaseId,
testRailTestCaseId,
testCaseName: tokens
.filter(
token =>
token !== `${TEST_RAIL_CASE_ID_PREFIX}${testRailTestCaseId || ''}`
)
.filter(
token =>
token !== `${APPLAUSE_CASE_ID_PREFIX}${applauseTestCaseId || ''}`
)
.join(' ')
.trim(),
};
}

interface ParsedTestCaseName {
testCaseName: string;
testRailTestCaseId?: string;
applauseTestCaseId?: string;
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './auto-api/index.ts';
export * from './public-api/index.ts';
export * from './config/config.ts';
export * from './shared/index.ts';
13 changes: 12 additions & 1 deletion src/public-api/dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export interface TestRunAutoResultDto {
testCycleId: number;
status: TestRunAutoResultStatus;
failureReason?: string;
sessionDetailsJson?: object;
sessionDetailsJson?: SessionDetails;
startTime?: Date;
endTime?: Date;
}
Expand All @@ -14,3 +14,14 @@ export enum TestRunAutoResultStatus {
CANCELED = 'CANCELED',
ERROR = 'ERROR',
}

export interface SessionDetails {
value: {
deviceName?: string;
orientation?: string;
platformName?: string;
platformVersion?: string;
browserName?: string;
browserVersion?: string;
};
}
1 change: 1 addition & 0 deletions src/shared/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './test-case.ts';
34 changes: 34 additions & 0 deletions src/shared/test-case.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export const TEST_RAIL_CASE_ID_PREFIX: string = 'TestRail-';
export const APPLAUSE_CASE_ID_PREFIX: string = 'Applause-';

export function parseTestCaseName(testCaseName: string): ParsedTestCaseName {
const matches = testCaseName.match(/(TestRail-\d+|Applause-\d+)/g);
const testRailCaseIds =
matches
?.filter(match => match.startsWith(TEST_RAIL_CASE_ID_PREFIX))
.map(match => match.substring(TEST_RAIL_CASE_ID_PREFIX.length)) || [];
const applauseCaseIds =
matches
?.filter(match => match.startsWith(APPLAUSE_CASE_ID_PREFIX))
.map(match => match.substring(APPLAUSE_CASE_ID_PREFIX.length)) || [];

if (testRailCaseIds.length > 1) {
console.warn('Multiple TestRail case ids detected in testCase name');
}
if (applauseCaseIds.length > 1) {
console.warn('Multiple Applause case ids detected in testCase name');
}
return {
applauseTestCaseId: applauseCaseIds[0],
testRailTestCaseId: testRailCaseIds[0],
testCaseName: testCaseName
.replace(/(TestRail-\d+|Applause-\d+)/g, '')
.trim(),
};
}

export interface ParsedTestCaseName {
testCaseName: string;
testRailTestCaseId?: string;
applauseTestCaseId?: string;
}

0 comments on commit 6b731ee

Please sign in to comment.