@@ -81,26 +81,39 @@ describe('package1:version:create', () => {
81
81
it ( `should create a new 1gp package version for package id ${ packageId } without waiting` , async ( ) => {
82
82
const command = `package1:version:create -n 1gpPackageNUT -i ${ packageId } -o 1gp` ;
83
83
const output = execCmd ( command , { ensureExitCode : 0 } ) . shellOutput . stdout ;
84
- expect ( output ) . to . match ( / P a c k a g e U p l o a d R e q u e s t h a s b e e n e n q u e u e d \. / ) ;
85
- expect ( output ) . to . match ( / p a c k a g e 1 : v e r s i o n : c r e a t e : g e t - i 0 H D .{ 15 } - o / ) ;
86
- // ensure the package has uploaded by waiting for the package report to be done
87
- // @ts -ignore
88
- uploadRequestId = / 0 H D \w * / . exec ( output ) ?. at ( 0 ) ;
89
- await pollUntilComplete ( uploadRequestId ) ;
84
+
85
+ // Sometimes the package version is created faster than the test expects for a
86
+ // non-waiting scenario so only verify the enqueued output.
87
+ if ( ! output . includes ( 'Successfully uploaded package' ) ) {
88
+ expect ( output ) . to . match ( / P a c k a g e U p l o a d R e q u e s t h a s b e e n e n q u e u e d \. / ) ;
89
+ expect ( output ) . to . match ( / p a c k a g e 1 : v e r s i o n : c r e a t e : g e t - i 0 H D .{ 15 } - o / ) ;
90
+ // ensure the package has uploaded by waiting for the package report to be done
91
+ // @ts -ignore
92
+ uploadRequestId = / 0 H D \w * / . exec ( output ) ?. at ( 0 ) ;
93
+ await pollUntilComplete ( uploadRequestId ) ;
94
+ }
90
95
} ) ;
91
96
92
97
it ( `should create a new 1gp package version for package id ${ packageId } (json)` , async ( ) => {
93
98
const command = `package1:version:create -n 1gpPackageNUT -i ${ packageId } --json -o 1gp` ;
94
99
const output = execCmd < PackageUploadRequest > ( command , { ensureExitCode : 0 } ) . jsonOutput ?. result ;
95
- expect ( output ?. Status ) . to . equal ( 'QUEUED' ) ;
96
- expect ( output ?. Id ) . to . be . a ( 'string' ) ;
97
- expect ( output ?. MetadataPackageId ) . to . be . a ( 'string' ) ;
98
- expect ( output ?. MetadataPackageVersionId ) . to . be . a ( 'string' ) ;
99
- expect ( output ?. MetadataPackageVersionId . startsWith ( '04t' ) ) . to . be . true ;
100
- expect ( output ?. MetadataPackageId . startsWith ( '033' ) ) . to . be . true ;
101
- // ensure the package has uploaded by waiting for the package report to be done
102
- // @ts -ignore
103
- await pollUntilComplete ( output ?. Id ) ;
100
+
101
+ // Sometimes the package version is created faster than the test expects for a
102
+ // non-waiting scenario so only verify the enqueued output.
103
+ if ( output ?. Status !== 'SUCCESS' ) {
104
+ expect ( output ?. Status ) . to . equal ( 'QUEUED' ) ;
105
+ expect ( output ?. Id ) . to . be . a ( 'string' ) ;
106
+ expect ( output ?. MetadataPackageId ) . to . be . a ( 'string' ) ;
107
+ expect ( output ?. MetadataPackageVersionId ) . to . be . a ( 'string' ) ;
108
+ expect ( output ?. MetadataPackageVersionId . startsWith ( '04t' ) ) . to . be . true ;
109
+ expect ( output ?. MetadataPackageId . startsWith ( '033' ) ) . to . be . true ;
110
+ // ensure the package has uploaded by waiting for the package report to be done
111
+ // @ts -ignore
112
+ await pollUntilComplete ( output ?. Id ) ;
113
+ }
114
+ // Use this test's 0Hd if it wasn't already set by the previous test so that
115
+ // tests run later won't fail.
116
+ uploadRequestId ??= output ?. Id ?? '' ;
104
117
} ) ;
105
118
106
119
describe ( 'package1:version:create:get' , ( ) => {
0 commit comments