Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/17 peridot #1681

Merged
merged 58 commits into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
1b7a059
update regex for extracting info from youtube url
keeeeeegan Apr 8, 2020
7bf3b59
Allows user to input id on its own OR a url to a video. Still need to…
keeeeeegan Apr 9, 2020
cefbffe
Allows youtube urls as well as embed codes
keeeeeegan Apr 10, 2020
fff5548
added supporting text to describe what to enter in time fields on sta…
keeeeeegan Apr 13, 2020
1264a1a
Updated ui for pasting to be more intuitive and visually pleasing
keeeeeegan Apr 27, 2020
fea8563
Implemented additional check for time end query var on youtube videos
keeeeeegan May 1, 2020
927dfbc
update regex for extracting info from youtube url
keeeeeegan Apr 8, 2020
9bb40e6
Allows user to input id on its own OR a url to a video. Still need to…
keeeeeegan Apr 9, 2020
5b65bce
Allows youtube urls as well as embed codes
keeeeeegan Apr 10, 2020
1dd84e9
added supporting text to describe what to enter in time fields on sta…
keeeeeegan Apr 13, 2020
379dad0
Updated ui for pasting to be more intuitive and visually pleasing
keeeeeegan Apr 27, 2020
8e66b0a
Implemented additional check for time end query var on youtube videos
keeeeeegan May 1, 2020
d5cfbf8
Added second field for the intered url for youtube videos
keeeeeegan May 29, 2020
9f4ba2f
Updating tests for new youtube validation code.
keeeeeegan Jun 23, 2020
c1c8f19
updated unescaped characters
keeeeeegan Jun 24, 2020
378b07b
fixes with testing and coverage
keeeeeegan Jul 22, 2020
ec389dd
merging with remote
keeeeeegan Jul 23, 2020
2f44ad2
Merge branch 'dev/12-ammolite' into issue/1234-youtube-user-friendly
keeeeeegan Jul 23, 2020
f623d84
added videoUrl to the adapter and converter for youtube chunks
keeeeeegan Jul 23, 2020
06fadaf
updated modal to allow text-based time inputs, both start and end tim…
keeeeeegan Jul 29, 2020
5f08315
Fixes to reach coverage and to fix issue with url validation
keeeeeegan Jul 29, 2020
f9f1c1f
fix to include iframe embeds
keeeeeegan Jul 29, 2020
2819048
gh test action optimization
iturgeon Oct 3, 2020
5d86ef4
Fix triple clicking focus issue
vutoan1245 Oct 7, 2020
941e0ed
makes sure .eslintrc included in eslint-config-obojobo package
iturgeon Oct 23, 2020
8547682
Added a better error message for invalid assessment ids
ctcuff Oct 26, 2020
8847b62
Renamed ERROR_ASSESSMENT_INVALID_ID to ERROR_ASSESSMENT_ID_NOT_FOUND
ctcuff Oct 26, 2020
7b1fe34
displays an error message when invalid id characters are entered
jpeterson976 Oct 28, 2020
7f86bf4
query timeouts added
iturgeon Nov 19, 2020
cd07526
Rectified how highest attempts are marked
maufcost Nov 30, 2020
76e2191
Fixed how highest attempts are marked and tweaked unit tests
maufcost Jan 6, 2021
e351d5e
Changed how highest attempts based on assessment scores are retrieved
maufcost Jan 21, 2021
11cb996
Updated snapshots
maufcost Jan 25, 2021
e238bb6
Updated snapshots according to dev/16
maufcost Jan 25, 2021
f54e51c
Removed duplicate loop and used existing variables
maufcost Jan 27, 2021
af6e0d8
Merge remote-tracking branch 'upstream/dev/16-connemara-marble' into …
zachberry Jan 28, 2021
c55f01b
Restores unnecessary files/changes to the project
zachberry Jan 28, 2021
347f577
* Updates YouTube modal to better parse various YouTube URLS
zachberry Jan 29, 2021
bb8936b
Removes left-in testing output
zachberry Jan 29, 2021
a361899
Removed more duplicated code
maufcost Feb 2, 2021
e5d5c1c
Merge branch 'dev/16-connemara-marble' into issue/1601-restrict-id-input
jpeterson976 Feb 4, 2021
262db2e
exported validation function to its own file
jpeterson976 Feb 4, 2021
2eb4650
renamed validate function and slight logic rework
jpeterson976 Feb 11, 2021
e9f2f71
Merge pull request #1438 from keeeeeegan/issue/1234-youtube-user-frie…
zachberry Feb 15, 2021
fec40d0
Merge pull request #1603 from iturgeon/issue/add-eslintrc-to-npm-package
zachberry Feb 15, 2021
69e2106
Merge pull request #1613 from iturgeon/issue/query-timeout
zachberry Feb 15, 2021
bc4cbc5
Merge pull request #1617 from maufcost/issue/1504-highest-attempt-ass…
zachberry Feb 22, 2021
27e67ef
Merge pull request #1605 from ctcuff/issue/1573-assessment-error-message
zachberry Feb 22, 2021
880d0dc
Merge pull request #1608 from jpeterson976/issue/1601-restrict-id-input
zachberry Feb 22, 2021
29cf498
Merge pull request #1585 from vutoan1245/issue/1550-triple-click-sele…
zachberry Feb 23, 2021
cb05e10
Merge branch 'dev/17-peridot' into issue/polish-test-action
iturgeon Feb 24, 2021
4bb4666
yarn updates needed to satisfy --frozen-lockfile installs
iturgeon Feb 24, 2021
aaef84a
Merge remote-tracking branch 'origin/master' into dev/17-peridot
zachberry Feb 24, 2021
8545057
Merge pull request #1572 from iturgeon/issue/polish-test-action
zachberry Feb 24, 2021
ff2a13b
upgrade katex from 0.11.1 to 0.12.0
iturgeon Feb 24, 2021
fc1a5d7
Merge pull request #1692 from iturgeon/issue/update-katex-to-12
iturgeon Feb 24, 2021
805ffa9
v11.3.0-alpha.0
iturgeon Feb 24, 2021
7473d66
v11.3.0
iturgeon Feb 25, 2021
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
14 changes: 12 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,19 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

# caches yarn dependencies in the yarn cache (not npm_modules)
# should help to speed up yarn install and be safe
# across changes to the repo and platforms
- name: Cache Yarn Deps
uses: c-hive/gha-yarn-cache@v1

- run: echo "github.ref = ${{ github.ref }}"
- run: npm install -g yarn
- run: yarn install

# frozen lockfile should make the cache more effective
# and our tests more predictable
- run: yarn install --frozen-lockfile

- run: yarn test:ci

build_docker_images:
Expand Down
4 changes: 4 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
"description": "PG-Promise SSL Configuration. https://github.com/vitaly-t/pg-promise/wiki/Connection-Syntax",
"value": "{\"rejectUnauthorized\":false}"
},
"DB_TIMEOUT": {
"description": "DB Query timeout in milliseconds https://github.com/brianc/node-postgres/pull/1760",
"value": "29000"
},
"OBO_LTI_KEYS_JSON": {
"description": "Edit the secret value. JSON string for LTI key:secret values.",
"value": "{\"obo-production-lti-key\":\"CHANGE_THIS_VALUE_NOW\"}"
Expand Down
2 changes: 1 addition & 1 deletion docker/obojobo-pm2-server-src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obojobo-pm2-server-app",
"version": "11.2.0",
"version": "11.3.0",
"description": "Reference project for deploying and customizing an Obojobo Next server",
"main": "./index.js",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"packages": [
"packages/**/*"
],
"version": "11.2.0",
"version": "11.3.0",
"command": {
"command": {
"run": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,5 @@
"yarn": "^1.15.2",
"node": "^12.11.1"
},
"version": "11.2.0"
"version": "11.3.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,24 @@ describe('AssessmentStore', () => {
)
})

test('startAttemptWithAPICall shows an error if the assessment ID is invalid', () => {
OboModel.create(getExampleAssessment())

AssessmentAPI.startAttempt.mockResolvedValueOnce({
status: 'error',
value: {
message: 'ID not found'
}
})

return AssessmentStore.startAttemptWithAPICall('draftId', 'visitId', 'assessmentId').then(
() => {
expect(ErrorUtil.show).toHaveBeenCalledTimes(1)
expect(AssessmentStore.triggerChange).toHaveBeenCalledTimes(1)
}
)
})

test('startAttemptWithAPICall shows a generic error if an unrecognized error is thrown and triggers a change', () => {
OboModel.create(getExampleAssessment())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import Common from 'src/scripts/common'
import { mount } from 'enzyme'

import EditorUtil from 'src/scripts/oboeditor/util/editor-util'
import isValidId from 'src/scripts/oboeditor/util/is-valid-id'
jest.mock('src/scripts/oboeditor/util/editor-util')
jest.mock('src/scripts/oboeditor/util/is-valid-id')

describe('Header', () => {
beforeEach(() => {
Expand Down Expand Up @@ -199,6 +201,7 @@ describe('Header', () => {
}
const component = mount(<Header {...props} />)
Common.models.OboModel.models['5'].setId.mockReturnValueOnce(true)
isValidId.mockReturnValueOnce(true)
component.instance().saveId('5', 'mock-id')

expect(EditorUtil.rebuildMenu).toHaveBeenCalled()
Expand Down Expand Up @@ -242,9 +245,54 @@ describe('Header', () => {
]
}
const component = mount(<Header {...props} />)
isValidId.mockReturnValueOnce(true)
Common.models.OboModel.models['5'].setId.mockReturnValueOnce(false)
component.instance().saveId('5', 'mock-id')

expect(EditorUtil.rebuildMenu).not.toHaveBeenCalled()
})

test('saveId does nothing if the old and new ids are the same', () => {
const props = {
index: 0,
list: [
{
id: '5',
type: 'header',
label: 'label5',
contentType: 'Page',
flags: {
assessment: false
}
}
]
}
const component = mount(<Header {...props} />)
component.instance().saveId('5', '5')

expect(EditorUtil.rebuildMenu).not.toHaveBeenCalled()
})

test('saveId checks if the id is valid', () => {
const props = {
index: 0,
list: [
{
id: '5',
type: 'header',
label: 'label5',
contentType: 'Page',
flags: {
assessment: false
}
}
]
}
const component = mount(<Header {...props} />)
isValidId.mockReturnValueOnce(false)
component.instance().saveId('5', '5!')

expect(isValidId).toHaveBeenCalled()
expect(Common.models.OboModel.models['5'].setId).not.toHaveBeenCalled()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import renderer from 'react-test-renderer'

import Common from '../../../../src/scripts/common'
import EditorUtil from '../../../../src/scripts/oboeditor/util/editor-util'
import isValidId from '../../../../src/scripts/oboeditor/util/is-valid-id'
import {
getTriggersWithActionsAdded,
getTriggersWithActionsRemoved,
Expand Down Expand Up @@ -56,6 +57,7 @@ jest.mock('../../../../src/scripts/common', () => ({
}))

jest.mock('../../../../src/scripts/oboeditor/util/editor-util')
jest.mock('../../../../src/scripts/oboeditor/util/is-valid-id')
jest.mock('../../../../src/scripts/common/util/trigger-util')
jest.mock('../../../../src/scripts/oboeditor/stores/editor-store', () => ({
state: { startingId: null }
Expand Down Expand Up @@ -323,6 +325,7 @@ describe('SubMenu', () => {
]

const component = mount(<SubMenu index={0} list={itemList} updateNavTargetId={jest.fn()} />)
isValidId.mockReturnValue(true)

component.instance().saveId('7', 'mock-id')
expect(EditorUtil.rebuildMenu).not.toHaveBeenCalled()
Expand All @@ -343,13 +346,34 @@ describe('SubMenu', () => {
}
]
Common.models.OboModel.models['7'].setId.mockReturnValueOnce(true)
isValidId.mockReturnValueOnce(true)

const component = mount(<SubMenu index={0} list={itemList} updateNavTargetId={jest.fn()} />)

component.instance().saveId('7', 'mock-id')
expect(EditorUtil.rebuildMenu).toHaveBeenCalled()
})

test('saveId checks if the id is valid', () => {
const itemList = [
{
id: 7,
type: 'link',
label: 'label7',
flags: {
assessment: false
}
}
]
const component = mount(<SubMenu index={0} list={itemList} updateNavTargetId={jest.fn()} />)
Common.models.OboModel.models['7'].setId = jest.fn()
isValidId.mockReturnValueOnce(false)
component.instance().saveId('7', '7!')

expect(isValidId).toHaveBeenCalled()
expect(Common.models.OboModel.models['7'].setId).not.toHaveBeenCalled()
})

test('saveContent updates model', () => {
const itemList = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Common from '../../../../src/scripts/common'
import Node from 'src/scripts/oboeditor/components/node/editor-component'
import InsertMenu from 'src/scripts/oboeditor/components/node/components/insert-menu'
import MoreInfoBox from 'src/scripts/oboeditor/components/navigation/more-info-box'
import isValidId from 'src/scripts/oboeditor/util/is-valid-id'

const mockNode = {
isInsertable: true,
Expand All @@ -17,6 +18,7 @@ const mockNode = {
cloneBlankNode: () => ({ type: 'mockNode' })
}

jest.mock('src/scripts/oboeditor/util/is-valid-id')
jest.mock('src/scripts/oboeditor/components/navigation/more-info-box', () =>
global.mockReactComponent(this, 'MockMoreInfoBox')
)
Expand Down Expand Up @@ -229,6 +231,7 @@ describe('Component Editor Node', () => {

test('saveId does not allow duplicate nodes', () => {
const component = rtr.create(<Node {...mockProps} />)
isValidId.mockReturnValueOnce(true)
const result = component.getInstance().saveId('mock-duplicate-id', 'mock-id2')
expect(result).toBe('The id "mock-id2" already exists. Please choose a unique id.')
expect(Transforms.setNodes).not.toHaveBeenCalled()
Expand All @@ -244,6 +247,7 @@ describe('Component Editor Node', () => {
test('saveId updates the node if ids are not the same', () => {
ReactEditor.findPath.mockReturnValue([0]) // for getSlatePath
const component = rtr.create(<Node {...mockProps} />)
isValidId.mockReturnValueOnce(true)
const result = component.getInstance().saveId('mock-id', 'mock-id2')
expect(result).toBe()
expect(Transforms.setNodes).toHaveBeenCalledWith(
Expand All @@ -253,6 +257,14 @@ describe('Component Editor Node', () => {
)
})

test('saveId checks if the id is valid', () => {
const component = rtr.create(<Node {...mockProps} />)
isValidId.mockReturnValueOnce(false)
component.getInstance().saveId('5', '5!')

expect(isValidId).toHaveBeenCalled()
})

test('saveContent calls Transforms.setNodes', () => {
const component = rtr.create(<Node {...mockProps} />)
component.getInstance().saveContent({}, {})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import ModalStore from '../../../src/scripts/common/stores/modal-store'
import Dispatcher from '../../../src/scripts/common/flux/dispatcher'
import OboModel from 'src/scripts/common/models/obo-model'

import { Editor } from 'slate'
import { Editor, Transforms } from 'slate'
import { ReactEditor } from 'slate-react'
// jest.mock('slate')
jest.mock('src/scripts/viewer/util/editor-api')
jest.mock('src/scripts/common/util/modal-util')
jest.mock('src/scripts/oboeditor/components/node/editor', () => ({
Expand Down Expand Up @@ -79,6 +80,43 @@ describe('VisualEditor', () => {
expect(component.toJSON()).toMatchSnapshot()
})

test('VisualEditor component handles triple click', () => {
const spy = jest.spyOn(Transforms, 'move').mockReturnValueOnce(true)
const props = {
insertableItems: 'mock-insertable-items',
page: {
attributes: { children: [{ type: 'mockNode' }] },
get: jest.fn(),
toJSON: () => ({ children: [{ type: 'mockNode' }] })
},
model: { title: 'Mock Title' }
}
const component = mount(<VisualEditor {...props} />)

// Double click
component
.find('.obojobo-draft--pages--page')
.at(0)
.simulate('click', { detail: 2 })
expect(spy).not.toHaveBeenCalled()

// Selection does not end at the beginning
component.instance().editor.selection.focus.offset = 1
component
.find('.obojobo-draft--pages--page')
.at(0)
.simulate('click', { detail: 3 })
expect(spy).not.toHaveBeenCalled()

// Selection ends at the beginning
component.instance().editor.selection.focus.offset = 0
component
.find('.obojobo-draft--pages--page')
.at(0)
.simulate('click', { detail: 3 })
expect(spy).toHaveBeenCalled()
})

test('VisualEditor component - editor is disable when modal is opened', () => {
ModalStore.init()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import isValidId from 'src/scripts/oboeditor/util/is-valid-id'

describe('Validate ID', () => {
test.each`
input | output
${'mock-id'} | ${true}
${'mock_id'} | ${true}
${'mock:id'} | ${true}
${'mock.id'} | ${true}
${'mock+id'} | ${false}
${'mock=id'} | ${false}
${'abc123'} | ${true}
${'ABC123'} | ${true}
${'"mock-id"'} | ${false}
${'/mock-id/'} | ${false}
${'[mock-id]'} | ${false}
`('isValidId("$input") = "$output"', ({ input, output }) => {
expect(isValidId(input)).toBe(output)
})
})
4 changes: 2 additions & 2 deletions packages/app/obojobo-document-engine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obojobo-document-engine",
"version": "11.2.0",
"version": "11.3.0",
"license": "AGPL-3.0-only",
"description": "",
"engines": {
Expand Down Expand Up @@ -45,7 +45,7 @@
"codemirror": "^5.58.1",
"date-fns": "^2.16.1",
"downloadjs": "^1.4.7",
"katex": "^0.11.1",
"katex": "^0.12.0",
"prop-types": "15.7.2",
"react": "^16.13.1",
"react-codemirror2": "^7.2.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ const injectKatexIfNeeded = async ({ value: draftModel }) => {

if (stringModel.includes('latex')) {
const jsProps = {
src: 'https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.11.1/katex.min.js'
src: 'https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.12.0/katex.min.js'
}
const cssProps = {
rel: 'stylesheet',
type: 'text/css',
href: 'https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.11.1/katex.min.css'
href: 'https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.12.0/katex.min.css'
}
insertDomTag(jsProps, 'script')
insertDomTag(cssProps, 'link')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Common from 'obojobo-document-engine/src/scripts/common'
import EditorUtil from '../../util/editor-util'
import isValidId from 'obojobo-document-engine/src/scripts/oboeditor/util/is-valid-id'
import React from 'react'
import MoreInfoBox from './more-info-box'

Expand Down Expand Up @@ -33,15 +34,21 @@ class Header extends React.Component {
}

saveId(oldId, newId) {
if (oldId === newId) return

const model = OboModel.models[oldId]

if (!newId) {
return 'Please enter an id'
return 'Please enter an id.'
}

if (!isValidId(newId)) {
return 'Invalid characters in id. Only letters, numbers, and special characters (-, _, :, .) are permitted.'
}

// prettier-ignore
if (!model.setId(newId)) {
return 'The id "' + newId + '" already exists. Please choose a unique id'
return 'The id "' + newId + '" already exists. Please choose a unique id.'
}

EditorUtil.rebuildMenu(OboModel.getRoot())
Expand Down
Loading