Skip to content

Commit

Permalink
Fxied breaking cypress test
Browse files Browse the repository at this point in the history
  • Loading branch information
goyal1092 committed Jul 10, 2023
1 parent 6f2ee69 commit aa2199f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
38 changes: 24 additions & 14 deletions __tests__/gui/tabular_comparison/tabular_comparison.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,27 @@ When('I click on add indictor', () => {

Then('I check result table', (type) => {
cy.get(`[data-testid=result-table]`).find('th').eq(0).should('have.text', 'Geography');
cy.get(`[data-testid=result-table]`).find('th').eq(1).should('have.text', 'Language most spoken at home : English');
cy.get(`[data-testid=result-table]`).find('th').eq(1).find('b').should('have.text', 'Language most spoken at home');
cy.get(`[data-testid=result-table]`).find('th').eq(1).find('[data-testid=filter-chip-0]').should('have.text', 'English');
cy.get(`[data-testid=result-table]`).find('th').eq(1).find('[data-testid=filter-chip-1]').should('have.text', '15-35 (ZA)');
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(0).find('td').eq(0).should('have.text', 'Eastern Cape');
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(0).find('td').eq(1).should('have.text', '301,909');
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(0).find('td').eq(1).should('have.text', '119,035');
})

Then('I check result table after adding second indicator', (type) => {
cy.get(`[data-testid=result-table]`).find('th').eq(0).should('have.text', 'Geography');
cy.get(`[data-testid=result-table]`).find('th').eq(1).should('have.text', 'Language most spoken at home : English');
cy.get(`[data-testid=result-table]`).find('th').eq(2).should('have.text', 'Employment status : Unemployed');
cy.get(`[data-testid=result-table]`).find('th').eq(1).find('b').should('have.text', 'Language most spoken at home');
cy.get(`[data-testid=result-table]`).find('th').eq(1).find('[data-testid=filter-chip-0]').should('have.text', 'English');
cy.get(`[data-testid=result-table]`).find('th').eq(1).find('[data-testid=filter-chip-1]').should('have.text', '15-35 (ZA)');
cy.get(`[data-testid=result-table]`).find('th').eq(2).find('b').should('have.text', 'Employment status');
cy.get(`[data-testid=result-table]`).find('th').eq(2).find('[data-testid=filter-chip-0]').should('have.text', 'Unemployed');
cy.get(`[data-testid=result-table]`).find('th').eq(2).find('[data-testid=filter-chip-1]').should('have.text', '15-35 (ZA)');
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(0).find('td').eq(0).should('have.text', 'Eastern Cape');
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(0).find('td').eq(1).should('have.text', '301,909');
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(0).find('td').eq(1).should('have.text', '119,035');
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(0).find('td').eq(1).should('have.css', 'background-color').and('eq', 'rgb(124, 162, 206)')
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(0).find('td').eq(2).should('have.text', '17.02%');
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(0).find('td').eq(2).should('have.text', '17.79%');
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(0).find('td').eq(2).should('have.css', 'background-color').and('eq', 'rgb(124, 162, 206)')
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(0).find('td').eq(2).should('have.attr', 'title').and('equal', '952,709');
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(0).find('td').eq(2).should('have.attr', 'title').and('equal', '384,780');
})

Then(/^I clear the (\w+) autocomplete field/, (type) => {
Expand All @@ -78,17 +84,21 @@ Then(/^I clear the (\w+) autocomplete field/, (type) => {

Then('I check result table after adding second geography', (type) => {
cy.get(`[data-testid=result-table]`).find('th').eq(0).should('have.text', 'Geography');
cy.get(`[data-testid=result-table]`).find('th').eq(1).should('have.text', 'Language most spoken at home : English');
cy.get(`[data-testid=result-table]`).find('th').eq(2).should('have.text', 'Employment status : Unemployed');
cy.get(`[data-testid=result-table]`).find('th').eq(1).find('b').should('have.text', 'Language most spoken at home');
cy.get(`[data-testid=result-table]`).find('th').eq(1).find('[data-testid=filter-chip-0]').should('have.text', 'English');
cy.get(`[data-testid=result-table]`).find('th').eq(1).find('[data-testid=filter-chip-1]').should('have.text', '15-35 (ZA)');
cy.get(`[data-testid=result-table]`).find('th').eq(2).find('b').should('have.text', 'Employment status');
cy.get(`[data-testid=result-table]`).find('th').eq(2).find('[data-testid=filter-chip-0]').should('have.text', 'Unemployed');
cy.get(`[data-testid=result-table]`).find('th').eq(2).find('[data-testid=filter-chip-1]').should('have.text', '15-35 (ZA)');
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(0).find('td').eq(0).should('have.text', 'Eastern Cape');
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(0).find('td').eq(1).should('have.text', '301,909');
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(0).find('td').eq(1).should('have.text', '119,035');
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(0).find('td').eq(1).should('have.css', 'background-color').and('eq', 'rgb(239, 243, 255)')
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(0).find('td').eq(2).should('have.text', '17.02%');
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(0).find('td').eq(2).should('have.text', '17.79%');
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(0).find('td').eq(2).should('have.css', 'background-color').and('eq', 'rgb(239, 243, 255)')
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(1).find('td').eq(0).should('have.text', 'Western Cape');
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(1).find('td').eq(1).should('have.text', '928,895');
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(1).find('td').eq(1).should('have.text', '372,879');
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(1).find('td').eq(1).should('have.css', 'background-color').and('eq', 'rgb(8, 81, 156)')
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(1).find('td').eq(2).should('have.text', '18.35%');
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(1).find('td').eq(2).should('have.text', '18.20%');
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(1).find('td').eq(2).should('have.css', 'background-color').and('eq', 'rgb(8, 81, 156)')
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(1).find('td').eq(2).should('have.attr', 'title').and('equal', '967,681');
cy.get(`[data-testid=result-table]`).find('tbody tr').eq(1).find('td').eq(2).should('have.attr', 'title').and('equal', '387,520');
})
8 changes: 5 additions & 3 deletions src/js/tabular_comparison/result.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,13 @@ const Result = (props) => {
<>
<b>{column.indicator}</b>
<Stack useFlexGap flexWrap="wrap" direction="row">
<CategoryChip>{getCategoryChipText(column.category)}</CategoryChip>
<CategoryChip data-testid={`filter-chip-0`}>
{getCategoryChipText(column.category)}
</CategoryChip>
{column.category !== null && column.filters.map(
(item) => {
(item, idx) => {
if (item.group.length > 0 && item.value.length > 0){
return <FilterChip>{getFilterChipText(item)}</FilterChip>
return <FilterChip data-testid={`filter-chip-${idx+1}`}>{getFilterChipText(item)}</FilterChip>
}
})
}
Expand Down

0 comments on commit aa2199f

Please sign in to comment.