-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3568 from huridocs/3553-missing-title-in-sync
Added custom title to translations in sync
- Loading branch information
Showing
6 changed files
with
115 additions
and
6 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
app/api/migrations/migrations/37-resync-translations/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export default { | ||
delta: 37, | ||
|
||
name: 'resync-tranlsations', | ||
|
||
description: 'Moves timestamp of current translation update logs forward to force resync', | ||
|
||
async up(db) { | ||
process.stdout.write('Updating updatelogs of translations...\r\n'); | ||
|
||
await db | ||
.collection('updatelogs') | ||
.updateMany({ namespace: 'translations' }, { $set: { timestamp: Date.now() } }); | ||
|
||
process.stdout.write('Updatelogs updated\r\n'); | ||
}, | ||
}; |
47 changes: 47 additions & 0 deletions
47
app/api/migrations/migrations/37-resync-translations/specs/37-resync-translations.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import testingDB from 'api/utils/testing_db'; | ||
import migration from '../index.js'; | ||
import fixtures, { translation1, translation2, translation3, entity1 } from './fixtures'; | ||
|
||
describe('migration resync translations', () => { | ||
let updatelogs; | ||
|
||
beforeEach(async () => { | ||
await testingDB.clearAllAndLoad(fixtures); | ||
spyOn(process.stdout, 'write'); | ||
spyOn(Date, 'now').and.returnValue(1000); | ||
await migration.up(testingDB.mongodb); | ||
}); | ||
|
||
afterAll(async () => { | ||
await testingDB.disconnect(); | ||
}); | ||
|
||
const getUpdatelog = mongoId => updatelogs.find(l => l.mongoId.toString() === mongoId.toString()); | ||
|
||
const expectLog = (logEntry, [namespace, deleted, timestamp]) => { | ||
expect(logEntry).toEqual(expect.objectContaining({ namespace, deleted, timestamp })); | ||
}; | ||
|
||
it('should have a delta number', () => { | ||
expect(migration.delta).toBe(37); | ||
}); | ||
|
||
it('should update the translation updatelogs to current timestamp and not affect others', async () => { | ||
updatelogs = await testingDB.mongodb | ||
.collection('updatelogs') | ||
.find({}) | ||
.toArray(); | ||
|
||
expect(updatelogs.length).toBe(4); | ||
|
||
const logTranslation1 = getUpdatelog(translation1); | ||
const logTranslation2 = getUpdatelog(translation2); | ||
const logTranslation3 = getUpdatelog(translation3); | ||
const logEntity1 = getUpdatelog(entity1); | ||
|
||
expectLog(logTranslation1, ['translations', false, 1000]); | ||
expectLog(logTranslation2, ['translations', false, 1000]); | ||
expectLog(logTranslation3, ['translations', true, 1000]); | ||
expectLog(logEntity1, ['entities', true, 8]); | ||
}); | ||
}); |
37 changes: 37 additions & 0 deletions
37
app/api/migrations/migrations/37-resync-translations/specs/fixtures.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import testingDB from 'api/utils/testing_db'; | ||
|
||
const translation1 = testingDB.id(); | ||
const translation2 = testingDB.id(); | ||
const translation3 = testingDB.id(); | ||
const entity1 = testingDB.id(); | ||
|
||
export default { | ||
updatelogs: [ | ||
{ | ||
mongoId: translation1, | ||
namespace: 'translations', | ||
deleted: false, | ||
timestamp: 6, | ||
}, | ||
{ | ||
mongoId: entity1, | ||
namespace: 'entities', | ||
deleted: true, | ||
timestamp: 8, | ||
}, | ||
{ | ||
mongoId: translation2, | ||
namespace: 'translations', | ||
deleted: false, | ||
timestamp: 10, | ||
}, | ||
{ | ||
mongoId: translation3, | ||
namespace: 'translations', | ||
deleted: true, | ||
timestamp: 12, | ||
}, | ||
], | ||
}; | ||
|
||
export { translation1, translation2, translation3, entity1 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters