Skip to content

Commit

Permalink
refactor(redux): sw-2353 export mount, multi-action dispatch (#1355)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcabrera authored Jul 11, 2024
1 parent c4ad94c commit bc73256
Show file tree
Hide file tree
Showing 4 changed files with 175 additions and 215 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ exports[`I18n Component should generate a predictable locale key output snapshot
},
{
"key": "curiosity-toolbar.notifications",
"match": "t('curiosity-toolbar.notifications', { context: ['export', 'completed', 'description'], count: allCompleted.length, fileName: completed?.[0]?.fileName })",
"match": "t('curiosity-toolbar.notifications', { context: ['export', 'completed', 'description'], count: completed.length, fileName: completed?.[0]?.fileName })",
},
{
"key": "curiosity-toolbar.notifications",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,84 +25,59 @@ exports[`ToolbarFieldExport Component should aggregate export status, polling st

exports[`ToolbarFieldExport Component should allow export service calls on existing exports: existingExports 1`] = `
[
{
"type": "return",
"value": undefined,
},
{
"type": "return",
"value": {
"payload": "swatch-exports-status",
"type": "@@INSIGHTS-CORE/NOTIFICATIONS/REMOVE_NOTIFICATION",
},
},
{
"type": "return",
"value": {
"payload": {
"autoDismiss": false,
"description": <div
aria-live="polite"
>
t(curiosity-toolbar.notifications_export_completed_description_existing, {"context":"pending","count":1,"completed":0,"pending":1})
<div
style={
{
"paddingTop": "0.5rem",
}
[],
[
{
"autoDismiss": false,
"description": <div
aria-live="polite"
>
t(curiosity-toolbar.notifications_export_completed_description_existing, {"context":"pending","count":1,"completed":0,"pending":1})
<div
style={
{
"paddingTop": "0.5rem",
}
}
>
<Button
autoFocus={true}
data-test="exportButtonConfirm"
onClick={[Function]}
variant="primary"
>
<Button
autoFocus={true}
data-test="exportButtonConfirm"
onClick={[Function]}
variant="primary"
>
t(curiosity-toolbar.button, {"context":"yes"})
</Button>
<Button
data-test="exportButtonCancel"
onClick={[Function]}
variant="plain"
>
t(curiosity-toolbar.button, {"context":"no"})
</Button>
</div>
</div>,
"dismissable": false,
"id": "swatch-exports-status",
"title": "t(curiosity-toolbar.notifications_export_completed_title, {"context":"existing","count":1})",
},
"type": "@@INSIGHTS-CORE/NOTIFICATIONS/ADD_NOTIFICATION",
},
},
{
"type": "return",
"value": [Function],
},
{
"type": "return",
"value": {
"type": "SET_PLATFORM_EXPORT_RESET",
t(curiosity-toolbar.button, {"context":"yes"})
</Button>
<Button
data-test="exportButtonCancel"
onClick={[Function]}
variant="plain"
>
t(curiosity-toolbar.button, {"context":"no"})
</Button>
</div>
</div>,
"dismissable": false,
"id": "swatch-exports-status",
"title": "t(curiosity-toolbar.notifications_export_completed_title, {"context":"existing","count":1})",
},
},
],
]
`;

exports[`ToolbarFieldExport Component should allow export service calls: createExport 1`] = `
[
{
"type": "return",
"value": {
"id": "mock-product-id",
"isPending": true,
"type": "SET_PLATFORM_EXPORT_STATUS",
},
},
{
"type": "return",
"value": "mock-product-id",
"value": [
{
"id": "mock-product-id",
"isPending": true,
"type": "SET_PLATFORM_EXPORT_STATUS",
},
"dispatch => Promise.resolve(dispatch(...args))",
],
},
{
"type": "return",
Expand Down Expand Up @@ -140,43 +115,24 @@ exports[`ToolbarFieldExport Component should allow service calls on user confirm

exports[`ToolbarFieldExport Component should expose an export polling status confirmation: statusConfirmation 1`] = `
[
{
"type": "return",
"value": {
"payload": "swatch-exports-individual-status",
"type": "@@INSIGHTS-CORE/NOTIFICATIONS/REMOVE_NOTIFICATION",
},
},
{
"type": "return",
"value": {
"payload": {
"description": "t(curiosity-toolbar.notifications_export_completed, {"context":"description","count":1,"fileName":"helloWorldFileName"})",
"dismissable": true,
"id": "swatch-exports-individual-status",
"title": "t(curiosity-toolbar.notifications_export_completed, {"context":"title"})",
"variant": "success",
[
[
[Function],
{
"id": "loremIpsum",
"isPending": false,
"pending": [
{
"fileName": "dolorSitFileName",
"id": "dolorSit",
},
],
"type": "SET_PLATFORM_EXPORT_STATUS",
},
"type": "@@INSIGHTS-CORE/NOTIFICATIONS/ADD_NOTIFICATION",
},
},
{
"type": "return",
"value": {
"id": "loremIpsum",
"isPending": false,
"pending": [
{
"fileName": "dolorSitFileName",
"id": "dolorSit",
},
],
"type": "SET_PLATFORM_EXPORT_STATUS",
},
},
{
"type": "return",
"value": [Function],
},
],
],
[
[Function],
],
]
`;
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('ToolbarFieldExport Component', () => {
});

await unmount();
expect(mockDispatch.mock.results).toMatchSnapshot('statusConfirmation');
expect(mockDispatch.mock.calls).toMatchSnapshot('statusConfirmation');
});

it('should allow export service calls', async () => {
Expand All @@ -70,6 +70,7 @@ describe('ToolbarFieldExport Component', () => {
it('should allow export service calls on existing exports', async () => {
const { unmount } = await renderHook((...args) => {
useExistingExports({
addNotification: mockService,
getExistingExports: mockService,
getExistingExportsStatus: mockService,
deleteExistingExports: mockService,
Expand All @@ -82,7 +83,7 @@ describe('ToolbarFieldExport Component', () => {
});

await unmount();
expect(mockDispatch.mock.results).toMatchSnapshot('existingExports');
expect(mockService.mock.calls).toMatchSnapshot('existingExports');
});

it('should allow service calls on user confirmation', async () => {
Expand Down
Loading

0 comments on commit bc73256

Please sign in to comment.