Skip to content

Commit

Permalink
test: Update InventoryTable.cy.js to use new selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
gkarat committed Apr 11, 2024
1 parent 78de35c commit 2eb9ad0
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/components/InventoryTable/InventoryTable.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
CHIP,
CHIP_GROUP,
CONDITIONAL_FILTER,
PT_CONDITIONAL_FILTER_TOGGLE,
DROPDOWN_ITEM,
PAGINATION_VALUES,
PRIMARY_TOOLBAR,
Expand Down Expand Up @@ -199,15 +200,15 @@ describe('with default parameters', () => {
});

it('has correct list of default filters', () => {
cy.get(CONDITIONAL_FILTER).click();
cy.get(PT_CONDITIONAL_FILTER_TOGGLE).click();
AVAILABLE_FILTER_NAMES.forEach((filterName, index) => {
cy.get(DROPDOWN_ITEM).eq(index).should('have.text', filterName);
});
});

describe('groups filter', () => {
it('options are populated correctly', () => {
cy.get(CONDITIONAL_FILTER).click();
cy.get(PT_CONDITIONAL_FILTER_TOGGLE).click();
cy.get(DROPDOWN_ITEM).contains('Group').click();
cy.ouiaId('FilterByGroup').click();
cy.ouiaId('FilterByGroupOption').should(
Expand All @@ -219,15 +220,15 @@ describe('with default parameters', () => {
const firstGroupName = shorterGroupsFixtures.results[0].name;

it('creates a chip', () => {
cy.get(CONDITIONAL_FILTER).click();
cy.get(PT_CONDITIONAL_FILTER_TOGGLE).click();
cy.get(DROPDOWN_ITEM).contains('Group').click();
cy.ouiaId('FilterByGroup').click();
cy.ouiaId('FilterByGroupOption').eq(0).click();
hasChip('Group', firstGroupName);
});

it('triggers new request', () => {
cy.get(CONDITIONAL_FILTER).click();
cy.get(PT_CONDITIONAL_FILTER_TOGGLE).click();
cy.get(DROPDOWN_ITEM).contains('Group').click();
cy.ouiaId('FilterByGroup').click();
cy.ouiaId('FilterByGroupOption').eq(0).click();
Expand Down Expand Up @@ -255,42 +256,42 @@ describe('hiding filters', () => {
it('can hide groups filter', () => {
mountTable({ hasAccess: true, hideFilters: { hostGroupFilter: true } });
waitForTable();
cy.get(CONDITIONAL_FILTER).click();
cy.get(PT_CONDITIONAL_FILTER_TOGGLE).click();
cy.get(DROPDOWN_ITEM).should('not.contain', 'Group');
});

it('can hide name filter', () => {
mountTable({ hasAccess: true, hideFilters: { name: true } });
waitForTable();
cy.get(CONDITIONAL_FILTER).click();
cy.get(PT_CONDITIONAL_FILTER_TOGGLE).click();
cy.get(DROPDOWN_ITEM).should('not.contain', 'Name');
});

it('can hide data collector filter', () => {
mountTable({ hasAccess: true, hideFilters: { registeredWith: true } });
waitForTable();
cy.get(CONDITIONAL_FILTER).click();
cy.get(PT_CONDITIONAL_FILTER_TOGGLE).click();
cy.get(DROPDOWN_ITEM).should('not.contain', 'Data Collector');
});

it('can hide rhcd filter', () => {
mountTable({ hasAccess: true, hideFilters: { rhcdFilter: true } });
waitForTable();
cy.get(CONDITIONAL_FILTER).click();
cy.get(PT_CONDITIONAL_FILTER_TOGGLE).click();
cy.get(DROPDOWN_ITEM).should('not.contain', 'RHC status');
});

it('can hide os filter', () => {
mountTable({ hasAccess: true, hideFilters: { operatingSystem: true } });
waitForTable();
cy.get(CONDITIONAL_FILTER).click();
cy.get(PT_CONDITIONAL_FILTER_TOGGLE).click();
cy.get(DROPDOWN_ITEM).should('not.contain', 'Operating System');
});

it('can hide last seen filter', () => {
mountTable({ hasAccess: true, hideFilters: { lastSeen: true } });
waitForTable();
cy.get(CONDITIONAL_FILTER).click();
cy.get(PT_CONDITIONAL_FILTER_TOGGLE).click();
cy.get(DROPDOWN_ITEM).should('not.contain', 'Last seen');
});
});
Expand All @@ -307,22 +308,22 @@ describe('with no group filter option', () => {
});

it('no group is the first option', () => {
cy.get(CONDITIONAL_FILTER).click();
cy.get(PT_CONDITIONAL_FILTER_TOGGLE).click();
cy.get(DROPDOWN_ITEM).contains('Group').click();
cy.ouiaId('FilterByGroup').click();
cy.ouiaId('FilterByGroupOption').first().should('have.text', 'No group');
});

it('creates no group chip', () => {
cy.get(CONDITIONAL_FILTER).click();
cy.get(PT_CONDITIONAL_FILTER_TOGGLE).click();
cy.get(DROPDOWN_ITEM).contains('Group').click();
cy.ouiaId('FilterByGroup').click();
cy.ouiaId('FilterByGroupOption').eq(0).click();
hasChip('Group', 'No group');
});

it('triggers new request with empty parameter', () => {
cy.get(CONDITIONAL_FILTER).click();
cy.get(PT_CONDITIONAL_FILTER_TOGGLE).click();
cy.get(DROPDOWN_ITEM).contains('Group').click();
cy.ouiaId('FilterByGroup').click();
cy.ouiaId('FilterByGroupOption').eq(0).click();
Expand Down

0 comments on commit 2eb9ad0

Please sign in to comment.