-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/splunk/addonfactory-ucc-…
…generator into develop
- Loading branch information
Showing
20 changed files
with
262 additions
and
34 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...nts/CheckboxGroup/stories/__images__/CheckboxGroup-input-page-view-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...nents/CheckboxGroup/stories/__images__/CheckboxGroup-required-view-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
ui/src/components/table/stories/__images__/TableWrapper-ouath-basic-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...e/stories/__images__/TableWrapper-simple-config-with-status-mapped-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...ents/table/stories/__images__/TableWrapper-simple-table-style-page-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
172 changes: 172 additions & 0 deletions
172
ui/src/components/table/tests/TableExpansionRow.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
import { render, screen, waitFor, waitForElementToBeRemoved, within } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import React from 'react'; | ||
import { http, HttpResponse } from 'msw'; | ||
import { BrowserRouter } from 'react-router-dom'; | ||
import TableWrapper, { ITableWrapperProps } from '../TableWrapper'; | ||
import { server } from '../../../mocks/server'; | ||
import { TableContextProvider } from '../../../context/TableContext'; | ||
import { setUnifiedConfig } from '../../../util/util'; | ||
import { getSimpleConfig } from '../stories/configMockups'; | ||
import { getMockServerResponseForInput } from '../../../mocks/server-response'; | ||
import { GlobalConfig } from '../../../types/globalConfig/globalConfig'; | ||
import { getBuildDirPath } from '../../../util/script'; | ||
import mockCustomInputRow from '../../../../../tests/testdata/test_addons/package_global_config_everything/package/appserver/static/js/build/custom/custom_input_row'; | ||
|
||
const inputName = 'example_input_one'; | ||
const interval = 7766; | ||
const updatedInterval = 7788; | ||
|
||
const props = { | ||
page: 'inputs', | ||
serviceName: inputName, | ||
handleRequestModalOpen: jest.fn(), | ||
handleOpenPageStyleDialog: jest.fn(), | ||
} satisfies ITableWrapperProps; | ||
|
||
const baseConfig = getSimpleConfig(); | ||
const customRowFileName = 'CustomInputRow'; | ||
|
||
function setup() { | ||
jest.mock(`${getBuildDirPath()}/custom/${customRowFileName}.js`, () => mockCustomInputRow, { | ||
virtual: true, | ||
}); | ||
|
||
const headers = [ | ||
{ | ||
label: 'Name', | ||
field: 'name', | ||
}, | ||
{ | ||
label: 'Interval', | ||
field: 'interval', | ||
}, | ||
]; | ||
setUnifiedConfig({ | ||
...baseConfig, | ||
pages: { | ||
...baseConfig.pages, | ||
inputs: { | ||
title: inputName, | ||
services: [ | ||
{ | ||
title: inputName, | ||
name: inputName, | ||
entity: [ | ||
{ | ||
label: 'Name', | ||
field: 'name', | ||
type: 'text', | ||
}, | ||
{ | ||
label: 'Interval', | ||
field: 'interval', | ||
type: 'text', | ||
}, | ||
], | ||
}, | ||
], | ||
table: { | ||
actions: ['edit'], | ||
header: headers, | ||
moreInfo: headers, | ||
customRow: { | ||
src: customRowFileName, | ||
type: 'external', | ||
}, | ||
}, | ||
}, | ||
}, | ||
} satisfies GlobalConfig); | ||
|
||
server.use( | ||
http.get(`/servicesNS/nobody/-/splunk_ta_uccexample_${inputName}`, () => | ||
HttpResponse.json( | ||
getMockServerResponseForInput([ | ||
{ | ||
name: inputName, | ||
content: { | ||
interval, | ||
}, | ||
}, | ||
]) | ||
) | ||
) | ||
); | ||
|
||
render( | ||
<TableContextProvider> | ||
<TableWrapper {...props} /> | ||
</TableContextProvider>, | ||
{ wrapper: BrowserRouter } | ||
); | ||
} | ||
|
||
async function expectIntervalInExpandedRow(inputRow: HTMLElement, expectedInterval: number) { | ||
const arrow = within(inputRow).getByRole('cell', { name: /expandable/i }); | ||
const isExpanded = arrow.getAttribute('aria-expanded'); | ||
if (isExpanded === 'false') { | ||
await userEvent.click(arrow); | ||
} | ||
await waitFor(() => expect(arrow.getAttribute('aria-expanded')).not.toBe('false')); | ||
const loading = screen.queryByText('Loading...'); | ||
if (loading) { | ||
await waitForElementToBeRemoved(loading); | ||
} | ||
|
||
const allDefinitions = screen.getAllByRole('definition').map((el) => el.textContent); | ||
|
||
expect(allDefinitions).toContain(`${expectedInterval} sec`); | ||
} | ||
|
||
it.failing('should update custom Expansion Row when Input has changed', async () => { | ||
setup(); | ||
const inputRow = await screen.findByRole('row', { name: `row-${inputName}` }); | ||
|
||
// simulate the server response for the post request | ||
server.use( | ||
http.post( | ||
`/servicesNS/nobody/-/splunk_ta_uccexample_${inputName}/${inputName}`, | ||
async ({ request }) => { | ||
const formData = await request.formData(); | ||
const formDataObject: Record<string, string> = {}; | ||
formData.forEach((value, key) => { | ||
if (typeof value === 'string') { | ||
formDataObject[key] = value; | ||
} | ||
}); | ||
return HttpResponse.json( | ||
getMockServerResponseForInput([ | ||
{ | ||
name: inputName, | ||
content: formDataObject, | ||
}, | ||
]) | ||
); | ||
} | ||
) | ||
); | ||
|
||
await expectIntervalInExpandedRow( | ||
await screen.findByRole('row', { name: `row-${inputName}` }), | ||
interval | ||
); | ||
|
||
await userEvent.click(within(inputRow).getByRole('button', { name: /edit/i })); | ||
const dialog = await screen.findByRole('dialog'); | ||
|
||
const textBoxes = within(dialog).getAllByRole('textbox'); | ||
expect(textBoxes).toHaveLength(2); | ||
const intervalInput = textBoxes[1]; | ||
expect(intervalInput).toHaveValue(interval.toString()); | ||
await userEvent.clear(intervalInput); | ||
await userEvent.type(intervalInput, updatedInterval.toString()); | ||
await userEvent.click(screen.getByRole('button', { name: /update/i })); | ||
|
||
await screen.findByRole('cell', { name: updatedInterval.toString() }); | ||
|
||
await expectIntervalInExpandedRow( | ||
await screen.findByRole('row', { name: `row-${inputName}` }), | ||
updatedInterval | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ation/stories/__images__/ConfigurationPage-configuration-page-view-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...ration/stories/__images__/ConfigurationPage-configuration-view-add-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...c/pages/Input/stories/__images__/InputPage-input-page-expanded-row-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
ui/src/pages/Input/stories/__images__/InputPage-input-page-view-add-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
ui/src/pages/Input/stories/__images__/InputPage-input-page-view-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...es/Input/stories/__images__/InputPage-input-page-view-update-input-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...stories/__images__/GlobalConfigPlayground-global-config-playground-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.