1717 ***********************************************************************/
1818
1919import type { Page , Locator } from '@playwright/test' ;
20- import { BasePage , ResourcesPage , expect as playExpect } from '@podman-desktop/tests-playwright' ; ;
20+ import { BasePage , ResourcesPage , expect as playExpect } from '@podman-desktop/tests-playwright' ;
2121
2222export class CreateResourcePage extends BasePage {
23- readonly heading : Locator ;
24- readonly content : Locator ;
25- readonly logIntoSandboxButton : Locator ;
26- readonly contextName : Locator ;
27- readonly setAsCurrentContext : Locator ;
28- readonly loginCommand : Locator ;
29- readonly closeButton : Locator ;
30- readonly createButton : Locator ;
23+ readonly heading : Locator ;
24+ readonly content : Locator ;
25+ readonly logIntoSandboxButton : Locator ;
26+ readonly contextName : Locator ;
27+ readonly setAsCurrentContext : Locator ;
28+ readonly loginCommand : Locator ;
29+ readonly closeButton : Locator ;
30+ readonly createButton : Locator ;
3131
32- constructor ( page : Page ) {
33- super ( page ) ;
34- this . heading = this . page . getByRole ( 'heading' , { name : 'Create Developer Sandbox' } ) ;
35- this . content = this . page . getByRole ( 'region' , { name : 'Tab Content' } ) ;
36- this . logIntoSandboxButton = this . page . getByRole ( 'button' , { name : 'Log into Developer Sandbox' } ) ;
37- this . contextName = this . page . getByRole ( 'textbox' , { name : 'Context name' } ) ;
38- this . setAsCurrentContext = this . page . getByRole ( 'checkbox' , { name : 'Set as current context' } ) ;
39- this . loginCommand = this . page . getByRole ( 'textbox' , { name : 'Login command from Developer Console' } ) ;
40- this . closeButton = this . page . getByRole ( 'button' , { name : 'Close page' } ) ;
41- this . createButton = this . page . getByRole ( 'button' , { name : 'Create' } ) ;
42- }
32+ constructor ( page : Page ) {
33+ super ( page ) ;
34+ this . heading = this . page . getByRole ( 'heading' , { name : 'Create Developer Sandbox' } ) ;
35+ this . content = this . page . getByRole ( 'region' , { name : 'Tab Content' } ) ;
36+ this . logIntoSandboxButton = this . page . getByRole ( 'button' , { name : 'Log into Developer Sandbox' } ) ;
37+ this . contextName = this . page . getByRole ( 'textbox' , { name : 'Context name' } ) ;
38+ this . setAsCurrentContext = this . page . getByRole ( 'checkbox' , { name : 'Set as current context' } ) ;
39+ this . loginCommand = this . page . getByRole ( 'textbox' , { name : 'Login command from Developer Console' } ) ;
40+ this . closeButton = this . page . getByRole ( 'button' , { name : 'Close page' } ) ;
41+ this . createButton = this . page . getByRole ( 'button' , { name : 'Create' } ) ;
42+ }
4343
44- async createResource ( loginCommandValue : string , contextNameValue ?: string , setAsCurrentContextValue = false ) : Promise < ResourcesPage > {
45- await this . loginCommand . fill ( loginCommandValue ) ;
44+ async createResource (
45+ loginCommandValue : string ,
46+ contextNameValue ?: string ,
47+ setAsCurrentContextValue = false ,
48+ ) : Promise < ResourcesPage > {
49+ await this . loginCommand . fill ( loginCommandValue ) ;
4650
47- if ( contextNameValue ) {
48- await this . contextName . fill ( contextNameValue ) ;
49- }
51+ if ( contextNameValue ) {
52+ await this . contextName . fill ( contextNameValue ) ;
53+ }
5054
51- if ( setAsCurrentContextValue !== ( await this . setAsCurrentContext . isChecked ( ) ) ) {
52- await this . setAsCurrentContext . locator ( '..' ) . click ( ) ;
53- playExpect ( await this . setAsCurrentContext . isChecked ( ) ) . toBe ( setAsCurrentContextValue ) ;
54- }
55+ if ( setAsCurrentContextValue !== ( await this . setAsCurrentContext . isChecked ( ) ) ) {
56+ await this . setAsCurrentContext . locator ( '..' ) . click ( ) ;
57+ playExpect ( await this . setAsCurrentContext . isChecked ( ) ) . toBe ( setAsCurrentContextValue ) ;
58+ }
5559
56- const successMessage = this . page . getByText ( 'Successful operation' ) ;
57- const goToResourcesButton = this . page . getByRole ( 'button' , { name : 'Go back to resources' } ) ;
58- await playExpect ( successMessage ) . toBeVisible ( ) ;
59- await playExpect ( goToResourcesButton ) . toBeVisible ( ) ;
60+ const successMessage = this . page . getByText ( 'Successful operation' ) ;
61+ const goToResourcesButton = this . page . getByRole ( 'button' , { name : 'Go back to resources' } ) ;
62+ await playExpect ( successMessage ) . toBeVisible ( ) ;
63+ await playExpect ( goToResourcesButton ) . toBeVisible ( ) ;
6064
61- await goToResourcesButton . click ( ) ;
62- return new ResourcesPage ( this . page ) ;
63- }
64- }
65+ await goToResourcesButton . click ( ) ;
66+ return new ResourcesPage ( this . page ) ;
67+ }
68+ }
0 commit comments