-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(commons): process metadata messages from before hooks (fixes #1075…
…, via #1041)
- Loading branch information
Showing
5 changed files
with
243 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 26 additions & 20 deletions
46
packages/allure-js-commons/src/sdk/reporter/LifecycleState.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,80 @@ | ||
import type { FixtureResult, StepResult, TestResult } from "../../model.js"; | ||
import type { FixtureType, FixtureWrapper, TestScope } from "./types.js"; | ||
import type { FixtureResultWrapper, FixtureType, TestResultWrapper, TestScope } from "./types.js"; | ||
|
||
export class LifecycleState { | ||
scopes = new Map<string, TestScope>(); | ||
#scopes = new Map<string, TestScope>(); | ||
|
||
testResults = new Map<string, TestResult>(); | ||
#testResults = new Map<string, TestResultWrapper>(); | ||
|
||
stepResults = new Map<string, StepResult>(); | ||
#stepResults = new Map<string, StepResult>(); | ||
|
||
fixturesResults = new Map<string, FixtureWrapper>(); | ||
#fixturesResults = new Map<string, FixtureResultWrapper>(); | ||
|
||
getScope = (uuid: string) => this.scopes.get(uuid); | ||
getScope = (uuid: string) => this.#scopes.get(uuid); | ||
|
||
getWrappedFixtureResult = (uuid: string) => this.fixturesResults.get(uuid); | ||
getWrappedFixtureResult = (uuid: string) => this.#fixturesResults.get(uuid); | ||
|
||
getFixtureResult = (uuid: string) => this.getWrappedFixtureResult(uuid)?.value; | ||
|
||
getTestResult = (uuid: string) => this.testResults.get(uuid); | ||
getWrappedTestResult = (uuid: string) => this.#testResults.get(uuid); | ||
|
||
getStepResult = (uuid: string) => this.stepResults.get(uuid); | ||
getTestResult = (uuid: string) => this.getWrappedTestResult(uuid)?.value; | ||
|
||
getStepResult = (uuid: string) => this.#stepResults.get(uuid); | ||
|
||
getExecutionItem = (uuid: string): FixtureResult | TestResult | StepResult | undefined => | ||
this.getFixtureResult(uuid) ?? this.getTestResult(uuid) ?? this.getStepResult(uuid); | ||
|
||
// test results | ||
setTestResult = (uuid: string, result: TestResult) => { | ||
this.testResults.set(uuid, result); | ||
setTestResult = (uuid: string, result: TestResult, scopeUuids: string[] = []) => { | ||
this.#testResults.set(uuid, { value: result, scopeUuids }); | ||
}; | ||
|
||
deleteTestResult = (uuid: string) => { | ||
this.testResults.delete(uuid); | ||
this.#testResults.delete(uuid); | ||
}; | ||
|
||
// steps | ||
setStepResult = (uuid: string, result: StepResult) => { | ||
this.stepResults.set(uuid, result); | ||
this.#stepResults.set(uuid, result); | ||
}; | ||
|
||
deleteStepResult = (uuid: string) => { | ||
this.stepResults.delete(uuid); | ||
this.#stepResults.delete(uuid); | ||
}; | ||
|
||
// fixtures | ||
setFixtureResult = (uuid: string, type: FixtureType, result: FixtureResult) => { | ||
const wrappedResult: FixtureWrapper = { | ||
setFixtureResult = (scopeUuid: string, uuid: string, type: FixtureType, result: FixtureResult) => { | ||
const wrappedResult: FixtureResultWrapper = { | ||
uuid, | ||
type, | ||
value: result, | ||
scopeUuid, | ||
}; | ||
this.fixturesResults.set(uuid, wrappedResult); | ||
this.#fixturesResults.set(uuid, wrappedResult); | ||
return wrappedResult; | ||
}; | ||
|
||
deleteFixtureResult = (uuid: string) => { | ||
this.fixturesResults.delete(uuid); | ||
this.#fixturesResults.delete(uuid); | ||
}; | ||
|
||
// test scopes | ||
setScope = (uuid: string, data: Partial<TestScope> = {}) => { | ||
const scope: TestScope = { | ||
labels: [], | ||
links: [], | ||
parameters: [], | ||
fixtures: [], | ||
tests: [], | ||
...data, | ||
uuid, | ||
}; | ||
this.scopes.set(uuid, scope); | ||
this.#scopes.set(uuid, scope); | ||
return scope; | ||
}; | ||
|
||
deleteScope = (uuid: string) => { | ||
this.scopes.delete(uuid); | ||
this.#scopes.delete(uuid); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.