Skip to content

Commit

Permalink
chore: upgrade mustache and other deps (#508)
Browse files Browse the repository at this point in the history
* chore: ignore pdf.js lib in public/assets

* chore: upgrade mustache and other deps

* chore: upgrade rollup TS plugin

* chore: upgrade ts-loader
  • Loading branch information
jhpedemonte authored Apr 26, 2023
1 parent 1fe45d8 commit 11c1f93
Show file tree
Hide file tree
Showing 19 changed files with 205 additions and 200 deletions.
3 changes: 2 additions & 1 deletion examples/discovery-search-app/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build
ibm-credentials.env
.env.local
build
public/assets/**
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
"@commitlint/config-conventional": "^11.0.0",
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^11.2.7",
"@testing-library/react-hooks": "^7.0.2",
"@testing-library/react-hooks": "^8.0.1",
"@types/babel__preset-env": "^7.9.2",
"@types/classnames": "^2.2.9",
"@types/debounce": "^1.2.0",
"@types/dompurify": "^3.0.2",
"@types/jest": "^24.0.18",
"@types/lodash": "^4.14.141",
"@types/md5": "2.3.2",
"@types/mustache": "^0.8.32",
"@types/mustache": "^4.2.2",
"@types/node": "^16.18.23",
"@types/react": "^17.0.38",
"@types/react-dom": "^17.0.11",
Expand Down Expand Up @@ -74,7 +74,7 @@
"regenerator-runtime": "^0.13.3",
"seedrandom": "^3.0.5",
"source-map-explorer": "2.0.1",
"ts-loader": "^6.2.1",
"ts-loader": "^9.4.2",
"typescript": "^3.8.2",
"vue": "^2.6.11",
"webpack": "5.72.1",
Expand Down
10 changes: 5 additions & 5 deletions packages/discovery-react-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
"dependencies": {
"@react-hook/size": "^2.1.2",
"buffer": "^6.0.3",
"classnames": "^2.2.6",
"debounce": "^1.2.0",
"classnames": "^2.3.2",
"debounce": "^1.2.1",
"dompurify": "^3.0.2",
"entities": "^4.4.0",
"entities": "^4.5.0",
"htmlparser2": "^4.0.0",
"lodash": "^4.17.21",
"mustache": "^3.1.0",
"mustache": "^4.2.0",
"pdfjs-dist": "2.6.347",
"react-error-boundary": "^1.2.5",
"react-resize-detector": "^4.2.1",
Expand Down Expand Up @@ -73,7 +73,7 @@
"rollup": "^2.57.0",
"rollup-plugin-string": "^3.0.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.30.0",
"rollup-plugin-typescript2": "^0.34.1",
"sass-embedded": "^1.52.2",
"sass-loader": "^12.3.0",
"style-loader": "^1.3.0",
Expand Down
1 change: 0 additions & 1 deletion packages/discovery-react-components/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const COMMON_PLUGINS = [
include: [pdfWorkerRegex]
}),
typescript({
rollupCommonJSResolveHack: true,
clean: true,
tsconfig: 'tsconfig.prod.json'
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ export interface ItemMap {

export type EnrichedHtml = EnrichedHtmlContract | EnrichedHtmlInvoice | EnrichedHtmlPurchaseOrder;

interface EnrichedHtmlContract {
export interface EnrichedHtmlContract {
contract: Contract;
}
interface EnrichedHtmlInvoice {
export interface EnrichedHtmlInvoice {
invoice: Invoice;
}
interface EnrichedHtmlPurchaseOrder {
export interface EnrichedHtmlPurchaseOrder {
purchase_order: PurchaseOrder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('elementFromPoint returns expected mock element', () => {
});

it('runs elementsFromPoint function for standard web browsers', () => {
document.elementsFromPoint = (x: number, y: number): Element[] => {
document.elementsFromPoint = (_x: number, _y: number): Element[] => {
return mockElements as unknown as Element[];
};

Expand All @@ -51,7 +51,7 @@ describe('elementFromPoint returns expected mock element', () => {
});

it('runs elementFromPointMs function for MS Edge browser', () => {
(document as MsDocument).msElementsFromPoint = (x: number, y: number): HTMLElement[] => {
(document as MsDocument).msElementsFromPoint = (_x: number, _y: number): HTMLElement[] => {
return mockElements as unknown as HTMLElement[];
};

Expand All @@ -61,7 +61,7 @@ describe('elementFromPoint returns expected mock element', () => {

it('runs elementFromPointFallback function for older browsers', () => {
let nextElementIndex = 0;
document.elementFromPoint = (x: number, y: number): Element | null => {
document.elementFromPoint = (_x: number, _y: number): Element | null => {
return nextElementIndex < mockElements.length
? (mockElements[nextElementIndex++] as unknown as Element)
: null;
Expand All @@ -73,7 +73,7 @@ describe('elementFromPoint returns expected mock element', () => {

it('runs elementFromPointFallback and fails to find element', () => {
let nextElementIndex = 0;
document.elementFromPoint = (x: number, y: number): Element | null => {
document.elementFromPoint = (_x: number, _y: number): Element | null => {
return nextElementIndex < mockElements.length
? (mockElements[nextElementIndex++] as unknown as Element)
: null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ describe('DocumentPreview', () => {
const results = {
matching_results: 1,
results: [selectedResult]
};
} as unknown as DiscoveryV2.QueryResponse;

render(
<DiscoverySearch
Expand Down Expand Up @@ -239,7 +239,7 @@ describe('DocumentPreview', () => {
const results = {
matching_results: 1,
results: [selectedResult]
};
} as unknown as DiscoveryV2.QueryResponse;

render(
<DiscoverySearch
Expand Down Expand Up @@ -289,7 +289,7 @@ describe('DocumentPreview', () => {
const results = {
matching_results: 1,
results: [selectedResult]
};
} as unknown as DiscoveryV2.QueryResponse;

render(
<DiscoverySearch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function normalizeText(text: string): string {
export class TextNormalizer {
readonly rawText: string;
readonly normalizedText: string;
private readonly normalizationMappings: SpanMapping[];
readonly normalizationMappings: SpanMapping[];

constructor(rawText: string) {
this.rawText = rawText;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from 'react';
import { act, render, BoundFunction, GetByText } from '@testing-library/react';
import DiscoveryV2 from 'ibm-watson/discovery/v2';
import 'utils/test/createRange.mock';
import SimpleDocument from '../SimpleDocument';
import { wrapWithContext } from 'utils/testingUtils';
import docArrayJson from 'components/DocumentPreview/__fixtures__/ArtEffectsTextArray.json';
import { SearchApiIFC, SearchContextIFC } from 'components/DiscoverySearch/DiscoverySearch';
import { wrapWithContext } from 'utils/testingUtils';
import SimpleDocument from '../SimpleDocument';

const noop = (): any => {
throw new Error();
Expand All @@ -16,7 +17,7 @@ describe('SimpleDocument', () => {
extracted_metadata: {
filename: 'i_am_a_file'
}
};
} as unknown as DiscoveryV2.QueryResult;

beforeAll(() => {
window.HTMLElement.prototype.scrollIntoView = jest.fn();
Expand All @@ -29,6 +30,8 @@ describe('SimpleDocument', () => {
document={minimalDoc}
setHideToolbarControls={(): void => {}}
setLoading={(): void => {}}
loading={false}
hideToolbarControls={false}
/>
);
});
Expand All @@ -42,9 +45,11 @@ describe('SimpleDocument', () => {
act(() => {
({ getByText } = render(
<SimpleDocument
document={docArrayJson}
document={docArrayJson as unknown as DiscoveryV2.QueryResult}
setLoading={(): void => {}}
setHideToolbarControls={(): void => mock('setHideToolbarControls called')}
loading={false}
hideToolbarControls={false}
/>
));
});
Expand All @@ -59,7 +64,7 @@ describe('SimpleDocument', () => {
const documentText = 'This is the text of the document.';
const customDoc = {
body_field: documentText
};
} as unknown as DiscoveryV2.QueryResult;
const context: Partial<SearchContextIFC> = {
componentSettings: {
fields_shown: {
Expand All @@ -79,6 +84,8 @@ describe('SimpleDocument', () => {
document={customDoc}
setHideToolbarControls={(): void => {}}
setLoading={(): void => {}}
loading={false}
hideToolbarControls={false}
/>,
api,
context
Expand All @@ -96,7 +103,7 @@ describe('SimpleDocument', () => {
const customDoc = {
body_field: bodyText,
passage_field: passageText
};
} as unknown as DiscoveryV2.QueryResult;

const context: Partial<SearchContextIFC> = {
componentSettings: {
Expand Down Expand Up @@ -126,6 +133,8 @@ describe('SimpleDocument', () => {
highlight={highlight}
setHideToolbarControls={(): void => {}}
setLoading={(): void => {}}
loading={false}
hideToolbarControls={false}
/>,
api,
context
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { QueryResult } from 'ibm-watson/discovery/v2';
import { detectPreviewType, getTextMappings, isCsvFile, isJsonFile } from '../documentData';
import jsonDoc from '../../__fixtures__/Art Effects Koya Creative Base TSA 2008.pdf.json';

describe('documentData', () => {
const noMetadata = {
extracted_metadata: {}
};
} as unknown as QueryResult;

let consoleError: jest.SpyInstance<any, any>;

Expand Down Expand Up @@ -73,7 +74,7 @@ describe('documentData', () => {
extracted_metadata: {
file_type: 'json'
}
};
} as unknown as QueryResult;
it('returns true if the document is a JSON file', () => {
const docTypeJson = isJsonFile(jsonFileType);
expect(docTypeJson).toEqual(true);
Expand All @@ -83,7 +84,7 @@ describe('documentData', () => {
extracted_metadata: {
file_type: 'csv'
}
};
} as unknown as QueryResult;
it('returns true if the document is a CSV file', () => {
const docTypeJson = isCsvFile(csvFileType);
expect(docTypeJson).toEqual(true);
Expand All @@ -93,7 +94,7 @@ describe('documentData', () => {
extracted_metadata: {
file_type: true
}
};
} as unknown as QueryResult;
it('returns false if the file type provided is not a string', () => {
const falseDocType = isJsonFile(noStringFileType);
expect(falseDocType).toEqual(false);
Expand Down
Loading

0 comments on commit 11c1f93

Please sign in to comment.