16
16
* SPDX-License-Identifier: Apache-2.0
17
17
***********************************************************************/
18
18
19
- import type { expect as playExpect , Locator , Page } from '@playwright/test' ;
19
+ import type { Locator , Page } from '@playwright/test' ;
20
+ import { expect as playExpect } from '@playwright/test' ;
20
21
21
22
import { BasePage } from '../base-page' ;
22
23
@@ -31,6 +32,7 @@ export class MachineCreationForm extends BasePage {
31
32
readonly rootPriviledgesCheckbox : Locator ;
32
33
readonly userModeNetworkingCheckbox : Locator ;
33
34
readonly startNowCheckbox : Locator ;
35
+ readonly createMachineButton : Locator ;
34
36
35
37
constructor ( page : Page ) {
36
38
super ( page ) ;
@@ -50,30 +52,31 @@ export class MachineCreationForm extends BasePage {
50
52
name : 'User mode networking' ,
51
53
} ) ;
52
54
this . startNowCheckbox = this . podmanMachineConfiguration . getByRole ( 'checkbox' , { name : 'Start the machine now' } ) ;
55
+ this . createMachineButton = this . podmanMachineConfiguration . getByRole ( 'button' , { name : 'Create' } ) ;
53
56
}
54
57
55
- async configureMachine (
58
+ async setupAndCreateMachine (
56
59
machineName : string ,
57
- isRootful : boolean = true ,
58
- enableUserNet : boolean = false ,
59
- startNow : boolean = true ,
60
+ isRootful : boolean ,
61
+ enableUserNet : boolean ,
62
+ startNow : boolean ,
60
63
) : Promise < void > {
61
- await playExpect ( this . podmanMachineConfiguration ) . toBeVisible ( ) ;
64
+ await playExpect ( this . podmanMachineConfiguration ) . toBeVisible ( { timeout : 10_000 } ) ;
65
+ await this . podmanMachineName . clear ( ) ;
62
66
await this . podmanMachineName . fill ( machineName ) ;
63
67
64
- if ( isRootful !== ( await this . rootPriviledgesCheckbox . isChecked ( ) ) ) {
65
- await this . rootPriviledgesCheckbox . locator ( '..' ) . click ( ) ;
66
- playExpect ( await this . rootPriviledgesCheckbox . isChecked ( ) ) . toBe ( isRootful ) ;
67
- }
68
+ await this . ensureCheckboxState ( isRootful , this . rootPriviledgesCheckbox ) ;
69
+ await this . ensureCheckboxState ( enableUserNet , this . userModeNetworkingCheckbox ) ;
70
+ await this . ensureCheckboxState ( startNow , this . startNowCheckbox ) ;
68
71
69
- if ( enableUserNet !== ( await this . userModeNetworkingCheckbox . isChecked ( ) ) ) {
70
- await this . userModeNetworkingCheckbox . locator ( '..' ) . click ( ) ;
71
- playExpect ( await this . userModeNetworkingCheckbox . isChecked ( ) ) . toBe ( enableUserNet ) ;
72
- }
72
+ await playExpect ( this . createMachineButton ) . toBeEnabled ( ) ;
73
+ await this . createMachineButton . click ( ) ;
74
+ }
73
75
74
- if ( startNow !== ( await this . startNowCheckbox . isChecked ( ) ) ) {
75
- await this . startNowCheckbox . locator ( '..' ) . click ( ) ;
76
- playExpect ( await this . startNowCheckbox . isChecked ( ) ) . toBe ( startNow ) ;
76
+ async ensureCheckboxState ( desiredState : boolean , checkbox : Locator ) : Promise < void > {
77
+ if ( desiredState !== ( await checkbox . isChecked ( ) ) ) {
78
+ await checkbox . locator ( '..' ) . click ( ) ;
79
+ playExpect ( await checkbox . isChecked ( ) ) . toBe ( desiredState ) ;
77
80
}
78
81
}
79
82
}
0 commit comments