|
| 1 | +import { apiCall } from '../utils/apiCallUtils'; |
| 2 | + |
| 3 | +import { filterByStatus } from '../utils/filterByStatusUtils'; |
| 4 | +import { filterByString } from '../utils/filterByStringUtils'; |
| 5 | +import { login } from '../utils/loginUtils'; |
| 6 | +import { pagination } from '../utils/paginationUtils'; |
| 7 | + |
| 8 | +describe('FilterComponent E2E Tests', () => { |
| 9 | + beforeEach(() => { |
| 10 | + login(); |
| 11 | + cy.waitUntilDashboardIsLoaded(); |
| 12 | + apiCall(); |
| 13 | + cy.get('[id="repositories"]').click(); |
| 14 | + |
| 15 | + // Replace with your custom wait command |
| 16 | + }); |
| 17 | + it('should work with valid value', () => { |
| 18 | + cy.get('[data-testid="search-input"]').type('repo'); |
| 19 | + cy.get('[data-testid="repository_card"]').should('exist'); |
| 20 | + cy.get('[data-testid="search-input"]').clear(); |
| 21 | + cy.get('[data-testid="search-input"]').type('random value'); |
| 22 | + cy.get('h4').contains('No Repositories found'); |
| 23 | + }); |
| 24 | + it('should apply filters where string', () => { |
| 25 | + // const columnList = ['ID', 'Name', '\]; |
| 26 | + // columnList.forEach((col) => { |
| 27 | + // filterByString(col); |
| 28 | + // }); |
| 29 | + const filterBy = ['ID', 'Name']; |
| 30 | + |
| 31 | + filterBy.forEach((item) => { |
| 32 | + const emptyText = 'No Repositories found'; |
| 33 | + cy.get('[data-testid="filter-icon"]').click(); |
| 34 | + cy.get('[data-testid="column-name-dropdown"]').select(item); |
| 35 | + cy.get('[data-testid="category-dropdown"]').select('Contains'); |
| 36 | + cy.get('[data-testid="filter-value-input"]').type('random value'); |
| 37 | + cy.checkRepoCardAndH4Visibility(emptyText); |
| 38 | + cy.get('[data-testid="filter-value-input"]').clear(); |
| 39 | + // Apply filters as needed |
| 40 | + cy.get('[data-testid="column-name-dropdown"]').select(item); |
| 41 | + cy.get('[data-testid="category-dropdown"]').select('Contains'); |
| 42 | + cy.get('[data-testid="filter-value-input"]').type('12'); |
| 43 | + cy.checkRepoCardAndH4Visibility(emptyText); |
| 44 | + cy.get('[data-testid="filter-value-input"]').clear(); |
| 45 | + |
| 46 | + cy.get('[data-testid="category-dropdown"]').select('Start With'); |
| 47 | + cy.get('[data-testid="filter-value-input"]').type('ee'); |
| 48 | + cy.checkRepoCardAndH4Visibility(emptyText); |
| 49 | + cy.get('[data-testid="filter-value-input"]').clear(); |
| 50 | + |
| 51 | + cy.get('[data-testid="category-dropdown"]').select('End With'); |
| 52 | + cy.get('[data-testid="filter-value-input"]').type('f3'); |
| 53 | + cy.checkRepoCardAndH4Visibility(emptyText); |
| 54 | + cy.get('[data-testid="filter-value-input"]').clear(); |
| 55 | + |
| 56 | + // cy.get('[data-testid="category-dropdown"]').select('Equal'); |
| 57 | + // cy.get('[data-testid="filter-value-input"]').type('1'); |
| 58 | + // cy.checkRepoCardAndH4Visibility(emptyText); |
| 59 | + // cy.get('[data-testid="filter-value-input"]').clear(); |
| 60 | + cy.get('[data-testid="filter-icon"]').click(); |
| 61 | + }); |
| 62 | + }); |
| 63 | + |
| 64 | + it('should navigate through pagination', () => { |
| 65 | + // Assuming you have a button or link for next and previous pagination |
| 66 | + // You can click these buttons to navigate through pages |
| 67 | + pagination(); // Click the "Previous" button |
| 68 | + // Add more assertions as needed |
| 69 | + }); |
| 70 | + |
| 71 | + it("should display respository's runs", () => { |
| 72 | + // cy.wait(5000); |
| 73 | + cy.waitForLoaderToDisappear(); |
| 74 | + // cy.get('table').should('exist'); |
| 75 | + |
| 76 | + // Select the first row within the table (modify the selector as needed) |
| 77 | + cy.get('[data-testid="repository_card"]') |
| 78 | + .first() // Select the first element with the data-testid |
| 79 | + .children() // Get the child elements |
| 80 | + .first() // Select the first child element |
| 81 | + .click({ force: true }); |
| 82 | + cy.get('[data-testid="run_tab"]').click(); |
| 83 | + cy.waitForLoaderToDisappear(); |
| 84 | + // cy.get('table').should('exist'); |
| 85 | + const columnList = ['Run ID', 'Run Name']; |
| 86 | + const emptyText = 'No runs'; |
| 87 | + columnList.forEach((col) => { |
| 88 | + filterByString(col, emptyText); |
| 89 | + }); |
| 90 | + filterByStatus(); |
| 91 | + }); |
| 92 | +}); |
0 commit comments