diff --git a/cypress/integration/edit-sequence/edit-sequence/index.js b/cypress/integration/edit-sequence/edit-sequence/index.js index 1f94077da..25f11793c 100644 --- a/cypress/integration/edit-sequence/edit-sequence/index.js +++ b/cypress/integration/edit-sequence/edit-sequence/index.js @@ -4,9 +4,9 @@ import { Given, Then } from 'cypress-cucumber-preprocessor/steps' * Local helpers */ -const saveAndExpect = (expected) => { +const saveAndExpect = (name, expected) => { cy.intercept( - { url: `**/scheduler/queues/${expected.name}`, method: 'PUT' }, + { url: `**/scheduler/queues/${name}`, method: 'PUT' }, (req) => { expect(req.body).to.deep.equal(expected) req.reply({ statusCode: 201 }) @@ -61,7 +61,7 @@ Given('the user adds jobs to the queue', () => { }) Then('the sequence is updated when the user saves the sequence', () => - saveAndExpect({ + saveAndExpect('one', { cronExpression: '0 0 * ? * *', name: 'Name', sequence: ['RWcaltWoKuN', 'p2HCjnAmSNE', 'xkxSSOLKc7X', 'RRKO5XbxBz4'], diff --git a/src/components/Forms/SequenceEditFormContainer.js b/src/components/Forms/SequenceEditFormContainer.js index c4d901178..dbd1b4a42 100644 --- a/src/components/Forms/SequenceEditFormContainer.js +++ b/src/components/Forms/SequenceEditFormContainer.js @@ -11,7 +11,6 @@ const SequenceEditFormContainer = ({ sequence }) => { const redirect = () => { history.push('/') } - const [submitJobQueue] = useUpdateJobQueue({ onSuccess: redirect }) // Create an object with only the values we want to use as initial values const { cronExpression, name } = sequence @@ -21,6 +20,11 @@ const SequenceEditFormContainer = ({ sequence }) => { name, } + const [submitJobQueue] = useUpdateJobQueue({ + onSuccess: redirect, + initialName: initialValues.name, + }) + return (
({ data: ({ queue }) => queue, }) -const useUpdateJobQueue = ({ onSuccess } = {}) => { +const useUpdateJobQueue = ({ onSuccess, initialName } = {}) => { const engine = useDataEngine() const updateJobQueue = (queue) => { - const mutation = createMutation(queue.name) + const mutation = createMutation(initialName) return engine .mutate(mutation, { variables: { queue } }) .then(() => {