| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709 |
- import { expect } from 'chai'
- import Settings from '@overleaf/settings'
- import assert from 'node:assert'
- import crypto from 'node:crypto'
- import mongodb from 'mongodb-legacy'
- import nock from 'nock'
- import * as ProjectHistoryClient from './helpers/ProjectHistoryClient.js'
- import * as ProjectHistoryApp from './helpers/ProjectHistoryApp.js'
- const { ObjectId } = mongodb
- const MockHistoryStore = () => nock('http://127.0.0.1:3100')
- const MockFileStore = () => nock('http://127.0.0.1:3009')
- const MockWeb = () => nock('http://127.0.0.1:3000')
- // Some helper methods to make the tests more compact
- function slTextUpdate(historyId, doc, userId, v, ts, op) {
- return {
- projectHistoryId: historyId,
- doc: doc.id,
- op,
- v,
- meta: {
- user_id: userId,
- ts: ts.getTime(),
- pathname: doc.pathname,
- doc_length: doc.length,
- },
- }
- }
- function slAddDocUpdate(historyId, doc, userId, ts, docLines, ranges = {}) {
- return {
- projectHistoryId: historyId,
- pathname: doc.pathname,
- ranges,
- docLines,
- doc: doc.id,
- meta: { user_id: userId, ts: ts.getTime() },
- }
- }
- function slAddDocUpdateWithVersion(
- historyId,
- doc,
- userId,
- ts,
- docLines,
- projectVersion,
- ranges = {}
- ) {
- const result = slAddDocUpdate(historyId, doc, userId, ts, docLines, ranges)
- result.version = projectVersion
- return result
- }
- function slAddFileUpdate(historyId, file, userId, ts, projectId) {
- return {
- projectHistoryId: historyId,
- pathname: file.pathname,
- url: `http://127.0.0.1:3009/project/${projectId}/file/${file.id}`,
- file: file.id,
- ranges: undefined,
- meta: { user_id: userId, ts: ts.getTime() },
- }
- }
- function createdBlobFileUpdate(historyId, file, userId, ts, projectId) {
- return {
- projectHistoryId: historyId,
- pathname: file.pathname,
- createdBlob: true,
- url: null,
- file: file.id,
- hash: file.hash,
- ranges: undefined,
- meta: { user_id: userId, ts: ts.getTime() },
- }
- }
- function slRenameUpdate(historyId, doc, userId, ts, pathname, newPathname) {
- return {
- projectHistoryId: historyId,
- pathname,
- new_pathname: newPathname,
- doc: doc.id,
- meta: { user_id: userId, ts: ts.getTime() },
- }
- }
- function olUpdate(doc, userId, ts, operations, v) {
- return {
- v2Authors: [userId],
- timestamp: ts.toJSON(),
- authors: [],
- operations,
- v2DocVersions: {
- [doc.id]: {
- pathname: doc.pathname.replace(/^\//, ''), // Strip leading /
- v: v || 1,
- },
- },
- }
- }
- function olTextOperation(doc, textOperation) {
- return {
- pathname: doc.pathname.replace(/^\//, ''), // Strip leading /
- textOperation,
- }
- }
- function olAddCommentOperation(doc, commentId, pos, length) {
- return {
- pathname: doc.pathname.replace(/^\//, ''), // Strip leading /
- commentId,
- ranges: [{ pos, length }],
- }
- }
- function olTextUpdate(doc, userId, ts, textOperation, v) {
- return olUpdate(doc, userId, ts, [olTextOperation(doc, textOperation)], v)
- }
- function olTextUpdates(doc, userId, ts, textOperations, v) {
- return olUpdate(
- doc,
- userId,
- ts,
- textOperations.map(textOperation => olTextOperation(doc, textOperation)),
- v
- )
- }
- function olRenameUpdate(doc, userId, ts, pathname, newPathname) {
- return {
- v2Authors: [userId],
- timestamp: ts.toJSON(),
- authors: [],
- operations: [
- {
- pathname,
- newPathname,
- },
- ],
- }
- }
- function olAddDocUpdate(doc, userId, ts, fileHash, rangesHash = undefined) {
- const update = {
- v2Authors: [userId],
- timestamp: ts.toJSON(),
- authors: [],
- operations: [
- {
- pathname: doc.pathname.replace(/^\//, ''), // Strip leading /
- file: {
- hash: fileHash,
- },
- },
- ],
- }
- if (rangesHash) {
- update.operations[0].file.rangesHash = rangesHash
- }
- return update
- }
- function olAddDocUpdateWithVersion(
- doc,
- userId,
- ts,
- fileHash,
- version,
- rangesHash = undefined
- ) {
- const result = olAddDocUpdate(doc, userId, ts, fileHash, rangesHash)
- result.projectVersion = version
- return result
- }
- function olAddFileUpdate(file, userId, ts, fileHash) {
- return {
- v2Authors: [userId],
- timestamp: ts.toJSON(),
- authors: [],
- operations: [
- {
- pathname: file.pathname.replace(/^\//, ''), // Strip leading /
- file: {
- hash: fileHash,
- },
- },
- ],
- }
- }
- describe('Sending Updates', function () {
- const historyId = new ObjectId().toString()
- beforeEach(async function () {
- this.timestamp = new Date()
- await ProjectHistoryApp.ensureRunning()
- this.userId = new ObjectId().toString()
- this.projectId = new ObjectId().toString()
- this.docId = new ObjectId().toString()
- this.doc = {
- id: this.docId,
- pathname: '/main.tex',
- length: 5,
- }
- MockHistoryStore().post('/api/projects').reply(200, {
- projectId: historyId,
- })
- MockWeb()
- .get(`/project/${this.projectId}/details`)
- .reply(200, {
- name: 'Test Project',
- overleaf: {
- history: {
- id: historyId,
- },
- },
- })
- await ProjectHistoryClient.initializeProject(historyId)
- })
- afterEach(function () {
- nock.cleanAll()
- })
- describe('basic update types', function () {
- beforeEach(function () {
- MockHistoryStore()
- .get(`/api/projects/${historyId}/latest/history`)
- .reply(200, {
- chunk: {
- startVersion: 0,
- history: {
- snapshot: {},
- changes: [],
- },
- },
- })
- })
- it('should send add doc updates to the history store', async function () {
- const fileHash = '0a207c060e61f3b88eaee0a8cd0696f46fb155eb'
- const createBlob = MockHistoryStore()
- .put(`/api/projects/${historyId}/blobs/${fileHash}`, 'a\nb')
- .reply(201)
- const addFile = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([
- olAddDocUpdate(this.doc, this.userId, this.timestamp, fileHash),
- ])
- return true
- })
- .query({ end_version: 0 })
- .reply(204)
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slAddDocUpdate(historyId, this.doc, this.userId, this.timestamp, 'a\nb')
- )
- await ProjectHistoryClient.flushProject(this.projectId)
- assert(
- createBlob.isDone(),
- '/api/projects/:historyId/blobs/:hash should have been called'
- )
- assert(
- addFile.isDone(),
- `/api/projects/${historyId}/changes should have been called`
- )
- })
- it('should send ranges to the history store', async function () {
- const fileHash = '49e886093b3eacbc12b99a1eb5aeaa44a6b9d90e'
- const rangesHash = 'fa9a429ff518bc9e5b2507a96ff0646b566eca65'
- const historyRanges = {
- trackedChanges: [
- {
- range: { pos: 4, length: 3 },
- tracking: {
- type: 'delete',
- userId: 'user-id-1',
- ts: '2024-01-01T00:00:00.000Z',
- },
- },
- ],
- comments: [
- {
- ranges: [{ pos: 0, length: 3 }],
- id: 'comment-id-1',
- },
- ],
- }
- // We need to set up the ranges mock first, as we will call it last..
- const createRangesBlob = MockHistoryStore()
- .put(`/api/projects/${historyId}/blobs/${rangesHash}`, historyRanges)
- .reply(201)
- const createBlob = MockHistoryStore()
- .put(`/api/projects/${historyId}/blobs/${fileHash}`, 'foo barbaz')
- .reply(201)
- const addFile = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([
- olAddDocUpdate(
- this.doc,
- this.userId,
- this.timestamp,
- fileHash,
- rangesHash
- ),
- ])
- return true
- })
- .query({ end_version: 0 })
- .reply(204)
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slAddDocUpdate(
- historyId,
- this.doc,
- this.userId,
- this.timestamp,
- 'foo barbaz',
- {
- changes: [
- {
- op: { p: 4, d: 'bar' },
- metadata: {
- ts: 1704067200000,
- user_id: 'user-id-1',
- },
- },
- ],
- comments: [
- {
- op: {
- p: 0,
- c: 'foo',
- t: 'comment-id-1',
- },
- metadata: { resolved: false },
- },
- ],
- }
- )
- )
- await ProjectHistoryClient.flushProject(this.projectId)
- assert(
- createBlob.isDone(),
- '/api/projects/:historyId/blobs/:hash should have been called to create content blob'
- )
- assert(
- createRangesBlob.isDone(),
- '/api/projects/:historyId/blobs/:hash should have been called to create ranges blob'
- )
- assert(
- addFile.isDone(),
- `/api/projects/${historyId}/changes should have been called`
- )
- })
- it('should strip non-BMP characters in add doc updates before sending to the history store', async function () {
- const fileHash = '11509fe05a41f9cdc51ea081342b5a4fc7c8d0fc'
- const createBlob = MockHistoryStore()
- .put(
- `/api/projects/${historyId}/blobs/${fileHash}`,
- 'a\nb\uFFFD\uFFFDc'
- )
- .reply(201)
- const addFile = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([
- olAddDocUpdate(this.doc, this.userId, this.timestamp, fileHash),
- ])
- return true
- })
- .query({ end_version: 0 })
- .reply(204)
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slAddDocUpdate(
- historyId,
- this.doc,
- this.userId,
- this.timestamp,
- 'a\nb\uD800\uDC00c'
- )
- )
- await ProjectHistoryClient.flushProject(this.projectId)
- assert(
- createBlob.isDone(),
- '/api/projects/:historyId/blobs/:hash should have been called'
- )
- assert(
- addFile.isDone(),
- `/api/projects/${historyId}/changes should have been called`
- )
- })
- it('should send text updates to the history store', async function () {
- const createChange = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([
- olTextUpdate(this.doc, this.userId, this.timestamp, [3, '\nc', 2]),
- ])
- return true
- })
- .query({ end_version: 0 })
- .reply(204)
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slTextUpdate(historyId, this.doc, this.userId, 1, this.timestamp, [
- { p: 3, i: '\nc' },
- ])
- )
- await ProjectHistoryClient.flushProject(this.projectId)
- assert(
- createChange.isDone(),
- `/api/projects/${historyId}/changes should have been called`
- )
- })
- it('should send renames to the history store', async function () {
- const createChange = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([
- olRenameUpdate(
- this.doc,
- this.userId,
- this.timestamp,
- 'main.tex',
- 'main2.tex'
- ),
- ])
- return true
- })
- .query({ end_version: 0 })
- .reply(204)
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slRenameUpdate(
- historyId,
- this.doc,
- this.userId,
- this.timestamp,
- '/main.tex',
- '/main2.tex'
- )
- )
- await ProjectHistoryClient.flushProject(this.projectId)
- assert(
- createChange.isDone(),
- `/api/projects/${historyId}/changes should have been called`
- )
- })
- it('should not get file from filestore if no url provided', async function () {
- const file = {
- id: new ObjectId().toString(),
- pathname: '/test.png',
- contents: Buffer.from([1, 2, 3]),
- hash: 'aed2973e4b8a7ff1b30ff5c4751e5a2b38989e74',
- }
- const fileStoreRequest = MockFileStore()
- .get(`/project/${this.projectId}/file/${file.id}`)
- .reply(200, file.contents)
- const checkBlob = MockHistoryStore()
- .head(`/api/projects/${historyId}/blobs/${file.hash}`)
- .reply(200)
- const addFile = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([
- olAddFileUpdate(file, this.userId, this.timestamp, file.hash),
- ])
- return true
- })
- .query({ end_version: 0 })
- .reply(204)
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- createdBlobFileUpdate(
- historyId,
- file,
- this.userId,
- this.timestamp,
- this.projectId
- )
- )
- await ProjectHistoryClient.flushProject(this.projectId)
- assert(
- !fileStoreRequest.isDone(),
- 'filestore should not have been called'
- )
- assert(
- checkBlob.isDone(),
- `HEAD /api/projects/${historyId}/blobs/${file.hash} should have been called`
- )
- assert(
- addFile.isDone(),
- `/api/projects/${historyId}/latest/files should have been called`
- )
- })
- it('should send add file updates to the history store', async function () {
- const file = {
- id: new ObjectId().toString(),
- pathname: '/test.png',
- contents: Buffer.from([1, 2, 3]),
- hash: 'aed2973e4b8a7ff1b30ff5c4751e5a2b38989e74',
- }
- const fileStoreRequest = MockFileStore()
- .get(`/project/${this.projectId}/file/${file.id}`)
- .reply(200, file.contents)
- const createBlob = MockHistoryStore()
- .put(`/api/projects/${historyId}/blobs/${file.hash}`, file.contents)
- .reply(201)
- const addFile = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([
- olAddFileUpdate(file, this.userId, this.timestamp, file.hash),
- ])
- return true
- })
- .query({ end_version: 0 })
- .reply(204)
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slAddFileUpdate(
- historyId,
- file,
- this.userId,
- this.timestamp,
- this.projectId
- )
- )
- await ProjectHistoryClient.flushProject(this.projectId)
- assert(
- fileStoreRequest.isDone(),
- `/project/${this.projectId}/file/${file.id} should have been called`
- )
- assert(
- createBlob.isDone(),
- `/api/projects/${historyId}/latest/files should have been called`
- )
- assert(
- addFile.isDone(),
- `/api/projects/${historyId}/latest/files should have been called`
- )
- })
- it('should send a stub to the history store when the file is large', async function () {
- const fileContents = Buffer.alloc(Settings.maxFileSizeInBytes + 1, 'X')
- const fileSize = Buffer.byteLength(fileContents)
- const fileHash = crypto
- .createHash('sha1')
- .update('blob ' + fileSize + '\x00')
- .update(fileContents, 'utf8')
- .digest('hex')
- const file = {
- id: new ObjectId().toString(),
- pathname: '/large.png',
- contents: fileContents,
- hash: fileHash,
- }
- const stubContents = [
- 'FileTooLargeError v1',
- 'File too large to be stored in history service',
- `id project-${this.projectId}-file-${file.id}`,
- `size ${fileSize} bytes`,
- `hash ${fileHash}`,
- '\0', // null byte to make this a binary file
- ].join('\n')
- const stubHash = crypto
- .createHash('sha1')
- .update('blob ' + Buffer.byteLength(stubContents) + '\x00')
- .update(stubContents, 'utf8')
- .digest('hex')
- const stub = {
- id: file.id,
- pathname: file.pathname,
- contents: stubContents,
- hash: stubHash,
- }
- const fileStoreRequest = MockFileStore()
- .get(`/project/${this.projectId}/file/${file.id}`)
- .reply(200, file.contents)
- const createBlob = MockHistoryStore()
- .put(`/api/projects/${historyId}/blobs/${stub.hash}`, stub.contents)
- .reply(201)
- const addFile = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([
- olAddFileUpdate(stub, this.userId, this.timestamp, stub.hash),
- ])
- return true
- })
- .query({ end_version: 0 })
- .reply(204)
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slAddFileUpdate(
- historyId,
- file,
- this.userId,
- this.timestamp,
- this.projectId
- )
- )
- await ProjectHistoryClient.flushProject(this.projectId)
- assert(
- addFile.isDone(),
- `/api/projects/${historyId}/latest/files should have been called`
- )
- assert(
- createBlob.isDone(),
- `/api/projects/${historyId}/latest/files should have been called`
- )
- assert(
- fileStoreRequest.isDone(),
- `/project/${this.projectId}/file/${file.id} should have been called`
- )
- })
- it('should handle comment ops', async function () {
- const createChange = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([
- olUpdate(this.doc, this.userId, this.timestamp, [
- olTextOperation(this.doc, [3, '\nc', 2]),
- olAddCommentOperation(this.doc, 'comment-id-1', 3, 2),
- ]),
- olUpdate(
- this.doc,
- this.userId,
- this.timestamp,
- [olAddCommentOperation(this.doc, 'comment-id-2', 2, 1)],
- 2
- ),
- ])
- return true
- })
- .query({ end_version: 0 })
- .reply(204)
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slTextUpdate(historyId, this.doc, this.userId, 1, this.timestamp, [
- { p: 3, i: '\nc' },
- { p: 3, c: '\nc', t: 'comment-id-1' },
- ])
- )
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slTextUpdate(historyId, this.doc, this.userId, 2, this.timestamp, [
- { p: 2, c: 'b', t: 'comment-id-2' },
- ])
- )
- await ProjectHistoryClient.flushProject(this.projectId)
- assert(
- createChange.isDone(),
- `/api/projects/${historyId}/changes should have been called`
- )
- })
- it('should be able to process lots of updates in batches', async function () {
- const BATCH_SIZE = 500
- const createFirstChangeBatch = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([
- olTextUpdate(
- this.doc,
- this.userId,
- this.timestamp,
- ['a'.repeat(BATCH_SIZE), 6],
- BATCH_SIZE - 1
- ),
- ])
- return true
- })
- .query({ end_version: 0 })
- .reply(204)
- const createSecondChangeBatch = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([
- olTextUpdate(
- this.doc,
- this.userId,
- this.timestamp,
- ['a'.repeat(50), BATCH_SIZE + 6],
- BATCH_SIZE - 1 + 50
- ),
- ])
- return true
- })
- .query({ end_version: 500 })
- .reply(204)
- // these need mocking again for the second batch
- MockHistoryStore()
- .get(`/api/projects/${historyId}/latest/history`)
- .reply(200, {
- chunk: {
- startVersion: BATCH_SIZE,
- history: {
- snapshot: {},
- changes: [],
- },
- },
- })
- MockWeb()
- .get(`/project/${this.projectId}/details`)
- .reply(200, {
- name: 'Test Project',
- overleaf: {
- history: {
- id: historyId,
- },
- },
- })
- // Push updates in a loop instead of using async.times
- for (let n = 0; n < BATCH_SIZE + 50; n++) {
- this.doc.length += 1
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slTextUpdate(historyId, this.doc, this.userId, n, this.timestamp, [
- { p: 0, i: 'a' },
- ])
- )
- }
- await ProjectHistoryClient.flushProject(this.projectId)
- assert(
- createFirstChangeBatch.isDone(),
- `/api/projects/${historyId}/changes should have been called for the first batch`
- )
- assert(
- createSecondChangeBatch.isDone(),
- `/api/projects/${historyId}/changes should have been called for the second batch`
- )
- })
- })
- describe('compressing updates', function () {
- beforeEach(function () {
- MockHistoryStore()
- .get(`/api/projects/${historyId}/latest/history`)
- .reply(200, {
- chunk: {
- startVersion: 0,
- history: {
- snapshot: {},
- changes: [],
- },
- },
- })
- })
- it('should concat adjacent text updates', async function () {
- const createChange = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([
- olTextUpdate(
- this.doc,
- this.userId,
- this.timestamp,
- [3, 'foobaz', 2],
- 2
- ),
- ])
- return true
- })
- .query({ end_version: 0 })
- .reply(204)
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slTextUpdate(historyId, this.doc, this.userId, 1, this.timestamp, [
- { p: 3, i: 'foobar' },
- { p: 6, d: 'bar' },
- ])
- )
- this.doc.length += 3
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slTextUpdate(historyId, this.doc, this.userId, 2, this.timestamp, [
- { p: 6, i: 'baz' },
- ])
- )
- await ProjectHistoryClient.flushProject(this.projectId)
- assert(
- createChange.isDone(),
- `/api/projects/${historyId}/changes should have been called`
- )
- })
- it('should take the timestamp of the first update', async function () {
- const timestamp1 = new Date(this.timestamp)
- const timestamp2 = new Date(this.timestamp.getTime() + 10000)
- const createChange = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([
- olTextUpdate(
- this.doc,
- this.userId,
- timestamp1,
- [3, 'foobaz', 2],
- 2
- ),
- ])
- return true
- })
- .query({ end_version: 0 })
- .reply(204)
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slTextUpdate(historyId, this.doc, this.userId, 1, timestamp1, [
- { p: 3, i: 'foo' },
- ])
- )
- this.doc.length += 3
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slTextUpdate(historyId, this.doc, this.userId, 2, timestamp2, [
- { p: 6, i: 'baz' },
- ])
- )
- await ProjectHistoryClient.flushProject(this.projectId)
- assert(
- createChange.isDone(),
- `/api/projects/${historyId}/changes should have been called`
- )
- })
- it('should not concat updates more than 60 seconds apart', async function () {
- const timestamp1 = new Date(this.timestamp)
- const timestamp2 = new Date(this.timestamp.getTime() + 120000)
- const createChange = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([
- olTextUpdate(this.doc, this.userId, timestamp1, [3, 'foo', 2], 1),
- olTextUpdate(this.doc, this.userId, timestamp2, [6, 'baz', 2], 2),
- ])
- return true
- })
- .query({ end_version: 0 })
- .reply(204)
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slTextUpdate(historyId, this.doc, this.userId, 1, timestamp1, [
- { p: 3, i: 'foo' },
- ])
- )
- this.doc.length += 3
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slTextUpdate(historyId, this.doc, this.userId, 2, timestamp2, [
- { p: 6, i: 'baz' },
- ])
- )
- await ProjectHistoryClient.flushProject(this.projectId)
- assert(
- createChange.isDone(),
- `/api/projects/${historyId}/changes should have been called`
- )
- })
- it('should not concat updates with different user_ids', async function () {
- const userId1 = new ObjectId().toString()
- const userId2 = new ObjectId().toString()
- const createChange = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([
- olTextUpdate(this.doc, userId1, this.timestamp, [3, 'foo', 2], 1),
- olTextUpdate(this.doc, userId2, this.timestamp, [6, 'baz', 2], 2),
- ])
- return true
- })
- .query({ end_version: 0 })
- .reply(204)
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slTextUpdate(historyId, this.doc, userId1, 1, this.timestamp, [
- { p: 3, i: 'foo' },
- ])
- )
- this.doc.length += 3
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slTextUpdate(historyId, this.doc, userId2, 2, this.timestamp, [
- { p: 6, i: 'baz' },
- ])
- )
- await ProjectHistoryClient.flushProject(this.projectId)
- assert(
- createChange.isDone(),
- `/api/projects/${historyId}/changes should have been called`
- )
- })
- it('should not concat updates with different docs', async function () {
- const doc1 = {
- id: new ObjectId().toString(),
- pathname: '/doc1.tex',
- length: 10,
- }
- const doc2 = {
- id: new ObjectId().toString(),
- pathname: '/doc2.tex',
- length: 10,
- }
- const createChange = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([
- olTextUpdate(doc1, this.userId, this.timestamp, [3, 'foo', 7], 1),
- olTextUpdate(doc2, this.userId, this.timestamp, [6, 'baz', 4], 2),
- ])
- return true
- })
- .query({ end_version: 0 })
- .reply(204)
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slTextUpdate(historyId, doc1, this.userId, 1, this.timestamp, [
- { p: 3, i: 'foo' },
- ])
- )
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slTextUpdate(historyId, doc2, this.userId, 2, this.timestamp, [
- { p: 6, i: 'baz' },
- ])
- )
- await ProjectHistoryClient.flushProject(this.projectId)
- assert(
- createChange.isDone(),
- `/api/projects/${historyId}/changes should have been called`
- )
- })
- it('should not send updates without any ops', async function () {
- const createChange = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([])
- return true
- })
- .query({ end_version: 0 })
- .reply(204)
- // These blank ops can get sent by doc-updater on setDocs from Dropbox that don't change anything
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slTextUpdate(historyId, this.doc, this.userId, 1, this.timestamp, [])
- )
- await ProjectHistoryClient.flushProject(this.projectId)
- assert(
- !createChange.isDone(),
- `/api/projects/${historyId}/changes should not have been called`
- )
- })
- it('should not send ops that compress to nothing', async function () {
- const createChange = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([])
- return true
- })
- .query({ end_version: 0 })
- .reply(204)
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slTextUpdate(historyId, this.doc, this.userId, 1, this.timestamp, [
- { i: 'foo', p: 3 },
- ])
- )
- this.doc.length += 3
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slTextUpdate(historyId, this.doc, this.userId, 2, this.timestamp, [
- { d: 'foo', p: 3 },
- ])
- )
- await ProjectHistoryClient.flushProject(this.projectId)
- assert(
- !createChange.isDone(),
- `/api/projects/${historyId}/changes should not have been called`
- )
- })
- it('should not send ops from a diff that are blank', async function () {
- this.doc.length = 300
- // Test case taken from a real life document where it was generating blank insert and
- // delete ops from a diff, and the blank delete was erroring on the OL history from
- // a text operation like [42, 0, 512], where the 0 was invalid.
- const createChange = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([
- olTextUpdates(this.doc, this.userId, this.timestamp, [
- [
- 87,
- -1,
- 67,
- '|l|ll|}\n\\hline',
- -4,
- 30,
- ' \\hline',
- 87,
- ' \\\\ \\hline',
- 24,
- ],
- ]),
- ])
- return true
- })
- .query({ end_version: 0 })
- .reply(204)
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slTextUpdate(historyId, this.doc, this.userId, 1, this.timestamp, [
- {
- p: 73,
- d: '\\begin{table}[h]\n\\centering\n\\caption{My caption}\n\\label{my-label}\n\\begin{tabular}{lll}\n & A & B \\\\\nLiter t up & 2 & 1 \\\\\nLiter Whiskey & 1 & 2 \\\\\nPris pr. liter & 200 & 250\n\\end{tabular}\n\\end{table}',
- },
- {
- p: 73,
- i: '\\begin{table}[]\n\\centering\n\\caption{My caption}\n\\label{my-label}\n\\begin{tabular}{|l|ll|}\n\\hline\n & A & B \\\\ \\hline\nLiter t up & 2 & 1 \\\\\nLiter Whiskey & 1 & 2 \\\\\nPris pr. liter & 200 & 250 \\\\ \\hline\n\\end{tabular}\n\\end{table}',
- },
- ])
- )
- await ProjectHistoryClient.flushProject(this.projectId)
- assert(
- createChange.isDone(),
- `/api/projects/${historyId}/changes should have been called`
- )
- })
- it('should not concat text updates across project structure ops', async function () {
- const newDoc = {
- id: new ObjectId().toString(),
- pathname: '/main.tex',
- hash: '0a207c060e61f3b88eaee0a8cd0696f46fb155eb',
- docLines: 'a\nb',
- }
- MockHistoryStore()
- .put(`/api/projects/${historyId}/blobs/${newDoc.hash}`)
- .reply(201)
- const createChange = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([
- olTextUpdate(
- this.doc,
- this.userId,
- this.timestamp,
- [3, 'foo', 2],
- 1
- ),
- olAddDocUpdate(newDoc, this.userId, this.timestamp, newDoc.hash),
- olTextUpdate(
- this.doc,
- this.userId,
- this.timestamp,
- [6, 'baz', 2],
- 2
- ),
- ])
- return true
- })
- .query({ end_version: 0 })
- .reply(204)
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slTextUpdate(historyId, this.doc, this.userId, 1, this.timestamp, [
- { p: 3, i: 'foobar' },
- { p: 6, d: 'bar' },
- ])
- )
- this.doc.length += 3
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slAddDocUpdate(
- historyId,
- newDoc,
- this.userId,
- this.timestamp,
- newDoc.docLines
- )
- )
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slTextUpdate(historyId, this.doc, this.userId, 2, this.timestamp, [
- { p: 6, i: 'baz' },
- ])
- )
- await ProjectHistoryClient.flushProject(this.projectId)
- assert(
- createChange.isDone(),
- `/api/projects/${historyId}/changes should have been called`
- )
- })
- it('should track the doc length when splitting ops', async function () {
- this.doc.length = 10
- const createChange = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([
- olTextUpdate(this.doc, this.userId, this.timestamp, [3, -3, 4], 1),
- olTextUpdate(
- this.doc,
- this.userId,
- this.timestamp,
- [3, 'barbaz', 4],
- 2
- ), // This has a base length of 10
- ])
- return true
- })
- .query({ end_version: 0 })
- .reply(204)
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slTextUpdate(historyId, this.doc, this.userId, 1, this.timestamp, [
- { p: 3, d: 'foo' },
- { p: 3, i: 'bar' }, // Make sure the length of the op generated from this is 7, not 10
- ])
- )
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slTextUpdate(historyId, this.doc, this.userId, 2, this.timestamp, [
- { p: 6, i: 'baz' },
- ])
- )
- await ProjectHistoryClient.flushProject(this.projectId)
- assert(
- createChange.isDone(),
- `/api/projects/${historyId}/changes should have been called`
- )
- })
- })
- describe('with bad pathnames', function () {
- beforeEach(function () {
- MockHistoryStore()
- .get(`/api/projects/${historyId}/latest/history`)
- .reply(200, {
- chunk: {
- startVersion: 0,
- history: {
- snapshot: {},
- changes: [],
- },
- },
- })
- })
- it('should replace \\\\ with _ and workaround * in pathnames', async function () {
- const doc = {
- id: this.doc.id,
- pathname: '\\main.tex',
- hash: 'b07b6b7a27667965f733943737124395c7577bea',
- docLines: 'aaabbbccc',
- length: 9,
- }
- MockHistoryStore()
- .put(`/api/projects/${historyId}/blobs/${doc.hash}`)
- .reply(201)
- const createChange = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([
- olAddDocUpdate(
- { id: doc.id, pathname: '_main.tex' },
- this.userId,
- this.timestamp,
- doc.hash
- ),
- olRenameUpdate(
- { id: doc.id, pathname: '_main.tex' },
- this.userId,
- this.timestamp,
- '_main.tex',
- '_main2.tex'
- ),
- olTextUpdate(
- { id: doc.id, pathname: '_main2.tex' },
- this.userId,
- this.timestamp,
- [3, 'foo', 6],
- 2
- ),
- olRenameUpdate(
- { id: doc.id, pathname: '_main2.tex' },
- this.userId,
- this.timestamp,
- '_main2.tex',
- '_main__ASTERISK__.tex'
- ),
- ])
- return true
- })
- .query({ end_version: 0 })
- .reply(204)
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slAddDocUpdate(
- historyId,
- doc,
- this.userId,
- this.timestamp,
- doc.docLines
- )
- )
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slRenameUpdate(
- historyId,
- doc,
- this.userId,
- this.timestamp,
- '/\\main.tex',
- '/\\main2.tex'
- )
- )
- doc.pathname = '\\main2.tex'
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slTextUpdate(historyId, doc, this.userId, 2, this.timestamp, [
- { p: 3, i: 'foo' },
- ])
- )
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slRenameUpdate(
- historyId,
- doc,
- this.userId,
- this.timestamp,
- '/\\main2.tex',
- '/\\main*.tex'
- )
- )
- doc.pathname = '\\main*.tex'
- await ProjectHistoryClient.flushProject(this.projectId)
- assert(
- createChange.isDone(),
- `/api/projects/${historyId}/changes should have been called`
- )
- })
- it('should workaround pathnames beginning with spaces', async function () {
- const doc = {
- id: this.doc.id,
- pathname: 'main.tex',
- hash: 'b07b6b7a27667965f733943737124395c7577bea',
- docLines: 'aaabbbccc',
- length: 9,
- }
- MockHistoryStore()
- .put(`/api/projects/${historyId}/blobs/${doc.hash}`)
- .reply(201)
- const createChange = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([
- olAddDocUpdate(
- { id: doc.id, pathname: 'main.tex' },
- this.userId,
- this.timestamp,
- doc.hash
- ),
- olRenameUpdate(
- { id: doc.id },
- this.userId,
- this.timestamp,
- 'main.tex',
- 'foo/__SPACE__main.tex'
- ),
- ])
- return true
- })
- .query({ end_version: 0 })
- .reply(204)
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slAddDocUpdate(
- historyId,
- doc,
- this.userId,
- this.timestamp,
- doc.docLines
- )
- )
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slRenameUpdate(
- historyId,
- doc,
- this.userId,
- this.timestamp,
- '/main.tex',
- '/foo/ main.tex'
- )
- )
- doc.pathname = '/foo/ main.tex'
- await ProjectHistoryClient.flushProject(this.projectId)
- assert(
- createChange.isDone(),
- `/api/projects/${historyId}/changes should have been called`
- )
- })
- })
- describe('with bad response from filestore', function () {
- beforeEach(function () {
- MockHistoryStore()
- .get(`/api/projects/${historyId}/latest/history`)
- .reply(200, {
- chunk: {
- startVersion: 0,
- history: {
- snapshot: {},
- changes: [],
- },
- },
- })
- })
- it('should return a 500 if the filestore returns a 500', async function () {
- const file = {
- id: new ObjectId().toString(),
- pathname: '/test.png',
- contents: Buffer.from([1, 2, 3]),
- hash: 'aed2973e4b8a7ff1b30ff5c4751e5a2b38989e74',
- }
- const fileStoreRequest = MockFileStore()
- .get(`/project/${this.projectId}/file/${file.id}`)
- .reply(500)
- const createBlob = MockHistoryStore()
- .put(`/api/projects/${historyId}/blobs/${file.hash}`, file.contents)
- .reply(201)
- const addFile = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([
- olAddFileUpdate(file, this.userId, this.timestamp, file.hash),
- ])
- return true
- })
- .query({ end_version: 0 })
- .reply(204)
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slAddFileUpdate(
- historyId,
- file,
- this.userId,
- this.timestamp,
- this.projectId
- )
- )
- const res = await ProjectHistoryClient.flushProject(this.projectId, {
- allowErrors: true,
- })
- expect(res.statusCode).to.equal(500)
- assert(
- fileStoreRequest.isDone(),
- `/project/${this.projectId}/file/${file.id} should have been called`
- )
- assert(
- !createBlob.isDone(),
- `/api/projects/${historyId}/latest/files should not have been called`
- )
- assert(
- !addFile.isDone(),
- `/api/projects/${historyId}/latest/files should not have been called`
- )
- })
- it('should return a 500 if the filestore request errors', async function () {
- const file = {
- id: new ObjectId().toString(),
- pathname: '/test.png',
- contents: Buffer.from([1, 2, 3]),
- hash: 'aed2973e4b8a7ff1b30ff5c4751e5a2b38989e74',
- }
- const fileStoreRequest = MockFileStore()
- .get(`/project/${this.projectId}/file/${file.id}`)
- .replyWithError('oh no!')
- const createBlob = MockHistoryStore()
- .put(`/api/projects/${historyId}/blobs/${file.hash}`, file.contents)
- .reply(201)
- const addFile = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([
- olAddFileUpdate(file, this.userId, this.timestamp, file.hash),
- ])
- return true
- })
- .query({ end_version: 0 })
- .reply(204)
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slAddFileUpdate(
- historyId,
- file,
- this.userId,
- this.timestamp,
- this.projectId
- )
- )
- const res = await ProjectHistoryClient.flushProject(this.projectId, {
- allowErrors: true,
- })
- expect(res.statusCode).to.equal(500)
- assert(
- fileStoreRequest.isDone(),
- `/project/${this.projectId}/file/${file.id} should have been called`
- )
- assert(
- !createBlob.isDone(),
- `/api/projects/${historyId}/latest/files should not have been called`
- )
- assert(
- !addFile.isDone(),
- `/api/projects/${historyId}/latest/files should not have been called`
- )
- })
- })
- describe('with an existing projectVersion field', function () {
- beforeEach(function () {
- MockHistoryStore()
- .get(`/api/projects/${historyId}/latest/history`)
- .reply(200, {
- chunk: {
- startVersion: 0,
- history: {
- snapshot: { projectVersion: '100.0' },
- changes: [],
- },
- },
- })
- })
- it('should discard project structure updates which have already been applied', async function () {
- const newDoc = []
- for (let i = 0; i <= 2; i++) {
- newDoc[i] = {
- id: new ObjectId().toString(),
- pathname: `/main${i}.tex`,
- hash: '0a207c060e61f3b88eaee0a8cd0696f46fb155eb',
- docLines: 'a\nb',
- }
- }
- MockHistoryStore()
- .put(`/api/projects/${historyId}/blobs/${newDoc[0].hash}`)
- .times(3)
- .reply(201)
- const createChange = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([
- olAddDocUpdateWithVersion(
- newDoc[1],
- this.userId,
- this.timestamp,
- newDoc[1].hash,
- '101.0'
- ),
- olAddDocUpdateWithVersion(
- newDoc[2],
- this.userId,
- this.timestamp,
- newDoc[2].hash,
- '102.0'
- ),
- ])
- return true
- })
- .query({ end_version: 0 })
- .reply(204)
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slAddDocUpdateWithVersion(
- historyId,
- newDoc[0],
- this.userId,
- this.timestamp,
- newDoc[0].docLines,
- '100.0'
- )
- )
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slAddDocUpdateWithVersion(
- historyId,
- newDoc[1],
- this.userId,
- this.timestamp,
- newDoc[1].docLines,
- '101.0'
- )
- )
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slAddDocUpdateWithVersion(
- historyId,
- newDoc[2],
- this.userId,
- this.timestamp,
- newDoc[2].docLines,
- '102.0'
- )
- )
- await ProjectHistoryClient.flushProject(this.projectId)
- assert(
- createChange.isDone(),
- `/api/projects/${historyId}/changes should have been called`
- )
- })
- })
- describe('with an existing docVersions field', function () {
- beforeEach(function () {
- MockHistoryStore()
- .get(`/api/projects/${historyId}/latest/history`)
- .reply(200, {
- chunk: {
- startVersion: 0,
- history: {
- snapshot: { v2DocVersions: { [this.doc.id]: { v: 100 } } }, // version 100 below already applied
- changes: [],
- },
- },
- })
- })
- it('should discard doc updates which have already been applied', async function () {
- const createChange = MockHistoryStore()
- .post(`/api/projects/${historyId}/legacy_changes`, body => {
- expect(body).to.deep.equal([
- olTextUpdate(
- this.doc,
- this.userId,
- this.timestamp,
- [6, 'baz', 2],
- 101
- ),
- ])
- return true
- })
- .query({ end_version: 0 })
- .reply(204)
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slTextUpdate(historyId, this.doc, this.userId, 100, this.timestamp, [
- { p: 3, i: 'foobar' }, // these ops should be skipped
- { p: 6, d: 'bar' },
- ])
- )
- this.doc.length += 3
- await ProjectHistoryClient.pushRawUpdate(
- this.projectId,
- slTextUpdate(historyId, this.doc, this.userId, 101, this.timestamp, [
- { p: 6, i: 'baz' }, // this op should be applied
- ])
- )
- await ProjectHistoryClient.flushProject(this.projectId)
- assert(
- createChange.isDone(),
- `/api/projects/${historyId}/changes should have been called`
- )
- })
- })
- })
|