Merge branch 'develop' of https://github.com/NodeBB/NodeBB into develop

This commit is contained in:
Barış Soner Uşaklı
2023-10-13 12:59:30 -04:00
2 changed files with 33 additions and 13 deletions

View File

@@ -34,7 +34,7 @@
"@fortawesome/fontawesome-free": "6.4.2",
"@isaacs/ttlcache": "1.4.1",
"@popperjs/core": "2.11.8",
"ace-builds": "1.29.0",
"ace-builds": "1.30.0",
"archiver": "6.0.1",
"async": "3.2.4",
"autoprefixer": "10.4.16",

View File

@@ -38,7 +38,7 @@ describe('i18n', () => {
const sourceStrings = new Map();
describe('source language file structure', () => {
const test = /^[0-9\w.\-/]+$/;
const test = /^[a-zA-Z0-9-/]+(\.([0-9a-z]+([A-Z][0-9a-zA-Z]*)*-*\.?)+)*$/; // enhanced by chatgpt so only it knows what this does.
it('should only contain valid JSON files', async () => {
try {
@@ -56,6 +56,37 @@ describe('i18n', () => {
});
describe('should only contain lowercase or numeric language keys separated by either dashes or periods', async () => {
describe('(regexp validation)', () => {
const valid = [
'foo.bar', 'foo.bar-baz', 'foo.bar.baz-quux-lorem-ipsum-dolor-sit-amet', 'foo.barBazQuux', // human generated
"example-name.isValid", "kebab-case.isGood", "camelcase.isFine", "camelcase.with-dashes.isAlsoFine", "single-character.is-ok", "abc.def", // chatgpt generated
];
const invalid = [
// human generated
'foo.PascalCase', 'foo.snake_case',
'badger.badger_badger_badger',
'foo.BarBazQuux',
// chatgpt generated
"!notValid", // Starts with a special character
"with space.isInvalid", // Contains a space
".startsWithPeriod.isInvalid", // Starts with a period
"invalid..case.isInvalid", // Consecutive periods
"camelCase.With-Dashes.isAlsoInvalid", // PascalCase "With" is not allowed
];
valid.forEach((key) => {
it(key, () => {
assert(test.test(key))
});
});
invalid.forEach((key) => {
it(key, () => {
assert(!test.test(key))
});
});
});
fullPaths.forEach((fullPath) => {
if (fullPath.endsWith('_DO_NOT_EDIT_FILES_HERE.md')) {
return;
@@ -71,17 +102,6 @@ describe('i18n', () => {
});
});
});
/*
it('regexp used in test should test according to expectations', () => {
const valid = ['foo.bar', 'foo.bar-baz', 'foo.bar.baz-quux-lorem-ipsum-dolor-sit-amet'];
const invalid = [
'camelCase', 'PascalCase', 'snake_case', 'badger.badger_badger_badger', 'snnnaaaaaaAAAAAAkeeee'
];
assert(valid.every(key => test.test(key)));
assert(!invalid.every(key => test.test(key)));
});
*/
});
folders.forEach((language) => {