From 83531499383a8bab177e20af69078a2929eec473 Mon Sep 17 00:00:00 2001 From: shadowusr Date: Mon, 16 Dec 2024 13:36:27 +0300 Subject: [PATCH] test: fix tests after modifying tree builder helpers and fix review issues --- .../suites/components/SuitesTreeView/utils.ts | 86 +++---- package-lock.json | 16 +- .../modals/screenshot-accepter/index.jsx | 238 ++++++++---------- 3 files changed, 154 insertions(+), 186 deletions(-) diff --git a/lib/static/new-ui/features/suites/components/SuitesTreeView/utils.ts b/lib/static/new-ui/features/suites/components/SuitesTreeView/utils.ts index f9d52093..4a74de57 100644 --- a/lib/static/new-ui/features/suites/components/SuitesTreeView/utils.ts +++ b/lib/static/new-ui/features/suites/components/SuitesTreeView/utils.ts @@ -239,64 +239,59 @@ const extractWeight = (entitesContext: EntitiesContext, treeNode: TreeNode, chil if (currentSortExpression.type === SortType.ByTestsCount) { return createWeight([0, testsCount, runsCount], {testsCount, runsCount}); - } else if (currentSortExpression.type === SortType.ByName) { + } + + if (currentSortExpression.type === SortType.ByName) { return createWeight([treeNode.data.title.join(' '), testsCount, runsCount], {testsCount, runsCount}); - } else if (currentSortExpression.type === SortType.ByFailedRuns) { - if (!childrenWeight) { - return createInvalidWeight(treeNode); - } + } + if (!childrenWeight) { + return createInvalidWeight(treeNode); + } + + if (currentSortExpression.type === SortType.ByFailedRuns) { // For now, we assume there are no nested groups and suite/test weights are always 1 dimensional return createWeight([childrenWeight.value[0], testsCount, runsCount], Object.assign({}, {testsCount, runsCount}, childrenWeight.metadata)); - } else if (currentSortExpression.type === SortType.ByDuration) { - if (!childrenWeight) { - return createInvalidWeight(treeNode); - } - - return childrenWeight; - } else if (currentSortExpression.type === SortType.ByStartTime) { - if (!childrenWeight) { - return createInvalidWeight(treeNode); - } + } + if ( + currentSortExpression.type === SortType.ByDuration || + currentSortExpression.type === SortType.ByStartTime + ) { return childrenWeight; } + break; } case EntityType.Suite: { if (currentSortExpression.type === SortType.ByName) { return createWeight([treeNode.data.title.join(' ')]); - } else if (currentSortExpression.type === SortType.ByFailedRuns) { - if (!childrenWeight) { - return createInvalidWeight(treeNode); - } - - return childrenWeight; - } else if (currentSortExpression.type === SortType.ByTestsCount) { - if (!childrenWeight) { - return createInvalidWeight(treeNode); - } + } - return childrenWeight; - } else if (currentSortExpression.type === SortType.ByDuration) { - if (!childrenWeight) { - return createInvalidWeight(treeNode); - } + if (!childrenWeight) { + return createInvalidWeight(treeNode); + } + if (currentSortExpression.type === SortType.ByDuration) { return createWeight([childrenWeight.value[0], treeNode.data.title.join(' ')], childrenWeight.metadata); - } else if (currentSortExpression.type === SortType.ByStartTime) { - if (!childrenWeight) { - return createInvalidWeight(treeNode); - } + } + if ( + currentSortExpression.type === SortType.ByFailedRuns || + currentSortExpression.type === SortType.ByTestsCount || + currentSortExpression.type === SortType.ByStartTime + ) { return childrenWeight; } + break; } case EntityType.Browser: { if (currentSortExpression.type === SortType.ByName) { return createWeight([treeNode.data.title.join(' ')]); - } else if (currentSortExpression.type === SortType.ByFailedRuns) { + } + + if (currentSortExpression.type === SortType.ByFailedRuns) { const browser = browsers[treeNode.data.entityId]; const groupId = getGroupId(treeNode.data); @@ -306,25 +301,32 @@ const extractWeight = (entitesContext: EntitiesContext, treeNode: TreeNode, chil ).length; return createWeight([failedRunsCount], {failedRunsCount}); - } else if (currentSortExpression.type === SortType.ByTestsCount) { + } + + if (currentSortExpression.type === SortType.ByTestsCount) { const browser = browsers[treeNode.data.entityId]; const groupId = getGroupId(treeNode.data); const runsCount = groupId ? browser.resultIds.filter(resultId => groups[groupId].resultIds.includes(resultId)).length : browser.resultIds.length; return createWeight([1, runsCount], {runsCount}); - } else if (currentSortExpression.type === SortType.ByDuration) { + } + + if (currentSortExpression.type === SortType.ByDuration) { const browser = browsers[treeNode.data.entityId]; const groupId = getGroupId(treeNode.data); const resultIds = groupId ? browser.resultIds.filter(resultId => groups[groupId].resultIds.includes(resultId)) : browser.resultIds; const totalTime = resultIds.reduce((accTime, resultId) => accTime + (results[resultId].duration ?? 0), 0); return createWeight([totalTime, treeNode.data.title.join(' ')], {runsCount: resultIds.length, duration: totalTime}); - } else if (currentSortExpression.type === SortType.ByStartTime) { + } + + if (currentSortExpression.type === SortType.ByStartTime) { const browser = browsers[treeNode.data.entityId]; const startTime = results[browser.resultIds[0]].timestamp; return createWeight([startTime], {startTime}); } + break; } } @@ -366,16 +368,16 @@ const aggregateWeights = ({currentSortExpression}: EntitiesContext, weights: Tre } if (currentSortExpression.type === SortType.ByStartTime) { - const MAX_DATE = new Date(8640000000000000).getTime(); + const MAX_TIMESTAMP = 8640000000000000; return weights.reduce((accWeight, weight) => { const newAccWeight = createWeight(accWeight.value.slice(0), accWeight.metadata); for (let i = 0; i < weight.value.length; i++) { - newAccWeight.value[i] = Math.min(Number(accWeight.value[i] || MAX_DATE), Number(weight.value[i])); + newAccWeight.value[i] = Math.min(Number(accWeight.value[i] || MAX_TIMESTAMP), Number(weight.value[i])); } if (weight.metadata.startTime !== undefined) { - newAccWeight.metadata.startTime = Math.min((newAccWeight.metadata.startTime || MAX_DATE), weight.metadata.startTime); + newAccWeight.metadata.startTime = Math.min((newAccWeight.metadata.startTime || MAX_TIMESTAMP), weight.metadata.startTime); } return newAccWeight; @@ -412,7 +414,7 @@ const generateTagsForWeight = (weight: TreeNodeWeight): string[] => { } if (durationSeconds < 0.1) { - tags.push('<0s in total'); + tags.push('~0s in total'); } else { tags.push(`${durationSeconds}s in total${averageDurationSeconds > 0.1 ? `, ${averageDurationSeconds}s on avg.` : ''}`); } diff --git a/package-lock.json b/package-lock.json index 47365a16..1278222a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4407,7 +4407,7 @@ }, "node_modules/@types/chai-subset": { "version": "1.3.5", - "resolved": "https://npm.yandex-team.ru/@types%2fchai-subset/-/chai-subset-1.3.5.tgz?rbtorrent=1f58fb42075b85f1333d9b94b69bce401965a4a5", + "resolved": "https://registry.npmjs.org/@types/chai-subset/-/chai-subset-1.3.5.tgz", "integrity": "sha512-c2mPnw+xHtXDoHmdtcCXGwyLMiauiAyxWMzhGpqHC4nqI/Y5G2XhTampslK2rb59kpcuHon03UH8W6iYUzw88A==", "dev": true, "dependencies": { @@ -8012,7 +8012,7 @@ }, "node_modules/chai-deep-equal-ignore-undefined": { "version": "1.1.1", - "resolved": "https://npm.yandex-team.ru/chai-deep-equal-ignore-undefined/-/chai-deep-equal-ignore-undefined-1.1.1.tgz?rbtorrent=", + "resolved": "https://registry.npmjs.org/chai-deep-equal-ignore-undefined/-/chai-deep-equal-ignore-undefined-1.1.1.tgz", "integrity": "sha512-BE4nUR2Jbqmmv8A0EuAydFRB/lXgXWAfa9TvO3YzHeGHAU7ZRwPZyu074oDl/CZtNXM7jXINpQxKBOe7N0P4bg==", "dev": true, "peerDependencies": { @@ -8033,8 +8033,8 @@ }, "node_modules/chai-subset": { "version": "1.6.0", - "resolved": "https://npm.yandex-team.ru/chai-subset/-/chai-subset-1.6.0.tgz?rbtorrent=4765bb074a08a12462a496cce4e11a8f8a430995", - "integrity": "sha1-pdDKFOMpp5WW7XAFi2ZGvWmIz+k=", + "resolved": "https://registry.npmjs.org/chai-subset/-/chai-subset-1.6.0.tgz", + "integrity": "sha512-K3d+KmqdS5XKW5DWPd5sgNffL3uxdDe+6GdnJh3AYPhwnBGRY5urfvfcbRtWIvvpz+KxkL9FeBB6MZewLUNwug==", "dev": true, "engines": { "node": ">=4" @@ -32477,7 +32477,7 @@ }, "@types/chai-subset": { "version": "1.3.5", - "resolved": "https://npm.yandex-team.ru/@types%2fchai-subset/-/chai-subset-1.3.5.tgz?rbtorrent=1f58fb42075b85f1333d9b94b69bce401965a4a5", + "resolved": "https://registry.npmjs.org/@types/chai-subset/-/chai-subset-1.3.5.tgz", "integrity": "sha512-c2mPnw+xHtXDoHmdtcCXGwyLMiauiAyxWMzhGpqHC4nqI/Y5G2XhTampslK2rb59kpcuHon03UH8W6iYUzw88A==", "dev": true, "requires": { @@ -35276,7 +35276,7 @@ }, "chai-deep-equal-ignore-undefined": { "version": "1.1.1", - "resolved": "https://npm.yandex-team.ru/chai-deep-equal-ignore-undefined/-/chai-deep-equal-ignore-undefined-1.1.1.tgz?rbtorrent=", + "resolved": "https://registry.npmjs.org/chai-deep-equal-ignore-undefined/-/chai-deep-equal-ignore-undefined-1.1.1.tgz", "integrity": "sha512-BE4nUR2Jbqmmv8A0EuAydFRB/lXgXWAfa9TvO3YzHeGHAU7ZRwPZyu074oDl/CZtNXM7jXINpQxKBOe7N0P4bg==", "dev": true, "requires": {} @@ -35290,8 +35290,8 @@ }, "chai-subset": { "version": "1.6.0", - "resolved": "https://npm.yandex-team.ru/chai-subset/-/chai-subset-1.6.0.tgz?rbtorrent=4765bb074a08a12462a496cce4e11a8f8a430995", - "integrity": "sha1-pdDKFOMpp5WW7XAFi2ZGvWmIz+k=", + "resolved": "https://registry.npmjs.org/chai-subset/-/chai-subset-1.6.0.tgz", + "integrity": "sha512-K3d+KmqdS5XKW5DWPd5sgNffL3uxdDe+6GdnJh3AYPhwnBGRY5urfvfcbRtWIvvpz+KxkL9FeBB6MZewLUNwug==", "dev": true }, "chalk": { diff --git a/test/unit/lib/static/components/modals/screenshot-accepter/index.jsx b/test/unit/lib/static/components/modals/screenshot-accepter/index.jsx index bb16ca7e..1b4cb178 100644 --- a/test/unit/lib/static/components/modals/screenshot-accepter/index.jsx +++ b/test/unit/lib/static/components/modals/screenshot-accepter/index.jsx @@ -9,7 +9,7 @@ import { addBrowserToTree, addImageToTree, addResultToTree, - addSuiteToTree, generateImageId, mkBrowserEntity, + addSuiteToTree, mkBrowserEntity, mkEmptyTree, mkImageEntityFail, mkRealStore, mkResultEntity, mkSuiteEntityLeaf, renderWithStore } from '../../../utils'; @@ -82,12 +82,12 @@ describe('', () => { addBrowserToTree({tree, browser}); const result1 = mkResultEntity('res-1', {parentId: browser.id}); addResultToTree({tree, result: result1}); - const image1 = mkImageEntityFail('img-1', {parentId: result1.id}); + const image1 = mkImageEntityFail('img-1', {stateName: 'plain', parentId: result1.id}); addImageToTree({tree, image: image1}); const result2 = mkResultEntity('res-2', {parentId: browser.id, attempt: 1}); addResultToTree({tree, result: result2}); - const image2 = mkImageEntityFail('img-2', {parentId: result2.id}); + const image2 = mkImageEntityFail('img-2', {stateName: 'plain', parentId: result2.id}); addImageToTree({tree, image: image2}); const store = mkRealStore({initialState: {tree}}); const currentImageId = image2.id; @@ -103,57 +103,39 @@ describe('', () => { it('should change image by clicking on "next" button', async () => { const user = userEvent.setup(); const tree = mkEmptyTree(); - addSuiteToTree({tree, suiteName: 'test-1'}); - addBrowserToTree({tree, suiteName: 'test-1', browserName: 'bro-1'}); - addResultToTree({tree, suiteName: 'test-1', browserName: 'bro-1', attempt: 0}); - addImageToTree({ - tree, - suiteName: 'test-1', - browserName: 'bro-1', - attempt: 0, - stateName: 'state-1', - expectedImgPath: 'img1-expected.png', - actualImgPath: 'img1-actual.png', - diffImgPath: 'img1-diff.png' - }); - addImageToTree({ - tree, - suiteName: 'test-1', - browserName: 'bro-1', - attempt: 0, - stateName: 'state-2', - expectedImgPath: 'img2-expected.png', - actualImgPath: 'img2-actual.png', - diffImgPath: 'img2-diff.png' - }); + const suite = mkSuiteEntityLeaf('test-1'); + addSuiteToTree({tree, suite}); + const browser = mkBrowserEntity('bro-1', {parentId: suite.id}); + addBrowserToTree({tree, browser}); + const result = mkResultEntity('res-1', {parentId: browser.id}); + addResultToTree({tree, result}); + const image1 = mkImageEntityFail('state-1', {parentId: result.id}); + addImageToTree({tree, image: image1}); + const image2 = mkImageEntityFail('state-2', {parentId: result.id}); + addImageToTree({tree, image: image2}); const store = mkRealStore({initialState: {tree}}); - const currentImageId = generateImageId({suiteName: 'test-1', browserName: 'bro-1', attempt: 0, stateName: 'state-1'}); + const currentImageId = image1.id; const component = renderWithStore(, store); await user.click(component.getByTitle('Show next image', {exact: false})); const imageElements = component.getAllByRole('img'); - imageElements.every(imageElement => expect(imageElement.src).to.include('img2')); + imageElements.every(imageElement => expect(imageElement.src).to.include('state-2')); }); it('should show a success message after accepting last screenshot', async () => { const user = userEvent.setup(); const tree = mkEmptyTree(); - addSuiteToTree({tree, suiteName: 'test-1'}); - addBrowserToTree({tree, suiteName: 'test-1', browserName: 'bro-1'}); - addResultToTree({tree, suiteName: 'test-1', browserName: 'bro-1', attempt: 0}); - addImageToTree({ - tree, - suiteName: 'test-1', - browserName: 'bro-1', - attempt: 0, - stateName: 'state-1', - expectedImgPath: 'img1-expected.png', - actualImgPath: 'img1-actual.png', - diffImgPath: 'img1-diff.png' - }); + const suite = mkSuiteEntityLeaf('test-1'); + addSuiteToTree({tree, suite}); + const browser = mkBrowserEntity('bro-1', {parentId: suite.id}); + addBrowserToTree({tree, browser}); + const result = mkResultEntity('res-1', {parentId: browser.id}); + addResultToTree({tree, result}); + const image1 = mkImageEntityFail('state-1', {parentId: result.id}); + addImageToTree({tree, image: image1}); const store = mkRealStore({initialState: {tree}}); - const currentImageId = generateImageId({suiteName: 'test-1', browserName: 'bro-1', attempt: 0, stateName: 'state-1'}); + const currentImageId = image1.id; const component = renderWithStore(, store); await user.click(component.getByText('Accept', {selector: 'button > *'})); @@ -164,24 +146,19 @@ describe('', () => { it('should should display meta info', async () => { const user = userEvent.setup(); const tree = mkEmptyTree(); - addSuiteToTree({tree, suiteName: 'test-1'}); - addBrowserToTree({tree, suiteName: 'test-1', browserName: 'bro-1'}); - addResultToTree({tree, suiteName: 'test-1', browserName: 'bro-1', attempt: 0, metaInfo: { + const suite = mkSuiteEntityLeaf('test-1'); + addSuiteToTree({tree, suite}); + const browser = mkBrowserEntity('bro-1', {parentId: suite.id}); + addBrowserToTree({tree, browser}); + const result = mkResultEntity('res-1', {parentId: browser.id, metaInfo: { key1: 'some-value-1', key2: 'some-value-2' }}); - addImageToTree({ - tree, - suiteName: 'test-1', - browserName: 'bro-1', - attempt: 0, - stateName: 'state-1', - expectedImgPath: 'img1-expected.png', - actualImgPath: 'img1-actual.png', - diffImgPath: 'img1-diff.png' - }); + addResultToTree({tree, result}); + const image1 = mkImageEntityFail('state-1', {parentId: result.id}); + addImageToTree({tree, image: image1}); const store = mkRealStore({initialState: {tree}}); - const currentImageId = generateImageId({suiteName: 'test-1', browserName: 'bro-1', attempt: 0, stateName: 'state-1'}); + const currentImageId = image1.id; const component = renderWithStore(, store); await user.click(component.getByText('Show meta', {selector: 'button > *'})); @@ -193,21 +170,16 @@ describe('', () => { it('should return to original state after clicking "undo"', async () => { const user = userEvent.setup(); const tree = mkEmptyTree(); - addSuiteToTree({tree, suiteName: 'test-1'}); - addBrowserToTree({tree, suiteName: 'test-1', browserName: 'bro-1'}); - addResultToTree({tree, suiteName: 'test-1', browserName: 'bro-1', attempt: 0}); - addImageToTree({ - tree, - suiteName: 'test-1', - browserName: 'bro-1', - attempt: 0, - stateName: 'state-1', - expectedImgPath: 'img1-expected.png', - actualImgPath: 'img1-actual.png', - diffImgPath: 'img1-diff.png' - }); + const suite = mkSuiteEntityLeaf('test-1'); + addSuiteToTree({tree, suite}); + const browser = mkBrowserEntity('bro-1', {parentId: suite.id}); + addBrowserToTree({tree, browser}); + const result = mkResultEntity('res-1', {parentId: browser.id}); + addResultToTree({tree, result}); + const image1 = mkImageEntityFail('state-1', {parentId: result.id}); + addImageToTree({tree, image: image1}); const store = mkRealStore({initialState: {tree}}); - const currentImageId = generateImageId({suiteName: 'test-1', browserName: 'bro-1', attempt: 0, stateName: 'state-1'}); + const currentImageId = image1.id; const component = renderWithStore(, store); await user.click(component.getByText('Accept', {selector: 'button > *'})); @@ -215,7 +187,7 @@ describe('', () => { expect(component.getByTestId('screenshot-accepter-progress-bar').dataset.content).to.equal('0/1'); const imageElements = component.getAllByRole('img'); - imageElements.every(imageElement => expect(imageElement.src).to.include('img1')); + imageElements.every(imageElement => expect(imageElement.src).to.include('state-1')); }); describe('exiting from screenshot accepter', () => { @@ -234,23 +206,18 @@ describe('', () => { const reduxAction = sinon.stub(); const user = userEvent.setup(); const tree = mkEmptyTree(); - addSuiteToTree({tree, suiteName: 'test-1'}); - addBrowserToTree({tree, suiteName: 'test-1', browserName: 'bro-1'}); - addResultToTree({tree, suiteName: 'test-1', browserName: 'bro-1', attempt: 0}); - addImageToTree({ - tree, - suiteName: 'test-1', - browserName: 'bro-1', - attempt: 0, - stateName: 'state-1', - expectedImgPath: 'img1-expected.png', - diffImgPath: 'img1-diff.png', - actualImgPath: 'img1-actual.png' - }); + const suite = mkSuiteEntityLeaf('test-1'); + addSuiteToTree({tree, suite}); + const browser = mkBrowserEntity('bro-1', {parentId: suite.id}); + addBrowserToTree({tree, browser}); + const result = mkResultEntity('res-1', {parentId: browser.id}); + addResultToTree({tree, result}); + const image1 = mkImageEntityFail('state-1', {parentId: result.id}); + addImageToTree({tree, image: image1}); const middleware = mkDispatchInterceptorMiddleware(reduxAction); const store = mkRealStore({initialState: {tree, view: {expand: EXPAND_ALL}}, middlewares: [middleware]}); - const currentImageId = generateImageId({suiteName: 'test-1', browserName: 'bro-1', attempt: 0, stateName: 'state-1'}); + const currentImageId = image1.id; const component = renderWithStore(, store); @@ -263,23 +230,18 @@ describe('', () => { const reduxAction = sinon.stub(); const user = userEvent.setup(); const tree = mkEmptyTree(); - addSuiteToTree({tree, suiteName: 'test-1'}); - addBrowserToTree({tree, suiteName: 'test-1', browserName: 'bro-1'}); - addResultToTree({tree, suiteName: 'test-1', browserName: 'bro-1', attempt: 0}); - addImageToTree({ - tree, - suiteName: 'test-1', - browserName: 'bro-1', - attempt: 0, - stateName: 'state-1', - expectedImgPath: 'img1-expected.png', - diffImgPath: 'img1-diff.png', - actualImgPath: 'img1-actual.png' - }); + const suite = mkSuiteEntityLeaf('test-1'); + addSuiteToTree({tree, suite}); + const browser = mkBrowserEntity('bro-1', {parentId: suite.id}); + addBrowserToTree({tree, browser}); + const result = mkResultEntity('res-1', {parentId: browser.id}); + addResultToTree({tree, result}); + const image1 = mkImageEntityFail('state-1', {parentId: result.id}); + addImageToTree({tree, image: image1}); const middleware = mkDispatchInterceptorMiddleware(reduxAction); const store = mkRealStore({initialState: {tree, view: {expand: EXPAND_ALL}}, middlewares: [middleware]}); - const currentImageId = generateImageId({suiteName: 'test-1', browserName: 'bro-1', attempt: 0, stateName: 'state-1'}); + const currentImageId = image1.id; const component = renderWithStore(, store); @@ -293,23 +255,18 @@ describe('', () => { const reduxAction = sinon.stub(); const user = userEvent.setup(); const tree = mkEmptyTree(); - addSuiteToTree({tree, suiteName: 'test-1'}); - addBrowserToTree({tree, suiteName: 'test-1', browserName: 'bro-1'}); - addResultToTree({tree, suiteName: 'test-1', browserName: 'bro-1', attempt: 0}); - addImageToTree({ - tree, - suiteName: 'test-1', - browserName: 'bro-1', - attempt: 0, - stateName: 'state-1', - expectedImgPath: 'img1-expected.png', - diffImgPath: 'img1-diff.png', - actualImgPath: 'img1-actual.png' - }); + const suite = mkSuiteEntityLeaf('test-1'); + addSuiteToTree({tree, suite}); + const browser = mkBrowserEntity('bro-1', {parentId: suite.id}); + addBrowserToTree({tree, browser}); + const result = mkResultEntity('res-1', {parentId: browser.id}); + addResultToTree({tree, result}); + const image1 = mkImageEntityFail('state-1', {parentId: result.id}); + addImageToTree({tree, image: image1}); const middleware = mkDispatchInterceptorMiddleware(reduxAction); const store = mkRealStore({initialState: {tree, view: {expand: EXPAND_ALL}}, middlewares: [middleware]}); - const currentImageId = generateImageId({suiteName: 'test-1', browserName: 'bro-1', attempt: 0, stateName: 'state-1'}); + const currentImageId = image1.id; const component = renderWithStore(, store); @@ -328,29 +285,38 @@ describe('', () => { beforeEach(() => { const tree = mkEmptyTree(); - addSuiteToTree({tree, suiteName: 'test-1'}); - addBrowserToTree({tree, suiteName: 'test-1', browserName: 'bro-1'}); - addResultToTree({tree, suiteName: 'test-1', browserName: 'bro-1', attempt: 0}); + const suite = mkSuiteEntityLeaf('test-1'); + addSuiteToTree({tree, suite}); + const browser = mkBrowserEntity('bro-1', {parentId: suite.id}); + addBrowserToTree({tree, browser}); + const result = mkResultEntity('res-1', {parentId: browser.id}); + addResultToTree({tree, result}); + for (let i = 1; i <= 10; i++) { - addImageToTree({ - tree, - suiteName: 'test-1', - browserName: 'bro-1', - attempt: 0, - stateName: `state-${i}`, - expectedImgPath: `img${i}-expected.png`, - diffImgPath: `img${i}-diff.png`, - actualImgPath: `img${i}-actual.png` - }); + const image = mkImageEntityFail(`state-${i}`, {parentId: result.id}); + addImageToTree({tree, image}); + + // addImageToTree({ + // + // tree, + // suiteName: 'test-1', + // browserName: 'bro-1', + // attempt: 0, + // stateName: `state-${i}`, + // expectedImgPath: `img${i}-expected.png`, + // diffImgPath: `img${i}-diff.png`, + // actualImgPath: `img${i}-actual.png` + // }); } const store = mkRealStore({initialState: {tree, view: {expand: EXPAND_ALL}}}); - const currentImageId = generateImageId({ - suiteName: 'test-1', - browserName: 'bro-1', - attempt: 0, - stateName: 'state-5' - }); + const currentImageId = Object.values(tree.images.byId)[4].id; + // generateImageId({ + // suiteName: 'test-1', + // browserName: 'bro-1', + // attempt: 0, + // stateName: 'state-5' + // }); component = renderWithStore(, store); }); @@ -359,7 +325,7 @@ describe('', () => { // Current image is 5. [2, 3, 4, 6, 7, 8].forEach(ind => { eachLabel_(label => { - assert.calledWith(preloadImageStub, `img${ind}-${label}.png`); + assert.calledWith(preloadImageStub, `state-${ind}-${label}`); }); }); }); @@ -367,7 +333,7 @@ describe('', () => { it('should not preload other images', () => { [1, 9, 10].forEach(ind => { eachLabel_(label => { - assert.neverCalledWith(preloadImageStub, `img${ind}-${label}.png`); + assert.neverCalledWith(preloadImageStub, `state-${ind}-${label}`); }); }); }); @@ -377,7 +343,7 @@ describe('', () => { await user.click(component.getByTitle('Show next image', {exact: false})); eachLabel_(label => { - assert.calledWith(preloadImageStub, `img9-${label}.png`); + assert.calledWith(preloadImageStub, `state-9-${label}`); }); }); @@ -386,7 +352,7 @@ describe('', () => { await user.click(component.getByText('Accept', {selector: 'button > *'})); eachLabel_(label => { - assert.calledWith(preloadImageStub, `img9-${label}.png`); + assert.calledWith(preloadImageStub, `state-9-${label}`); }); }); });