turn attachments into getter
This commit is contained in:
parent
ba69c19baa
commit
365b30f64f
|
|
@ -240,8 +240,6 @@ export class TeleReporterReceiver {
|
||||||
result.error = result.errors?.[0];
|
result.error = result.errors?.[0];
|
||||||
result.attachments = this._parseAttachments(payload.attachments);
|
result.attachments = this._parseAttachments(payload.attachments);
|
||||||
this._reporter.onTestEnd?.(test, result);
|
this._reporter.onTestEnd?.(test, result);
|
||||||
for (const step of result.steps)
|
|
||||||
step.attachments = step._attachmentIndices.map(index => result.attachments[index]);
|
|
||||||
// Free up the memory as won't see these step ids.
|
// Free up the memory as won't see these step ids.
|
||||||
result._stepMap = new Map();
|
result._stepMap = new Map();
|
||||||
}
|
}
|
||||||
|
|
@ -252,7 +250,7 @@ export class TeleReporterReceiver {
|
||||||
const parentStep = payload.parentStepId ? result._stepMap.get(payload.parentStepId) : undefined;
|
const parentStep = payload.parentStepId ? result._stepMap.get(payload.parentStepId) : undefined;
|
||||||
|
|
||||||
const location = this._absoluteLocation(payload.location);
|
const location = this._absoluteLocation(payload.location);
|
||||||
const step = new TeleTestStep(payload, parentStep, location);
|
const step = new TeleTestStep(payload, parentStep, location, result);
|
||||||
if (parentStep)
|
if (parentStep)
|
||||||
parentStep.steps.push(step);
|
parentStep.steps.push(step);
|
||||||
else
|
else
|
||||||
|
|
@ -265,9 +263,9 @@ export class TeleReporterReceiver {
|
||||||
const test = this._tests.get(testId)!;
|
const test = this._tests.get(testId)!;
|
||||||
const result = test.results.find(r => r._id === resultId)!;
|
const result = test.results.find(r => r._id === resultId)!;
|
||||||
const step = result._stepMap.get(payload.id)!;
|
const step = result._stepMap.get(payload.id)!;
|
||||||
|
step._endPayload = payload;
|
||||||
step.duration = payload.duration;
|
step.duration = payload.duration;
|
||||||
step.error = payload.error;
|
step.error = payload.error;
|
||||||
step._attachmentIndices = payload.attachments ?? [];
|
|
||||||
this._reporter.onStepEnd?.(test, result, step);
|
this._reporter.onStepEnd?.(test, result, step);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -516,18 +514,20 @@ class TeleTestStep implements reporterTypes.TestStep {
|
||||||
parent: reporterTypes.TestStep | undefined;
|
parent: reporterTypes.TestStep | undefined;
|
||||||
duration: number = -1;
|
duration: number = -1;
|
||||||
steps: reporterTypes.TestStep[] = [];
|
steps: reporterTypes.TestStep[] = [];
|
||||||
attachments: reporterTypes.TestStep['attachments'] = [];
|
|
||||||
error: reporterTypes.TestError | undefined;
|
error: reporterTypes.TestError | undefined;
|
||||||
|
|
||||||
private _startTime: number = 0;
|
private result: TeleTestResult;
|
||||||
_attachmentIndices: number[] = [];
|
_endPayload?: JsonTestStepEnd;
|
||||||
|
|
||||||
constructor(payload: JsonTestStepStart, parentStep: reporterTypes.TestStep | undefined, location: reporterTypes.Location | undefined) {
|
private _startTime: number = 0;
|
||||||
|
|
||||||
|
constructor(payload: JsonTestStepStart, parentStep: reporterTypes.TestStep | undefined, location: reporterTypes.Location | undefined, result: TeleTestResult) {
|
||||||
this.title = payload.title;
|
this.title = payload.title;
|
||||||
this.category = payload.category;
|
this.category = payload.category;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.parent = parentStep;
|
this.parent = parentStep;
|
||||||
this._startTime = payload.startTime;
|
this._startTime = payload.startTime;
|
||||||
|
this.result = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
titlePath() {
|
titlePath() {
|
||||||
|
|
@ -542,6 +542,10 @@ class TeleTestStep implements reporterTypes.TestStep {
|
||||||
set startTime(value: Date) {
|
set startTime(value: Date) {
|
||||||
this._startTime = +value;
|
this._startTime = +value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get attachments() {
|
||||||
|
return this._endPayload!.attachments?.map(index => this.result.attachments[index]) ?? [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TeleTestResult implements reporterTypes.TestResult {
|
export class TeleTestResult implements reporterTypes.TestResult {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue