1- import { readFileSync , writeFileSync } from 'node:fs' ;
2- import os from 'node:os' ;
3- import path from 'node:path' ;
4-
5- import TOML from '@ltd/j-toml' ;
61import { expect , test } from '@playwright/test' ;
72import { v4 as uuidv4 } from 'uuid' ;
83
94import { closePopupsIfExist , isHosted } from './helpers/helpers' ;
105import { ensureAuthenticated } from './helpers/login' ;
116import { ibFrame , navigateToLandingPage } from './helpers/navHelpers' ;
127
13- const awsCredentials = `
14- [default]
15- aws_access_key_id = supersecret
16- aws_secret_access_key = secretsquirrel
17- ` ;
18-
198test . describe . serial ( 'test' , ( ) => {
209 const blueprintName = uuidv4 ( ) ;
2110 test ( 'create blueprint' , async ( { page } ) => {
@@ -191,96 +180,12 @@ test.describe.serial('test', () => {
191180 await frame . getByRole ( 'button' , { name : 'Delete' } ) . click ( ) ;
192181 } ) ;
193182
194- test ( 'cockpit worker config' , async ( { page } ) => {
195- if ( isHosted ( ) ) {
196- return ;
197- }
198-
199- await ensureAuthenticated ( page ) ;
200- await closePopupsIfExist ( page ) ;
201- // Navigate to IB landing page and get the frame
202- await navigateToLandingPage ( page ) ;
203- await page . goto ( '/cockpit-image-builder' ) ;
204- const frame = ibFrame ( page ) ;
205-
206- const header = frame . getByText ( 'Configure AWS Uploads' ) ;
207- if ( ! ( await header . isVisible ( ) ) ) {
208- await frame
209- . getByRole ( 'button' , { name : 'Configure Cloud Providers' } )
210- . click ( ) ;
211- await expect ( header ) . toBeVisible ( ) ;
212- }
213-
214- const bucket = 'cockpit-ib-playwright-bucket' ;
215- const credentials = '/test/credentials' ;
216- const switchInput = frame . locator ( '#aws-config-switch' ) ;
217- await expect ( switchInput ) . toBeVisible ( ) ;
218-
219- // introduce a wait time, since it takes some time to load the
220- // worker config file.
221- await page . waitForTimeout ( 1000 ) ;
222-
223- // If this test fails for any reason, the config should already be loaded
224- // and visible on the retury. If it is go back to the landing page
225- if ( await switchInput . isChecked ( ) ) {
226- await frame . getByRole ( 'button' , { name : 'Cancel' } ) . click ( ) ;
227- await expect (
228- frame . getByRole ( 'heading' , { name : 'All images' } ) ,
229- ) . toBeVisible ( ) ;
230- } else {
231- const switchToggle = frame . locator ( '.pf-v6-c-switch' ) ;
232- await switchToggle . click ( ) ;
233-
234- await frame
235- . getByPlaceholder ( 'AWS bucket' )
236- // this doesn't need to exist, we're just testing that
237- // the form works as expected
238- . fill ( bucket ) ;
239- await frame . getByPlaceholder ( 'Path to AWS credentials' ) . fill ( credentials ) ;
240- await frame . getByRole ( 'button' , { name : 'Submit' } ) . click ( ) ;
241- await expect (
242- frame . getByRole ( 'heading' , { name : 'All images' } ) ,
243- ) . toBeVisible ( ) ;
244- }
245-
246- await frame
247- . getByRole ( 'button' , { name : 'Configure Cloud Providers' } )
248- . click ( ) ;
249- await expect ( header ) . toBeVisible ( ) ;
250-
251- // introduce a wait time, since it takes some time to load the
252- // worker config file.
253- await page . waitForTimeout ( 1500 ) ;
254-
255- await expect ( frame . locator ( '#aws-config-switch' ) ) . toBeChecked ( ) ;
256-
257- await expect ( frame . getByPlaceholder ( 'AWS bucket' ) ) . toHaveValue ( bucket ) ;
258- await expect ( frame . getByPlaceholder ( 'Path to AWS credentials' ) ) . toHaveValue (
259- credentials ,
260- ) ;
261- await frame . getByRole ( 'button' , { name : 'Cancel' } ) . click ( ) ;
262-
263- const config = readFileSync ( '/etc/osbuild-worker/osbuild-worker.toml' ) ;
264- // this is for testing, the field `aws` should exist
265- // eslint-disable-next-line
266- const parsed = TOML . parse ( config . toString ( ) ) as any ;
267- expect ( parsed . aws ?. bucket ) . toBe ( bucket ) ;
268- expect ( parsed . aws ?. credentials ) . toBe ( credentials ) ;
269- } ) ;
270-
271183 const cockpitBlueprintname = uuidv4 ( ) ;
272184 test ( 'cockpit cloud upload' , async ( { page } ) => {
273185 if ( isHosted ( ) ) {
274186 return ;
275187 }
276188
277- // this needs to be set so ibcli will list aws targets
278- // as an available image type
279- writeFileSync (
280- path . join ( os . homedir ( ) , '.aws' , 'credentials' ) ,
281- awsCredentials ,
282- ) ;
283-
284189 await ensureAuthenticated ( page ) ;
285190 await closePopupsIfExist ( page ) ;
286191 // Navigate to IB landing page and get the frame
@@ -296,6 +201,11 @@ test.describe.serial('test', () => {
296201 // the first card should be the AWS card
297202 await frame . locator ( '.pf-v6-c-card' ) . first ( ) . click ( ) ;
298203 await frame . getByRole ( 'button' , { name : 'Next' , exact : true } ) . click ( ) ;
204+ await frame
205+ . getByPlaceholder ( 'AWS bucket' )
206+ // this doesn't need to exist, we're just testing that
207+ // the form works as expected
208+ . fill ( 'some-random-bucket' ) ;
299209 await frame . getByRole ( 'button' , { name : 'Next' , exact : true } ) . click ( ) ;
300210 await frame . getByRole ( 'button' , { name : 'Review and finish' } ) . click ( ) ;
301211 await frame . getByRole ( 'button' , { name : 'Back' , exact : true } ) . click ( ) ;
0 commit comments