Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/production' into saveEntity_proc…
Browse files Browse the repository at this point in the history
…ess_transactional
  • Loading branch information
daneryl committed Feb 4, 2025
2 parents 6d311c2 + aec3851 commit 76bf90c
Show file tree
Hide file tree
Showing 32 changed files with 552 additions and 879 deletions.
30 changes: 15 additions & 15 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ updates:
schedule:
interval: daily
ignore:
- dependency-name: "@types/*"
- dependency-name: "@sentry/node" #6880
versions: [">= 7.114.0"]
- dependency-name: '@types/*'
- dependency-name: '@sentry/node' #6880
versions: ['>= 7.114.0']
- dependency-name: flowbite #Flowbite & flowbite-datepicker upgrade #6993
versions: [">= 2.3.1"]
versions: ['>= 2.3.1']
- dependency-name: flowbite-datepicker #Flowbite & flowbite-datepicker upgrade #6993
versions: [">= 1.2.8"]
versions: ['>= 1.2.8']
- dependency-name: flowbite-react #Flowbite & flowbite-datepicker upgrade #6993
versions: [">= 0.10.1"]
versions: ['>= 0.10.1']
- dependency-name: Mongoose #Mongoose upgrade #7017
versions: [">= 8.4.3"]
- dependency-name: "@socket.io*"
Expand All @@ -23,14 +23,14 @@ updates:
- dependency-name: otplib
- dependency-name: redux
- dependency-name: redux-thunk
- dependency-name: "@typescript-eslint/eslint-plugin"
- dependency-name: "@typescript-eslint/parser"
- dependency-name: '@typescript-eslint/eslint-plugin'
- dependency-name: '@typescript-eslint/parser'
- dependency-name: eslint #6784
- dependency-name: fetch-mock
- dependency-name: react-router-dom
- dependency-name: react-datepicker
- dependency-name: recharts
- dependency-name: "@headlessui/react"
- dependency-name: '@headlessui/react'
- dependency-name: react-player
open-pull-requests-limit: 5
labels:
Expand All @@ -40,19 +40,19 @@ updates:
babel:
applies-to: version-updates
patterns:
- "@babel*"
- '@babel*'
storybook:
applies-to: version-updates
patterns:
- "@storybook*"
- '@storybook*'
sentry:
applies-to: version-updates
patterns:
- "@sentry*"
- '@sentry*'
dnd-kit:
applies-to: version-updates
patterns:
- "@dnd-kit*"
- '@dnd-kit*'
socket.io:
applies-to: version-updates
patterns:
Expand All @@ -69,9 +69,9 @@ updates:
applies-to: version-updates
update-types: [minor, patch]
patterns:
- "*"
- '*'
dev-major-dependencies:
applies-to: version-updates
update-types: [major]
patterns:
- "*"
- '*'
4 changes: 2 additions & 2 deletions app/api/entities/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,15 +506,15 @@ export default {
async getUnrestrictedWithDocuments(query, select, options = {}) {
const { documentsFullText, ...restOfOptions } = options;
const entities = await this.getUnrestricted(query, select, restOfOptions);
return withDocuments(entities, documentsFullText, restOfOptions);
return withDocuments(entities, documentsFullText);
},

async get(query, select, options = {}) {
const { withoutDocuments, documentsFullText, ...restOfOptions } = options;
const extendedSelect = withoutDocuments ? select : extendSelect(select);
const entities = await model.get(query, extendedSelect, restOfOptions);

return withoutDocuments ? entities : withDocuments(entities, documentsFullText, options);
return withoutDocuments ? entities : withDocuments(entities, documentsFullText);
},

async getWithRelationships(query, select, pagination) {
Expand Down
4 changes: 2 additions & 2 deletions app/api/entities/managerFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { files as filesAPI, storage } from 'api/files';
import { processDocument } from 'api/files/processDocument';
import { search } from 'api/search';
import { legacyLogger } from 'api/log';
import { prettifyError } from 'api/utils/handleError';
import { handleError, prettifyError } from 'api/utils/handleError';
import { ClientEntitySchema } from 'app/istore';
import { FileType } from 'shared/types/fileType';
import { MetadataObjectSchema } from 'shared/types/commonTypes';
Expand Down Expand Up @@ -205,7 +205,7 @@ const saveFiles = async (
.filter(result => result.status === 'rejected')
.map(rejected => {
const { reason } = rejected as PromiseRejectedResult;
return legacyLogger.error(prettifyError(reason));
handleError(reason);
});

if (socketEmiter) {
Expand Down
5 changes: 3 additions & 2 deletions app/api/entities/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default app => {
activitylogMiddleware,
async (req, res, next) => {
try {
await withTransaction(async ({ abort }) => {
const result = await withTransaction(async ({ abort }) => {
const entityToSave = req.body.entity ? JSON.parse(req.body.entity) : req.body;
const result = await saveEntity(entityToSave, {

Check failure on line 86 in app/api/entities/routes.js

View workflow job for this annotation

GitHub Actions / eslint

'result' is already declared in the upper scope on line 84 column 15
user: req.user,
Expand All @@ -94,8 +94,9 @@ export default app => {
if (errors.length) {
await abort();
}
res.json(req.body.entity ? result : entity);
return req.body.entity ? result : entity;
});
res.json(result);
} catch (e) {
next(e);
}
Expand Down
2 changes: 1 addition & 1 deletion app/api/files/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const files = {
await filesModel.delete(query);
if (toDeleteFiles.length > 0) {
const idsToDelete = toDeleteFiles.map(f => f._id!.toString());
await connections.delete({ file: { $in: idsToDelete } }, null, false);
await connections.delete({ file: { $in: idsToDelete } });
await V2.deleteTextReferencesToFiles(idsToDelete);

await Promise.all(
Expand Down
27 changes: 16 additions & 11 deletions app/api/utils/testingEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,25 @@ const testingEnvironment = {
},

setFakeContext() {
const originalAppContextGet = appContext.get.bind(appContext);

appContextGetMock = jest.spyOn(appContext, 'get').mockImplementation((key: string) => {
if (key === 'mongoSession') {
return undefined;
}
return originalAppContextGet(key);
});
appContextSetMock = jest.spyOn(appContext, 'set').mockImplementation(() => {});
if (!jest.isMockFunction(appContext.get)) {
const originalAppContextGet = appContext.get.bind(appContext);
appContextGetMock = jest.spyOn(appContext, 'get').mockImplementation((key: string) => {
if (key === 'mongoSession' || key === 'fileOperations' || key === 'reindexOperations') {
return undefined;
}
return originalAppContextGet(key);
});
appContextSetMock = jest.spyOn(appContext, 'set').mockImplementation(() => {});
}
},

unsetFakeContext() {
appContextGetMock.mockRestore();
appContextSetMock.mockRestore();
if (jest.isMockFunction(appContext.get)) {
appContextGetMock.mockRestore();
}
if (jest.isMockFunction(appContext.set)) {
appContextSetMock.mockRestore();
}
},

async setFixtures(fixtures?: DBFixture) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ exports[`StackedDualBarChart should allow overriding default data and label and
height={320}
>
<BarChart
barCategoryGap="10%"
barGap={4}
data={
Array [
Object {
Expand All @@ -18,7 +16,6 @@ exports[`StackedDualBarChart should allow overriding default data and label and
]
}
height={300}
layout="horizontal"
margin={
Object {
"bottom": 0,
Expand All @@ -27,9 +24,6 @@ exports[`StackedDualBarChart should allow overriding default data and label and
"top": 0,
}
}
reverseStackOrder={false}
stackOffset="none"
syncMethod="index"
>
<XAxis
allowDataOverflow={false}
Expand Down Expand Up @@ -215,11 +209,8 @@ exports[`StackedDualBarChart should render a BarChart with default values 1`] =
height={320}
>
<BarChart
barCategoryGap="10%"
barGap={4}
data={Array []}
height={300}
layout="horizontal"
margin={
Object {
"bottom": 0,
Expand All @@ -228,9 +219,6 @@ exports[`StackedDualBarChart should render a BarChart with default values 1`] =
"top": 0,
}
}
reverseStackOrder={false}
stackOffset="none"
syncMethod="index"
>
<XAxis
allowDataOverflow={false}
Expand Down
4 changes: 1 addition & 3 deletions app/react/Forms/components/specs/MediaField.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,7 @@ describe('MediaField', () => {
await render(imageProps);
const img = renderResult.container.getElementsByTagName('img')[0];
fireEvent.error(img);
expect(
await screen.findByText('This file type is not supported on media fields')
).toBeInTheDocument();
expect(await screen.findByText('Error loading your image')).toBeInTheDocument();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ exports[`BarChart Markdown component should render the data passed by mapStateTo
height={320}
>
<BarChart
barCategoryGap="10%"
barGap={4}
data={
Array [
Object {
Expand All @@ -44,17 +42,6 @@ exports[`BarChart Markdown component should render the data passed by mapStateTo
}
height={300}
layout="horizontal"
margin={
Object {
"bottom": 5,
"left": 5,
"right": 5,
"top": 5,
}
}
reverseStackOrder={false}
stackOffset="none"
syncMethod="index"
>
<XAxis
allowDataOverflow={false}
Expand Down Expand Up @@ -198,8 +185,6 @@ exports[`BarChart Markdown component when excludeZero should render without zero
height={320}
>
<BarChart
barCategoryGap="10%"
barGap={4}
data={
Array [
Object {
Expand All @@ -221,17 +206,6 @@ exports[`BarChart Markdown component when excludeZero should render without zero
}
height={300}
layout="horizontal"
margin={
Object {
"bottom": 5,
"left": 5,
"right": 5,
"top": 5,
}
}
reverseStackOrder={false}
stackOffset="none"
syncMethod="index"
>
<XAxis
allowDataOverflow={false}
Expand Down Expand Up @@ -420,8 +394,6 @@ exports[`BarChart Markdown component when passing maxCategories should only rend
height={320}
>
<BarChart
barCategoryGap="10%"
barGap={4}
data={
Array [
Object {
Expand All @@ -438,17 +410,6 @@ exports[`BarChart Markdown component when passing maxCategories should only rend
}
height={300}
layout="horizontal"
margin={
Object {
"bottom": 5,
"left": 5,
"right": 5,
"top": 5,
}
}
reverseStackOrder={false}
stackOffset="none"
syncMethod="index"
>
<XAxis
allowDataOverflow={false}
Expand Down Expand Up @@ -582,8 +543,6 @@ exports[`BarChart Markdown component when passing maxCategories should render ot
height={320}
>
<BarChart
barCategoryGap="10%"
barGap={4}
data={
Array [
Object {
Expand All @@ -601,17 +560,6 @@ exports[`BarChart Markdown component when passing maxCategories should render ot
}
height={300}
layout="horizontal"
margin={
Object {
"bottom": 5,
"left": 5,
"right": 5,
"top": 5,
}
}
reverseStackOrder={false}
stackOffset="none"
syncMethod="index"
>
<XAxis
allowDataOverflow={false}
Expand Down Expand Up @@ -745,8 +693,6 @@ exports[`BarChart Markdown component when passing scatter parameter should displ
height={320}
>
<BarChart
barCategoryGap="10%"
barGap={4}
data={
Array [
Object {
Expand Down Expand Up @@ -783,17 +729,6 @@ exports[`BarChart Markdown component when passing scatter parameter should displ
}
height={300}
layout="horizontal"
margin={
Object {
"bottom": 5,
"left": 5,
"right": 5,
"top": 5,
}
}
reverseStackOrder={false}
stackOffset="none"
syncMethod="index"
>
<XAxis
allowDataOverflow={false}
Expand Down
Loading

0 comments on commit 76bf90c

Please sign in to comment.