Skip to content

Commit b50239a

Browse files
authored
[minor] add historyId to interface (#74)
1 parent be29210 commit b50239a

File tree

7 files changed

+59
-0
lines changed

7 files changed

+59
-0
lines changed

src/commands/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export const registerCommands = () => {
4747
attachment: (allure, name, content, type) => allure.attachment(name, content, type),
4848
owner: (allure, name) => allure.owner(name),
4949
fullName: (allure, name) => allure.fullName(name),
50+
historyId: (allure, value) => allure.historyId(value),
5051
lead: (allure, name) => allure.lead(name),
5152
layer: (allure, name) => allure.layer(name),
5253
browser: (allure, name) => allure.browser(name),

src/cypress/types.ts

+8
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,14 @@ declare namespace Cypress {
182182
*/
183183
fullName(value: string): T;
184184

185+
/**
186+
* Sets test history Id
187+
* @param value string to group in timeline
188+
* @example
189+
* cy.allure().historyId('1c6b6e73-6043-4772-a079-c722afcd1700');
190+
*/
191+
historyId(value: string): T;
192+
185193
/**
186194
* Sets label 'owner' - will be shown in allure report as Owner field
187195
* @param value owner name

src/plugins/allure-reporter-plugin.ts

+6
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,12 @@ export class AllureReporter {
601601
}
602602
}
603603

604+
historyId(arg: AllureTaskArgs<'fullName'>) {
605+
if (this.currentTest) {
606+
this.currentTest.historyId = arg.value;
607+
}
608+
}
609+
604610
parameter(arg: AllureTaskArgs<'parameter'>) {
605611
if (this.currentExecutable) {
606612
this.currentExecutable.addParameter(arg.name, arg.value);

src/plugins/allure-types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type AllureTask = {
3636
step: { name: string; status?: string; date?: number };
3737
parameter: { name: string; value: string };
3838
fullName: { value: string };
39+
historyId: { value: string };
3940
link: { url: string; name?: string; type?: LinkType };
4041
testParameter: { name: string; value: string };
4142
testStatus: { result: Status; details?: StatusDetails };

src/plugins/allure.ts

+8
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,19 @@ export const allureTasks = (opts: ReporterOptions): AllureTasks => {
285285
allureReporter.attachment(arg);
286286
log('attachment');
287287
},
288+
288289
fullName: (arg: AllureTaskArgs<'fullName'>) => {
289290
log(`fullName ${JSON.stringify(arg)}`);
290291
allureReporter.fullName(arg);
291292
log('fullName');
292293
},
294+
295+
historyId: (arg: AllureTaskArgs<'historyId'>) => {
296+
log(`historyId ${JSON.stringify(arg)}`);
297+
allureReporter.historyId(arg);
298+
log('historyId');
299+
},
300+
293301
link: (arg: AllureTaskArgs<'link'>) => {
294302
log(`link ${JSON.stringify(arg)}`);
295303
allureReporter.link(arg);

src/setup/allure-mocha-reporter.ts

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export const allureInterface = (
104104
fn({ task: 'step', arg: { name, status: status ?? Status.PASSED, date: Date.now() } }),
105105
deleteResults: () => fn({ task: 'deleteResults', arg: {} }),
106106
fullName: (value: string) => fn({ task: 'fullName', arg: { value } }),
107+
historyId: (value: string) => fn({ task: 'historyId', arg: { value } }),
107108
testAttachment: (name: string, content: string | Buffer, type) =>
108109
fn({ task: 'testAttachment', arg: { name, content, type } }),
109110
testStatus: (result: Status, details?: StatusDetails) => fn({ task: 'testStatus', arg: { result, details } }),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { createResTest2 } from '../../../cy-helper/utils';
2+
import { AllureTest, parseAllure } from 'allure-js-parser';
3+
4+
describe('should set historyId by using cy.allure() interface', () => {
5+
const res = createResTest2(
6+
[
7+
`
8+
describe('set historyId for test', () => {
9+
it('01 historyId', () => {
10+
cy.allure().historyId('1c6b6e73-6043-4772-a079-c722afcd1700');
11+
});
12+
});
13+
`,
14+
],
15+
{},
16+
);
17+
describe('check results', () => {
18+
let resAllure: AllureTest[];
19+
20+
beforeAll(() => {
21+
resAllure = parseAllure(res.watch);
22+
});
23+
24+
it('should have simple step with 0 duration', () => {
25+
const tests = resAllure.filter(t => t.name === '01 historyId');
26+
expect(tests.length).toEqual(1);
27+
28+
expect(tests[0].historyId).toEqual(
29+
'1c6b6e73-6043-4772-a079-c722afcd1700',
30+
);
31+
expect(tests[0].name).toEqual('01 historyId');
32+
});
33+
});
34+
});

0 commit comments

Comments
 (0)