Skip to content

Commit

Permalink
fix: use correct endpoint for update
Browse files Browse the repository at this point in the history
  • Loading branch information
ismay committed Aug 8, 2023
1 parent d1ecf3b commit 9a1c5c2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions cypress/integration/edit-sequence/edit-sequence/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down Expand Up @@ -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'],
Expand Down
6 changes: 5 additions & 1 deletion src/components/Forms/SequenceEditFormContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -21,6 +20,11 @@ const SequenceEditFormContainer = ({ sequence }) => {
name,
}

const [submitJobQueue] = useUpdateJobQueue({
onSuccess: redirect,
initialName: initialValues.name,
})

return (
<Form
name={sequence.name}
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/job-queues/use-update-job-queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ const createMutation = (name) => ({
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(() => {
Expand Down

0 comments on commit 9a1c5c2

Please sign in to comment.