-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transition start execution running (#1056)
* Add setExecutionRequsted reducer function * Include the new reducer in the saga * Add some new cluster selector functions * Dispatch execution requested with correct payload * Manage loading state executions * Navigate to correct wanda views in the fe * Add test to execution trigger component * Fix urlencode serialization * Apply eslint fixes * Use factorized/faked data in the trigger checks comp tests * Replace usingWanda by usingNewChecksEngine
- Loading branch information
Showing
19 changed files
with
281 additions
and
48 deletions.
There are no files selected for viewing
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
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
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
66 changes: 66 additions & 0 deletions
66
assets/js/components/TriggerChecksExecutionRequest/TriggerChecksExecutionRequest.test.jsx
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,66 @@ | ||
import React from 'react'; | ||
|
||
import { screen, act } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { faker } from '@faker-js/faker'; | ||
import { withState, renderWithRouter } from '@lib/test-utils'; | ||
|
||
import { clusterFactory, hostFactory } from '@lib/test-utils/factories'; | ||
|
||
import TriggerChecksExecutionRequest from './TriggerChecksExecutionRequest'; | ||
|
||
describe('TriggerChecksExecutionRequest', () => { | ||
it('should dispatch execution requested on click', async () => { | ||
const user = userEvent.setup(); | ||
const cluster1 = clusterFactory.build({ | ||
selected_checks: [faker.datatype.uuid(), faker.datatype.uuid()], | ||
}); | ||
const cluster2 = clusterFactory.build({ | ||
selected_checks: [faker.datatype.uuid(), faker.datatype.uuid()], | ||
}); | ||
const { id: clusterID1, selected_checks: clusterSelectedChecks1 } = | ||
cluster1; | ||
const { id: clusterID2 } = cluster2; | ||
|
||
const host1 = hostFactory.build({ cluster_id: clusterID1 }); | ||
const host2 = hostFactory.build({ cluster_id: clusterID1 }); | ||
const host3 = hostFactory.build({ cluster_id: clusterID2 }); | ||
const { id: hostID1 } = host1; | ||
const { id: hostID2 } = host2; | ||
|
||
const initialState = { | ||
clustersList: { | ||
clusters: [cluster1, cluster2], | ||
}, | ||
hostsList: { | ||
hosts: [host1, host2, host3], | ||
}, | ||
}; | ||
|
||
const [statefulView, store] = withState( | ||
<TriggerChecksExecutionRequest | ||
clusterId={clusterID1} | ||
usingNewChecksEngine | ||
/>, | ||
initialState | ||
); | ||
|
||
await act(async () => renderWithRouter(statefulView)); | ||
|
||
const button = screen.getByRole('button'); | ||
await user.click(button); | ||
|
||
const actions = store.getActions(); | ||
const expectedActions = [ | ||
{ | ||
type: 'EXECUTION_REQUESTED', | ||
payload: { | ||
clusterID: clusterID1, | ||
hosts: [hostID1, hostID2], | ||
checks: clusterSelectedChecks1, | ||
}, | ||
}, | ||
]; | ||
expect(actions).toEqual(expectedActions); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { urlEncode } from '.'; | ||
|
||
describe('Serialization', () => { | ||
it('should encode the given params as url', async () => { | ||
const url = urlEncode({ a: 'b', c: 'd', e: 'f' }); | ||
const expected = 'a=b&c=d&e=f'; | ||
|
||
expect(url).toEqual(expected); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export const checksSelectedAction = 'CHECKS_SELECTED'; | ||
export const CHECKS_SELECTED = 'CHECKS_SELECTED'; | ||
|
||
export const checksSelected = (selectedChecks, clusterID) => ({ | ||
type: checksSelectedAction, | ||
type: CHECKS_SELECTED, | ||
payload: { checks: selectedChecks, clusterID }, | ||
}); |
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 |
---|---|---|
@@ -1,6 +1,12 @@ | ||
export const UPDATE_LAST_EXECUTION = 'UPDATE_LAST_EXECUTION'; | ||
export const EXECUTION_REQUESTED = 'EXECUTION_REQUESTED'; | ||
|
||
export const updateLastExecution = (groupID) => ({ | ||
type: UPDATE_LAST_EXECUTION, | ||
payload: { groupID }, | ||
}); | ||
|
||
export const executionRequested = (clusterID, hosts, checks) => ({ | ||
type: EXECUTION_REQUESTED, | ||
payload: { clusterID, hosts, checks }, | ||
}); |
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
Oops, something went wrong.