Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,16 @@ describe('ProgressModal', () => {
});

describe('when publishing', () => {
let storeConfig;
let storeConfig, stopTask;

beforeEach(() => {
storeConfig = cloneDeep(STORE_CONFIG);
jest
.spyOn(storeConfig.modules.currentChannel.getters, 'currentChannel')
.mockReturnValue({ publishing: true });
stopTask = jest
.spyOn(storeConfig.modules.currentChannel.actions, 'stopTask')
.mockResolvedValue();
});

it('progress modal should be displayed', () => {
Expand Down Expand Up @@ -139,17 +142,17 @@ describe('ProgressModal', () => {
expect(getProgressModal(wrapper).exists()).toBe(true);
});

it('confirmation of the cancel modal should stop publishing', () => {
const cancelTaskAndClose = jest.fn();
wrapper.setMethods({ cancelTaskAndClose });
it('confirmation of the cancel modal should stop publishing and reload the page', async () => {
// open the cancel modal
getStopButton(wrapper).trigger('click');
// confirm stop publishing
getCancelModal(wrapper)
.find('form')
.trigger('submit');

expect(cancelTaskAndClose).toHaveBeenCalledTimes(1);
expect(stopTask).toHaveBeenCalledTimes(1);
await wrapper.vm.$nextTick();
expect(pageReload).toHaveBeenCalledTimes(1);
});
});

Expand Down Expand Up @@ -181,13 +184,11 @@ describe('ProgressModal', () => {
});

it('clicking on refresh button should stop publishing and reload the page', async () => {
const cancelTaskAndClose = jest.fn();
wrapper.setMethods({ cancelTaskAndClose });
getRefreshButton(wrapper).trigger('click');

expect(stopTask).toHaveBeenCalledTimes(1);
await wrapper.vm.$nextTick();

expect(cancelTaskAndClose).toHaveBeenCalledTimes(1);
expect(pageReload).toHaveBeenCalledTimes(1);
});
});

Expand Down Expand Up @@ -221,19 +222,17 @@ describe('ProgressModal', () => {
});

it('clicking on refresh button should stop publishing and reload the page', async () => {
const cancelTaskAndClose = jest.fn();
wrapper.setMethods({ cancelTaskAndClose });
getRefreshButton(wrapper).trigger('click');

expect(stopTask).toHaveBeenCalledTimes(1);
await wrapper.vm.$nextTick();

expect(cancelTaskAndClose).toHaveBeenCalledTimes(1);
expect(pageReload).toHaveBeenCalledTimes(1);
});
});
});

describe('when syncing', () => {
let propsData, storeConfig;
let propsData, storeConfig, stopTask;

beforeEach(() => {
propsData = {
Expand All @@ -243,6 +242,9 @@ describe('ProgressModal', () => {
jest
.spyOn(storeConfig.modules.currentChannel.getters, 'currentChannel')
.mockReturnValue({ publishing: false });
stopTask = jest
.spyOn(storeConfig.modules.currentChannel.actions, 'stopTask')
.mockResolvedValue();
});

it('progress modal should be displayed', () => {
Expand Down Expand Up @@ -295,8 +297,18 @@ describe('ProgressModal', () => {
expect(getProgressModal(wrapper).exists()).toBe(true);
});

// TODO @MisRob (this logic has been added in another branch)
it('confirmation of the cancel modal should stop syncing and reload the page', () => {});
it('confirmation of the cancel modal should stop syncing and reload the page', async () => {
// open the cancel modal
getStopButton(wrapper).trigger('click');
// confirm stop publishing
getCancelModal(wrapper)
.find('form')
.trigger('submit');

expect(stopTask).toHaveBeenCalledTimes(1);
await wrapper.vm.$nextTick();
expect(pageReload).toHaveBeenCalledTimes(1);
});
});

describe('errored out', () => {
Expand Down Expand Up @@ -327,13 +339,11 @@ describe('ProgressModal', () => {
});

it('clicking on refresh button should stop syncing and reload the page', async () => {
const cancelTaskAndClose = jest.fn();
wrapper.setMethods({ cancelTaskAndClose });
getRefreshButton(wrapper).trigger('click');

expect(stopTask).toHaveBeenCalledTimes(1);
await wrapper.vm.$nextTick();

expect(cancelTaskAndClose).toHaveBeenCalledTimes(1);
expect(pageReload).toHaveBeenCalledTimes(1);
});
});

Expand Down Expand Up @@ -367,13 +377,11 @@ describe('ProgressModal', () => {
});

it('clicking on refresh button should stop syncing and reload the page', async () => {
const cancelTaskAndClose = jest.fn();
wrapper.setMethods({ cancelTaskAndClose });
getRefreshButton(wrapper).trigger('click');

expect(stopTask).toHaveBeenCalledTimes(1);
await wrapper.vm.$nextTick();

expect(cancelTaskAndClose).toHaveBeenCalledTimes(1);
expect(pageReload).toHaveBeenCalledTimes(1);
});
});
});
Expand Down