Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
daneryl committed Mar 4, 2021
1 parent a9f8a39 commit a9d15fc
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 44 deletions.
2 changes: 1 addition & 1 deletion app/api/entities/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ async function updateEntity(entity, _template) {
d.template = entity.template;
}

if (typeof entity.template !== 'undefined') {
if (typeof entity.generatedToc !== 'undefined') {
d.generatedToc = entity.generatedToc;
}
return model.save(d);
Expand Down
15 changes: 15 additions & 0 deletions app/api/entities/specs/entities.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,21 @@ describe('entities', () => {
});
});

describe('when generatedToc is undefined', () => {
it('should not replicate the value to all languages', async () => {
const doc = { _id: batmanFinishesId, sharedId: 'shared', generatedToc: true };
await entities.save(doc, { language: 'en' });
await entities.save({ _id: batmanFinishesId, sharedId: 'shared' }, { language: 'en' });
const [docES, docEN] = await Promise.all([
entities.getById('shared', 'es'),
entities.getById('shared', 'en'),
]);

expect(docES.generatedToc).toBe(true);
expect(docEN.generatedToc).toBe(true);
});
});

it('should sync select/multiselect/dates/multidate/multidaterange/numeric', done => {
const doc = {
_id: syncPropertiesEntityId,
Expand Down
2 changes: 1 addition & 1 deletion app/api/search/elasticTypes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RequestParams } from '@elastic/elasticsearch';
import { RequestBody } from '@elastic/elasticsearch/lib/Transport';
import { Aggregations } from 'shared/types/Aggregations.d.ts';
import { Aggregations } from 'shared/types/Aggregations';

interface ShardsResponse {
total: number;
Expand Down
1 change: 0 additions & 1 deletion app/react/App/scss/modules/_search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@
padding: 15px;
color: $c-grey-dark;


&:not(:last-child),
.form-group:not(:last-child) & {
border-bottom: 1px solid $c-grey-light;
Expand Down
1 change: 0 additions & 1 deletion app/react/Documents/components/DocumentSidePanel.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable max-lines */
import { Tabs, TabLink, TabContent } from 'react-tabs-redux';
import { browserHistory } from 'react-router';
import { connect } from 'react-redux';
Expand Down
3 changes: 2 additions & 1 deletion app/react/Documents/components/scss/showToc.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@
float: right;
font-weight: normal;
padding-right: 4px;
}
}

2 changes: 0 additions & 2 deletions app/react/Documents/components/scss/toc.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import '../../../App/scss/config/_colors.scss';

.tocHeader {
h1 {
display: inline-block;
Expand Down
4 changes: 1 addition & 3 deletions app/react/Library/actions/specs/libraryActions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe('libraryActions', () => {
const aggregations = [{ prop: { buckets: [] } }];
const templates = [{ name: 'Decision' }, { name: 'Ruling' }];
const thesauris = [{ _id: 'abc1' }];
let getState;

describe('setDocuments', () => {
it('should return a SET_DOCUMENTS action ', () => {
Expand All @@ -40,7 +41,6 @@ describe('libraryActions', () => {
describe('setTemplates', () => {
const documentTypes = ['typea'];
let dispatch;
let getState;
const filters = {
documentTypes,
properties: ['library properties'],
Expand Down Expand Up @@ -160,10 +160,8 @@ describe('libraryActions', () => {

afterEach(() => backend.restore());

//eslint-disable-next-line max-statements
describe('searchDocuments', () => {
let store;
let getState;
let state;
const storeKey = 'library';
beforeEach(() => {
Expand Down
4 changes: 2 additions & 2 deletions app/react/ToggledFeatures/tocGeneration/TocGeneratedLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { FileType } from 'shared/types/fileType';

export interface TocGeneratedLabelProps {
file: FileType;
children: JSX.Element | string;
children: React.ReactChild;
}

export const TocGeneratedLabel = ({ file, children }: TocGeneratedLabelProps) => (
<FeatureToggle feature="tocGeneration">
{file.generatedToc && <span className="badge">{children}</span>}
{file.generatedToc && <div className="badge">{children}</div>}
</FeatureToggle>
);
41 changes: 10 additions & 31 deletions app/react/ToggledFeatures/tocGeneration/specs/actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ import { tocGenerationActions } from '../actions';
const middlewares = [thunk];
const mockStore = configureMockStore(middlewares);

const createDoc = (generatedToc: boolean, fileId: string): ClientEntitySchema => ({
name: 'doc',
_id: 'id',
sharedId: 'sharedId',
defaultDoc: { _id: fileId, generatedToc },
documents: [{ _id: fileId, generatedToc }],
});

describe('reviewToc', () => {
it('should store the document with the response of reviewToc', done => {
mockID();
Expand All @@ -26,37 +34,8 @@ describe('reviewToc', () => {
type: 'reloadRelationships',
});

const doc: ClientEntitySchema = {
name: 'doc',
_id: 'id',
sharedId: 'sharedId',
defaultDoc: {
_id: fileId,
generatedToc: true,
},
documents: [
{
_id: fileId,
generatedToc: true,
},
],
};

const updatedEntity = {
name: 'doc',
_id: 'id',
sharedId: 'sharedId',
defaultDoc: {
_id: fileId,
generatedToc: false,
},
documents: [
{
_id: fileId,
generatedToc: false,
},
],
};
const doc = createDoc(true, fileId);
const updatedEntity = createDoc(false, fileId);

const expectedActions = [
{ type: 'rrf/reset', model: 'documentViewer.sidepanel.metadata' },
Expand Down
2 changes: 1 addition & 1 deletion app/shared/types/settingsSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export const settingsSchema = {
_id: { type: 'string' },
tocGeneration: {
type: 'object',
required: ['active', 'url'],
required: ['url'],
additionalProperties: false,
properties: {
url: { type: 'string' },
Expand Down

0 comments on commit a9d15fc

Please sign in to comment.