@@ -2,14 +2,23 @@ import { expect, Locator, Page } from '@playwright/test';
22
33export class FolderCreationModal {
44 private readonly modal : Locator ;
5+ private readonly page : Page ;
56 constructor ( page : Page ) {
6- this . modal = page . locator ( '#create-folder-modal' ) ;
7+ this . modal = page . locator (
8+ '.ant-modal-content:has-text("Create a new storage folder")' ,
9+ ) ;
10+ this . page = page ;
11+ }
12+
13+ async modalToBeVisible ( ) : Promise < void > {
14+ await expect ( this . modal ) . toBeVisible ( ) ;
715 }
816
917 async getFolderNameInput ( ) : Promise < Locator > {
10- const folderNameInput = this . modal
11- . locator ( 'ant-form-item-row:has-text("Folder name")' )
12- . locator ( 'input' ) ;
18+ const folderNameInput = (
19+ await this . getFormItemByLabel ( 'Folder Name' )
20+ ) . locator ( 'input' ) ;
21+
1322 await expect ( folderNameInput ) . toBeVisible ( ) ;
1423 return folderNameInput ;
1524 }
@@ -21,20 +30,152 @@ export class FolderCreationModal {
2130 }
2231
2332 async getLocationSelector ( ) : Promise < Locator > {
24- const locationSelector = this . modal
25- . locator ( 'ant-form-item-row:has-text(" Location") ')
26- . locator (
27- '.ant-form-item-control-input-content > .ant-select > .ant-select-selector' ,
28- ) ;
33+ const locationSelector = (
34+ await this . getFormItemByLabel ( ' Location')
35+ ) . locator (
36+ '.ant-form-item-control-input-content > .ant-select > .ant-select-selector' ,
37+ ) ;
2938 await expect ( locationSelector ) . toBeVisible ( ) ;
3039 return locationSelector ;
3140 }
3241
33- async getRadioByLabel ( label : string ) : Promise < Locator > {
42+ async getLocationSelectorInput ( ) : Promise < Locator > {
43+ const locationSelectorInput = ( await this . getLocationSelector ( ) ) . locator (
44+ 'input' ,
45+ ) ;
46+ await expect ( locationSelectorInput ) . toBeVisible ( ) ;
47+ return locationSelectorInput ;
48+ }
49+
50+ async fillLocationSelector ( text : string ) : Promise < void > {
51+ const locationSelectorInput = await this . getLocationSelectorInput ( ) ;
52+ await locationSelectorInput . fill ( text ) ;
53+ await expect ( locationSelectorInput ) . toHaveValue ( text ) ;
54+ }
55+
56+ async getLocationOptionContainer ( ) : Promise < Locator > {
57+ await ( await this . getLocationSelector ( ) ) . click ( ) ;
58+ const locationOptionContainer = this . page . locator ( '.ant-select-dropdown' ) ;
59+ await expect ( locationOptionContainer ) . toBeVisible ( ) ;
60+ return locationOptionContainer ;
61+ }
62+
63+ async getLocationOptionByText ( text : string ) : Promise < Locator > {
64+ const locationOptionContainer = await this . getLocationOptionContainer ( ) ;
65+ const locationOption = locationOptionContainer
66+ . getByRole ( 'option' , {
67+ name : text ,
68+ } )
69+ . first ( ) ;
70+ await expect ( locationOption ) . toBeVisible ( ) ;
71+ return locationOption ;
72+ }
73+
74+ async selectLocationOptionByText ( text : string ) : Promise < void > {
75+ const locationOption = await this . getLocationOptionByText ( text ) ;
76+ await locationOption . click ( ) ;
77+ await expect ( locationOption ) . toHaveAttribute ( 'aria-selected' , 'true' ) ;
78+ }
79+
80+ async getFormItemByLabel ( label : string ) : Promise < Locator > {
3481 const RadioContainer = this . modal . locator (
35- `ant-form-item-row:has-text("${ label } ")` ,
82+ `. ant-form-item-row:has-text("${ label } ")` ,
3683 ) ;
3784 await expect ( RadioContainer ) . toBeVisible ( ) ;
3885 return RadioContainer ;
3986 }
87+
88+ async getUsageModeFormItem ( ) : Promise < Locator > {
89+ return await this . getFormItemByLabel ( 'Usage Mode' ) ;
90+ }
91+
92+ async getTypeFormItem ( ) : Promise < Locator > {
93+ return await this . getFormItemByLabel ( 'Type' ) ;
94+ }
95+
96+ async getPermissionFormItem ( ) : Promise < Locator > {
97+ return await this . getFormItemByLabel ( 'Permission' ) ;
98+ }
99+
100+ async getProjectFormItem ( ) : Promise < Locator > {
101+ return await this . getFormItemByLabel ( 'Project' ) ;
102+ }
103+
104+ async getCloneableFormItem ( ) : Promise < Locator > {
105+ return await this . getFormItemByLabel ( 'Cloneable' ) ;
106+ }
107+
108+ async getCloneableSwitchButton ( ) : Promise < Locator > {
109+ const cloneableToggleButton = (
110+ await this . getCloneableFormItem ( )
111+ ) . getByLabel ( 'Cloneable' ) ;
112+ await expect ( cloneableToggleButton ) . toBeVisible ( ) ;
113+ return cloneableToggleButton ;
114+ }
115+
116+ async getGeneralUsageModeRadio ( ) : Promise < Locator > {
117+ const usageModeFormItem = await this . getUsageModeFormItem ( ) ;
118+ return usageModeFormItem . getByLabel ( 'General' , {
119+ exact : true ,
120+ } ) ;
121+ }
122+
123+ async getModelUsageModeRadio ( ) : Promise < Locator > {
124+ const usageModeFormItem = await this . getUsageModeFormItem ( ) ;
125+ return usageModeFormItem . getByLabel ( 'Model' , {
126+ exact : true ,
127+ } ) ;
128+ }
129+
130+ async getUserTypeRadio ( ) : Promise < Locator > {
131+ const typeFormItem = await this . getTypeFormItem ( ) ;
132+ return typeFormItem . getByLabel ( 'User' , {
133+ exact : true ,
134+ } ) ;
135+ }
136+
137+ async getProjectTypeRadio ( ) : Promise < Locator > {
138+ const typeFormItem = await this . getTypeFormItem ( ) ;
139+ return typeFormItem . getByLabel ( 'Project' , {
140+ exact : true ,
141+ } ) ;
142+ }
143+
144+ async getReadWritePermissionRadio ( ) : Promise < Locator > {
145+ const permissionFormItem = await this . getPermissionFormItem ( ) ;
146+ return permissionFormItem . getByLabel ( 'Read & Write' , {
147+ exact : true ,
148+ } ) ;
149+ }
150+
151+ async getReadOnlyPermissionRadio ( ) : Promise < Locator > {
152+ const permissionFormItem = await this . getPermissionFormItem ( ) ;
153+ return permissionFormItem . getByLabel ( 'Read Only' , {
154+ exact : true ,
155+ } ) ;
156+ }
157+
158+ async getCreateButton ( ) : Promise < Locator > {
159+ const createButton = this . modal . getByTestId ( 'create-folder-button' ) ;
160+ await expect ( createButton ) . toBeVisible ( ) ;
161+ return createButton ;
162+ }
163+
164+ async getCancelButton ( ) : Promise < Locator > {
165+ const cancelButton = this . modal . getByRole ( 'button' , {
166+ name : 'Cancel' ,
167+ exact : true ,
168+ } ) ;
169+ await expect ( cancelButton ) . toBeVisible ( ) ;
170+ return cancelButton ;
171+ }
172+
173+ async getResetButton ( ) : Promise < Locator > {
174+ const resetButton = this . modal . getByRole ( 'button' , {
175+ name : 'Reset' ,
176+ exact : true ,
177+ } ) ;
178+ await expect ( resetButton ) . toBeVisible ( ) ;
179+ return resetButton ;
180+ }
40181}
0 commit comments