Skip to content
Merged
Show file tree
Hide file tree
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 @@ -95,7 +95,7 @@
},
data() {
return {
updateDescendants: false,
updateDescendants: true,
error: '',
/**
* selectedValues is an object with the following structure:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
return {
selectedLanguage: '',
searchQuery: '',
updateDescendants: false,
updateDescendants: true,
isMultipleNodeLanguages: false,
changed: false,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,11 @@ describe('EditBooleanMapModal', () => {
expect(wrapper.find('[data-test="update-descendants-checkbox"]').exists()).toBeFalsy();
});

test('should call updateContentNode on success submit if the user does not check the update descendants checkbox', async () => {
test('should call updateContentNode on success submit if the user uncheck the update descendants checkbox', async () => {
nodes['node1'].kind = ContentKindsNames.TOPIC;

const wrapper = makeWrapper({ nodeIds: ['node1'], isDescendantsUpdatable: true });
wrapper.find('[data-test="update-descendants-checkbox"]').element.click();
await wrapper.vm.handleSave();

expect(contentNodeActions.updateContentNode).toHaveBeenCalledWith(expect.anything(), {
Expand All @@ -287,11 +288,10 @@ describe('EditBooleanMapModal', () => {
});
});

test('should call updateContentNodeDescendants on success submit if the user checks the descendants checkbox', async () => {
test('should call updateContentNodeDescendants on success submit if the user does not uncheck the update descendants checkbox', async () => {
nodes['node1'].kind = ContentKindsNames.TOPIC;

const wrapper = makeWrapper({ nodeIds: ['node1'], isDescendantsUpdatable: true });
wrapper.find('[data-test="update-descendants-checkbox"]').element.click();
await wrapper.vm.handleSave();

expect(contentNodeActions.updateContentNodeDescendants).toHaveBeenCalledWith(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ describe('EditLanguageModal', () => {
});

describe('topic nodes present', () => {
it('should display the checkbox to apply change to descendants if a topic is present', () => {
[wrapper] = makeWrapper(['test-en-topic', 'test-en-res']);
test('should display a selected checkbox to apply change to descendants if a topic is present', () => {
const [wrapper] = makeWrapper(['test-en-topic', 'test-en-res']);

expect(
wrapper.findComponent('[data-test="update-descendants-checkbox"]').exists(),
Expand All @@ -236,30 +236,33 @@ describe('EditLanguageModal', () => {
).toBeFalsy();
});

it('should call updateContentNode with the right language on success submit if the user does not check the checkbox', async () => {
[wrapper, mocks] = makeWrapper(['test-en-topic', 'test-en-res']);
test('should call updateContentNodeDescendants with the right language on success submit by default', async () => {
const [wrapper, mocks] = makeWrapper(['test-en-topic', 'test-en-res']);

await chooseLanguage(wrapper, 'es');
await wrapper.vm.handleSave();
await wrapper.vm.$nextTick();

expect(mocks.updateContentNode).toHaveBeenCalledWith({
expect(mocks.updateContentNodeDescendants).toHaveBeenCalledWith({
id: 'test-en-topic',
language: 'es',
});
});

it('should call updateContentNodeDescendants with the right language on success submit if the user checks the checkbox', async () => {
[wrapper, mocks] = makeWrapper(['test-en-topic', 'test-en-res']);
test('should call updateContentNode with the right language on success submit if the user unchecks check the checkbox', async () => {
const [wrapper, mocks] = makeWrapper(['test-en-topic', 'test-en-res']);

await chooseLanguage(wrapper, 'es');
wrapper.findComponent('[data-test="update-descendants-checkbox"]').vm.$emit('change', true);

// Uncheck the descendants checkbox
const descendantsCheckbox = wrapper.findComponent(
'[data-test="update-descendants-checkbox"]',
);
descendantsCheckbox.vm.$emit('change', false);
await wrapper.vm.$nextTick();
expect(wrapper.vm.updateDescendants).toBe(true);

await wrapper.vm.handleSave();
await wrapper.vm.$nextTick();

expect(mocks.updateContentNodeDescendants).toHaveBeenCalledWith({
expect(mocks.updateContentNode).toHaveBeenCalledWith({
id: 'test-en-topic',
language: 'es',
});
Expand Down