@@ -696,9 +696,9 @@ describe("plugin", () => {
696696 } ) ;
697697
698698 describe ( "report assets" , ( ) => {
699- const makeSingleFileStore = ( testResults : TestResult [ ] ) : AllureStore =>
699+ const makeSingleFileStore = ( testResults : TestResult [ ] , metadata : Record < string , unknown > = { } ) : AllureStore =>
700700 ( {
701- metadataByKey : vi . fn ( ) . mockResolvedValue ( undefined ) ,
701+ metadataByKey : vi . fn ( async ( key : string ) => metadata [ key ] ) ,
702702 allEnvironments : vi . fn ( ) . mockResolvedValue ( [ "default" ] ) ,
703703 allEnvironmentIdentities : vi
704704 . fn ( )
@@ -759,6 +759,14 @@ describe("plugin", () => {
759759 return data ;
760760 } ;
761761
762+ const extractReportOptions = ( html : string ) => {
763+ const match = html . match ( / w i n d o w \. a l l u r e R e p o r t O p t i o n s = ( \{ .* ?\} ) \s * < \/ s c r i p t > / s) ;
764+
765+ expect ( match , "index.html must include report options" ) . not . toBeNull ( ) ;
766+
767+ return JSON . parse ( match ! [ 1 ] ) ;
768+ } ;
769+
762770 it ( "should copy every emitted multi-file asset" , async ( ) => {
763771 const addedFiles = new Map < string , Buffer > ( ) ;
764772 const reportFiles : ReportFiles = {
@@ -866,5 +874,60 @@ describe("plugin", () => {
866874 // data test results file for the test must be present
867875 expect ( Object . keys ( embeddedData ) . some ( ( k ) => k . startsWith ( "data/test-results/" ) ) ) . toBe ( true ) ;
868876 } ) ;
877+
878+ it ( "should include launch timing and allure2 executor metadata in report options" , async ( ) => {
879+ const testResults : TestResult [ ] = [
880+ {
881+ id : "tr-1" ,
882+ name : "passed test" ,
883+ status : "passed" ,
884+ environment : "default" ,
885+ start : 1000 ,
886+ stop : 2000 ,
887+ labels : [ ] ,
888+ } ,
889+ {
890+ id : "tr-retry" ,
891+ name : "failed retry" ,
892+ status : "failed" ,
893+ environment : "default" ,
894+ isRetry : true ,
895+ start : 500 ,
896+ stop : 2500 ,
897+ labels : [ ] ,
898+ } ,
899+ ] as TestResult [ ] ;
900+ const executor = {
901+ name : "TeamCity" ,
902+ type : "teamcity" ,
903+ buildName : "Wrike #123" ,
904+ buildUrl : "https://teamcity.example/build/123" ,
905+ reportUrl : "https://teamcity.example/report/123" ,
906+ } ;
907+ const addedFiles = new Map < string , Buffer > ( ) ;
908+ const reportFiles : ReportFiles = {
909+ addFile : vi . fn ( async ( path : string , data : Buffer ) => {
910+ addedFiles . set ( path , data ) ;
911+ return path ;
912+ } ) ,
913+ } ;
914+ const plugin = new AwesomePlugin ( { singleFile : true } ) ;
915+
916+ await plugin . start ( makeSingleFileContext ( reportFiles ) ) ;
917+ await plugin . done (
918+ makeSingleFileContext ( reportFiles ) ,
919+ makeSingleFileStore ( testResults , { allure2_executor : executor } ) ,
920+ ) ;
921+
922+ const indexHtml = addedFiles . get ( "index.html" ) ?. toString ( "utf-8" ) ?? "" ;
923+ const reportOptions = extractReportOptions ( indexHtml ) ;
924+
925+ expect ( reportOptions . runSummary ) . toEqual ( {
926+ start : 500 ,
927+ stop : 2500 ,
928+ duration : 2000 ,
929+ } ) ;
930+ expect ( reportOptions . executor ) . toEqual ( executor ) ;
931+ } ) ;
869932 } ) ;
870933} ) ;
0 commit comments