@windward/core 0.13.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/bitbucket-pipelines.yml +8 -0
- package/components/Content/Blocks/UserUpload/ManageDataTableUserFiles.vue +2 -11
- package/components/Content/Blocks/Video.vue +1 -1
- package/components/Glossary/GlossaryVerification.vue +240 -0
- package/components/Navigation/Items/AskTheExpert.vue +1 -37
- package/components/Navigation/Items/GlossaryNav.vue +8 -2
- package/components/Navigation/Items/UserUploadNav.vue +10 -2
- package/components/Settings/AccordionSettings.vue +37 -27
- package/components/Settings/ClickableIconsSettings.vue +34 -7
- package/components/Settings/ImageSettings.vue +5 -12
- package/components/Settings/TabSettings.vue +33 -23
- package/components/Settings/TextEditorSettings.vue +16 -245
- package/components/Settings/VideoSettings.vue +1 -1
- package/components/utils/ContentViewer.vue +3 -3
- package/components/utils/TinyMCEWrapper.vue +24 -14
- package/components/utils/glossary/CourseGlossary.vue +66 -91
- package/components/utils/glossary/CourseGlossaryForm.vue +42 -13
- package/components/utils/glossary/GlossaryToolTip.vue +7 -11
- package/helpers/GlossaryHelper.ts +18 -16
- package/i18n/en-US/pages/glossary.ts +3 -1
- package/i18n/en-US/shared/notification.ts +5 -0
- package/i18n/en-US/shared/permission.ts +4 -0
- package/i18n/es-ES/pages/glossary.ts +3 -1
- package/i18n/es-ES/shared/notification.ts +5 -0
- package/i18n/es-ES/shared/permission.ts +8 -4
- package/i18n/sv-SE/pages/glossary.ts +3 -1
- package/i18n/sv-SE/shared/notification.ts +4 -0
- package/i18n/sv-SE/shared/permission.ts +8 -4
- package/jest.config.js +3 -0
- package/models/BaseModel.ts +16 -0
- package/models/CourseGlossaryTerm.ts +22 -0
- package/models/UserFileAsset.ts +1 -0
- package/package.json +4 -3
- package/pages/glossary.vue +11 -3
- package/pages/userUpload.vue +1 -1
- package/plugin.js +32 -22
- package/store/glossary.js +57 -0
- package/test/Components/Content/Blocks/Feedback.spec.js +3 -1
- package/test/Components/Content/Blocks/Video.spec.js +2 -2
- package/test/Components/Glossary/GlossaryVerification.spec.js +19 -0
- package/test/Components/utils/glossary/CourseGlossary.spec.js +19 -0
- package/test/Components/utils/glossary/CourseGlossaryForm.spec.js +28 -0
- package/test/__mocks__/helpersMock.js +0 -24
- package/test/__mocks__/modelMock.js +5 -0
- package/test/helpers/GlossaryHelper.spec.js +32 -14
- package/test/mocks.js +11 -0
- package/test/setup/before.js +15 -0
- package/helpers/GlossaryTerm.ts +0 -31
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
type_title: {
|
|
3
3
|
'plugin->windward->core->organization->course->user->feedback':
|
|
4
|
-
'Feedback
|
|
4
|
+
'Feedback-åtkomst för den aktuella användaren',
|
|
5
5
|
'plugin->windward->core->organization->course->user->userUpload':
|
|
6
|
-
'
|
|
6
|
+
'Användaruppladdning blockerar åtkomst för den aktuella användaren',
|
|
7
|
+
'plugin->windward->core->organization->course->glossary':
|
|
8
|
+
'Kursordlista',
|
|
7
9
|
},
|
|
8
10
|
|
|
9
11
|
type_description: {
|
|
10
12
|
'plugin->windward->core->organization->course->user->feedback':
|
|
11
|
-
'
|
|
13
|
+
'De nuvarande användarna har tillgång till feedbackblocket',
|
|
12
14
|
'plugin->windward->core->organization->course->user->userUpload':
|
|
13
|
-
'
|
|
15
|
+
'De nuvarande användarna har tillgång till användaruppladdningsblocket',
|
|
16
|
+
'plugin->windward->core->organization->course->glossary':
|
|
17
|
+
'Få tillgång till och hantera kursordlistan i den nuvarande organisationen för dina egna kurser',
|
|
14
18
|
},
|
|
15
19
|
}
|
package/jest.config.js
CHANGED
|
@@ -5,6 +5,8 @@ module.exports = {
|
|
|
5
5
|
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
|
|
6
6
|
'<rootDir>/test/__mocks__/fileMock.js',
|
|
7
7
|
'\\.(css|less)$': '<rootDir>/test/__mocks__/styleMock.js',
|
|
8
|
+
'^!raw-loader!sass-loader!(.*)$':
|
|
9
|
+
'<rootDir>/test/__mocks__/styleMock.js',
|
|
8
10
|
},
|
|
9
11
|
moduleFileExtensions: ['ts', 'js', 'vue', 'json'],
|
|
10
12
|
transform: {
|
|
@@ -12,4 +14,5 @@ module.exports = {
|
|
|
12
14
|
'^.+\\.js$': 'babel-jest',
|
|
13
15
|
'.*\\.(vue)$': 'vue-jest',
|
|
14
16
|
},
|
|
17
|
+
setupFiles: ['<rootDir>/test/setup/before.js'],
|
|
15
18
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import Model from '~/models/Model'
|
|
3
|
+
|
|
4
|
+
export default class BaseModel extends Model {
|
|
5
|
+
constructor(...args: any) {
|
|
6
|
+
if (args.length === 0) {
|
|
7
|
+
super()
|
|
8
|
+
} else {
|
|
9
|
+
super(...args)
|
|
10
|
+
|
|
11
|
+
// Constructor level checks / overrides here
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return this
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import BaseModel from './BaseModel'
|
|
3
|
+
|
|
4
|
+
export default class CourseGlossaryTerm extends BaseModel {
|
|
5
|
+
public id!: string
|
|
6
|
+
// eslint-disable-next-line camelcase
|
|
7
|
+
public course_id!: string
|
|
8
|
+
public term!: string
|
|
9
|
+
public definition!: string
|
|
10
|
+
public tags!: string
|
|
11
|
+
// eslint-disable-next-line camelcase
|
|
12
|
+
public alternate_forms!: any
|
|
13
|
+
// eslint-disable-next-line camelcase
|
|
14
|
+
public related_terms!: any
|
|
15
|
+
|
|
16
|
+
private required: string[] = ['term', 'definition']
|
|
17
|
+
|
|
18
|
+
// Set the resource route of the model
|
|
19
|
+
resource() {
|
|
20
|
+
return 'course-glossary-terms'
|
|
21
|
+
}
|
|
22
|
+
}
|
package/models/UserFileAsset.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@windward/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Windward UI Core Plugins",
|
|
5
5
|
"main": "plugin.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"homepage": "https://bitbucket.org/mindedge/windward-ui-plugin-core#readme",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@mindedge/vuetify-player": "^0.4.
|
|
24
|
+
"@mindedge/vuetify-player": "^0.4.9",
|
|
25
25
|
"@tinymce/tinymce-vue": "^3.2.8",
|
|
26
26
|
"accessibility-scanner": "^0.0.1",
|
|
27
27
|
"eslint": "^8.11.0",
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
"prettier": "^2.6.0",
|
|
33
33
|
"raw-loader": "^4.0.2",
|
|
34
34
|
"speechreader": "^1.1.5",
|
|
35
|
-
"tinymce": "^7.1.0"
|
|
35
|
+
"tinymce": "^7.1.0",
|
|
36
|
+
"vuedraggable": "^2.24.3"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"@babel/preset-env": "^7.16.11",
|
package/pages/glossary.vue
CHANGED
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
<v-row justify="center" align="center">
|
|
3
3
|
<v-col cols="12">
|
|
4
4
|
<v-alert
|
|
5
|
-
v-if="
|
|
5
|
+
v-if="
|
|
6
|
+
$PermissionService.userHasAccessTo(
|
|
7
|
+
'plugin.windward.core.organization.course.glossary',
|
|
8
|
+
'writable'
|
|
9
|
+
) && !$ContextService.courseInSourceOrganization()
|
|
10
|
+
"
|
|
6
11
|
type="warning"
|
|
7
12
|
>
|
|
8
13
|
{{ $t('shared.forms.source_organization_course_lock') }}
|
|
@@ -26,11 +31,14 @@ import { CourseGlossary } from '../utils/index'
|
|
|
26
31
|
export default {
|
|
27
32
|
name: 'Glossary',
|
|
28
33
|
components: { CourseGlossary },
|
|
29
|
-
layout: '
|
|
34
|
+
layout: 'course',
|
|
30
35
|
middleware: ['auth', 'privilege'],
|
|
31
36
|
meta: {
|
|
32
37
|
privilege: {
|
|
33
|
-
'windward.organization.course.
|
|
38
|
+
'windward.organization.course.content': {
|
|
39
|
+
readable: true,
|
|
40
|
+
},
|
|
41
|
+
'plugin.windward.core.organization.course.glossary': {
|
|
34
42
|
readable: true,
|
|
35
43
|
},
|
|
36
44
|
},
|
package/pages/userUpload.vue
CHANGED
|
@@ -59,7 +59,7 @@ export default {
|
|
|
59
59
|
name: 'PluginUserUploadPage',
|
|
60
60
|
middleware: ['auth', 'privilege'],
|
|
61
61
|
components: { CourseSectionSwitch, ManageDataTableUserFiles },
|
|
62
|
-
layout: '
|
|
62
|
+
layout: 'course',
|
|
63
63
|
meta: {
|
|
64
64
|
privilege: {
|
|
65
65
|
'windward.organization.course.section.user': {
|
package/plugin.js
CHANGED
|
@@ -3,7 +3,6 @@ import locales from './i18n'
|
|
|
3
3
|
// Content Blocks
|
|
4
4
|
import Video from './components/Content/Blocks/Video'
|
|
5
5
|
import Tab from './components/Content/Blocks/Tab'
|
|
6
|
-
import Math from './components/Content/Blocks/Math'
|
|
7
6
|
import MathExpressionEditor from './components/utils/MathExpressionEditor'
|
|
8
7
|
import Accordion from './components/Content/Blocks/Accordion'
|
|
9
8
|
import Feedback from './components/Content/Blocks/Feedback.vue'
|
|
@@ -47,29 +46,37 @@ import HorizontalRuleSettings from './components/Settings/HorizontalRuleSettings
|
|
|
47
46
|
import UserUploadPage from './pages/userUpload.vue'
|
|
48
47
|
import GlossaryToolTip from './components/utils/glossary/GlossaryToolTip.vue'
|
|
49
48
|
import TextEditorSettings from './components/Settings/TextEditorSettings.vue'
|
|
50
|
-
import MathSettings from './components/Settings/MathSettings.vue'
|
|
51
49
|
import FillInTheBlanks from './components/utils/FillInBlank/FillInTheBlanksManager.vue'
|
|
52
50
|
import FillInBlankInput from './components/utils/FillInBlank/FillInBlankInput.vue'
|
|
53
51
|
|
|
52
|
+
import GlossaryStore from './store/glossary.js'
|
|
53
|
+
|
|
54
54
|
export default {
|
|
55
55
|
name: 'windward.core.name',
|
|
56
56
|
version: null,
|
|
57
57
|
hooks: {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
'clear:context': (app) => {
|
|
59
|
+
app.store.dispatch('glossary/clear')
|
|
60
|
+
},
|
|
61
|
+
'load:context': (app, context) => {
|
|
62
|
+
// If the context switched to a course then load the glossary terms
|
|
63
|
+
if (
|
|
64
|
+
context === 'course' &&
|
|
65
|
+
app.store.getters['course/get'] &&
|
|
66
|
+
app.store.getters['course/get'].id
|
|
67
|
+
) {
|
|
68
|
+
app.store.dispatch(
|
|
69
|
+
'glossary/load',
|
|
70
|
+
app.store.getters['course/get']
|
|
71
|
+
)
|
|
72
|
+
}
|
|
61
73
|
},
|
|
62
|
-
beforeDestroy: () => {},
|
|
63
|
-
beforeNavigate: () => {},
|
|
64
|
-
onNavigate: () => {},
|
|
65
|
-
onLoad: (page) => {},
|
|
66
|
-
onContent: () => {},
|
|
67
74
|
},
|
|
68
75
|
i18n: locales.messages,
|
|
69
76
|
pages: [
|
|
70
77
|
{
|
|
71
78
|
page: 'user-uploads',
|
|
72
|
-
path: '/course/:course/user-uploads',
|
|
79
|
+
path: '/course/:course/section/:section/user-uploads',
|
|
73
80
|
i18n: 'menu.user-upload',
|
|
74
81
|
icon: 'mdi-cloud-upload',
|
|
75
82
|
name: 'PluginUserUploadPage',
|
|
@@ -77,7 +84,7 @@ export default {
|
|
|
77
84
|
},
|
|
78
85
|
{
|
|
79
86
|
page: 'glossary',
|
|
80
|
-
path: '/course/:course/glossary',
|
|
87
|
+
path: '/course/:course/section/:section/glossary',
|
|
81
88
|
i18n: 'windward.core.shared.menu.course_glossary',
|
|
82
89
|
icon: 'mdi-comment-text-multiple',
|
|
83
90
|
name: 'CourseGlossaryPage',
|
|
@@ -119,7 +126,7 @@ export default {
|
|
|
119
126
|
display: ['menu'],
|
|
120
127
|
permissions: {
|
|
121
128
|
'windward.organization.course.file': {
|
|
122
|
-
|
|
129
|
+
writable: true,
|
|
123
130
|
},
|
|
124
131
|
},
|
|
125
132
|
},
|
|
@@ -169,6 +176,15 @@ export default {
|
|
|
169
176
|
grouping: 'components.content.blocks.group.multimedia',
|
|
170
177
|
},
|
|
171
178
|
},
|
|
179
|
+
{
|
|
180
|
+
tag: 'core-user-upload',
|
|
181
|
+
template: UserUpload,
|
|
182
|
+
metadata: {
|
|
183
|
+
icon: 'mdi-cloud-upload',
|
|
184
|
+
name: 'windward.core.shared.content_blocks.title.user_upload',
|
|
185
|
+
grouping: 'components.content.blocks.group.multimedia',
|
|
186
|
+
},
|
|
187
|
+
},
|
|
172
188
|
{
|
|
173
189
|
tag: 'core-tab',
|
|
174
190
|
template: Tab,
|
|
@@ -214,15 +230,6 @@ export default {
|
|
|
214
230
|
grouping: 'components.content.blocks.group.multimedia',
|
|
215
231
|
},
|
|
216
232
|
},
|
|
217
|
-
{
|
|
218
|
-
tag: 'core-user-upload',
|
|
219
|
-
template: UserUpload,
|
|
220
|
-
metadata: {
|
|
221
|
-
icon: 'mdi-cloud-upload',
|
|
222
|
-
name: 'windward.core.shared.content_blocks.title.user_upload',
|
|
223
|
-
grouping: 'components.content.blocks.group.multimedia',
|
|
224
|
-
},
|
|
225
|
-
},
|
|
226
233
|
{
|
|
227
234
|
tag: 'core-file-download',
|
|
228
235
|
template: FileDownload,
|
|
@@ -434,4 +441,7 @@ export default {
|
|
|
434
441
|
},
|
|
435
442
|
],
|
|
436
443
|
},
|
|
444
|
+
store: {
|
|
445
|
+
glossary: GlossaryStore,
|
|
446
|
+
},
|
|
437
447
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import _ from 'lodash'
|
|
2
|
+
import Course from '~/models/Course'
|
|
3
|
+
import CourseGlossaryTerm from '../models/CourseGlossaryTerm'
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
// Required so these states / methods are placed under glossary/get and not just get
|
|
7
|
+
namespaced: true,
|
|
8
|
+
state: () => ({
|
|
9
|
+
glossary: {
|
|
10
|
+
course: null,
|
|
11
|
+
terms: [],
|
|
12
|
+
},
|
|
13
|
+
}),
|
|
14
|
+
|
|
15
|
+
getters: {
|
|
16
|
+
get(state) {
|
|
17
|
+
return state.glossary
|
|
18
|
+
},
|
|
19
|
+
getCourse(state) {
|
|
20
|
+
return state.glossary.course
|
|
21
|
+
},
|
|
22
|
+
getTerms(state) {
|
|
23
|
+
return state.glossary.terms
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
mutations: {
|
|
28
|
+
setTerms(state, terms) {
|
|
29
|
+
state.glossary.terms = _.cloneDeep(terms)
|
|
30
|
+
},
|
|
31
|
+
setCourse(state, course) {
|
|
32
|
+
state.glossary.course = _.cloneDeep(course)
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
actions: {
|
|
37
|
+
clear(context) {
|
|
38
|
+
context.commit('setTerms', [])
|
|
39
|
+
context.commit('setCourse', null)
|
|
40
|
+
},
|
|
41
|
+
async load(context, course) {
|
|
42
|
+
try {
|
|
43
|
+
// Store the course that these terms are in context to
|
|
44
|
+
context.commit('setCourse', course)
|
|
45
|
+
|
|
46
|
+
const terms = await CourseGlossaryTerm.custom(
|
|
47
|
+
new Course(course),
|
|
48
|
+
new CourseGlossaryTerm()
|
|
49
|
+
).get()
|
|
50
|
+
|
|
51
|
+
context.commit('setTerms', terms)
|
|
52
|
+
} catch (e) {
|
|
53
|
+
console.error('Error loading glossary terms:', e)
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { mount } from '@vue/test-utils'
|
|
2
|
-
import Vuetify from 'vuetify'
|
|
3
2
|
import Vue from 'vue'
|
|
4
|
-
|
|
3
|
+
import Vuetify from 'vuetify'
|
|
5
4
|
import { defaultMocks } from '@/test/mocks'
|
|
6
5
|
|
|
7
6
|
jest.mock('@mindedge/vuetify-player', () => {
|
|
@@ -47,6 +46,7 @@ const metadata = {
|
|
|
47
46
|
type: 'video/mp4',
|
|
48
47
|
},
|
|
49
48
|
],
|
|
49
|
+
tracks: [],
|
|
50
50
|
},
|
|
51
51
|
],
|
|
52
52
|
},
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { shallowMount } from '@vue/test-utils'
|
|
2
|
+
import Vue from 'vue'
|
|
3
|
+
import Vuetify from 'vuetify'
|
|
4
|
+
import { defaultMocks } from '@/test/mocks'
|
|
5
|
+
import GlossaryVerification from '@/components/Glossary/GlossaryVerification.vue'
|
|
6
|
+
|
|
7
|
+
Vue.use(Vuetify)
|
|
8
|
+
|
|
9
|
+
describe('GlossaryVerification component', () => {
|
|
10
|
+
test('is a Vue instance', () => {
|
|
11
|
+
const wrapper = shallowMount(GlossaryVerification, {
|
|
12
|
+
vuetify: new Vuetify(),
|
|
13
|
+
mocks: defaultMocks,
|
|
14
|
+
propsData: {},
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
expect(wrapper.vm).toBeTruthy()
|
|
18
|
+
})
|
|
19
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { shallowMount } from '@vue/test-utils'
|
|
2
|
+
import Vue from 'vue'
|
|
3
|
+
import Vuetify from 'vuetify'
|
|
4
|
+
import { defaultMocks } from '@/test/mocks'
|
|
5
|
+
import CourseGlossary from '@/components/utils/glossary/CourseGlossary.vue'
|
|
6
|
+
|
|
7
|
+
Vue.use(Vuetify)
|
|
8
|
+
|
|
9
|
+
describe('CourseGlossary component', () => {
|
|
10
|
+
test('is a Vue instance', () => {
|
|
11
|
+
const wrapper = shallowMount(CourseGlossary, {
|
|
12
|
+
vuetify: new Vuetify(),
|
|
13
|
+
mocks: defaultMocks,
|
|
14
|
+
propsData: {},
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
expect(wrapper.vm).toBeTruthy()
|
|
18
|
+
})
|
|
19
|
+
})
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { shallowMount } from '@vue/test-utils'
|
|
2
|
+
import Vue from 'vue'
|
|
3
|
+
import Vuetify from 'vuetify'
|
|
4
|
+
import { defaultMocks } from '@/test/mocks'
|
|
5
|
+
import CourseGlossaryForm from '@/components/utils/glossary/CourseGlossaryForm.vue'
|
|
6
|
+
|
|
7
|
+
Vue.use(Vuetify)
|
|
8
|
+
|
|
9
|
+
describe('CourseGlossaryForm component', () => {
|
|
10
|
+
test('is a Vue instance', () => {
|
|
11
|
+
const wrapper = shallowMount(CourseGlossaryForm, {
|
|
12
|
+
vuetify: new Vuetify(),
|
|
13
|
+
mocks: defaultMocks,
|
|
14
|
+
propsData: {
|
|
15
|
+
value: {
|
|
16
|
+
term: '',
|
|
17
|
+
definition: '',
|
|
18
|
+
alternate_forms: [],
|
|
19
|
+
related_terms: [],
|
|
20
|
+
},
|
|
21
|
+
glossary: [],
|
|
22
|
+
editMode: false,
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
expect(wrapper.vm).toBeTruthy()
|
|
27
|
+
})
|
|
28
|
+
})
|
|
@@ -39,27 +39,3 @@ jest.mock(
|
|
|
39
39
|
},
|
|
40
40
|
{ virtual: true }
|
|
41
41
|
)
|
|
42
|
-
|
|
43
|
-
jest.mock(
|
|
44
|
-
'lodash',
|
|
45
|
-
() => {
|
|
46
|
-
return {
|
|
47
|
-
cloneDeep: (v) => {
|
|
48
|
-
return JSON.parse(JSON.stringify(v))
|
|
49
|
-
},
|
|
50
|
-
isEmpty: () => {
|
|
51
|
-
return jest.fn()
|
|
52
|
-
},
|
|
53
|
-
isBoolean: () => {
|
|
54
|
-
return jest.fn()
|
|
55
|
-
},
|
|
56
|
-
flatten: () => {
|
|
57
|
-
return jest.fn()
|
|
58
|
-
},
|
|
59
|
-
get: () => {
|
|
60
|
-
return jest.fn()
|
|
61
|
-
},
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
{ virtual: true }
|
|
65
|
-
)
|
|
@@ -55,7 +55,12 @@ const mockVirtualModels = [
|
|
|
55
55
|
]
|
|
56
56
|
|
|
57
57
|
const mockModels = [
|
|
58
|
+
{ path: '../../models/BaseModel', resource: '' },
|
|
58
59
|
{ path: '../../models/UserFileAsset', resource: 'user-files' },
|
|
60
|
+
{
|
|
61
|
+
path: '../../models/CourseGlossaryTerm',
|
|
62
|
+
resource: 'course-glossary-terms',
|
|
63
|
+
},
|
|
59
64
|
]
|
|
60
65
|
|
|
61
66
|
// DO NOT ALTER THE BELOW CODE
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { defaultMocks } from '@/test/mocks'
|
|
1
2
|
import GlossaryHelper from '../../helpers/GlossaryHelper'
|
|
2
|
-
import
|
|
3
|
+
import CourseGlossaryTerm from '../../models/CourseGlossaryTerm'
|
|
3
4
|
|
|
4
5
|
const contentHtml =
|
|
5
6
|
'<p>Voluptas est quis ut <strong>consequatur.</strong>' +
|
|
@@ -32,14 +33,16 @@ const glossary = [
|
|
|
32
33
|
{
|
|
33
34
|
term: 'veniam',
|
|
34
35
|
definition: 'venom is venomus',
|
|
35
|
-
alternate_forms:
|
|
36
|
-
|
|
36
|
+
alternate_forms: [],
|
|
37
|
+
related_terms: [],
|
|
37
38
|
},
|
|
38
39
|
{
|
|
39
40
|
term: 'Architecto',
|
|
40
41
|
definition: 'Architecto is a word that means architect of the universe',
|
|
41
42
|
alternate_forms: ['Architect', 'universe'],
|
|
42
|
-
|
|
43
|
+
related_terms: [
|
|
44
|
+
{ id: '00000000-0000-0000-1000-000000000000', term: 'a,b,c,d' },
|
|
45
|
+
],
|
|
43
46
|
},
|
|
44
47
|
{
|
|
45
48
|
term: 'Voluptatem',
|
|
@@ -47,14 +50,14 @@ const glossary = [
|
|
|
47
50
|
'Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of ' +
|
|
48
51
|
'classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock,' +
|
|
49
52
|
' a Latin professor at Hampden-Sydney College in Virginia',
|
|
50
|
-
alternate_forms:
|
|
51
|
-
|
|
53
|
+
alternate_forms: [],
|
|
54
|
+
related_terms: [],
|
|
52
55
|
},
|
|
53
56
|
{
|
|
54
57
|
term: 'crisis change',
|
|
55
58
|
definition: 'n/a',
|
|
56
59
|
alternate_forms: ['crisis', 'change'],
|
|
57
|
-
|
|
60
|
+
related_terms: [],
|
|
58
61
|
},
|
|
59
62
|
{
|
|
60
63
|
term: 'valores periféricos',
|
|
@@ -62,6 +65,7 @@ const glossary = [
|
|
|
62
65
|
'Valores que son importantes pero no esenciales para una organización.',
|
|
63
66
|
tags: 'valores periféricos',
|
|
64
67
|
alternate_forms: [],
|
|
68
|
+
related_terms: [],
|
|
65
69
|
},
|
|
66
70
|
]
|
|
67
71
|
const glossaryRender =
|
|
@@ -72,12 +76,14 @@ const glossaryRender =
|
|
|
72
76
|
'<plugin-core-glossary-tool-tip>' +
|
|
73
77
|
'<template v-slot:term>Architecto</template>' +
|
|
74
78
|
'<template v-slot:definition>Architecto is a word that means architect of the universe</template>' +
|
|
79
|
+
'<template v-slot:alternate_forms>Architect,universe</template>' +
|
|
75
80
|
'<template v-slot:related_terms>a,b,c,d</template>' +
|
|
76
81
|
'</plugin-core-glossary-tool-tip>'
|
|
77
82
|
const glossaryRenderMultiple =
|
|
78
83
|
'<plugin-core-glossary-tool-tip>' +
|
|
79
84
|
'<template v-slot:term>Architecto</template>' +
|
|
80
85
|
'<template v-slot:definition>Architecto is a word that means architect of the universe</template>' +
|
|
86
|
+
'<template v-slot:alternate_forms>Architect,universe</template>' +
|
|
81
87
|
'<template v-slot:related_terms>a,b,c,d</template>' +
|
|
82
88
|
'</plugin-core-glossary-tool-tip>' +
|
|
83
89
|
'<p>Voluptas est quis ut <strong>consequatur.</strong> ' +
|
|
@@ -87,14 +93,16 @@ const glossaryRenderMultiple =
|
|
|
87
93
|
'<plugin-core-glossary-tool-tip>' +
|
|
88
94
|
'<template v-slot:term>Architecto</template>' +
|
|
89
95
|
'<template v-slot:definition>Architecto is a word that means architect of the universe</template>' +
|
|
96
|
+
'<template v-slot:alternate_forms>Architect,universe</template>' +
|
|
90
97
|
'<template v-slot:related_terms>a,b,c,d</template>' +
|
|
91
98
|
'</plugin-core-glossary-tool-tip>'
|
|
92
99
|
|
|
93
|
-
const term = new
|
|
100
|
+
const term = new CourseGlossaryTerm(glossary[1])
|
|
94
101
|
const expectedToolTip =
|
|
95
102
|
'<plugin-core-glossary-tool-tip>' +
|
|
96
103
|
'<template v-slot:term>Architecto</template>' +
|
|
97
104
|
'<template v-slot:definition>Architecto is a word that means architect of the universe</template>' +
|
|
105
|
+
'<template v-slot:alternate_forms>Architect,universe</template>' +
|
|
98
106
|
'<template v-slot:related_terms>a,b,c,d</template>' +
|
|
99
107
|
'</plugin-core-glossary-tool-tip>'
|
|
100
108
|
const glossaryRenderCapitalized =
|
|
@@ -105,6 +113,7 @@ const glossaryRenderCapitalized =
|
|
|
105
113
|
'<plugin-core-glossary-tool-tip>' +
|
|
106
114
|
'<template v-slot:term>Crisis change</template>' +
|
|
107
115
|
'<template v-slot:definition>n/a</template>' +
|
|
116
|
+
'<template v-slot:alternate_forms>crisis,change</template>' +
|
|
108
117
|
'</plugin-core-glossary-tool-tip>'
|
|
109
118
|
const glossaryRenderCapitalizedSpaceBefore =
|
|
110
119
|
'<p>Voluptas est quis ut <strong>consequatur.</strong> ' +
|
|
@@ -114,6 +123,7 @@ const glossaryRenderCapitalizedSpaceBefore =
|
|
|
114
123
|
'<plugin-core-glossary-tool-tip>' +
|
|
115
124
|
'<template v-slot:term> Crisis change</template>' +
|
|
116
125
|
'<template v-slot:definition>n/a</template>' +
|
|
126
|
+
'<template v-slot:alternate_forms>crisis,change</template>' +
|
|
117
127
|
'</plugin-core-glossary-tool-tip>'
|
|
118
128
|
const glossaryRenderCapitalizedSpaceAfter =
|
|
119
129
|
'<p>Voluptas est quis ut <strong>consequatur.</strong> ' +
|
|
@@ -123,6 +133,7 @@ const glossaryRenderCapitalizedSpaceAfter =
|
|
|
123
133
|
'<plugin-core-glossary-tool-tip>' +
|
|
124
134
|
'<template v-slot:term>Crisis change </template>' +
|
|
125
135
|
'<template v-slot:definition>n/a</template>' +
|
|
136
|
+
'<template v-slot:alternate_forms>crisis,change</template>' +
|
|
126
137
|
'</plugin-core-glossary-tool-tip>'
|
|
127
138
|
const glossaryRenderCapitalizedSpaceBeforeAfter =
|
|
128
139
|
'<p>Voluptas est quis ut <strong>consequatur.</strong> ' +
|
|
@@ -132,6 +143,7 @@ const glossaryRenderCapitalizedSpaceBeforeAfter =
|
|
|
132
143
|
'<plugin-core-glossary-tool-tip>' +
|
|
133
144
|
'<template v-slot:term> Crisis change </template>' +
|
|
134
145
|
'<template v-slot:definition>n/a</template>' +
|
|
146
|
+
'<template v-slot:alternate_forms>crisis,change</template>' +
|
|
135
147
|
'</plugin-core-glossary-tool-tip>'
|
|
136
148
|
describe('GlossaryHelper ', () => {
|
|
137
149
|
test('detects text has glossary words', () => {
|
|
@@ -162,7 +174,7 @@ describe('GlossaryHelper ', () => {
|
|
|
162
174
|
accentedGlossaryTerm + contentHtml,
|
|
163
175
|
glossary
|
|
164
176
|
)
|
|
165
|
-
).toEqual([new
|
|
177
|
+
).toEqual([new CourseGlossaryTerm(glossary[4])])
|
|
166
178
|
})
|
|
167
179
|
test('can retrieve un-verified glossary terms', () => {
|
|
168
180
|
expect(
|
|
@@ -170,7 +182,9 @@ describe('GlossaryHelper ', () => {
|
|
|
170
182
|
glossaryWord2 + contentHtml + glossaryWord2,
|
|
171
183
|
glossary
|
|
172
184
|
)
|
|
173
|
-
).toEqual([
|
|
185
|
+
).toEqual([
|
|
186
|
+
new CourseGlossaryTerm({ term: 'unverified', definition: 'n/a' }),
|
|
187
|
+
])
|
|
174
188
|
})
|
|
175
189
|
test('does not mistake alternate forms for un-verified glossary terms', () => {
|
|
176
190
|
expect(
|
|
@@ -178,7 +192,9 @@ describe('GlossaryHelper ', () => {
|
|
|
178
192
|
glossaryWord2 + contentHtml + glossaryWord4,
|
|
179
193
|
glossary
|
|
180
194
|
)
|
|
181
|
-
).toEqual([
|
|
195
|
+
).toEqual([
|
|
196
|
+
new CourseGlossaryTerm({ term: 'unverified', definition: 'n/a' }),
|
|
197
|
+
])
|
|
182
198
|
})
|
|
183
199
|
|
|
184
200
|
test('can retrieve un-verified glossary terms with space', () => {
|
|
@@ -188,8 +204,8 @@ describe('GlossaryHelper ', () => {
|
|
|
188
204
|
glossary
|
|
189
205
|
)
|
|
190
206
|
).toEqual([
|
|
191
|
-
new
|
|
192
|
-
new
|
|
207
|
+
new CourseGlossaryTerm({ term: 'Climate', definition: 'n/a' }),
|
|
208
|
+
new CourseGlossaryTerm({ term: 'unverified', definition: 'n/a' }),
|
|
193
209
|
])
|
|
194
210
|
})
|
|
195
211
|
|
|
@@ -199,7 +215,9 @@ describe('GlossaryHelper ', () => {
|
|
|
199
215
|
glossaryWord2 + contentHtml + glossaryWord,
|
|
200
216
|
glossary
|
|
201
217
|
)
|
|
202
|
-
).toEqual([
|
|
218
|
+
).toEqual([
|
|
219
|
+
new CourseGlossaryTerm({ term: 'unverified', definition: 'n/a' }),
|
|
220
|
+
])
|
|
203
221
|
})
|
|
204
222
|
test('can render glossary tooltip component', () => {
|
|
205
223
|
expect(GlossaryHelper.makeToolTip(term, 'Architecto')).toEqual(
|
package/test/mocks.js
CHANGED
|
@@ -46,6 +46,17 @@ jest.mock(
|
|
|
46
46
|
// Just return an empty object
|
|
47
47
|
return getters
|
|
48
48
|
},
|
|
49
|
+
mapActions(obj) {
|
|
50
|
+
const actions = {}
|
|
51
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
52
|
+
// Return a function since mapActions only work in the methods section
|
|
53
|
+
actions[key] = () => {
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Just return an empty object
|
|
58
|
+
return actions
|
|
59
|
+
},
|
|
49
60
|
}
|
|
50
61
|
},
|
|
51
62
|
{ virtual: true }
|