From a914b382334fc7541f0a5df0f87ce3600437b372 Mon Sep 17 00:00:00 2001 From: Brandon Stull Date: Tue, 21 Nov 2023 16:56:09 -0500 Subject: [PATCH] #554 Addressed unit test errors and missing coverage. Cleaned up unused files and/or blocks of code. Cleaned up/clarified files per findings from tests. --- package.json | 1 + .../__tests__/Viewer/components/nav.test.js | 143 +++ .../Viewer/components/viewer-app.test.js | 157 ++- .../__snapshots__/nav-store.test.js.snap | 260 +++++ .../stores/assessment-state-helpers.test.js | 6 +- .../__tests__/Viewer/stores/nav-store.test.js | 1 + .../Viewer/stores/variable-store.test.js | 151 +++ .../Viewer/util/variable-util.test.js | 167 +++ .../__tests__/common/models/obo-model.test.js | 5 +- .../__snapshots__/more-info-box.test.js.snap | 6 +- .../navigation/more-info-box.test.js | 70 +- .../variable-list-modal.test.js.snap | 25 - .../__snapshots__/new-variable.test.js.snap | 14 +- .../variables/variable-block.test.js | 26 + .../variables/variable-list-modal.test.js | 976 ++++++++++++------ .../variable-property.test.js.snap | 10 +- .../variable-property.test.js | 60 ++ .../variable-property/variable-value.test.js | 90 ++ .../variables/variable-util.test.js | 677 ++++++++++++ .../components/visual-editor.test.js | 38 +- .../components/navigation/more-info-box.js | 4 +- .../variables/variable-list-modal.js | 183 +--- .../components/variables/variable-util.js | 193 +++- .../oboeditor/components/visual-editor.js | 2 - .../src/scripts/viewer/components/nav.js | 5 +- .../scripts/viewer/components/viewer-app.js | 19 +- .../scripts/viewer/stores/question-store.js | 3 - .../variable-store/variable-generator.js | 269 ----- .../viewer/stores/variable-store/variables.js | 173 ---- .../src/scripts/viewer/util/variable-util.js | 35 +- .../scripts/viewer/util/varible-util.old.js | 171 --- .../src/parsers/code-node-parser.js | 2 +- .../__tests__/src/variables-parser.test.js | 26 + .../__tests__/models/draft_node.test.js | 120 ++- .../models/variable-generator.test.js | 414 ++++++++ .../__tests__/models/visit.test.js | 28 + .../__tests__/routes/api/visits.test.js | 164 ++- .../server/models/draft_node.js | 4 +- .../server/models/variable-generator.js | 194 +--- .../components/full-review/index.js | 17 +- .../components/full-review/index.test.js | 88 ++ .../server/attempt-start.js | 2 +- .../server/attempt-start.test.js | 184 +++- 43 files changed, 3757 insertions(+), 1426 deletions(-) create mode 100644 packages/app/obojobo-document-engine/__tests__/Viewer/stores/variable-store.test.js create mode 100644 packages/app/obojobo-document-engine/__tests__/Viewer/util/variable-util.test.js delete mode 100644 packages/app/obojobo-document-engine/__tests__/oboeditor/components/variables/__snapshots__/variable-list-modal.test.js.snap create mode 100644 packages/app/obojobo-document-engine/__tests__/oboeditor/components/variables/variable-util.test.js delete mode 100644 packages/app/obojobo-document-engine/src/scripts/viewer/stores/variable-store/variable-generator.js delete mode 100644 packages/app/obojobo-document-engine/src/scripts/viewer/stores/variable-store/variables.js delete mode 100644 packages/app/obojobo-document-engine/src/scripts/viewer/util/varible-util.old.js create mode 100644 packages/app/obojobo-document-xml-parser/__tests__/src/variables-parser.test.js create mode 100644 packages/app/obojobo-express/__tests__/models/variable-generator.test.js diff --git a/package.json b/package.json index 9cb61c894f..17d4a5c266 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "test:ci": "TZ='America/New_York' CI=true jest --ci --useStderr --coverage --coverageReporters text-summary cobertura", "test:ci:each": "lerna run test:ci", "test:dev": "TZ='America/New_York' jest --verbose --watchAll --coverage --coverageReporters lcov", + "test:view-lcov": "open ./coverage/lcov-report/index.html", "postinstall": "husky install" }, "devDependencies": { diff --git a/packages/app/obojobo-document-engine/__tests__/Viewer/components/nav.test.js b/packages/app/obojobo-document-engine/__tests__/Viewer/components/nav.test.js index f072903c55..a492627dd8 100644 --- a/packages/app/obojobo-document-engine/__tests__/Viewer/components/nav.test.js +++ b/packages/app/obojobo-document-engine/__tests__/Viewer/components/nav.test.js @@ -126,6 +126,7 @@ describe('Nav', () => { beforeEach(() => { jest.clearAllMocks() + mockDispatcherTrigger.mockReset() }) test('renders opened', () => { @@ -195,6 +196,148 @@ describe('Nav', () => { expect(tree).toMatchSnapshot() }) + test('does not try to substitute labels if no brackets are found', () => { + // this shouldn't run in this test, but if it does the label will be changed + mockDispatcherTrigger.mockImplementationOnce((trigger, event) => { + event.text = 'not-label5' + return event + }) + NavUtil.getOrderedList.mockReturnValueOnce([ + { id: 4, type: 'heading', label: 'label4' }, + { + id: 5, + type: 'link', + label: 'label5', + flags: { visited: false, complete: false, correct: false }, + // exists to be passed along to variable utilities, doesn't matter for testing + sourceModel: {} + } + ]) + const props = { + navState: { + open: false, + locked: true, + navTargetId: 56 // select this item + } + } + const component = renderer.create(