|
| 1 | +/** |
| 2 | + * Page objects for Registered Model and Model Version Details pages. |
| 3 | + * ModelVersionDetails extends RegisteredModelDetails, scoping selectors to the version details card. |
| 4 | + */ |
| 5 | + |
| 6 | +class RegisteredModelDetails { |
| 7 | + findPropertiesExpandableSection() { |
| 8 | + return cy.findByTestId('properties-expandable-section').first(); |
| 9 | + } |
| 10 | + |
| 11 | + findPropertiesTable() { |
| 12 | + return this.findPropertiesExpandableSection().findByTestId('properties-table'); |
| 13 | + } |
| 14 | + |
| 15 | + findAddPropertyButton() { |
| 16 | + return this.findPropertiesExpandableSection().findByTestId('add-property-button'); |
| 17 | + } |
| 18 | + |
| 19 | + findPropertyKeyInput() { |
| 20 | + return this.findPropertiesExpandableSection().findByTestId('add-property-key-input'); |
| 21 | + } |
| 22 | + |
| 23 | + findPropertyValueInput() { |
| 24 | + return this.findPropertiesExpandableSection().findByTestId('add-property-value-input'); |
| 25 | + } |
| 26 | + |
| 27 | + findSavePropertyButton() { |
| 28 | + return this.findPropertiesExpandableSection().findByTestId('save-edit-button-property'); |
| 29 | + } |
| 30 | + |
| 31 | + findDiscardPropertyButton() { |
| 32 | + return this.findPropertiesExpandableSection().findByTestId('discard-edit-button-property'); |
| 33 | + } |
| 34 | + |
| 35 | + // PF v6 ExpandableSection does not support data-testid on the internal toggle button; |
| 36 | + // querying by aria-expanded is the most stable alternative available. |
| 37 | + findPropertiesToggleButton() { |
| 38 | + return this.findPropertiesExpandableSection().find('button[aria-expanded]').first(); |
| 39 | + } |
| 40 | + |
| 41 | + ensurePropertiesExpanded() { |
| 42 | + this.findPropertiesToggleButton() |
| 43 | + .scrollIntoView() |
| 44 | + .then(($btn) => { |
| 45 | + if ($btn.attr('aria-expanded') === 'false') { |
| 46 | + cy.wrap($btn).click(); |
| 47 | + } |
| 48 | + }); |
| 49 | + this.findPropertiesToggleButton().should('have.attr', 'aria-expanded', 'true'); |
| 50 | + } |
| 51 | + |
| 52 | + findExpandPropertiesButton() { |
| 53 | + return this.findPropertiesExpandableSection().findByTestId('expand-control-button'); |
| 54 | + } |
| 55 | + |
| 56 | + addCustomProperty(key: string, value: string) { |
| 57 | + this.findAddPropertyButton().click(); |
| 58 | + this.findPropertyKeyInput().type(key); |
| 59 | + this.findPropertyValueInput().type(value); |
| 60 | + this.findSavePropertyButton().click(); |
| 61 | + } |
| 62 | + |
| 63 | + shouldHaveCustomProperty(key: string, value: string) { |
| 64 | + this.findPropertiesExpandableSection().within(() => { |
| 65 | + cy.contains(key).should('be.visible'); |
| 66 | + cy.contains(value).should('be.visible'); |
| 67 | + }); |
| 68 | + return this; |
| 69 | + } |
| 70 | + |
| 71 | + findLabel(labelText: string) { |
| 72 | + return cy.findByTestId('label').contains(labelText); |
| 73 | + } |
| 74 | + |
| 75 | + findLabelGroup() { |
| 76 | + return cy.findByTestId('popover-label-group'); |
| 77 | + } |
| 78 | + |
| 79 | + findModalLabelGroup() { |
| 80 | + return cy.findByTestId('modal-label-group'); |
| 81 | + } |
| 82 | + |
| 83 | + shouldHaveLabel(labelText: string) { |
| 84 | + cy.contains(labelText).should('be.visible'); |
| 85 | + return this; |
| 86 | + } |
| 87 | +} |
| 88 | + |
| 89 | +class ModelVersionDetails extends RegisteredModelDetails { |
| 90 | + findVersionDetailsCard() { |
| 91 | + return cy.findByTestId('version-details-card'); |
| 92 | + } |
| 93 | + |
| 94 | + findPropertiesExpandableSection() { |
| 95 | + return this.findVersionDetailsCard().findByTestId('properties-expandable-section'); |
| 96 | + } |
| 97 | +} |
| 98 | + |
| 99 | +export const registeredModelDetails = new RegisteredModelDetails(); |
| 100 | +export const modelVersionDetails = new ModelVersionDetails(); |
0 commit comments