Skip to content
Draft
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 @@ -98,6 +98,7 @@
id: nodeId,
title: title.trim(),
description: description.trim(),
checkComplete: true,
});
/* eslint-disable-next-line kolibri/vue-no-undefined-string-uses */
this.$store.dispatch('showSnackbarSimple', commonStrings.$tr('changesSaved'));
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ describe('EditTitleDescriptionModal', () => {
},
},
}),
propsData: {
nodeId,
},
propsData: { nodeId },
});

updateContentNode = jest.spyOn(wrapper.vm, 'updateContentNode').mockImplementation(() => {});
Expand Down Expand Up @@ -70,7 +68,8 @@ describe('EditTitleDescriptionModal', () => {
expect(updateContentNode).toHaveBeenCalledWith({
id: nodeId,
title: newTitle,
description: newDescription,
description: newDescription ?? '',
checkComplete: true,
});
});

Expand All @@ -80,11 +79,11 @@ describe('EditTitleDescriptionModal', () => {
descriptionInput.vm.$emit('input', '');

modal.vm.$emit('submit');

expect(updateContentNode).toHaveBeenCalledWith({
id: nodeId,
title: newTitle,
description: '',
checkComplete: true,
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
slider-color="primary"
>
<VTab
class="px-2"
href="#questions"
class="pa-1"
exact
@change="tab = 'questions'"
>
Expand All @@ -86,7 +87,8 @@
/>
</VTab>
<VTab
class="px-2"
href="#details"
class="pa-1"
exact
@change="tab = 'details'"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@
} from 'shared/constants';
import { constantsTranslationMixin, metadataTranslationMixin } from 'shared/mixins';
import { crossComponentTranslator } from 'shared/i18n';
import { LanguagesNames } from 'shared/leUtils/Languages';

function getValueFromResults(results) {
if (results.length === 0) {
Expand Down Expand Up @@ -715,7 +716,17 @@
},
},
role: generateGetterSetter('role_visibility'),
language: generateGetterSetter('language'),
language: {
get() {
const value = this.getValueFromNodes('language');
return value === nonUniqueValue ? LanguagesNames.MUL : value;
},
set(value) {
if (!(value === LanguagesNames.MUL && this.language === LanguagesNames.MUL)) {
this.update({ language: value });
}
},
},
accessibility: generateNestedNodesGetterSetter('accessibility_labels'),
contentLevel: generateNestedNodesGetterSetterObject('grade_levels'),
resourcesNeeded: generateNestedNodesGetterSetterObject('learner_needs'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@
<div>
<!-- Filters -->
<SearchFilterBar />
<VLayout row>
<VFlex shrink>
<SearchFilters :searchResults="nodes" />
</VFlex>

<!-- Main area with cards -->
<VFlex class="pl-4">
<KGrid>
<KGridItem
:layout4="{ span: 4 }"
:layout8="{ span: 3 }"
:layout12="{ span: 5 }"
>
<SearchFilters
style="width: 100%"
:searchResults="nodes"
/>
</KGridItem>
<KGridItem
:layout4="{ span: 4 }"
:layout8="{ span: 5 }"
:layout12="{ span: 7 }"
>
<VContainer v-if="loadFailed">
<p class="text-xs-center">
<Icon icon="error" />
Expand Down Expand Up @@ -105,8 +114,8 @@
</div>
</div>
</VContainer>
</VFlex>
</VLayout>
</KGridItem>
</KGrid>
</div>

</template>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mount } from '@vue/test-utils';
import { mount, shallowMount } from '@vue/test-utils';
import LanguageDropdown from '../LanguageDropdown.vue';
import TestForm from './TestForm.vue';
import { LanguagesList } from 'shared/leUtils/Languages';
Expand Down Expand Up @@ -61,4 +61,24 @@ describe('languageDropdown', () => {
await wrapper.vm.$nextTick();
expect(wrapper.find('.error--text').exists()).toBe(true);
});

it('returns formatted language text when native_name is present', () => {
const wrapper = shallowMount(LanguageDropdown, {
mocks: {
$tr: (key, params) => `${params.language} (${params.code})`,
},
});
const item = { native_name: 'Español,Spanish', id: 'es' };
expect(wrapper.vm.languageText(item)).toBe('Español (es)');
});

it('returns formatted language text when native_name is an empty string', () => {
const wrapper = shallowMount(LanguageDropdown, {
mocks: {
$tr: (key, params) => `${params.language} (${params.code})`,
},
});
const item = { native_name: '', id: 'de' };
expect(wrapper.vm.languageText(item)).toBe(' (de)');
});
});