|
| 1 | +import { Common } from '../utils/common'; |
| 2 | + |
| 3 | +describe('self-service Login', () => { |
| 4 | + it('Sign In to self-service', { retries: 2 }, () => { |
| 5 | + Common.LogintoAAP(); |
| 6 | + }); |
| 7 | +}); |
| 8 | + |
| 9 | +describe('Execution Environment Tabview Tests', () => { |
| 10 | + beforeEach(() => { |
| 11 | + // Navigate to EE tab page and wait for it to load |
| 12 | + cy.visit('/self-service/ee'); |
| 13 | + cy.wait(2000); |
| 14 | + |
| 15 | + cy.url({ timeout: 15000 }).should('include', '/self-service/ee'); |
| 16 | + cy.get('main', { timeout: 15000 }).should('be.visible'); |
| 17 | + }); |
| 18 | + |
| 19 | + it('Validates Catalog and Create tabs are visible and switchable', () => { |
| 20 | + cy.get('body').then($body => { |
| 21 | + // Catalog tab |
| 22 | + if ($body.text().includes('Catalog')) { |
| 23 | + cy.contains('Catalog').should('exist'); |
| 24 | + } else { |
| 25 | + cy.log(' Catalog tab label not found'); |
| 26 | + } |
| 27 | + |
| 28 | + // Create tab |
| 29 | + if ($body.text().includes('Create')) { |
| 30 | + cy.contains('Create').should('exist'); |
| 31 | + } else { |
| 32 | + cy.log(' Create tab label not found'); |
| 33 | + } |
| 34 | + }); |
| 35 | + |
| 36 | + // Switch to Create tab and verify main remains visible |
| 37 | + cy.contains('Create').click({ force: true }); |
| 38 | + cy.wait(1000); |
| 39 | + cy.get('main', { timeout: 15000 }).should('be.visible'); |
| 40 | + |
| 41 | + // Switch back to Catalog tab and verify main remains visible |
| 42 | + cy.contains('Catalog').click({ force: true }); |
| 43 | + cy.wait(1000); |
| 44 | + cy.get('main', { timeout: 15000 }).should('be.visible'); |
| 45 | + }); |
| 46 | + |
| 47 | + it('Validates Catalog tab: empty state CTA redirects to Create tab', () => { |
| 48 | + // Ensure Catalog tab is active (it should be default, but be explicit) |
| 49 | + cy.get('body').then($body => { |
| 50 | + if ($body.text().includes('Catalog')) { |
| 51 | + cy.contains('Catalog').click({ force: true }); |
| 52 | + cy.wait(1000); |
| 53 | + } |
| 54 | + }); |
| 55 | + |
| 56 | + cy.get('main', { timeout: 15000 }).should('be.visible'); |
| 57 | + |
| 58 | + cy.get('body').then($body => { |
| 59 | + const text = $body.text(); |
| 60 | + const hasEmptyState = text.includes( |
| 61 | + 'No Execution Environment definition files, yet', |
| 62 | + ); |
| 63 | + |
| 64 | + if (!hasEmptyState) { |
| 65 | + cy.log( |
| 66 | + ' EE Catalog is not in empty state (definitions exist) - skipping empty state CTA test', |
| 67 | + ); |
| 68 | + return; |
| 69 | + } |
| 70 | + cy.contains('No Execution Environment definition files, yet').should( |
| 71 | + 'exist', |
| 72 | + ); |
| 73 | + cy.log('EE Catalog empty state detected'); |
| 74 | + |
| 75 | + // Button: "Create Execution Environment definition file" |
| 76 | + if (text.includes('Create Execution Environment definition file')) { |
| 77 | + // Element may be clipped; just ensure it exists and click forcefully |
| 78 | + cy.contains('Create Execution Environment definition file').should( |
| 79 | + 'exist', |
| 80 | + ); |
| 81 | + |
| 82 | + cy.contains('Create Execution Environment definition file').click({ |
| 83 | + force: true, |
| 84 | + }); |
| 85 | + cy.wait(2000); |
| 86 | + |
| 87 | + // Verify we are on Create tab (CreateContent) |
| 88 | + cy.get('body').then($createBody => { |
| 89 | + const createText = $createBody.text(); |
| 90 | + if (createText.includes('Create an Execution Environment')) { |
| 91 | + cy.contains('Create an Execution Environment').should('exist'); |
| 92 | + cy.log(' Empty state CTA navigated to Create tab (CreateContent)'); |
| 93 | + } else { |
| 94 | + cy.log( |
| 95 | + ' After CTA click, Create tab content text not clearly visible', |
| 96 | + ); |
| 97 | + } |
| 98 | + }); |
| 99 | + } else { |
| 100 | + cy.log( |
| 101 | + ' Empty state CTA button "Create Execution Environment definition file" not found', |
| 102 | + ); |
| 103 | + } |
| 104 | + }); |
| 105 | + }); |
| 106 | + |
| 107 | + it('Validates Create tab: Add Template button, filters and template Start button', () => { |
| 108 | + // Switch to Create tab from EE tabview |
| 109 | + cy.get('body').then($body => { |
| 110 | + if ($body.text().includes('Create')) { |
| 111 | + cy.contains('Create').click({ force: true }); |
| 112 | + cy.wait(2000); |
| 113 | + } else { |
| 114 | + cy.log(' Create tab not found on EE page'); |
| 115 | + } |
| 116 | + }); |
| 117 | + |
| 118 | + cy.get('main', { timeout: 15000 }).should('be.visible'); |
| 119 | + |
| 120 | + // Add Template button and navigation to catalog-import |
| 121 | + cy.get('body').then($body => { |
| 122 | + const hasAddTemplate = |
| 123 | + $body.find('[data-testid="add-template-button"]').length > 0 || |
| 124 | + $body.text().toLowerCase().includes('add template'); |
| 125 | + |
| 126 | + if (!hasAddTemplate) { |
| 127 | + cy.log( |
| 128 | + ' Add Template button not available on Create tab (permission or config)', |
| 129 | + ); |
| 130 | + return; |
| 131 | + } |
| 132 | + |
| 133 | + cy.log(' Add Template button found on Create tab'); |
| 134 | + |
| 135 | + if ($body.find('[data-testid="add-template-button"]').length > 0) { |
| 136 | + cy.get('[data-testid="add-template-button"]').click({ force: true }); |
| 137 | + } else { |
| 138 | + cy.contains(/add template/i).click({ force: true }); |
| 139 | + } |
| 140 | + |
| 141 | + cy.wait(3000); |
| 142 | + cy.url().then(url => { |
| 143 | + if (url.includes('/catalog-import')) { |
| 144 | + cy.log(' Navigated to catalog import from Add Template'); |
| 145 | + } else { |
| 146 | + cy.log( |
| 147 | + ` After Add Template, URL did not include /catalog-import. Current URL: ${url}`, |
| 148 | + ); |
| 149 | + } |
| 150 | + }); |
| 151 | + |
| 152 | + // Go back to EE Create tab to test filters + templates |
| 153 | + cy.visit('/self-service/ee'); |
| 154 | + cy.wait(2000); |
| 155 | + cy.contains('Create').click({ force: true }); |
| 156 | + cy.wait(2000); |
| 157 | + }); |
| 158 | + |
| 159 | + // Filters on Create tab: search input + user picker |
| 160 | + cy.get('body').then($body => { |
| 161 | + // Search bar |
| 162 | + if ($body.find('[data-testid="search-bar-container"]').length > 0) { |
| 163 | + cy.get('[data-testid="search-bar-container"]').within(() => { |
| 164 | + cy.get('input').first().as('eeSearch'); |
| 165 | + }); |
| 166 | + |
| 167 | + cy.get('@eeSearch').type('ee', { force: true }); |
| 168 | + cy.wait(1000); |
| 169 | + cy.get('@eeSearch').clear({ force: true }); |
| 170 | + cy.log(' EE Create tab search bar interaction verified'); |
| 171 | + } else { |
| 172 | + cy.log(' EE Create tab search bar container not found'); |
| 173 | + } |
| 174 | + |
| 175 | + // User filter (All/Starred) via UserListPicker |
| 176 | + const $container = $body |
| 177 | + .find('[data-testid="user-picker-container"]') |
| 178 | + .first(); |
| 179 | + |
| 180 | + if ($container.length === 0) { |
| 181 | + cy.log(' EE Create tab user picker container not found'); |
| 182 | + return; |
| 183 | + } |
| 184 | + |
| 185 | + const $buttons = $container.find('button, [role="button"]'); |
| 186 | + |
| 187 | + if ($buttons.length === 0) { |
| 188 | + cy.log( |
| 189 | + ' User picker container has no clickable buttons (no All/Starred controls visible)', |
| 190 | + ); |
| 191 | + return; |
| 192 | + } |
| 193 | + |
| 194 | + const starredButton = $buttons.filter((_, btn) => { |
| 195 | + const txt = (btn.textContent || '').toLowerCase(); |
| 196 | + const aria = (btn.getAttribute('aria-label') || '').toLowerCase(); |
| 197 | + return txt.includes('starred') || aria.includes('starred'); |
| 198 | + }); |
| 199 | + |
| 200 | + if (starredButton.length > 0) { |
| 201 | + cy.wrap(starredButton.first()).click({ force: true }); |
| 202 | + cy.wait(1000); |
| 203 | + cy.log(' Switched EE Create tab filter to Starred'); |
| 204 | + |
| 205 | + const allButton = $buttons.filter((_, btn) => { |
| 206 | + const txt = (btn.textContent || '').toLowerCase(); |
| 207 | + const aria = (btn.getAttribute('aria-label') || '').toLowerCase(); |
| 208 | + return txt.includes('all') || aria.includes('all'); |
| 209 | + }); |
| 210 | + |
| 211 | + if (allButton.length > 0) { |
| 212 | + cy.wrap(allButton.first()).click({ force: true }); |
| 213 | + cy.wait(1000); |
| 214 | + cy.log(' Switched EE Create tab filter back to All'); |
| 215 | + } |
| 216 | + } else { |
| 217 | + cy.log( |
| 218 | + ' No explicit All/Starred buttons found in user picker on Create tab', |
| 219 | + ); |
| 220 | + } |
| 221 | + }); |
| 222 | + |
| 223 | + // Template cards and Start/Create button on Create tab |
| 224 | + cy.get('body').then($body => { |
| 225 | + const hasTemplates = |
| 226 | + $body.find('[data-testid="templates-container"]').length > 0 || |
| 227 | + $body.find('.MuiCard-root, article, .template').length > 0; |
| 228 | + |
| 229 | + if (!hasTemplates) { |
| 230 | + cy.log(' No EE templates found on Create tab (empty state)'); |
| 231 | + return; |
| 232 | + } |
| 233 | + |
| 234 | + cy.log(' EE Create tab templates container/cards found'); |
| 235 | + |
| 236 | + cy.get( |
| 237 | + '[data-testid="templates-container"], .MuiCard-root, article, .template', |
| 238 | + ) |
| 239 | + .first() |
| 240 | + .then($card => { |
| 241 | + cy.wrap($card).within(() => { |
| 242 | + cy.get('button').then($buttons => { |
| 243 | + if ($buttons.length === 0) { |
| 244 | + cy.log(' No buttons found in EE template card'); |
| 245 | + return; |
| 246 | + } |
| 247 | + |
| 248 | + const startButton = $buttons.filter((_, btn) => { |
| 249 | + const txt = (btn.textContent || '').toLowerCase(); |
| 250 | + const testId = ( |
| 251 | + btn.getAttribute('data-testid') || '' |
| 252 | + ).toLowerCase(); |
| 253 | + return ( |
| 254 | + txt.includes('start') || |
| 255 | + txt.includes('create') || |
| 256 | + testId.includes('start') || |
| 257 | + testId.includes('create') |
| 258 | + ); |
| 259 | + }); |
| 260 | + |
| 261 | + if (startButton.length > 0) { |
| 262 | + cy.wrap(startButton.first()).click({ force: true }); |
| 263 | + cy.wait(2000); |
| 264 | + cy.log(' EE template Start/Create button clicked'); |
| 265 | + cy.get('main', { timeout: 15000 }).should('be.visible'); |
| 266 | + } else { |
| 267 | + cy.log( |
| 268 | + ' No explicit Start/Create button found in EE template card', |
| 269 | + ); |
| 270 | + } |
| 271 | + }); |
| 272 | + }); |
| 273 | + }); |
| 274 | + }); |
| 275 | + }); |
| 276 | + |
| 277 | + it('Validates Create tab sidebar filters: Starred, My Org All, and Tags', () => { |
| 278 | + // Switch to Create tab |
| 279 | + cy.contains('Create').click({ force: true }); |
| 280 | + cy.wait(2000); |
| 281 | + cy.get('main', { timeout: 15000 }).should('be.visible'); |
| 282 | + |
| 283 | + cy.get('body').then($body => { |
| 284 | + const text = $body.text(); |
| 285 | + |
| 286 | + // Personal -> Starred filter |
| 287 | + if (text.includes('Personal') && text.includes('Starred')) { |
| 288 | + cy.log(' Personal / Starred section found on sidebar'); |
| 289 | + cy.contains('Starred').click({ force: true }); |
| 290 | + cy.wait(1000); |
| 291 | + cy.log(' Clicked Starred filter in sidebar'); |
| 292 | + } else { |
| 293 | + cy.log(' Sidebar Personal / Starred section not found'); |
| 294 | + } |
| 295 | + |
| 296 | + // My Org -> All filter |
| 297 | + if (text.includes('My Org') && text.includes('All')) { |
| 298 | + cy.log(' My Org / All section found on sidebar'); |
| 299 | + cy.contains('All').click({ force: true }); |
| 300 | + cy.wait(1000); |
| 301 | + cy.log(' Clicked My Org All filter in sidebar'); |
| 302 | + } else { |
| 303 | + cy.log(' Sidebar My Org / All section not found'); |
| 304 | + } |
| 305 | + |
| 306 | + // Tags dropdown |
| 307 | + if (text.includes('Tags')) { |
| 308 | + cy.log(' Tags filter label found on sidebar'); |
| 309 | + cy.contains('Tags').click({ force: true }); |
| 310 | + cy.wait(1000); |
| 311 | + cy.log(' Clicked Tags filter (dropdown should open if available)'); |
| 312 | + } else { |
| 313 | + cy.log(' Tags filter label not found on sidebar'); |
| 314 | + } |
| 315 | + }); |
| 316 | + }); |
| 317 | +}); |
0 commit comments