Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/production' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
daneryl committed Sep 28, 2023
2 parents a68a929 + d0a3ebb commit 255484e
Show file tree
Hide file tree
Showing 31 changed files with 195 additions and 1,589 deletions.
1 change: 0 additions & 1 deletion app/api/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export const config = {
activityLogs: ACTIVITY_LOGS_FOLDER || `${filesRootPath}/log/`,
featureFlags: {
s3Storage: false,
translationsV2: false,
},
},
externalServices: Boolean(process.env.EXTERNAL_SERVICES) || false,
Expand Down
5 changes: 2 additions & 3 deletions app/api/csv/specs/csvLoaderFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import db from 'api/utils/testing_db';
import { propertyTypes } from 'shared/propertyTypes';
import { templateUtils } from 'api/templates';
import { LanguageISO6391 } from 'shared/types/commonTypes';
import { fixturesTranslationsV2ToTranslationsLegacy } from 'api/i18n/specs/fixturesTranslationsV2ToTranslationsLegacy';
import { TranslationDBO } from 'api/i18n.v2/schemas/TranslationDBO';
import { getFixturesFactory } from 'api/utils/fixturesFactory';

Expand Down Expand Up @@ -164,11 +163,11 @@ export default {
},
],

translations: fixturesTranslationsV2ToTranslationsLegacy([
translationsV2: [
...commonTranslationsV2('en'),
...commonTranslationsV2('es'),
...commonTranslationsV2('fr'),
]),
],
};

export { template1Id, templateWithGeneratedTitle, thesauri1Id };
5 changes: 2 additions & 3 deletions app/api/csv/specs/csvLoaderSelectsFixtures.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import db from 'api/utils/testing_db';
import { getFixturesFactory } from 'api/utils/fixturesFactory';
import { fixturesTranslationsV2ToTranslationsLegacy } from 'api/i18n/specs/fixturesTranslationsV2ToTranslationsLegacy';

const fixtureFactory = getFixturesFactory();
const createTranslationDBO = fixtureFactory.v2.database.translationDBO;
Expand Down Expand Up @@ -76,7 +75,7 @@ const fixtures = {
],
},
],
translations: fixturesTranslationsV2ToTranslationsLegacy([
translationsV2: [
createTranslationDBO('B', 'Bes', 'es', {
id: fixtureFactory.id('multiselect_thesaurus').toString(),
type: 'Thesaurus',
Expand Down Expand Up @@ -197,7 +196,7 @@ const fixtures = {
type: 'Uwazi UI',
label: 'System',
}),
]),
],
};

export { fixtures, fixtureFactory };
3 changes: 1 addition & 2 deletions app/api/csv/specs/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import db, { DBFixture } from 'api/utils/testing_db';
import { propertyTypes } from 'shared/propertyTypes';
import { templateUtils } from 'api/templates';
import { TranslationDBO } from 'api/i18n.v2/schemas/TranslationDBO';
import { fixturesTranslationsV2ToTranslationsLegacy } from 'api/i18n/specs/fixturesTranslationsV2ToTranslationsLegacy';
import { getFixturesFactory } from 'api/utils/fixturesFactory';

const template1Id = db.id();
Expand Down Expand Up @@ -125,7 +124,7 @@ const fixtures: DBFixture = {
},
],

translations: fixturesTranslationsV2ToTranslationsLegacy(translationsV2),
translationsV2,
};

export { fixtures, template1Id, thesauri1Id, templateToRelateId };
14 changes: 4 additions & 10 deletions app/api/entities/specs/denormalization.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import thesauris from 'api/thesauri';
import { elasticTesting } from 'api/utils/elastic_testing';
import translations from 'api/i18n/translations';
import { getFixturesFactory } from '../../utils/fixturesFactory';
import { fixturesTranslationsV2ToTranslationsLegacy } from 'api/i18n/specs/fixturesTranslationsV2ToTranslationsLegacy';

const load = async (data: DBFixture, index?: string) => {
return db.setupFixturesAndContext(
const load = async (data: DBFixture, index?: string) =>
db.setupFixturesAndContext(
{
...data,
settings: [
Expand All @@ -22,14 +21,9 @@ const load = async (data: DBFixture, index?: string) => {
],
},
],
translations: data.translations || [
{ locale: 'en', contexts: [] },
{ locale: 'es', contexts: [] },
],
},
index
);
};

describe('Denormalize relationships', () => {
const factory = getFixturesFactory();
Expand Down Expand Up @@ -627,7 +621,7 @@ describe('Denormalize relationships', () => {
{ language: 'es' }
),
],
translations: fixturesTranslationsV2ToTranslationsLegacy([
translationsV2: [
createTranslationDBO('One', 'One', 'en', {
id: factory.id('Numbers').toString(),
type: 'Thesaurus',
Expand Down Expand Up @@ -659,7 +653,7 @@ describe('Denormalize relationships', () => {
type: 'Thesaurus',
label: 'Numbers',
}),
]),
],
},
'index_denormalization'
);
Expand Down
4 changes: 0 additions & 4 deletions app/api/entities/specs/entitiesDeleteMultiple.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ const loadFixtures = async () =>
],
},
],
translations: [
{ locale: 'en', contexts: [] },
{ locale: 'es', contexts: [] },
],
},
'entities.delete.multiple.spec2'
);
Expand Down
5 changes: 2 additions & 3 deletions app/api/entities/specs/fixtures.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable max-lines */
/* eslint-disable max-len */
import { fixturesTranslationsV2ToTranslationsLegacy } from 'api/i18n/specs/fixturesTranslationsV2ToTranslationsLegacy';
import { getFixturesFactory } from 'api/utils/fixturesFactory';
import db from 'api/utils/testing_db';
import { AccessLevels, PermissionType } from 'shared/types/permissionSchema';
Expand Down Expand Up @@ -661,7 +660,7 @@ export default {
],
},
],
translations: fixturesTranslationsV2ToTranslationsLegacy([
translationsV2: [
{
language: 'pt',
key: 'town2',
Expand Down Expand Up @@ -752,7 +751,7 @@ export default {
value: 'Country1',
context: { id: dictionary.toString(), type: 'Thesauri', label: 'dictionary' },
},
]),
],

ixsuggestions: [
{
Expand Down
2 changes: 1 addition & 1 deletion app/api/i18n.v2/database/MongoTranslationsDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,6 @@ export class MongoTranslationsDataSource
])
.toArray();

return result?.notFoundKeys || [];
return result?.notFoundKeys || keys;
}
}
2 changes: 0 additions & 2 deletions app/api/i18n/specs/fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { getFixturesFactory } from 'api/utils/fixturesFactory';
import db, { DBFixture } from 'api/utils/testing_db';
import { fixturesTranslationsV2ToTranslationsLegacy } from './fixturesTranslationsV2ToTranslationsLegacy';

const entityTemplateId = db.id();
const documentTemplateId = db.id();
Expand Down Expand Up @@ -164,7 +163,6 @@ const translationsV2: DBFixture['translationsV2'] = [
const fixtures: DBFixture = {
// eslint-disable-next-line camelcase
translationsV2,
translations: fixturesTranslationsV2ToTranslationsLegacy(translationsV2),
settings: [
{
_id: db.id(),
Expand Down
57 changes: 0 additions & 57 deletions app/api/i18n/specs/fixturesTranslationsV2ToTranslationsLegacy.ts

This file was deleted.

41 changes: 20 additions & 21 deletions app/api/i18n/specs/routes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { availableLanguages } from 'shared/languagesList';
import { LanguageSchema } from 'shared/types/commonTypes';
import { UserRole } from 'shared/types/userSchema';
import { DefaultTranslations } from '../defaultTranslations';
import { fixturesTranslationsV2ToTranslationsLegacy } from './fixturesTranslationsV2ToTranslationsLegacy';
import { sortByLocale } from './sortByLocale';

describe('i18n translations routes', () => {
Expand Down Expand Up @@ -65,9 +64,8 @@ describe('i18n translations routes', () => {
},
],
translationsV2,
translations: fixturesTranslationsV2ToTranslationsLegacy(translationsV2),
},
'index'
'index_i18n_routes'
);
});

Expand Down Expand Up @@ -305,12 +303,6 @@ describe('i18n translations routes', () => {
{
locale: 'zh',
contexts: [
{
id: 'contextID',
label: 'Template',
type: 'Entity',
values: { title: 'Template 1' },
},
{
id: 'System',
label: 'User Interface',
Expand All @@ -319,6 +311,12 @@ describe('i18n translations routes', () => {
Search: 'Search',
},
},
{
id: 'contextID',
label: 'Template',
type: 'Entity',
values: { title: 'Template 1' },
},
],
},
],
Expand All @@ -328,18 +326,18 @@ describe('i18n translations routes', () => {
{
locale: 'ja',
contexts: [
{
id: 'contextID',
label: 'Template',
type: 'Entity',
values: { title: 'Template 1' },
},
{
id: 'System',
label: 'User Interface',
type: 'Uwazi UI',
values: { Search: 'Search' },
},
{
id: 'contextID',
label: 'Template',
type: 'Entity',
values: { title: 'Template 1' },
},
],
},
],
Expand All @@ -366,6 +364,7 @@ describe('i18n translations routes', () => {

describe('when encountering an error', () => {
let mockCalls: any[];
jest.spyOn(console, 'error').mockImplementation(() => true);
let response: request.Response;
let settingsAddLanguageMock: jest.SpyInstance;

Expand Down Expand Up @@ -417,12 +416,6 @@ describe('i18n translations routes', () => {
expect(response.body).toMatchObject([
{
contexts: [
{
id: 'contextID',
label: 'Template',
type: 'Entity',
values: { title: 'Plantilla 1' },
},
{
id: 'System',
label: 'User Interface',
Expand All @@ -431,6 +424,12 @@ describe('i18n translations routes', () => {
Search: 'Buscar traducida',
},
},
{
id: 'contextID',
label: 'Template',
type: 'Entity',
values: { title: 'Plantilla 1' },
},
],
locale: 'es',
},
Expand Down
Loading

0 comments on commit 255484e

Please sign in to comment.