11from wait_for import wait_for
22
33from airgun .entities .base import BaseEntity
4+ from airgun .exceptions import DisabledWidgetError
45from airgun .navigation import NavigateStepWithWait as NavigateStep , navigator
6+ from airgun .views .common import TableRowKebabMenu
57from airgun .views .contentcredential import (
6- ContentCredentialCreateView ,
78 ContentCredentialEditView ,
89 ContentCredentialsTableView ,
10+ CreateContentCredentialModal ,
911 DeleteContentCredentialModal ,
1012)
1113from airgun .views .product import ProductEditView
@@ -16,15 +18,60 @@ class ContentCredentialEntity(BaseEntity):
1618 endpoint_path = '/labs/content_credentials'
1719
1820 def create (self , values ):
19- """Create new content credentials entity."""
20- raise NotImplementedError (
21- 'Content Credential create is not yet implemented in the React UI'
21+ """Create new content credentials entity via modal.
22+
23+ Args:
24+ values (dict): Should contain:
25+ - name (str): Name of the credential
26+ - content_type (str): Type - 'GPG Key' or 'Certificate'
27+ - content (str): The GPG key or certificate content
28+
29+ Raises:
30+ DisabledWidgetError: If the create button is disabled due to missing required fields
31+ """
32+ view = self .navigate_to (self , 'All' )
33+ view .create_button .click ()
34+ modal = CreateContentCredentialModal (self .browser )
35+ modal .wait_displayed ()
36+ modal .fill (
37+ {
38+ 'name_input' : values .get ('name' , '' ),
39+ 'content_type' : values .get ('content_type' , '' ),
40+ 'content_text_box' : values .get ('content' , '' ),
41+ }
42+ )
43+ if modal .create_button .disabled :
44+ raise DisabledWidgetError (
45+ 'Create button is disabled. Required fields (name and content) must be filled.'
46+ )
47+ modal .create_button .click ()
48+ wait_for (
49+ lambda : not modal .is_displayed ,
50+ timeout = 30 ,
51+ delay = 0.5 ,
52+ handle_exception = True ,
53+ message = 'Waiting for create modal to close' ,
54+ )
55+ wait_for (
56+ lambda : view .table .row (name = values ['name' ]),
57+ timeout = 30 ,
58+ delay = 0.5 ,
59+ handle_exception = True ,
60+ message = f'Waiting for credential "{ values ["name" ]} " to appear in table' ,
2261 )
2362
2463 def delete (self , entity_name ):
25- """Delete existing content credentials entity via kebab menu."""
26- view = self .navigate_to (self , 'Edit' , entity_name = entity_name )
27- view .actions .item_select ('Delete' )
64+ """Delete existing content credentials entity via table row kebab menu."""
65+ view = self .navigate_to (self , 'All' )
66+ view .search (entity_name )
67+ wait_for (
68+ lambda : view .table .row (name = entity_name ),
69+ timeout = 30 ,
70+ delay = 0.5 ,
71+ handle_exception = True ,
72+ message = f'Waiting for credential "{ entity_name } " row to appear' ,
73+ )
74+ TableRowKebabMenu (parent = view .table .row (name = entity_name )).item_select ('Delete' )
2875 modal = DeleteContentCredentialModal (self .browser )
2976 modal .wait_displayed ()
3077 modal .confirm_delete .click ()
@@ -108,18 +155,6 @@ def step(self, *args, **kwargs):
108155 self .view .menu .select ('Lab Features' , 'Content Credentials' )
109156
110157
111- @navigator .register (ContentCredentialEntity , 'New' )
112- class AddNewContentCredential (NavigateStep ):
113- """Navigate to Create Content Credential page (stub)."""
114-
115- VIEW = ContentCredentialCreateView
116-
117- def step (self , * args , ** kwargs ):
118- raise NotImplementedError (
119- 'Content Credential create is not yet implemented in the React UI'
120- )
121-
122-
123158@navigator .register (ContentCredentialEntity , 'Edit' )
124159class EditContentCredential (NavigateStep ):
125160 """Navigate to Content Credential details screen.
0 commit comments