From 63de249236e8088b0cd04b7bc4fd24c7e59c6366 Mon Sep 17 00:00:00 2001 From: webzwo0i Date: Fri, 29 Oct 2021 00:53:36 +0200 Subject: [PATCH] tests: do not re-add identical text with setText --- src/tests/backend/specs/api/pad.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/tests/backend/specs/api/pad.js b/src/tests/backend/specs/api/pad.js index cf16f87f8..e91689851 100644 --- a/src/tests/backend/specs/api/pad.js +++ b/src/tests/backend/specs/api/pad.js @@ -461,6 +461,35 @@ describe(__filename, function () { .expect('Content-Type', /json/); assert.equal(res.body.code, 0); }); + + it('does not add an useless revision', async function () { + let res = await agent.post(`${endPoint('setText')}&padID=${testPadId}`) + .field({text: 'identical text\n'}) + .expect(200) + .expect('Content-Type', /json/); + assert.equal(res.body.code, 0); + + res = await agent.get(`${endPoint('getText')}&padID=${testPadId}`) + .expect(200) + .expect('Content-Type', /json/); + assert.equal(res.body.data.text, 'identical text\n'); + + res = await agent.get(`${endPoint('getRevisionsCount')}&padID=${testPadId}`) + .expect(200) + .expect('Content-Type', /json/); + const revCount = res.body.data.revisions; + + res = await agent.post(`${endPoint('setText')}&padID=${testPadId}`) + .field({text: 'identical text\n'}) + .expect(200) + .expect('Content-Type', /json/); + assert.equal(res.body.code, 0); + + res = await agent.get(`${endPoint('getRevisionsCount')}&padID=${testPadId}`) + .expect(200) + .expect('Content-Type', /json/); + assert.equal(res.body.data.revisions, revCount); + }); }); describe('copyPadWithoutHistory', function () {