mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #20694 from overleaf/em-tracked-changes-accept-timestamp
Fix history timestamp when accepting tracked changes GitOrigin-RevId: d68aff0996e7d639f3dd4a68784c0dc0482c55ab
This commit is contained in:
parent
6c2cf20125
commit
4b7f58861a
3 changed files with 25 additions and 9 deletions
|
@ -230,6 +230,7 @@ const RangesManager = {
|
||||||
op: [op],
|
op: [op],
|
||||||
meta: {
|
meta: {
|
||||||
...change.metadata,
|
...change.metadata,
|
||||||
|
ts: Date.now(),
|
||||||
doc_length: docLength,
|
doc_length: docLength,
|
||||||
pathname,
|
pathname,
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,6 +13,7 @@ export type Update = {
|
||||||
meta?: {
|
meta?: {
|
||||||
tc?: boolean
|
tc?: boolean
|
||||||
user_id?: string
|
user_id?: string
|
||||||
|
ts?: number
|
||||||
}
|
}
|
||||||
projectHistoryId?: string
|
projectHistoryId?: string
|
||||||
}
|
}
|
||||||
|
@ -79,6 +80,7 @@ export type HistoryUpdate = {
|
||||||
doc: string
|
doc: string
|
||||||
v?: number
|
v?: number
|
||||||
meta?: {
|
meta?: {
|
||||||
|
ts?: number
|
||||||
pathname?: string
|
pathname?: string
|
||||||
doc_length?: number
|
doc_length?: number
|
||||||
history_doc_length?: number
|
history_doc_length?: number
|
||||||
|
|
|
@ -757,6 +757,7 @@ describe('RangesManager', function () {
|
||||||
|
|
||||||
describe('getHistoryUpdatesForAcceptedChanges', function () {
|
describe('getHistoryUpdatesForAcceptedChanges', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
this.clock = sinon.useFakeTimers()
|
||||||
this.RangesManager = SandboxedModule.require(MODULE_PATH, {
|
this.RangesManager = SandboxedModule.require(MODULE_PATH, {
|
||||||
requires: {
|
requires: {
|
||||||
'@overleaf/ranges-tracker': (this.RangesTracker =
|
'@overleaf/ranges-tracker': (this.RangesTracker =
|
||||||
|
@ -766,6 +767,10 @@ describe('RangesManager', function () {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
afterEach(function () {
|
||||||
|
this.clock.restore()
|
||||||
|
})
|
||||||
|
|
||||||
it('should create history updates for accepted track inserts', function () {
|
it('should create history updates for accepted track inserts', function () {
|
||||||
// 'one two three four five' <-- text before changes
|
// 'one two three four five' <-- text before changes
|
||||||
const ranges = {
|
const ranges = {
|
||||||
|
@ -777,6 +782,8 @@ describe('RangesManager', function () {
|
||||||
}
|
}
|
||||||
const lines = ['loremone two thipsumree four five']
|
const lines = ['loremone two thipsumree four five']
|
||||||
|
|
||||||
|
const now = Date.now()
|
||||||
|
|
||||||
const result = this.RangesManager.getHistoryUpdatesForAcceptedChanges({
|
const result = this.RangesManager.getHistoryUpdatesForAcceptedChanges({
|
||||||
docId: this.doc_id,
|
docId: this.doc_id,
|
||||||
acceptedChangeIds: ranges.changes.map(change => change.id),
|
acceptedChangeIds: ranges.changes.map(change => change.id),
|
||||||
|
@ -793,7 +800,7 @@ describe('RangesManager', function () {
|
||||||
user_id: TEST_USER_ID,
|
user_id: TEST_USER_ID,
|
||||||
doc_length: 33,
|
doc_length: 33,
|
||||||
pathname: '',
|
pathname: '',
|
||||||
ts: ranges.changes[0].metadata.ts,
|
ts: now,
|
||||||
},
|
},
|
||||||
op: [
|
op: [
|
||||||
{
|
{
|
||||||
|
@ -809,7 +816,7 @@ describe('RangesManager', function () {
|
||||||
user_id: TEST_USER_ID,
|
user_id: TEST_USER_ID,
|
||||||
doc_length: 33,
|
doc_length: 33,
|
||||||
pathname: '',
|
pathname: '',
|
||||||
ts: ranges.changes[1].metadata.ts,
|
ts: now,
|
||||||
},
|
},
|
||||||
op: [
|
op: [
|
||||||
{
|
{
|
||||||
|
@ -833,6 +840,8 @@ describe('RangesManager', function () {
|
||||||
}
|
}
|
||||||
const lines = ['one four five']
|
const lines = ['one four five']
|
||||||
|
|
||||||
|
const now = Date.now()
|
||||||
|
|
||||||
const result = this.RangesManager.getHistoryUpdatesForAcceptedChanges({
|
const result = this.RangesManager.getHistoryUpdatesForAcceptedChanges({
|
||||||
docId: this.doc_id,
|
docId: this.doc_id,
|
||||||
acceptedChangeIds: ranges.changes.map(change => change.id),
|
acceptedChangeIds: ranges.changes.map(change => change.id),
|
||||||
|
@ -850,7 +859,7 @@ describe('RangesManager', function () {
|
||||||
doc_length: 15,
|
doc_length: 15,
|
||||||
history_doc_length: 23,
|
history_doc_length: 23,
|
||||||
pathname: '',
|
pathname: '',
|
||||||
ts: ranges.changes[0].metadata.ts,
|
ts: now,
|
||||||
},
|
},
|
||||||
op: [
|
op: [
|
||||||
{
|
{
|
||||||
|
@ -866,7 +875,7 @@ describe('RangesManager', function () {
|
||||||
doc_length: 15,
|
doc_length: 15,
|
||||||
history_doc_length: 20,
|
history_doc_length: 20,
|
||||||
pathname: '',
|
pathname: '',
|
||||||
ts: ranges.changes[1].metadata.ts,
|
ts: now,
|
||||||
},
|
},
|
||||||
op: [
|
op: [
|
||||||
{
|
{
|
||||||
|
@ -889,6 +898,8 @@ describe('RangesManager', function () {
|
||||||
}
|
}
|
||||||
const lines = ['one four five']
|
const lines = ['one four five']
|
||||||
|
|
||||||
|
const now = Date.now()
|
||||||
|
|
||||||
const result = this.RangesManager.getHistoryUpdatesForAcceptedChanges({
|
const result = this.RangesManager.getHistoryUpdatesForAcceptedChanges({
|
||||||
docId: this.doc_id,
|
docId: this.doc_id,
|
||||||
acceptedChangeIds: [ranges.changes[1].id],
|
acceptedChangeIds: [ranges.changes[1].id],
|
||||||
|
@ -906,7 +917,7 @@ describe('RangesManager', function () {
|
||||||
doc_length: 15,
|
doc_length: 15,
|
||||||
history_doc_length: 23,
|
history_doc_length: 23,
|
||||||
pathname: '',
|
pathname: '',
|
||||||
ts: ranges.changes[1].metadata.ts,
|
ts: now,
|
||||||
},
|
},
|
||||||
op: [
|
op: [
|
||||||
{
|
{
|
||||||
|
@ -932,6 +943,8 @@ describe('RangesManager', function () {
|
||||||
}
|
}
|
||||||
const lines = ['one xxx four ']
|
const lines = ['one xxx four ']
|
||||||
|
|
||||||
|
const now = Date.now()
|
||||||
|
|
||||||
const result = this.RangesManager.getHistoryUpdatesForAcceptedChanges({
|
const result = this.RangesManager.getHistoryUpdatesForAcceptedChanges({
|
||||||
docId: this.doc_id,
|
docId: this.doc_id,
|
||||||
acceptedChangeIds: [
|
acceptedChangeIds: [
|
||||||
|
@ -954,7 +967,7 @@ describe('RangesManager', function () {
|
||||||
doc_length: 15,
|
doc_length: 15,
|
||||||
history_doc_length: 27,
|
history_doc_length: 27,
|
||||||
pathname: '',
|
pathname: '',
|
||||||
ts: ranges.changes[0].metadata.ts,
|
ts: now,
|
||||||
},
|
},
|
||||||
op: [
|
op: [
|
||||||
{
|
{
|
||||||
|
@ -970,7 +983,7 @@ describe('RangesManager', function () {
|
||||||
doc_length: 15,
|
doc_length: 15,
|
||||||
history_doc_length: 24,
|
history_doc_length: 24,
|
||||||
pathname: '',
|
pathname: '',
|
||||||
ts: ranges.changes[2].metadata.ts,
|
ts: now,
|
||||||
},
|
},
|
||||||
op: [
|
op: [
|
||||||
{
|
{
|
||||||
|
@ -988,7 +1001,7 @@ describe('RangesManager', function () {
|
||||||
doc_length: 15,
|
doc_length: 15,
|
||||||
history_doc_length: 24,
|
history_doc_length: 24,
|
||||||
pathname: '',
|
pathname: '',
|
||||||
ts: ranges.changes[3].metadata.ts,
|
ts: now,
|
||||||
},
|
},
|
||||||
op: [
|
op: [
|
||||||
{
|
{
|
||||||
|
@ -1011,7 +1024,7 @@ function makeRanges(ops) {
|
||||||
changes.push({
|
changes.push({
|
||||||
id: id.toString(),
|
id: id.toString(),
|
||||||
op,
|
op,
|
||||||
metadata: { user_id: TEST_USER_ID, ts: new Date(ts) },
|
metadata: { user_id: TEST_USER_ID, ts: new Date(ts).toISOString() },
|
||||||
})
|
})
|
||||||
id += 1
|
id += 1
|
||||||
ts += 1000 // use a unique timestamp for each change
|
ts += 1000 // use a unique timestamp for each change
|
||||||
|
|
Loading…
Reference in a new issue