Skip to content

Commit

Permalink
Merge pull request #2072 from ucfopen/dev/31-taconite
Browse files Browse the repository at this point in the history
Dev/31 - Taconite
  • Loading branch information
FrenjaminBanklin authored Jul 10, 2023
2 parents 26ee56c + 73d12b6 commit 5693d59
Show file tree
Hide file tree
Showing 180 changed files with 11,341 additions and 660 deletions.
39 changes: 32 additions & 7 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,39 @@
"imageSize": 100,
"commit": false,
"contributors": [
{
"login": "Viggie1",
"name": "Viggie Kontonotas",
"avatar_url": "https://avatars.githubusercontent.com/u/93793808?v=4",
"profile": "https://github.com/Viggie1",
"contributions": [
"code",
"test",
"review"
]
},
{
"login": "RachelDau",
"name": "Rachel Dauns",
"avatar_url": "https://avatars.githubusercontent.com/u/112724541?v=4",
"profile": "https://github.com/RachelDau",
"contributions": [
"code",
"test",
"review"
]
},
{
"login": "deundrewilliams",
"name": "deundrewilliams",
"name": "Deundre Williams",
"avatar_url": "https://avatars.githubusercontent.com/u/41072160?v=4",
"profile": "https://github.com/deundrewilliams",
"contributions": [
"code",
"review",
"test"
"test",
"a11y",
"bug"
]
},
{
Expand All @@ -30,7 +54,7 @@
},
{
"login": "walid-i",
"name": "walid-i",
"name": "Walid Islam",
"avatar_url": "https://avatars.githubusercontent.com/u/57739844?v=4",
"profile": "https://github.com/walid-i",
"contributions": [
Expand Down Expand Up @@ -59,7 +83,8 @@
"code",
"test",
"review",
"bug"
"bug",
"design"
]
},
{
Expand Down Expand Up @@ -88,7 +113,7 @@
},
{
"login": "AnthonyRodriguez726",
"name": "AnthonyRodriguez726",
"name": "Anthony Rodriguez",
"avatar_url": "https://avatars2.githubusercontent.com/u/11856062?v=4",
"profile": "https://github.com/AnthonyRodriguez726",
"contributions": [
Expand Down Expand Up @@ -119,7 +144,7 @@
},
{
"login": "SidTheEngineer",
"name": "Sid",
"name": "Sidney Packer",
"avatar_url": "https://avatars0.githubusercontent.com/u/19176417?v=4",
"profile": "https://github.com/SidTheEngineer",
"contributions": [
Expand Down Expand Up @@ -177,7 +202,7 @@
},
{
"login": "ssilverm",
"name": "Shea",
"name": "Shea Silverman",
"avatar_url": "https://avatars3.githubusercontent.com/u/1273237?v=4",
"profile": "http://blog.sheasilverman.com",
"contributions": [
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": "15.1.1",
"version": "16.0.1",
"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": "15.1.1",
"version": "16.0.1",
"command": {
"command": {
"run": {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "obojobo-next",
"version": "15.0.0",
"version": "16.0.1",
"repository": "https://github.com/ucfopen/Obojobo.git",
"homepage": "https://ucfopen.github.io/Obojobo-Docs/",
"license": "AGPL-3.0-only",
Expand Down Expand Up @@ -79,6 +79,7 @@
"packages/obonode/obojobo-chunks-break",
"packages/obonode/obojobo-chunks-code",
"packages/obonode/obojobo-chunks-figure",
"packages/obonode/obojobo-chunks-excerpt",
"packages/obonode/obojobo-chunks-heading",
"packages/obonode/obojobo-chunks-html",
"packages/obonode/obojobo-chunks-iframe",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('Registry', () => {
"commandHandler": null,
"componentClass": null,
"default": false,
"disallowedChildren": Array [],
"getPasteNode": [Function],
"icon": null,
"init": [Function],
Expand Down Expand Up @@ -58,6 +59,7 @@ describe('Registry', () => {
"commandHandler": null,
"componentClass": null,
"default": false,
"disallowedChildren": Array [],
"getPasteNode": [Function],
"icon": null,
"init": [Function],
Expand Down Expand Up @@ -125,6 +127,7 @@ describe('Registry', () => {
"commandHandler": null,
"componentClass": null,
"default": false,
"disallowedChildren": Array [],
"getNavItem": "mockGetNavItem",
"getPasteNode": [Function],
"icon": "mockIcon",
Expand Down Expand Up @@ -174,6 +177,7 @@ describe('Registry', () => {
"commandHandler": null,
"componentClass": null,
"default": false,
"disallowedChildren": Array [],
"getNavItem": "mockGetNavItem",
"getPasteNode": [Function],
"icon": "mockIcon",
Expand Down Expand Up @@ -218,6 +222,7 @@ describe('Registry', () => {
"commandHandler": null,
"componentClass": null,
"default": false,
"disallowedChildren": Array [],
"getNavItem": "mockGetNavItem",
"getPasteNode": [Function],
"icon": "mockIcon",
Expand Down Expand Up @@ -261,6 +266,7 @@ describe('Registry', () => {
"commandHandler": null,
"componentClass": null,
"default": false,
"disallowedChildren": Array [],
"getNavItem": "mockGetNavItem",
"getPasteNode": [Function],
"icon": "mockIcon",
Expand Down Expand Up @@ -303,6 +309,7 @@ describe('Registry', () => {
"commandHandler": null,
"componentClass": null,
"default": false,
"disallowedChildren": Array [],
"getNavItem": "mockGetNavItem",
"getPasteNode": [Function],
"icon": "mockIcon",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ describe('InsertMenu', () => {
<InsertMenu dropOptions={testOptions} icon="+" masterOnClick={jest.fn()} />
)

const allChildren = component.root.children[0].children

// number of elements we define plus the 'open' icon
expect(allChildren.length).toBe(testOptions.length + 1)

// non-separator components
const buttons = component.root.findAllByProps({ className: 'insert-button' })
expect(buttons.length).toBe(2)

// make sure they're in the right order
expect(allChildren[1]).toBe(buttons[0])
expect(allChildren[2].props.className).toBe('separator')
expect(allChildren[3]).toBe(buttons[1])

const tree = component.toJSON()
expect(tree).toMatchSnapshot()
})
Expand Down Expand Up @@ -157,4 +171,39 @@ describe('InsertMenu', () => {

expect(html).toMatchSnapshot()
})

test('InsertMenu component does not render more than one separator in a row', () => {
const thisTestOptions = [
{
isInsertable: false,
name: 'dummyItem1',
components: {}
},
{ separator: true },
{ separator: true },
{
isInsertable: false,
name: 'dummyItem2',
components: {}
}
]
const component = renderer.create(
<InsertMenu dropOptions={thisTestOptions} icon="+" masterOnClick={jest.fn()} />
)

const allChildren = component.root.children[0].children

// number of elements we define plus the 'open' icon
// minus one, since the second separator should be ignored
expect(allChildren.length).toBe(thisTestOptions.length)

// non-separator components
const buttons = component.root.findAllByProps({ className: 'insert-button' })
expect(buttons.length).toBe(2)

// make sure they're in the right order
expect(allChildren[1]).toBe(buttons[0])
expect(allChildren[2].props.className).toBe('separator')
expect(allChildren[3]).toBe(buttons[1])
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const mockNode = {
name: 'mockItem',
templateObject: 'mockNode',
insertJSON: { type: 'mockType' },
type: 'mockType',
cloneBlankNode: () => ({ type: 'mockNode' })
}

Expand All @@ -32,7 +33,10 @@ jest.mock('Common', () => ({
OboModel: {}
},
Registry: {
insertableItems: [mockNode]
insertableItems: [mockNode],
getItemForType: jest.fn().mockReturnValue({
disallowedChildren: []
})
}
}))

Expand Down Expand Up @@ -66,6 +70,13 @@ describe('Component Editor Node', () => {
}

Common.models.OboModel.create = jest.fn().mockReturnValue({ setId: () => true })
// otherwise Common.Registry.insertableItems returns an array with a single undefined in it
Object.defineProperty(Common.Registry, 'insertableItems', {
get: () => [mockNode]
})

// always return some value - clear this mock and override for specific test cases
Editor.parent.mockReturnValue([{ children: [1], type: 'ObojoboDraft.Pages.Page' }])
})

test('Node builds the expected component with no classname', () => {
Expand All @@ -84,6 +95,7 @@ describe('Component Editor Node', () => {
test('Node builds the expected component when not selected null contentDescription', () => {
// mock parts needed to display MoreInfoBox
const mockParentNode = { children: [1] }
Editor.parent.mockClear()
Editor.parent.mockReturnValue([mockParentNode])
ReactEditor.findPath.mockReturnValue([0])

Expand All @@ -96,6 +108,7 @@ describe('Component Editor Node', () => {
test('Node builds the expected component when selected', () => {
// mock parts needed to display MoreInfoBox
const mockParentNode = { children: [1] }
Editor.parent.mockClear()
Editor.parent.mockReturnValue([mockParentNode])
ReactEditor.findPath.mockReturnValue([0])

Expand All @@ -104,6 +117,11 @@ describe('Component Editor Node', () => {
// render
const component = rtr.create(<Node {...testProps} />)

const insertMenuComponents = component.root.findAllByType(InsertMenu)
insertMenuComponents.forEach(i => {
expect(i.props.dropOptions).toEqual([mockNode])
})

// verify
const tree = component.toJSON()
expect(tree).toMatchSnapshot()
Expand All @@ -112,6 +130,7 @@ describe('Component Editor Node', () => {
test('Node builds the expected component when selected when parent is a question node', () => {
// mock parts needed to display MoreInfoBox
const mockParentNode = { children: [1, 2, 3], type: 'ObojoboDraft.Chunks.Question' }
Editor.parent.mockClear()
Editor.parent.mockReturnValue([mockParentNode])
ReactEditor.findPath.mockReturnValue([1])

Expand All @@ -133,6 +152,7 @@ describe('Component Editor Node', () => {
children: [1, 2, { type: 'ObojoboDraft.Chunks.Question' }],
type: 'ObojoboDraft.Chunks.Question'
}
Editor.parent.mockClear()
Editor.parent.mockReturnValue([mockParentNode])
ReactEditor.findPath.mockReturnValue([0])

Expand All @@ -152,6 +172,7 @@ describe('Component Editor Node', () => {
test('Node builds the expected component when selected when parent is an assessment', () => {
// mock parts needed to display MoreInfoBox
const mockParentNode = { children: [1, 2, 3], type: 'ObojoboDraft.Sections.Assessment' }
Editor.parent.mockClear()
Editor.parent.mockReturnValue([mockParentNode])
ReactEditor.findPath.mockReturnValue([1])

Expand All @@ -171,6 +192,7 @@ describe('Component Editor Node', () => {
test('Node component inserts node above', () => {
// mock parts needed to display MoreInfoBox
const mockParentNode = { children: [1] }
Editor.parent.mockClear()
Editor.parent.mockReturnValue([mockParentNode])
Editor.start.mockReturnValue('mock-start-return')
ReactEditor.findPath.mockReturnValue([0])
Expand Down Expand Up @@ -199,6 +221,7 @@ describe('Component Editor Node', () => {
// mock parts needed to display MoreInfoBox
const mockParentNode = { children: [1] }
Path.next.mockReturnValue('mock-next-return')
Editor.parent.mockClear()
Editor.parent.mockReturnValue([mockParentNode])
ReactEditor.findPath.mockReturnValue([0])

Expand Down Expand Up @@ -353,4 +376,29 @@ describe('Component Editor Node', () => {

expect(editor.toggleEditable).toHaveBeenCalledTimes(4)
})

test('child InsertMenu components are given correct dropOptions based on parent node', () => {
const mockParentNode = { children: [1], type: 'ObojoboDraft.Chunk.Question' }
Editor.parent.mockClear()
Editor.parent.mockReturnValue([mockParentNode])
// pretend the registry says this parent can't have 'mockType' children
Common.Registry.getItemForType = jest.fn().mockReturnValue({
disallowedChildren: ['mockType']
})
ReactEditor.findPath.mockReturnValue([1])

const testProps = { ...mockProps, selected: true }

// render
const component = rtr.create(<Node {...testProps} />)

expect(Common.Registry.getItemForType).toHaveBeenCalledWith('ObojoboDraft.Chunk.Question')

// the InsertMenu items otherwise receive an array with the mockNode object in dropOptions
// make sure they're given an empty array instead
const insertMenuComponents = component.root.findAllByType(InsertMenu)
insertMenuComponents.forEach(i => {
expect(i.props.dropOptions).toEqual([])
})
})
})
Loading

0 comments on commit 5693d59

Please sign in to comment.