Skip to content

Commit

Permalink
Enrich existing e2e test for the svg icon
Browse files Browse the repository at this point in the history
  • Loading branch information
EMaksy committed Jan 22, 2025
1 parent 607d218 commit d79e746
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion assets/js/common/Select/Select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export const OPTION_ALL = 'all';
const defaultOnChange = () => {};
const defaultRenderOption = (item) => item.value;

const deepCompareSelection=(optionValue, value) => isEqual(optionValue, value);
const deepCompareSelection = (optionValue, value) =>
isEqual(optionValue, value);

function Select({
optionsName,
Expand Down
15 changes: 14 additions & 1 deletion test/e2e/cypress/e2e/checks_catalog.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,15 @@ context('Checks catalog', () => {
});

describe('Filtering', () => {
const selectedIconSelector =
'.absolute.inset-y-0.right-2.end-1.flex.items-center.pl-3.text-green-600';
const filteringScenarios = [
{
selectedFilters: [
{
dropdown: 'providers-selection-dropdown',
option: 'AWS',
selectedIcon: selectedIconSelector,
},
],
expectedRequest: `${checksCatalogURL}?provider=aws`,
Expand All @@ -108,10 +111,12 @@ context('Checks catalog', () => {
{
dropdown: 'providers-selection-dropdown',
option: 'AWS',
selectedIcon: selectedIconSelector,
},
{
dropdown: 'targets-selection-dropdown',
option: 'Clusters',
selectedIcon: selectedIconSelector,
},
],
expectedRequest: `${checksCatalogURL}?provider=aws&target_type=cluster`,
Expand All @@ -121,14 +126,17 @@ context('Checks catalog', () => {
{
dropdown: 'providers-selection-dropdown',
option: 'AWS',
selectedIcon: selectedIconSelector,
},
{
dropdown: 'targets-selection-dropdown',
option: 'Clusters',
selectedIcon: selectedIconSelector,
},
{
dropdown: 'cluster-types-selection-dropdown',
option: 'HANA Scale Up Perf. Opt.',
selectedIcon: selectedIconSelector,
},
],
expectedRequest: `${checksCatalogURL}?provider=aws&target_type=cluster&cluster_type=hana_scale_up&hana_scenario=performance_optimized`,
Expand All @@ -138,14 +146,17 @@ context('Checks catalog', () => {
{
dropdown: 'providers-selection-dropdown',
option: 'AWS',
selectedIcon: selectedIconSelector,
},
{
dropdown: 'targets-selection-dropdown',
option: 'Clusters',
selectedIcon: selectedIconSelector,
},
{
dropdown: 'cluster-types-selection-dropdown',
option: 'HANA Scale Up Cost Opt.',
selectedIcon: selectedIconSelector,
},
],
expectedRequest: `${checksCatalogURL}?provider=aws&target_type=cluster&cluster_type=hana_scale_up&hana_scenario=cost_optimized`,
Expand All @@ -157,8 +168,10 @@ context('Checks catalog', () => {
cy.intercept(expectedRequest, {
body: { items: catalog },
}).as('request');
selectedFilters.forEach(({ dropdown, option }) => {
selectedFilters.forEach(({ dropdown, option, selectedIcon }) => {
cy.get(`.${dropdown}`).click();
// test if the selected item has the green SVG icon rendered which shows the current selection
cy.get(selectedIcon).should('be.visible');
cy.get(`.${dropdown}`).get('span').contains(option).click();
});
cy.wait('@request');
Expand Down

0 comments on commit d79e746

Please sign in to comment.