|
| 1 | +/** |
| 2 | + * Copyright 2026 GitProxy Contributors |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +describe('Tag Push Functionality', () => { |
| 18 | + beforeEach(() => { |
| 19 | + cy.login('admin', 'admin'); |
| 20 | + cy.on('uncaught:exception', () => false); |
| 21 | + |
| 22 | + // Create test data for tag pushes |
| 23 | + cy.createTestTagPush(); |
| 24 | + }); |
| 25 | + |
| 26 | + describe('Tag Push Display in PushesTable', () => { |
| 27 | + it('can navigate to push dashboard and view push table', () => { |
| 28 | + cy.visit('/dashboard/push'); |
| 29 | + |
| 30 | + // Wait for API call to complete |
| 31 | + cy.wait('@getPushes'); |
| 32 | + |
| 33 | + // Check that we can see the basic table structure |
| 34 | + cy.get('table', { timeout: 10000 }).should('exist'); |
| 35 | + cy.get('thead').should('exist'); |
| 36 | + cy.get('tbody').should('exist'); |
| 37 | + |
| 38 | + // Now we should have test data, so we can check for rows |
| 39 | + cy.get('tbody tr').should('have.length.at.least', 1); |
| 40 | + |
| 41 | + // Check the structure of the first row |
| 42 | + cy.get('tbody tr') |
| 43 | + .first() |
| 44 | + .within(() => { |
| 45 | + cy.get('td').should('have.length.at.least', 6); // We know there are multiple columns |
| 46 | + // Check for tag-specific content |
| 47 | + cy.contains('v1.0.0').should('exist'); // Tag name |
| 48 | + cy.contains('test-tagger').should('exist'); // Tagger |
| 49 | + }); |
| 50 | + }); |
| 51 | + |
| 52 | + it('has search functionality', () => { |
| 53 | + cy.visit('/dashboard/push'); |
| 54 | + cy.wait('@getPushes'); |
| 55 | + |
| 56 | + // Check search input exists |
| 57 | + cy.get('input[type="text"]').first().should('exist'); |
| 58 | + |
| 59 | + // Test searching for tag name |
| 60 | + cy.get('input[type="text"]').first().type('v1.0.0'); |
| 61 | + cy.get('tbody tr').should('have.length.at.least', 1); |
| 62 | + }); |
| 63 | + |
| 64 | + it('can interact with push table entries', () => { |
| 65 | + cy.visit('/dashboard/push'); |
| 66 | + cy.wait('@getPushes'); |
| 67 | + |
| 68 | + cy.get('tbody tr').should('have.length.at.least', 1); |
| 69 | + |
| 70 | + // Check for clickable elements in the first row |
| 71 | + cy.get('tbody tr') |
| 72 | + .first() |
| 73 | + .within(() => { |
| 74 | + // Should have links and buttons |
| 75 | + cy.get('a').should('have.length.at.least', 1); // Repository links, etc. |
| 76 | + cy.get('button').should('have.length.at.least', 1); // Action button |
| 77 | + }); |
| 78 | + }); |
| 79 | + }); |
| 80 | + |
| 81 | + describe('Tag Push Details Page', () => { |
| 82 | + it('can access push details page structure', () => { |
| 83 | + // Try to access a push details page directly |
| 84 | + cy.visit('/dashboard/push/test-push-id', { failOnStatusCode: false }); |
| 85 | + |
| 86 | + // Check basic page structure exists (regardless of whether push exists) |
| 87 | + cy.get('body').should('exist'); // Basic content check |
| 88 | + |
| 89 | + // If we end up redirected, that's also acceptable behavior |
| 90 | + cy.url().should('include', '/dashboard'); |
| 91 | + }); |
| 92 | + }); |
| 93 | + |
| 94 | + describe('Basic UI Navigation', () => { |
| 95 | + it('can navigate between dashboard pages', () => { |
| 96 | + cy.visit('/dashboard/push'); |
| 97 | + cy.wait('@getPushes'); |
| 98 | + cy.get('table', { timeout: 10000 }).should('exist'); |
| 99 | + |
| 100 | + // Test navigation to repo dashboard |
| 101 | + cy.visit('/dashboard/repo'); |
| 102 | + cy.get('table', { timeout: 10000 }).should('exist'); |
| 103 | + |
| 104 | + // Test navigation to user management if it exists |
| 105 | + cy.visit('/dashboard/user'); |
| 106 | + cy.get('body').should('exist'); |
| 107 | + }); |
| 108 | + }); |
| 109 | + |
| 110 | + describe('Application Robustness', () => { |
| 111 | + it('handles navigation to non-existent push gracefully', () => { |
| 112 | + // Try to visit a non-existent push detail page |
| 113 | + cy.visit('/dashboard/push/non-existent-push-id', { failOnStatusCode: false }); |
| 114 | + |
| 115 | + // Should either redirect or show error page, but not crash |
| 116 | + cy.get('body').should('exist'); |
| 117 | + }); |
| 118 | + |
| 119 | + it('maintains functionality after page refresh', () => { |
| 120 | + cy.visit('/dashboard/push'); |
| 121 | + cy.wait('@getPushes'); |
| 122 | + cy.get('table', { timeout: 10000 }).should('exist'); |
| 123 | + |
| 124 | + // Refresh the page |
| 125 | + cy.reload(); |
| 126 | + // Wait for API call again after reload |
| 127 | + cy.wait('@getPushes'); |
| 128 | + |
| 129 | + // Wait for page to reload and check basic functionality |
| 130 | + cy.get('body').should('exist'); |
| 131 | + |
| 132 | + // Give more time for table to load after refresh, or check if redirected |
| 133 | + cy.url().then((url) => { |
| 134 | + if (url.includes('/dashboard/push')) { |
| 135 | + cy.get('table', { timeout: 15000 }).should('exist'); |
| 136 | + } else { |
| 137 | + // If redirected (e.g., to login), that's also acceptable behavior |
| 138 | + cy.get('body').should('exist'); |
| 139 | + } |
| 140 | + }); |
| 141 | + }); |
| 142 | + }); |
| 143 | +}); |
0 commit comments