From 159123da80a04f258c8e2c3b8af5ceca5e958f74 Mon Sep 17 00:00:00 2001 From: rohanm-crest Date: Mon, 11 Nov 2024 18:38:24 +0530 Subject: [PATCH 1/7] fix: update new data in more info in inputs --- ui/src/components/table/CustomTableControl.jsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ui/src/components/table/CustomTableControl.jsx b/ui/src/components/table/CustomTableControl.jsx index 544dd32f2..9e2c93943 100644 --- a/ui/src/components/table/CustomTableControl.jsx +++ b/ui/src/components/table/CustomTableControl.jsx @@ -27,7 +27,18 @@ class CustomTableControl extends Component { this.shouldRender = true; } - componentDidMount() { + static getDerivedStateFromProps(nextProps, prevState) { + // Update row if props.row has changed + if (nextProps.row !== prevState.row) { + return { + row: { ...nextProps.row }, + loading: false, // Set loading to false when new row data is received + }; + } + return null; + } + + async componentDidMount() { const globalConfig = getUnifiedConfigs(); this.loadCustomControl() .then(async (Control) => { From 4c09a6c0e23efc26d692fab58671fccd9eccb159 Mon Sep 17 00:00:00 2001 From: rohanm-crest Date: Tue, 12 Nov 2024 14:49:10 +0530 Subject: [PATCH 2/7] fix: data load in moreinfo with custom retain --- .../components/table/CustomTableControl.jsx | 134 ++++++++++-------- 1 file changed, 77 insertions(+), 57 deletions(-) diff --git a/ui/src/components/table/CustomTableControl.jsx b/ui/src/components/table/CustomTableControl.jsx index 9e2c93943..6ffb0d5d2 100644 --- a/ui/src/components/table/CustomTableControl.jsx +++ b/ui/src/components/table/CustomTableControl.jsx @@ -21,15 +21,17 @@ class CustomTableControl extends Component { this.state = { loading: true, row: { ...props.row }, - checkMethodIsPresent: false, - methodNotPresentError: '', + checkMethodIsPresent: false, // Flag to track if methods are available in custom control + methodNotPresentError: '', // Stores error message if a method is missing + rowUpdatedByControl: false, // Flag to track if the row was updated by custom control }; - this.shouldRender = true; + this.shouldRender = true; // Flag to control rendering logic } + // Lifecycle method that updates the component's state when props change static getDerivedStateFromProps(nextProps, prevState) { - // Update row if props.row has changed - if (nextProps.row !== prevState.row) { + // Update row data only if the row prop has changed and it wasn't updated by control itself + if (!prevState.rowUpdatedByControl && nextProps.row !== prevState.row) { return { row: { ...nextProps.row }, loading: false, // Set loading to false when new row data is received @@ -38,69 +40,32 @@ class CustomTableControl extends Component { return null; } - async componentDidMount() { - const globalConfig = getUnifiedConfigs(); - this.loadCustomControl() - .then(async (Control) => { - if (typeof Control !== 'function') { - this.setState({ - loading: false, - methodNotPresentError: 'Loaded module is not a constructor function', - }); - return; - } - this.customControl = new Control( - globalConfig, - this.props.serviceName, - this.el, - this.state.row, - this.props.field - ); - - const result = await this.callCustomMethod('getDLRows'); - try { - // check if getDLRow is exist in the custom input row file - if (result && typeof result === 'object' && !Array.isArray(result)) { - this.setState({ - row: { ...result }, - checkMethodIsPresent: true, - loading: false, - }); - } else if (result !== null) { - // check if getDLRow return invalid object - this.setState({ - loading: false, - checkMethodIsPresent: true, - methodNotPresentError: 'getDLRows method did not return a valid object', - }); - } else { - // if getDLRow is not present then check render method is present or not - this.handleNoGetDLRows(); - } - } catch (error) { - onCustomControlError({ methodName: 'getDLRows', error }); - this.handleNoGetDLRows(); - } - }) - .catch(() => - this.setState({ - loading: false, - methodNotPresentError: 'Error loading custom control', - }) - ); + // Lifecycle method called after the component has been mounted (first render) + componentDidMount() { + this.initializeCustomControl(); } shouldComponentUpdate(nextProps, nextState) { - if (this.props.row !== nextProps.row) { + // Trigger re-render if row prop or state has changed + if (this.props.row !== nextProps.row || this.state.row !== nextState.row) { return true; } + // Check if loading state is false and shouldRender flag is true to trigger re-render if (!nextState.loading && this.shouldRender) { - this.shouldRender = false; + this.shouldRender = false; // Disable further re-renders return true; } return false; } + componentDidUpdate(prevProps) { + // If the row prop has changed, re-initialize the custom control + if (prevProps.row !== this.props.row) { + this.initializeCustomControl(); + this.setState({ rowUpdatedByControl: false }); + } + } + loadCustomControl = () => new Promise((resolve, reject) => { const { type, fileName } = this.props; @@ -153,6 +118,61 @@ class CustomTableControl extends Component { })); }; + // Function to initialize the custom control, loading the module and calling methods on it + async initializeCustomControl() { + const globalConfig = getUnifiedConfigs(); + this.loadCustomControl() + .then(async (Control) => { + if (typeof Control !== 'function') { + this.setState({ + loading: false, + methodNotPresentError: 'Loaded module is not a constructor function', + }); + return; + } + + this.customControl = new Control( + globalConfig, + this.props.serviceName, + this.el, + this.state.row, + this.props.field + ); + + // Call the "getDLRows" method on the custom control instance + const result = await this.callCustomMethod('getDLRows'); + try { + if (result && typeof result === 'object' && !Array.isArray(result)) { + // If getDLRows returns a valid object, update state with new row data + this.setState({ + row: { ...result }, + checkMethodIsPresent: true, + loading: false, + rowUpdatedByControl: true, + }); + } else if (result !== null) { + // If result is not valid, show an error + this.setState({ + loading: false, + checkMethodIsPresent: true, + methodNotPresentError: 'getDLRows method did not return a valid object', + }); + } else { + this.handleNoGetDLRows(); + } + } catch (error) { + onCustomControlError({ methodName: 'getDLRows', error }); + this.handleNoGetDLRows(); + } + }) + .catch(() => + this.setState({ + loading: false, + methodNotPresentError: 'Error loading custom control', + }) + ); + } + render() { const { row, loading, checkMethodIsPresent, methodNotPresentError } = this.state; const { moreInfo } = this.props; From e22c7bd8b06fa715ed7a0ce8d5e61aade0ccd2cb Mon Sep 17 00:00:00 2001 From: rohanm-crest Date: Fri, 15 Nov 2024 12:13:25 +0530 Subject: [PATCH 3/7] test(ui): added unit test case for enable count --- .../components/table/stories/rowDataMockup.ts | 100 ++++++++++++++++++ .../table/tests/TableWrapper.test.tsx | 35 +++++- 2 files changed, 133 insertions(+), 2 deletions(-) diff --git a/ui/src/components/table/stories/rowDataMockup.ts b/ui/src/components/table/stories/rowDataMockup.ts index f36b58b08..fa52b2a25 100644 --- a/ui/src/components/table/stories/rowDataMockup.ts +++ b/ui/src/components/table/stories/rowDataMockup.ts @@ -394,6 +394,98 @@ export const ROW_DATA = [ }, ]; +export const ROW_DATA_FOR_COUNT = [ + ...ROW_DATA, + { + name: 'testsomethingelse1', + id: 'https://localhost:8000/servicesNS/nobody/Splunk_TA_UCCExample/splunk_ta_uccexample_account/testsomethingelse', + updated: '1970-01-01T00:00:00+00:00', + links: { + alternate: + '/servicesNS/nobody/Splunk_TA_UCCExample/splunk_ta_uccexample_account/testsomethingelse', + list: '/servicesNS/nobody/Splunk_TA_UCCExample/splunk_ta_uccexample_account/testsomethingelse', + edit: '/servicesNS/nobody/Splunk_TA_UCCExample/splunk_ta_uccexample_account/testsomethingelse', + remove: '/servicesNS/nobody/Splunk_TA_UCCExample/splunk_ta_uccexample_account/testsomethingelse', + }, + author: 'admin', + acl: { + app: 'Splunk_TA_UCCExample', + can_change_perms: true, + can_list: true, + can_share_app: true, + can_share_global: true, + can_share_user: true, + can_write: true, + modifiable: true, + owner: 'admin', + perms: { + read: ['*'], + write: ['admin', 'sc_admin'], + }, + removable: true, + sharing: 'global', + }, + content: { + account_multiple_select: 'two', + account_radio: '1', + auth_type: 'basic', + custom_endpoint: 'login.example.com', + disabled: true, + 'eai:acl': null, + 'eai:appName': 'Splunk_TA_UCCExample', + 'eai:userName': 'nobody', + password: '******', + custom_text: 'testsomethingelse', + token: '******', + username: 'test1', + }, + }, + { + name: 'zzzzzzzz', + id: 'https://localhost:8000/servicesNS/nobody/Splunk_TA_UCCExample/splunk_ta_uccexample_account/zzzzzzz', + updated: '1970-01-01T00:00:00+00:00', + links: { + alternate: + '/servicesNS/nobody/Splunk_TA_UCCExample/splunk_ta_uccexample_account/zzzzzzz', + list: '/servicesNS/nobody/Splunk_TA_UCCExample/splunk_ta_uccexample_account/zzzzzzz', + edit: '/servicesNS/nobody/Splunk_TA_UCCExample/splunk_ta_uccexample_account/zzzzzzz', + remove: '/servicesNS/nobody/Splunk_TA_UCCExample/splunk_ta_uccexample_account/zzzzzzz', + }, + author: 'admin', + acl: { + app: 'Splunk_TA_UCCExample', + can_change_perms: true, + can_list: true, + can_share_app: true, + can_share_global: true, + can_share_user: true, + can_write: true, + modifiable: true, + owner: 'admin', + perms: { + read: ['*'], + write: ['admin', 'sc_admin'], + }, + removable: true, + sharing: 'global', + }, + content: { + account_multiple_select: 'one', + account_radio: '1', + auth_type: 'basic', + custom_endpoint: 'login.example.com', + disabled: true, + 'eai:acl': null, + 'eai:appName': 'Splunk_TA_UCCExample', + 'eai:userName': 'nobody', + password: '******', + custom_text: '222222', + token: '******', + username: 'zzzzz', + }, + }, +]; + export const MockRowData = { links: { create: `/servicesNS/nobody/-/splunk_ta_uccexample_account/_new`, @@ -402,6 +494,14 @@ export const MockRowData = { entry: ROW_DATA, messages: [], }; +export const MockRowDataForStatusCount = { + links: { + create: `/servicesNS/nobody/-/splunk_ta_uccexample_account/_new`, + }, + updated: '2023-08-21T11:54:12+00:00', + entry: ROW_DATA_FOR_COUNT, + messages: [], +}; export const ServerHandlers = [ http.get(`/servicesNS/nobody/-/splunk_ta_uccexample_account`, () => diff --git a/ui/src/components/table/tests/TableWrapper.test.tsx b/ui/src/components/table/tests/TableWrapper.test.tsx index df1d27445..918c31ca9 100644 --- a/ui/src/components/table/tests/TableWrapper.test.tsx +++ b/ui/src/components/table/tests/TableWrapper.test.tsx @@ -3,12 +3,16 @@ import userEvent from '@testing-library/user-event'; import React from 'react'; import { http, HttpResponse } from 'msw'; import { BrowserRouter } from 'react-router-dom'; -import { MockRowData } from '../stories/rowDataMockup'; +import { MockRowData, MockRowDataForStatusCount } from '../stories/rowDataMockup'; import TableWrapper, { ITableWrapperProps } from '../TableWrapper'; import { server } from '../../../mocks/server'; import { TableContextProvider } from '../../../context/TableContext'; import { setUnifiedConfig } from '../../../util/util'; -import { getSimpleConfigWithMapping, SIMPLE_NAME_TABLE_MOCK_DATA } from '../stories/configMockups'; +import { + getSimpleConfigStylePage, + getSimpleConfigWithMapping, + SIMPLE_NAME_TABLE_MOCK_DATA, +} from '../stories/configMockups'; jest.mock('immutability-helper'); @@ -183,3 +187,30 @@ it('Correctly render status labels with mapped values', async () => { const inActiveStatusCell = within(inActiveRow).getByTestId('status'); expect(inActiveStatusCell).toHaveTextContent('Disabled Field'); }); + +it('Check inputs count is visible', async () => { + const props = { + page: 'inputs', + serviceName: 'example_input_one', + handleRequestModalOpen, + handleOpenPageStyleDialog, + displayActionBtnAllRows: false, + } satisfies ITableWrapperProps; + + server.use( + http.get('/servicesNS/nobody/-/splunk_ta_uccexample_example_input_one', () => + HttpResponse.json(MockRowDataForStatusCount) + ) + ); + + setUnifiedConfig(getSimpleConfigStylePage()); + + render( + + + , + { wrapper: BrowserRouter } + ); + const statusCount = await screen.findByText('11 Inputs (7 of 11 enabled)'); + expect(statusCount).toBeInTheDocument(); +}); From 2b5c18c3790b20f2862d6d550a2525c1bf56ffdd Mon Sep 17 00:00:00 2001 From: rohanm-crest Date: Wed, 20 Nov 2024 17:53:15 +0530 Subject: [PATCH 4/7] chore: added test --- .../components/table/stories/configMockups.ts | 8 ++++ .../table/tests/CustomTableRow.test.tsx | 42 ++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/ui/src/components/table/stories/configMockups.ts b/ui/src/components/table/stories/configMockups.ts index f92c8a354..676bf5c77 100644 --- a/ui/src/components/table/stories/configMockups.ts +++ b/ui/src/components/table/stories/configMockups.ts @@ -359,6 +359,14 @@ export const SIMPLE_TABLE_MOCK_DATA_STYLE_PAGE = { label: 'Name', field: 'name', }, + { + label: 'Status', + field: 'disabled', + mapping: { + true: 'Inactive', + false: 'Active', + }, + }, ], }, }, diff --git a/ui/src/components/table/tests/CustomTableRow.test.tsx b/ui/src/components/table/tests/CustomTableRow.test.tsx index 102e279f8..11dab8b5e 100644 --- a/ui/src/components/table/tests/CustomTableRow.test.tsx +++ b/ui/src/components/table/tests/CustomTableRow.test.tsx @@ -1,8 +1,9 @@ -import { render, screen, within } from '@testing-library/react'; +import { render, screen, waitFor, waitForElementToBeRemoved, within } from '@testing-library/react'; import React from 'react'; import { BrowserRouter } from 'react-router-dom'; import { http, HttpResponse } from 'msw'; +import userEvent from '@testing-library/user-event'; import { TableContextProvider } from '../../../context/TableContext'; import { server } from '../../../mocks/server'; import { setUnifiedConfig } from '../../../util/util'; @@ -83,3 +84,42 @@ it('Correctly render status labels with default values', async () => { const inactiveStatusCell = within(inactiveRow).getByTestId('status'); expect(inactiveStatusCell).toHaveTextContent('Inactive'); }); + +it('check status is changed in moreinfo after toggle', async () => { + // Wait for spinner to disappear + await waitForElementToBeRemoved(() => document.querySelector('[data-test="wait-spinner"]')); + + const rows = await screen.findAllByTestId('row'); + const row = rows[1]; // Selecting a specific row (1st row in the list) + + // Expand the row if not already expanded + const arrow = within(row).getByRole('cell', { name: /expandable/i }); + const isExpanded = arrow.getAttribute('aria-expanded'); + if (isExpanded === 'false') { + await userEvent.click(arrow); // Click the expand icon + } + // Wait until the row's state changes to expanded + await waitFor(() => expect(arrow.getAttribute('aria-expanded')).not.toBe('false')); + + // Wait for loading to complete if present + const loading = screen.queryByText('Loading...'); + if (loading) { + await waitForElementToBeRemoved(loading); + } + + const descriptionActive = await screen.findAllByTestId('description'); // This gets an array + expect(descriptionActive[1]).toHaveTextContent('Active'); // Check the first element for 'Active' + + // const switchContainers = screen.getAllByTestId('switch'); + const switchButtons = screen.getAllByTestId('button'); // Locate all switch buttons + + const switchButton = switchButtons[0]; // Use the first switch for demonstration + await userEvent.click(switchButton); + await waitFor(() => expect(switchButton).toHaveAttribute('aria-checked', 'false')); // Wait for toggle + + // Additional checks for terms and descriptions + const descriptionInactive = await screen.findAllByTestId('description'); // This gets an array + expect(descriptionInactive[1]).toHaveTextContent('Inactive'); // Check the first element for 'Inactive' + + // screen.debug(undefined, 70000); +}); From 898df8c64d3c4cb9f43b9a21a75741bf722abeec Mon Sep 17 00:00:00 2001 From: rohanm-crest Date: Wed, 20 Nov 2024 18:37:38 +0530 Subject: [PATCH 5/7] refactor: changes the test case for more info --- .../table/tests/CustomTableRow.test.tsx | 64 +++++++++++++------ 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/ui/src/components/table/tests/CustomTableRow.test.tsx b/ui/src/components/table/tests/CustomTableRow.test.tsx index 11dab8b5e..1963dc95e 100644 --- a/ui/src/components/table/tests/CustomTableRow.test.tsx +++ b/ui/src/components/table/tests/CustomTableRow.test.tsx @@ -14,6 +14,26 @@ import { getSimpleConfigStylePage } from '../stories/configMockups'; const handleRequestModalOpen = jest.fn(); const handleOpenPageStyleDialog = jest.fn(); +const MockRowDataTogglingResponseDisableTrue = { + entry: [{ content: { disabled: true } }], +}; + +const MockRowDataTogglingResponseDisableFalse = { + entry: [{ content: { disabled: false } }], +}; + +const serverUseDisabledForEntity = (entity: string, isDisabledTrue: boolean) => { + server.use( + http.post(`/servicesNS/nobody/-/splunk_ta_uccexample_example_input_one/${entity}`, () => + HttpResponse.json( + isDisabledTrue + ? MockRowDataTogglingResponseDisableTrue + : MockRowDataTogglingResponseDisableFalse + ) + ) + ); +}; + beforeEach(() => { const props = { page: 'inputs', @@ -85,41 +105,45 @@ it('Correctly render status labels with default values', async () => { expect(inactiveStatusCell).toHaveTextContent('Inactive'); }); -it('check status is changed in moreinfo after toggle', async () => { - // Wait for spinner to disappear +it('toggles the switch row and verifies status change in more info', async () => { + // Wait for loading spinner to disappear await waitForElementToBeRemoved(() => document.querySelector('[data-test="wait-spinner"]')); - const rows = await screen.findAllByTestId('row'); - const row = rows[1]; // Selecting a specific row (1st row in the list) + // Locate the specific row using the aria-label + const activeRowDataName = { name: MockRowData.entry[0].name }; + const selectedRow = await screen.findByLabelText(`row-${activeRowDataName?.name}`); - // Expand the row if not already expanded - const arrow = within(row).getByRole('cell', { name: /expandable/i }); + // Check if the row is collapsed and expand it if necessary + const arrow = within(selectedRow).getByRole('cell', { name: /expandable/i }); const isExpanded = arrow.getAttribute('aria-expanded'); if (isExpanded === 'false') { - await userEvent.click(arrow); // Click the expand icon + await userEvent.click(arrow); // Click the expand icon to expand the row } - // Wait until the row's state changes to expanded - await waitFor(() => expect(arrow.getAttribute('aria-expanded')).not.toBe('false')); + // Verify the row is expanded + expect(arrow).toHaveAttribute('aria-expanded', 'true'); - // Wait for loading to complete if present + // Wait for any "Loading..." indicator to disappear if it's displayed const loading = screen.queryByText('Loading...'); if (loading) { await waitForElementToBeRemoved(loading); } - const descriptionActive = await screen.findAllByTestId('description'); // This gets an array - expect(descriptionActive[1]).toHaveTextContent('Active'); // Check the first element for 'Active' + // Check that the initial status in the description is "Active" + const descriptionActive = await screen.findAllByTestId('description'); // Locate all description elements + expect(descriptionActive[1]).toHaveTextContent('Active'); // Verify the description is "Active" - // const switchContainers = screen.getAllByTestId('switch'); - const switchButtons = screen.getAllByTestId('button'); // Locate all switch buttons + // Simulate disabling the server entity + serverUseDisabledForEntity('aaaaaa', true); - const switchButton = switchButtons[0]; // Use the first switch for demonstration + // Locate the toggle switch button within the row + const switchButton = await within(selectedRow).findByRole('switch'); + // Toggle the switch await userEvent.click(switchButton); - await waitFor(() => expect(switchButton).toHaveAttribute('aria-checked', 'false')); // Wait for toggle - // Additional checks for terms and descriptions - const descriptionInactive = await screen.findAllByTestId('description'); // This gets an array - expect(descriptionInactive[1]).toHaveTextContent('Inactive'); // Check the first element for 'Inactive' + // Verify the switch's state has changed to unchecked (disabled) + await waitFor(() => expect(switchButton).toHaveAttribute('aria-checked', 'false')); - // screen.debug(undefined, 70000); + // Check that the updated status in the description is "Inactive" + const descriptionInactive = await screen.findAllByTestId('description'); + expect(descriptionInactive[1]).toHaveTextContent('Inactive'); // Verify the description is "Inactive" }); From da649c5feb14f888611d0799120f53e0f61f3cef Mon Sep 17 00:00:00 2001 From: rohanm-crest Date: Thu, 21 Nov 2024 16:25:06 +0530 Subject: [PATCH 6/7] test: refactor test case for more-info --- .../table/tests/CustomTableRow.test.tsx | 66 +------------------ .../table/tests/TableExpansionRow.test.tsx | 2 +- 2 files changed, 2 insertions(+), 66 deletions(-) diff --git a/ui/src/components/table/tests/CustomTableRow.test.tsx b/ui/src/components/table/tests/CustomTableRow.test.tsx index 1963dc95e..102e279f8 100644 --- a/ui/src/components/table/tests/CustomTableRow.test.tsx +++ b/ui/src/components/table/tests/CustomTableRow.test.tsx @@ -1,9 +1,8 @@ -import { render, screen, waitFor, waitForElementToBeRemoved, within } from '@testing-library/react'; +import { render, screen, within } from '@testing-library/react'; import React from 'react'; import { BrowserRouter } from 'react-router-dom'; import { http, HttpResponse } from 'msw'; -import userEvent from '@testing-library/user-event'; import { TableContextProvider } from '../../../context/TableContext'; import { server } from '../../../mocks/server'; import { setUnifiedConfig } from '../../../util/util'; @@ -14,26 +13,6 @@ import { getSimpleConfigStylePage } from '../stories/configMockups'; const handleRequestModalOpen = jest.fn(); const handleOpenPageStyleDialog = jest.fn(); -const MockRowDataTogglingResponseDisableTrue = { - entry: [{ content: { disabled: true } }], -}; - -const MockRowDataTogglingResponseDisableFalse = { - entry: [{ content: { disabled: false } }], -}; - -const serverUseDisabledForEntity = (entity: string, isDisabledTrue: boolean) => { - server.use( - http.post(`/servicesNS/nobody/-/splunk_ta_uccexample_example_input_one/${entity}`, () => - HttpResponse.json( - isDisabledTrue - ? MockRowDataTogglingResponseDisableTrue - : MockRowDataTogglingResponseDisableFalse - ) - ) - ); -}; - beforeEach(() => { const props = { page: 'inputs', @@ -104,46 +83,3 @@ it('Correctly render status labels with default values', async () => { const inactiveStatusCell = within(inactiveRow).getByTestId('status'); expect(inactiveStatusCell).toHaveTextContent('Inactive'); }); - -it('toggles the switch row and verifies status change in more info', async () => { - // Wait for loading spinner to disappear - await waitForElementToBeRemoved(() => document.querySelector('[data-test="wait-spinner"]')); - - // Locate the specific row using the aria-label - const activeRowDataName = { name: MockRowData.entry[0].name }; - const selectedRow = await screen.findByLabelText(`row-${activeRowDataName?.name}`); - - // Check if the row is collapsed and expand it if necessary - const arrow = within(selectedRow).getByRole('cell', { name: /expandable/i }); - const isExpanded = arrow.getAttribute('aria-expanded'); - if (isExpanded === 'false') { - await userEvent.click(arrow); // Click the expand icon to expand the row - } - // Verify the row is expanded - expect(arrow).toHaveAttribute('aria-expanded', 'true'); - - // Wait for any "Loading..." indicator to disappear if it's displayed - const loading = screen.queryByText('Loading...'); - if (loading) { - await waitForElementToBeRemoved(loading); - } - - // Check that the initial status in the description is "Active" - const descriptionActive = await screen.findAllByTestId('description'); // Locate all description elements - expect(descriptionActive[1]).toHaveTextContent('Active'); // Verify the description is "Active" - - // Simulate disabling the server entity - serverUseDisabledForEntity('aaaaaa', true); - - // Locate the toggle switch button within the row - const switchButton = await within(selectedRow).findByRole('switch'); - // Toggle the switch - await userEvent.click(switchButton); - - // Verify the switch's state has changed to unchecked (disabled) - await waitFor(() => expect(switchButton).toHaveAttribute('aria-checked', 'false')); - - // Check that the updated status in the description is "Inactive" - const descriptionInactive = await screen.findAllByTestId('description'); - expect(descriptionInactive[1]).toHaveTextContent('Inactive'); // Verify the description is "Inactive" -}); diff --git a/ui/src/components/table/tests/TableExpansionRow.test.tsx b/ui/src/components/table/tests/TableExpansionRow.test.tsx index 9fdd0ca94..0dcca8b66 100644 --- a/ui/src/components/table/tests/TableExpansionRow.test.tsx +++ b/ui/src/components/table/tests/TableExpansionRow.test.tsx @@ -119,7 +119,7 @@ async function expectIntervalInExpandedRow(inputRow: HTMLElement, expectedInterv expect(allDefinitions).toContain(`${expectedInterval} sec`); } -it.failing('should update custom Expansion Row when Input has changed', async () => { +it('should update custom Expansion Row when Input has changed', async () => { setup(); const inputRow = await screen.findByRole('row', { name: `row-${inputName}` }); From 2cf0ba71b1dd821f6509a38b535534b14f2bd84f Mon Sep 17 00:00:00 2001 From: rohanm-crest Date: Thu, 21 Nov 2024 16:28:25 +0530 Subject: [PATCH 7/7] chore: remove unwanted code --- ui/src/components/table/stories/configMockups.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/ui/src/components/table/stories/configMockups.ts b/ui/src/components/table/stories/configMockups.ts index 00f5514fb..507032372 100644 --- a/ui/src/components/table/stories/configMockups.ts +++ b/ui/src/components/table/stories/configMockups.ts @@ -359,14 +359,6 @@ export const SIMPLE_TABLE_MOCK_DATA_STYLE_PAGE = { label: 'Name', field: 'name', }, - { - label: 'Status', - field: 'disabled', - mapping: { - true: 'Inactive', - false: 'Active', - }, - }, ], }, },