forked from RedHatInsights/frontend-components
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Cypress): refactor after review
- Loading branch information
Showing
6 changed files
with
61 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Cypress, cy } from 'cypress'; | ||
import _ from 'lodash'; | ||
|
||
import { ROW, TABLE, TBODY, TITLE } from './selectors'; | ||
|
||
export function checkTableHeaders(expectedHeaders) { | ||
/* patternfly/react-table-4.71.16, for some reason, renders extra empty `th` container; | ||
thus, it is necessary to look at the additional `scope` attr to distinguish between visible columns | ||
*/ | ||
return cy | ||
.get('table th[scope="col"]') | ||
.then(($els) => { | ||
return _.map(Cypress.$.makeArray($els), 'innerText'); | ||
}) | ||
.should('deep.equal', expectedHeaders); | ||
} | ||
|
||
export function checkRowCounts(n, isSelectableTable = false) { | ||
return isSelectableTable ? cy.get('table').find(TBODY).should('have.length', n) : cy.get('table').find(TBODY).find(ROW).should('have.length', n); | ||
} | ||
|
||
export function columnName2UrlParam(name) { | ||
return name.toLowerCase().replace(/ /g, '_'); | ||
} | ||
|
||
export function tableIsSortedBy(columnTitle) { | ||
return cy.get('table').find(`th[data-label="${columnTitle}"]`).should('have.class', 'pf-c-table__sort pf-m-selected'); | ||
} | ||
|
||
export function checkEmptyState(title, checkIcon = false) { | ||
checkRowCounts(1); | ||
cy.get(TABLE) | ||
// @ts-ignore | ||
// NEED TO FIX type error here | ||
.ouiaId('empty-state') | ||
.should('have.length', 1) | ||
.within(() => { | ||
cy.get('.pf-c-empty-state__icon').should('have.length', checkIcon ? 1 : 0); | ||
cy.get(`h5${TITLE}`).should('have.text', title); | ||
}); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/utils/src/CypressUtils/index.ts → packages/utils/src/CypressUtils/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export * from './UIConstants'; | ||
export * from './selectors'; | ||
export * from './UIFilters'; | ||
export * from './TableUtils'; | ||
export * from './PaginationUtils'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters