diff options
Diffstat (limited to 'spec/frontend/releases/stores')
3 files changed, 51 insertions, 1 deletions
diff --git a/spec/frontend/releases/stores/modules/detail/actions_spec.js b/spec/frontend/releases/stores/modules/detail/actions_spec.js index ce3b690213c..48fba3adb24 100644 --- a/spec/frontend/releases/stores/modules/detail/actions_spec.js +++ b/spec/frontend/releases/stores/modules/detail/actions_spec.js @@ -352,6 +352,32 @@ describe('Release edit/new actions', () => { }); }); + describe('when the GraphQL returns errors as data', () => { + beforeEach(() => { + gqClient.mutate.mockResolvedValue({ data: { releaseCreate: { errors: ['Yikes!'] } } }); + }); + + it(`commits ${types.RECEIVE_SAVE_RELEASE_ERROR} with an error object`, () => { + return testAction(actions.createRelease, undefined, state, [ + { + type: types.RECEIVE_SAVE_RELEASE_ERROR, + payload: expect.any(Error), + }, + ]); + }); + + it(`shows a flash message`, () => { + return actions + .createRelease({ commit: jest.fn(), dispatch: jest.fn(), state, getters: {} }) + .then(() => { + expect(createFlash).toHaveBeenCalledTimes(1); + expect(createFlash).toHaveBeenCalledWith({ + message: 'Yikes!', + }); + }); + }); + }); + describe('when the GraphQL network request fails', () => { beforeEach(() => { gqClient.mutate.mockRejectedValue(error); diff --git a/spec/frontend/releases/stores/modules/detail/getters_spec.js b/spec/frontend/releases/stores/modules/detail/getters_spec.js index 4ac6eaebaa2..2982dc5c46c 100644 --- a/spec/frontend/releases/stores/modules/detail/getters_spec.js +++ b/spec/frontend/releases/stores/modules/detail/getters_spec.js @@ -320,7 +320,9 @@ describe('Release edit/new getters', () => { it(description, () => { const expectedVariablesObject = { input: expect.objectContaining(expectedVariables) }; - const actualVariables = getters.releaseUpdateMutatationVariables(state); + const actualVariables = getters.releaseUpdateMutatationVariables(state, { + releasedAtChanged: Object.hasOwn(state.release, 'releasedAt'), + }); expect(actualVariables).toEqual(expectedVariablesObject); }); @@ -409,4 +411,19 @@ describe('Release edit/new getters', () => { }, ); }); + + describe('releasedAtChange', () => { + it('is false if the released at date has not changed', () => { + const date = new Date(); + expect( + getters.releasedAtChanged({ originalReleasedAt: date, release: { releasedAt: date } }), + ).toBe(false); + }); + + it('is true if the date changed', () => { + const originalReleasedAt = new Date(); + const releasedAt = new Date(2022, 5, 30); + expect(getters.releasedAtChanged({ originalReleasedAt, release: { releasedAt } })).toBe(true); + }); + }); }); diff --git a/spec/frontend/releases/stores/modules/detail/mutations_spec.js b/spec/frontend/releases/stores/modules/detail/mutations_spec.js index 60b57c7a7ff..8bbf550b77d 100644 --- a/spec/frontend/releases/stores/modules/detail/mutations_spec.js +++ b/spec/frontend/releases/stores/modules/detail/mutations_spec.js @@ -36,6 +36,12 @@ describe('Release edit/new mutations', () => { }, }); }); + + it('saves the original released at date as well', () => { + mutations[types.INITIALIZE_EMPTY_RELEASE](state); + + expect(state.originalReleasedAt).toEqual(new Date()); + }); }); describe(`${types.REQUEST_RELEASE}`, () => { @@ -57,6 +63,7 @@ describe('Release edit/new mutations', () => { expect(state.release).toEqual(release); expect(state.originalRelease).toEqual(release); + expect(state.originalReleasedAt).toEqual(release.releasedAt); }); }); |