diff --git a/test/helpers/api-integration.helper.js b/test/helpers/api-integration.helper.js index 0154d51035..644576e3fc 100644 --- a/test/helpers/api-integration.helper.js +++ b/test/helpers/api-integration.helper.js @@ -6,8 +6,6 @@ import { } from 'lodash'; import { MongoClient as mongo } from 'mongodb'; import { v4 as generateUUID } from 'uuid'; -import i18n from '../../common/script/src/i18n'; -i18n.translations = require('../../website/src/libs/i18n.js').translations; import { ApiUser, ApiGroup } from './api-integration/api-classes'; @@ -17,22 +15,7 @@ import { requester } from './api-integration/requester' requester.setApiVersion('v2'); export { requester }; - -// Use this to verify error messages returned by the server -// That way, if the translated string changes, the test -// will not break. NOTE: it checks against errors with string as well. -export function translate (key, variables) { - const STRING_ERROR_MSG = 'Error processing the string. Please see Help > Report a Bug.'; - const STRING_DOES_NOT_EXIST_MSG = /^String '.*' not found.$/; - - let translatedString = i18n.t(key, variables); - - expect(translatedString).to.not.be.empty; - expect(translatedString).to.not.eql(STRING_ERROR_MSG); - expect(translatedString).to.not.match(STRING_DOES_NOT_EXIST_MSG); - - return translatedString; -} +export { translate } from './api-integration/translate'; // Useful for checking things that have been deleted, // but you no longer have access to, diff --git a/test/helpers/api-integration/translate.js b/test/helpers/api-integration/translate.js new file mode 100644 index 0000000000..b37df1618c --- /dev/null +++ b/test/helpers/api-integration/translate.js @@ -0,0 +1,19 @@ +import i18n from '../../../common/script/src/i18n'; +i18n.translations = require('../../../website/src/libs/i18n.js').translations; + +// Use this to verify error messages returned by the server +// That way, if the translated string changes, the test +// will not break. NOTE: it checks against errors with string as well. +export function translate (key, variables) { + const STRING_ERROR_MSG = 'Error processing the string. Please see Help > Report a Bug.'; + const STRING_DOES_NOT_EXIST_MSG = /^String '.*' not found.$/; + + let translatedString = i18n.t(key, variables); + + expect(translatedString).to.not.be.empty; + expect(translatedString).to.not.eql(STRING_ERROR_MSG); + expect(translatedString).to.not.match(STRING_DOES_NOT_EXIST_MSG); + + return translatedString; +} +