Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix selected cluster type ui in Checks catalog view #3229

Merged
merged 2 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion assets/js/common/Select/Select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import { Listbox, Transition } from '@headlessui/react';
import { CheckIcon, ChevronUpDownIcon } from '@heroicons/react/20/solid';

import classNames from 'classnames';
import { find, get } from 'lodash';
import { find, get, isEqual } from 'lodash';

export const OPTION_ALL = 'all';

const defaultOnChange = () => {};
const defaultRenderOption = (item) => item.value;

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

function Select({
optionsName,
options,
Expand Down Expand Up @@ -42,6 +45,7 @@ function Select({
disabled={disabled}
value={value}
onChange={onChange}
by={deepCompareSelection}
>
<div className="relative">
<Listbox.Button
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 =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question @EMaksy :
why did you create this constant and put in all the array entries?
I mean, you could simply have the constant and use it in the test, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very fair point, when working on this first i thought the ui selector would be different, but nope.
You are right we can just test directly, will create a follow up pr

'.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
Loading