Skip to content

Commit

Permalink
Merge pull request #156 from reportportal/feature/EPMRPP-95591-rewrit…
Browse files Browse the repository at this point in the history
…e-suites-creation-flow

EPMRPP-95591 || Rewrite suites creation flow
  • Loading branch information
AmsterGet authored Jan 30, 2025
2 parents 9befa11 + ccbfcff commit e4e4184
Show file tree
Hide file tree
Showing 8 changed files with 254 additions and 408 deletions.
15 changes: 11 additions & 4 deletions __tests__/mocks/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,32 @@ const { TEST_ITEM_STATUSES } = require('../../src/constants');

const mockDate = 1712900000000;
const duration = 5;
const testFilePath = `C:${path.sep}testProject${path.sep}example.js`;
const failedTestResult = {
title: 'failed title',
status: TEST_ITEM_STATUSES.FAILED,
ancestorTitles: ['Failed suite name', 'Failed test name'],
failureMessages: ['error message'],
invocations: 1,
duration,
startedAt: mockDate,
};
const skippedTestResult = {
title: 'skipped title',
status: TEST_ITEM_STATUSES.SKIPPED,
ancestorTitles: ['Skipped suite name', 'Skipped test name'],
failureMessages: [],
invocations: 1,
duration,
invocations: 2,
};
const testResult = {
testResults: [failedTestResult],
testFilePath,
};
const testResultWithSkipped = {
testResults: [failedTestResult, skippedTestResult],
testFilePath,
};
const testObj = {
path: `C:${path.sep}testProject${path.sep}example.js`,
path: testFilePath,
};
const mockFile = { name: 'test_img_name', type: 'image/png', content: 'content' };

Expand All @@ -33,6 +38,8 @@ module.exports = {
failedTestResult,
skippedTestResult,
testResult,
testResultWithSkipped,
testObj,
mockFile,
testFilePath,
};
65 changes: 1 addition & 64 deletions __tests__/objectUtils.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 EPAM Systems
* Copyright 2025 EPAM Systems
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,12 +19,8 @@ const path = require('path');
const {
getAgentOptions,
getStartLaunchObject,
getSuiteStartObject,
getTestStartObject,
getStepStartObject,
getAgentInfo,
getCodeRef,
getFullTestName,
getFullStepName,
getSystemAttributes,
} = require('../src/utils/objectUtils');
Expand Down Expand Up @@ -117,52 +113,6 @@ describe('Object Utils script', () => {
});
});

describe('getStepStartObject', () => {
test('should return step start object with correct values', () => {
const expectedStepStartObject = {
type: 'STEP',
name: 'step title',
retry: true,
startTime: new Date().valueOf() - duration,
};

const stepStartObject = getStepStartObject('step title', true, undefined, duration);

expect(stepStartObject).toBeDefined();
expect(stepStartObject).toEqual(expectedStepStartObject);
});
});

describe('getTestStartObject', () => {
test('should return test start object with correct values', () => {
const expectedTestStartObject = {
type: 'TEST',
name: 'test title',
startTime: new Date().valueOf() - duration,
};

const testStartObject = getTestStartObject('test title', undefined, duration);

expect(testStartObject).toBeDefined();
expect(testStartObject).toEqual(expectedTestStartObject);
});
});

describe('getSuiteStartObject', () => {
test('should return suite start object with correct values', () => {
const expectedSuiteStartObject = {
type: 'SUITE',
name: 'suite name',
startTime: new Date().valueOf() - duration,
};

const suiteStartObject = getSuiteStartObject('suite name', undefined, duration);

expect(suiteStartObject).toBeDefined();
expect(suiteStartObject).toEqual(expectedSuiteStartObject);
});
});

describe('getAgentOptions', () => {
test(
'should return agent options object with correct values, some parameters taken from' +
Expand Down Expand Up @@ -301,19 +251,6 @@ describe('Object Utils script', () => {
});
});

describe('getFullTestName', () => {
test('should return correct full test name', () => {
const mockedTest = {
ancestorTitles: ['rootDescribe', 'parentDescribe', 'testTitle'],
};
const expectedFullTestName = 'rootDescribe/parentDescribe/testTitle';

const fullTestName = getFullTestName(mockedTest);

expect(fullTestName).toEqual(expectedFullTestName);
});
});

describe('getFullStepName', () => {
test('should return correct full step name', () => {
const mockedTest = {
Expand Down
Loading

0 comments on commit e4e4184

Please sign in to comment.