From 9ca81a72af7b61dd9e450210105c650571c15a5f Mon Sep 17 00:00:00 2001 From: Tim Down <158919+timdown@users.noreply.github.com> Date: Thu, 25 May 2023 11:22:49 +0100 Subject: [PATCH] Merge pull request #13218 from overleaf/td-history-update-change-list-tests History migration: Update change list fixtures to ensure file diff request happens GitOrigin-RevId: 5ec7b4389bc4d7f1343f9e3d26c0bcb7e4585ab5 --- .../history/components/change-list.spec.tsx | 28 ++++++--------- .../features/history/fixtures/labels.ts | 6 ++-- .../features/history/fixtures/updates.ts | 34 +++++++++---------- 3 files changed, 31 insertions(+), 37 deletions(-) diff --git a/services/web/test/frontend/features/history/components/change-list.spec.tsx b/services/web/test/frontend/features/history/components/change-list.spec.tsx index 6b5633e7c7..4d520aeceb 100644 --- a/services/web/test/frontend/features/history/components/change-list.spec.tsx +++ b/services/web/test/frontend/features/history/components/change-list.spec.tsx @@ -118,6 +118,12 @@ describe('change list', function () { // 2nd details entry cy.get('@details') .eq(1) + .within(() => { + cy.findAllByTestId('history-version-badge').should('have.length', 0) + }) + // 3rd details entry + cy.get('@details') + .eq(2) .within(() => { cy.findAllByTestId('history-version-badge').as('tags') }) @@ -130,12 +136,6 @@ describe('change list', function () { cy.findByRole('button', { name: /delete/i }).should('not.exist') }) ) - // 3rd details entry - cy.get('@details') - .eq(2) - .within(() => { - cy.findAllByTestId('history-version-badge').should('have.length', 0) - }) cy.findByLabelText(/labels/i).click({ force: true }) cy.findAllByTestId('history-version-details').as('details') cy.get('@details').should('have.length', 2) @@ -328,10 +328,7 @@ describe('change list', function () { }) }) - // Skipping this test for now because it relies on a request to be made that - // isn't required and no longer happens. - // eslint-disable-next-line mocha/no-skipped-tests - it.skip('resets from compare to view mode when switching tabs', function () { + it('resets from compare to view mode when switching tabs', function () { cy.findAllByTestId('history-version-details') .eq(1) .within(() => { @@ -424,10 +421,7 @@ describe('change list', function () { cy.wait('@download') }) - // Skipping this test for now because it relies on a request to be made that - // isn't required and no longer happens. - // eslint-disable-next-line mocha/no-skipped-tests - it.skip('compares versions', function () { + it('compares versions', function () { cy.findAllByTestId('history-version-details').should($versions => { const [first, ...rest] = Array.from($versions) expect(first).to.have.attr('data-selected', 'true') @@ -436,9 +430,9 @@ describe('change list', function () { ) }) - cy.intercept('GET', '/project/*/filetree/diff*', { statusCode: 200 }).as( - 'compareDiff' - ) + cy.intercept('GET', '/project/*/filetree/diff*', { + body: { diff: [{ pathname: 'main.tex' }, { pathname: 'name.tex' }] }, + }).as('compareDiff') cy.findAllByTestId('history-version-details') .last() diff --git a/services/web/test/frontend/features/history/fixtures/labels.ts b/services/web/test/frontend/features/history/fixtures/labels.ts index a8a1635aae..e5e78e71b4 100644 --- a/services/web/test/frontend/features/history/fixtures/labels.ts +++ b/services/web/test/frontend/features/history/fixtures/labels.ts @@ -20,7 +20,7 @@ export const labels = [ { id: '6436bcf630293cb49e7f13a4', comment: 'tag-3', - version: 3, + version: 1, user_id: '631710ab1094c5002647184e', created_at: '2023-04-12T14:15:18.892Z', user_display_name: 'bobby.lapointe', @@ -28,7 +28,7 @@ export const labels = [ { id: '6436bcf830293cb49e7f13a5', comment: 'tag-4', - version: 3, + version: 1, user_id: '631710ab1094c5002647184e', created_at: '2023-04-12T14:15:20.814Z', user_display_name: 'bobby.lapointe', @@ -36,7 +36,7 @@ export const labels = [ { id: '6436bcfb30293cb49e7f13a6', comment: 'tag-5', - version: 3, + version: 1, user_id: '631710ab1094c5002647184e', created_at: '2023-04-12T14:15:23.481Z', user_display_name: 'bobby.lapointe', diff --git a/services/web/test/frontend/features/history/fixtures/updates.ts b/services/web/test/frontend/features/history/fixtures/updates.ts index 3832d6bd6b..7484145189 100644 --- a/services/web/test/frontend/features/history/fixtures/updates.ts +++ b/services/web/test/frontend/features/history/fixtures/updates.ts @@ -57,22 +57,7 @@ export const updates = { start_ts: 1681220029569, end_ts: 1681220031589, }, - labels: [ - { - id: '6436bcf630293cb49e7f13a4', - comment: 'tag-3', - version: 3, - user_id: '631710ab1094c5002647184e', - created_at: '2023-04-12T14:15:18.892Z', - }, - { - id: '6436bcf830293cb49e7f13a5', - comment: 'tag-4', - version: 3, - user_id: '631710ab1094c5002647184e', - created_at: '2023-04-12T14:15:20.814Z', - }, - ], + labels: [], pathnames: ['main.tex'], project_ops: [], }, @@ -91,7 +76,22 @@ export const updates = { start_ts: 1669218226672, end_ts: 1669218226672, }, - labels: [], + labels: [ + { + id: '6436bcf630293cb49e7f13a4', + comment: 'tag-3', + version: 3, + user_id: '631710ab1094c5002647184e', + created_at: '2023-04-12T14:15:18.892Z', + }, + { + id: '6436bcf830293cb49e7f13a5', + comment: 'tag-4', + version: 3, + user_id: '631710ab1094c5002647184e', + created_at: '2023-04-12T14:15:20.814Z', + }, + ], pathnames: [], project_ops: [{ add: { pathname: 'main.tex' }, atV: 0 }], },