From 9470f2436512162ed0c01b646c1e1567bb37c12b Mon Sep 17 00:00:00 2001 From: Stephen Fraser Date: Fri, 11 Mar 2022 10:17:00 +0000 Subject: [PATCH] Fixed tests --- .../capture-models/editor/bugs/01-nuking-selector.test.ts | 2 +- .../__tests__/capture-models/editor/current-form.test.ts | 2 +- .../__tests__/capture-models/editor/structure-editor.test.ts | 1 + .../__tests__/capture-models/helpers/create-revision.test.ts | 4 ++-- .../capture-models/helpers/filter-capture-model.test.ts | 2 +- .../capture-models/helpers/filter-empty-structures.test.ts | 2 +- .../capture-models/helpers/hydrate-partial-document.test.ts | 4 ++-- .../madoc-ts/__tests__/capture-models/helpers/ocr.test.ts | 4 ++-- 8 files changed, 11 insertions(+), 10 deletions(-) diff --git a/services/madoc-ts/__tests__/capture-models/editor/bugs/01-nuking-selector.test.ts b/services/madoc-ts/__tests__/capture-models/editor/bugs/01-nuking-selector.test.ts index 566087141..a71850d3f 100644 --- a/services/madoc-ts/__tests__/capture-models/editor/bugs/01-nuking-selector.test.ts +++ b/services/madoc-ts/__tests__/capture-models/editor/bugs/01-nuking-selector.test.ts @@ -3,7 +3,7 @@ */ import { hydrateRevisionStore } from '../../../../src/frontend/shared/capture-models/editor/stores/revisions/revisions-store'; -import { registerField } from '../../../../src/frontend/shared/capture-models/plugin-api'; +import { registerField } from '../../../../src/frontend/shared/capture-models/plugin-api/global-store'; registerField({ label: 'Text field', diff --git a/services/madoc-ts/__tests__/capture-models/editor/current-form.test.ts b/services/madoc-ts/__tests__/capture-models/editor/current-form.test.ts index f82438c04..04b5e5c87 100644 --- a/services/madoc-ts/__tests__/capture-models/editor/current-form.test.ts +++ b/services/madoc-ts/__tests__/capture-models/editor/current-form.test.ts @@ -3,7 +3,7 @@ import { CaptureModel } from '../../../src/frontend/shared/capture-models/types/ describe('current form', () => { describe('createFormFieldReducer', () => { - const doc: CaptureModel = require('../../../../fixtures/simple.json'); + const doc: CaptureModel = require('../../../fixtures/simple.json'); test('simple flat fields', () => { const reducer = createFormFieldReducer(doc.document); diff --git a/services/madoc-ts/__tests__/capture-models/editor/structure-editor.test.ts b/services/madoc-ts/__tests__/capture-models/editor/structure-editor.test.ts index 9d3d81a3c..4d2cacec0 100644 --- a/services/madoc-ts/__tests__/capture-models/editor/structure-editor.test.ts +++ b/services/madoc-ts/__tests__/capture-models/editor/structure-editor.test.ts @@ -8,6 +8,7 @@ import { mergeFlatKeys, structureToFlatStructureDefinition, } from '../../../src/frontend/shared/capture-models/editor/core/structure-editor'; +import { expandModelFields } from '../../../src/frontend/shared/capture-models/helpers/expand-model-fields'; import { registerField } from '../../../src/frontend/shared/capture-models/plugin-api/global-store'; import { CaptureModel } from '../../../src/frontend/shared/capture-models/types/capture-model'; diff --git a/services/madoc-ts/__tests__/capture-models/helpers/create-revision.test.ts b/services/madoc-ts/__tests__/capture-models/helpers/create-revision.test.ts index c76baf84c..e4cab5d12 100644 --- a/services/madoc-ts/__tests__/capture-models/helpers/create-revision.test.ts +++ b/services/madoc-ts/__tests__/capture-models/helpers/create-revision.test.ts @@ -29,7 +29,7 @@ const { generateId } = require('../../../src/frontend/shared/capture-models/help generateId.mockImplementation(() => '[--------GENERATED-ID--------]'); describe('create revision', () => { - const captureModel: CaptureModel = require('../../../../fixtures/03-revisions/06-model-root.json'); + const captureModel: CaptureModel = require('../../../fixtures/03-revisions/06-model-root.json'); const [ createFieldA, editModelA, @@ -937,7 +937,7 @@ describe('create revision', () => { }); describe('Revision with revised field', () => { - const multi = require('../../../../fixtures/03-revisions/05-allow-multiple-transcriptions.json'); + const multi = require('../../../fixtures/03-revisions/05-allow-multiple-transcriptions.json'); test('Canonical revision should contain both types and filter out the empty', () => { const [main] = captureModelToRevisionList(multi, true); diff --git a/services/madoc-ts/__tests__/capture-models/helpers/filter-capture-model.test.ts b/services/madoc-ts/__tests__/capture-models/helpers/filter-capture-model.test.ts index 4c2cd33fc..52c3ba20c 100644 --- a/services/madoc-ts/__tests__/capture-models/helpers/filter-capture-model.test.ts +++ b/services/madoc-ts/__tests__/capture-models/helpers/filter-capture-model.test.ts @@ -2,7 +2,7 @@ import { filterCaptureModel } from '../../../src/frontend/shared/capture-models/ import { CaptureModel } from '../../../src/frontend/shared/capture-models/types/capture-model'; describe('filterCaptureModel', () => { - const personModel: CaptureModel = require('../../../../fixtures/02-nesting/05-nested-model-multiple.json'); + const personModel: CaptureModel = require('../../../fixtures/02-nesting/05-nested-model-multiple.json'); test('non-filter entity maintains structure', () => { const filtered = filterCaptureModel( 'something', diff --git a/services/madoc-ts/__tests__/capture-models/helpers/filter-empty-structures.test.ts b/services/madoc-ts/__tests__/capture-models/helpers/filter-empty-structures.test.ts index a46cee01d..5431cb249 100644 --- a/services/madoc-ts/__tests__/capture-models/helpers/filter-empty-structures.test.ts +++ b/services/madoc-ts/__tests__/capture-models/helpers/filter-empty-structures.test.ts @@ -2,7 +2,7 @@ import { filterEmptyStructureFields } from '../../../src/frontend/shared/capture import { filterEmptyStructures } from '../../../src/frontend/shared/capture-models/helpers/filter-empty-structures'; import { CaptureModel } from '../../../src/frontend/shared/capture-models/types/capture-model'; -const filterEmpty = require('../../../../fixtures/06-invalid/01-empty-structure.json'); +const filterEmpty = require('../../../fixtures/06-invalid/01-empty-structure.json'); describe('filterEmptyStructures', () => { test('filterEmptyStructureFields - non-nested', () => { diff --git a/services/madoc-ts/__tests__/capture-models/helpers/hydrate-partial-document.test.ts b/services/madoc-ts/__tests__/capture-models/helpers/hydrate-partial-document.test.ts index 7630a9039..fc1b384fd 100644 --- a/services/madoc-ts/__tests__/capture-models/helpers/hydrate-partial-document.test.ts +++ b/services/madoc-ts/__tests__/capture-models/helpers/hydrate-partial-document.test.ts @@ -6,7 +6,7 @@ // eslint-disable-next-line if (global) { global.globalThis = global; } else { try { globalThis = typeof globalThis !== 'undefined' ? this : globalThis; } catch (e) {} } -import React from 'react'; +import * as React from 'react'; import { captureModelToRevisionList } from '../../../src/frontend/shared/capture-models/helpers/capture-model-to-revision-list'; import { hydratePartialDocument } from '../../../src/frontend/shared/capture-models/helpers/hydrate-partial-document'; import { registerField } from '../../../src/frontend/shared/capture-models/plugin-api/global-store'; @@ -33,7 +33,7 @@ const GENERATED_ID = '[--------GENERATED-ID--------]'; generateId.mockImplementation(() => GENERATED_ID); describe('hydratePartialDocument', () => { - const captureModel: CaptureModel = require('../../../../fixtures/03-revisions/06-model-root.json'); + const captureModel: CaptureModel = require('../../../fixtures/03-revisions/06-model-root.json'); const [ createFieldA, editModelA, diff --git a/services/madoc-ts/__tests__/capture-models/helpers/ocr.test.ts b/services/madoc-ts/__tests__/capture-models/helpers/ocr.test.ts index 4a1073d9b..cd7ae8043 100644 --- a/services/madoc-ts/__tests__/capture-models/helpers/ocr.test.ts +++ b/services/madoc-ts/__tests__/capture-models/helpers/ocr.test.ts @@ -31,10 +31,10 @@ registerField({ // import { fieldsToInserts } from '../../../database/src/utility/fields-to-inserts'; function getModel() { - return require('../../../../fixtures/02-nesting/06-ocr.json') as CaptureModel; + return require('../../../fixtures/02-nesting/06-ocr.json') as CaptureModel; } function getRevisionA() { - return require('../../../../fixtures/98-revision-requests/add-ocr-text.json') as RevisionRequest; + return require('../../../fixtures/98-revision-requests/add-ocr-text.json') as RevisionRequest; } describe('OCR Capture model', () => {