|
| 1 | +import { TableRow } from './components/table'; |
| 2 | + |
| 3 | +class McpDeploymentTableRow extends TableRow { |
| 4 | + findServer(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 5 | + return this.find().findByTestId('mcp-deployment-server'); |
| 6 | + } |
| 7 | + |
| 8 | + findName(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 9 | + return this.find().findByTestId('mcp-deployment-name'); |
| 10 | + } |
| 11 | + |
| 12 | + findStatusLabel(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 13 | + return this.find().findByTestId('mcp-deployment-status-label'); |
| 14 | + } |
| 15 | + |
| 16 | + findServiceViewButton(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 17 | + return this.find().findByTestId('mcp-deployment-service-view'); |
| 18 | + } |
| 19 | + |
| 20 | + findServiceUnavailable(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 21 | + return this.find().findByTestId('mcp-deployment-service-unavailable'); |
| 22 | + } |
| 23 | + |
| 24 | + findDeleteAction(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 25 | + return this.findKebabAction('Delete'); |
| 26 | + } |
| 27 | + |
| 28 | + findEditAction(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 29 | + return this.findKebabAction('Edit'); |
| 30 | + } |
| 31 | +} |
| 32 | + |
| 33 | +class McpDeployModal { |
| 34 | + findModal(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 35 | + return cy.findByTestId('mcp-deploy-modal'); |
| 36 | + } |
| 37 | + |
| 38 | + shouldBeOpen(): void { |
| 39 | + this.findModal().should('be.visible'); |
| 40 | + } |
| 41 | + |
| 42 | + shouldNotExist(): void { |
| 43 | + cy.findByTestId('mcp-deploy-modal').should('not.exist'); |
| 44 | + } |
| 45 | + |
| 46 | + findTitle(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 47 | + return this.findModal().findByTestId('mcp-deploy-modal-title'); |
| 48 | + } |
| 49 | + |
| 50 | + findNameInput(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 51 | + return this.findModal().findByTestId('mcp-deploy-name'); |
| 52 | + } |
| 53 | + |
| 54 | + findOciImageInput(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 55 | + return this.findModal().findByTestId('mcp-deploy-oci-image-input'); |
| 56 | + } |
| 57 | + |
| 58 | + findProjectSelector(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 59 | + return this.findModal().findByTestId('mcp-deploy-project-selector'); |
| 60 | + } |
| 61 | + |
| 62 | + findSubmitButton(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 63 | + return this.findModal().findByTestId('mcp-deploy-submit-button'); |
| 64 | + } |
| 65 | + |
| 66 | + findCloseButton(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 67 | + return this.findModal().findByTestId('mcp-deploy-close-button'); |
| 68 | + } |
| 69 | + |
| 70 | + findResetButton(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 71 | + return this.findModal().findByTestId('mcp-deploy-reset-button'); |
| 72 | + } |
| 73 | + |
| 74 | + findSubmitError(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 75 | + return this.findModal().findByTestId('mcp-deploy-submit-error'); |
| 76 | + } |
| 77 | + |
| 78 | + findLoadError(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 79 | + return this.findModal().findByTestId('mcp-deploy-load-error'); |
| 80 | + } |
| 81 | + |
| 82 | + findLoadingSpinner(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 83 | + return this.findModal().findByTestId('mcp-deploy-modal-spinner'); |
| 84 | + } |
| 85 | +} |
| 86 | + |
| 87 | +class McpServerDetailsPage { |
| 88 | + findDeployButton(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 89 | + return cy.findByTestId('mcp-deploy-button'); |
| 90 | + } |
| 91 | + |
| 92 | + findBreadcrumbServerName(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 93 | + return cy.findByTestId('breadcrumb-server-name'); |
| 94 | + } |
| 95 | + |
| 96 | + // PF6 Button's isLoading spinner is internal to PatternFly — no data-testid is available |
| 97 | + findDeployButtonSpinner(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 98 | + return this.findDeployButton().find('[role="progressbar"]'); |
| 99 | + } |
| 100 | +} |
| 101 | + |
| 102 | +class McpDeploymentsPage { |
| 103 | + findTable(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 104 | + return cy.findByTestId('mcp-deployments-table'); |
| 105 | + } |
| 106 | + |
| 107 | + findEmptyState(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 108 | + return cy.findByTestId('mcp-deployments-empty-state'); |
| 109 | + } |
| 110 | + |
| 111 | + findSelectProjectState(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 112 | + return cy.findByTestId('mcp-deployments-select-project'); |
| 113 | + } |
| 114 | + |
| 115 | + findFilterInput(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 116 | + return cy.findByTestId('mcp-deployments-filter-input'); |
| 117 | + } |
| 118 | + |
| 119 | + findTableRows(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 120 | + return this.findTable().find('[data-testid^="mcp-deployment-row-"]'); |
| 121 | + } |
| 122 | + |
| 123 | + // mod-arch-shared's ApplicationsPage uses data-id — we can't change the third-party component |
| 124 | + findLoadingState(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 125 | + return cy.get('[data-id="loading-empty-state"]'); |
| 126 | + } |
| 127 | + |
| 128 | + findLoadingSpinner(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 129 | + return this.findLoadingState().find('[role="progressbar"]'); |
| 130 | + } |
| 131 | + |
| 132 | + findErrorState(): Cypress.Chainable<JQuery<HTMLElement>> { |
| 133 | + return cy.get('[data-id="error-empty-state"]'); |
| 134 | + } |
| 135 | + |
| 136 | + getRow(name: string): McpDeploymentTableRow { |
| 137 | + return new McpDeploymentTableRow( |
| 138 | + () => |
| 139 | + cy.findByTestId(`mcp-deployment-row-${name}`) as unknown as Cypress.Chainable< |
| 140 | + JQuery<HTMLTableRowElement> |
| 141 | + >, |
| 142 | + ); |
| 143 | + } |
| 144 | +} |
| 145 | + |
| 146 | +export const mcpDeploymentsPage = new McpDeploymentsPage(); |
| 147 | +export const mcpDeployModal = new McpDeployModal(); |
| 148 | +export const mcpServerDetailsPage = new McpServerDetailsPage(); |
0 commit comments