Skip to content

Commit a2b860a

Browse files
committed
fix misplaced mocks
1 parent 8ec4e52 commit a2b860a

7 files changed

Lines changed: 60 additions & 46 deletions

File tree

File renamed without changes.
File renamed without changes.

client/features/multichain/pages/search-results/SearchResults.pw.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22

33
import type { GetAddressResponse } from '@blockscout/multichain-aggregator-types';
44

5-
import * as searchMock from 'client/features/multichain/stubs/search';
5+
import * as searchMock from 'client/features/multichain/mocks/search';
66

77
import * as chainDataMock from 'mocks/multichain/chains';
88
import { ENVS_MAP } from 'playwright/fixtures/mockEnvs';

client/slices/search/components/search-bar/SearchBarDesktop.pw.tsx

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ import React from 'react';
22

33
import * as searchMock from 'client/slices/search/mocks';
44

5+
import { metatag1, metatag2, metatag3 } from 'client/features/address-metadata/mocks/search';
6+
import { tacOperation1 } from 'client/features/chain-variants/tac/mocks/search';
7+
import { blob1 } from 'client/features/data-availability/mocks/search';
8+
import { domain1 } from 'client/features/name-services/domains/stubs/search';
9+
import { userOp1 } from 'client/features/user-ops/mocks/search';
10+
511
import { apps as appsMock } from 'mocks/apps/apps';
612
import { ENVS_MAP } from 'playwright/fixtures/mockEnvs';
713
import { test, expect } from 'playwright/lib';
@@ -79,9 +85,9 @@ test('search by address hash', async({ render, page, mockApiResponse }) => {
7985

8086
test('search by meta tag +@dark-mode', async({ render, page, mockApiResponse }) => {
8187
const apiUrl = await mockApiResponse('general:quick_search', [
82-
searchMock.metatag1,
83-
searchMock.metatag2,
84-
searchMock.metatag3,
88+
metatag1,
89+
metatag2,
90+
metatag3,
8591
], { queryParams: { q: 'utko' } });
8692
await render(<SearchBarDesktop/>);
8793
await page.getByPlaceholder(/search/i).fill('utko');
@@ -127,10 +133,10 @@ test('search by tx hash', async({ render, page, mockApiResponse }) => {
127133

128134
test('search by tac operation hash', async({ render, page, mockApiResponse }) => {
129135
const apiUrl = await mockApiResponse('general:quick_search', [
130-
searchMock.tacOperation1,
131-
], { queryParams: { q: searchMock.tacOperation1.tac_operation.operation_id } });
136+
tacOperation1,
137+
], { queryParams: { q: tacOperation1.tac_operation.operation_id } });
132138
await render(<SearchBarDesktop/>);
133-
await page.getByPlaceholder(/search/i).fill(searchMock.tacOperation1.tac_operation.operation_id);
139+
await page.getByPlaceholder(/search/i).fill(tacOperation1.tac_operation.operation_id);
134140
await page.waitForResponse(apiUrl);
135141

136142
await expect(page).toHaveScreenshot({ clip: { x: 0, y: 0, width: 1200, height: 300 } });
@@ -139,10 +145,10 @@ test('search by tac operation hash', async({ render, page, mockApiResponse }) =>
139145
test('search by blob hash', async({ render, page, mockApiResponse, mockEnvs }) => {
140146
await mockEnvs(ENVS_MAP.dataAvailability);
141147
const apiUrl = await mockApiResponse('general:quick_search', [
142-
searchMock.blob1,
143-
], { queryParams: { q: searchMock.blob1.blob_hash } });
148+
blob1,
149+
], { queryParams: { q: blob1.blob_hash } });
144150
await render(<SearchBarDesktop/>);
145-
await page.getByPlaceholder(/search/i).fill(searchMock.blob1.blob_hash);
151+
await page.getByPlaceholder(/search/i).fill(blob1.blob_hash);
146152
await page.waitForResponse(apiUrl);
147153

148154
await expect(page).toHaveScreenshot({ clip: { x: 0, y: 0, width: 1200, height: 300 } });
@@ -151,11 +157,11 @@ test('search by blob hash', async({ render, page, mockApiResponse, mockEnvs }) =
151157
test('search by domain name', async({ render, page, mockApiResponse, mockEnvs }) => {
152158
await mockEnvs(ENVS_MAP.nameService);
153159
const apiUrl = await mockApiResponse('general:quick_search', [
154-
searchMock.domain1,
155-
], { queryParams: { q: searchMock.domain1.ens_info.name } });
160+
domain1,
161+
], { queryParams: { q: domain1.ens_info.name } });
156162

157163
await render(<SearchBarDesktop/>);
158-
await page.getByPlaceholder(/search/i).fill(searchMock.domain1.ens_info.name);
164+
await page.getByPlaceholder(/search/i).fill(domain1.ens_info.name);
159165
await page.waitForResponse(apiUrl);
160166

161167
await expect(page).toHaveScreenshot({ clip: { x: 0, y: 0, width: 1200, height: 300 } });
@@ -164,7 +170,7 @@ test('search by domain name', async({ render, page, mockApiResponse, mockEnvs })
164170
test('search by user op hash', async({ render, page, mockApiResponse, mockEnvs }) => {
165171
await mockEnvs(ENVS_MAP.userOps);
166172
const apiUrl = await mockApiResponse('general:quick_search', [
167-
searchMock.userOp1,
173+
userOp1,
168174
], { queryParams: { q: searchMock.tx1.transaction_hash } });
169175
await render(<SearchBarDesktop/>);
170176
await page.getByPlaceholder(/search/i).fill(searchMock.tx1.transaction_hash);

client/slices/search/components/search-bar/SearchBarMobile.pw.tsx

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import React from 'react';
33

44
import * as searchMock from 'client/slices/search/mocks';
55

6+
import { metatag1, metatag2, metatag3 } from 'client/features/address-metadata/mocks/search';
7+
import { tacOperation1 } from 'client/features/chain-variants/tac/mocks/search';
8+
import { blob1 } from 'client/features/data-availability/mocks/search';
9+
import { domain1 } from 'client/features/name-services/domains/stubs/search';
10+
import { userOp1 } from 'client/features/user-ops/mocks/search';
11+
612
import { apps as appsMock } from 'mocks/apps/apps';
713
import { ENVS_MAP } from 'playwright/fixtures/mockEnvs';
814
import { test, expect, devices } from 'playwright/lib';
@@ -109,9 +115,9 @@ test('search by address hash', async({ render, page, mockApiResponse }) => {
109115

110116
test('search by meta tag', async({ render, page, mockApiResponse }) => {
111117
const apiUrl = await mockApiResponse('general:quick_search', [
112-
searchMock.metatag1,
113-
searchMock.metatag2,
114-
searchMock.metatag3,
118+
metatag1,
119+
metatag2,
120+
metatag3,
115121
], { queryParams: { q: 'utko' } });
116122
await render(<SearchBarMobile/>);
117123
await openSearchDrawer(page);
@@ -161,11 +167,11 @@ test('search by tx hash', async({ render, page, mockApiResponse }) => {
161167

162168
test('search by tac operation hash', async({ render, page, mockApiResponse }) => {
163169
const apiUrl = await mockApiResponse('general:quick_search', [
164-
searchMock.tacOperation1,
165-
], { queryParams: { q: searchMock.tacOperation1.tac_operation.operation_id } });
170+
tacOperation1,
171+
], { queryParams: { q: tacOperation1.tac_operation.operation_id } });
166172
await render(<SearchBarMobile/>);
167173
await openSearchDrawer(page);
168-
await getSearchInput(page).fill(searchMock.tacOperation1.tac_operation.operation_id);
174+
await getSearchInput(page).fill(tacOperation1.tac_operation.operation_id);
169175
await page.waitForResponse(apiUrl);
170176

171177
await expect(page).toHaveScreenshot({ clip: { x: 0, y: 0, width: 1200, height: 600 } });
@@ -174,11 +180,11 @@ test('search by tac operation hash', async({ render, page, mockApiResponse }) =>
174180
test('search by blob hash', async({ render, page, mockApiResponse, mockEnvs }) => {
175181
await mockEnvs(ENVS_MAP.dataAvailability);
176182
const apiUrl = await mockApiResponse('general:quick_search', [
177-
searchMock.blob1,
178-
], { queryParams: { q: searchMock.blob1.blob_hash } });
183+
blob1,
184+
], { queryParams: { q: blob1.blob_hash } });
179185
await render(<SearchBarMobile/>);
180186
await openSearchDrawer(page);
181-
await getSearchInput(page).fill(searchMock.blob1.blob_hash);
187+
await getSearchInput(page).fill(blob1.blob_hash);
182188
await page.waitForResponse(apiUrl);
183189

184190
await expect(page).toHaveScreenshot({ clip: { x: 0, y: 0, width: 1200, height: 600 } });
@@ -187,12 +193,12 @@ test('search by blob hash', async({ render, page, mockApiResponse, mockEnvs }) =
187193
test('search by domain name', async({ render, page, mockApiResponse, mockEnvs }) => {
188194
await mockEnvs(ENVS_MAP.nameService);
189195
const apiUrl = await mockApiResponse('general:quick_search', [
190-
searchMock.domain1,
191-
], { queryParams: { q: searchMock.domain1.ens_info.name } });
196+
domain1,
197+
], { queryParams: { q: domain1.ens_info.name } });
192198

193199
await render(<SearchBarMobile/>);
194200
await openSearchDrawer(page);
195-
await getSearchInput(page).fill(searchMock.domain1.ens_info.name);
201+
await getSearchInput(page).fill(domain1.ens_info.name);
196202
await page.waitForResponse(apiUrl);
197203

198204
await expect(page).toHaveScreenshot({ clip: { x: 0, y: 0, width: 1200, height: 600 } });
@@ -201,7 +207,7 @@ test('search by domain name', async({ render, page, mockApiResponse, mockEnvs })
201207
test('search by user op hash', async({ render, page, mockApiResponse, mockEnvs }) => {
202208
await mockEnvs(ENVS_MAP.userOps);
203209
const apiUrl = await mockApiResponse('general:quick_search', [
204-
searchMock.userOp1,
210+
userOp1,
205211
], { queryParams: { q: searchMock.tx1.transaction_hash } });
206212
await render(<SearchBarMobile/>);
207213
await openSearchDrawer(page);

client/slices/search/mocks.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,11 @@ import type {
77
SearchResult,
88
} from 'client/slices/search/types/api';
99

10-
import { metatag1 } from 'client/features/address-metadata/stubs/search';
10+
import { metatag1 } from 'client/features/address-metadata/mocks/search';
1111
import { tacOperation1 } from 'client/features/chain-variants/tac/mocks/search';
1212
import { blob1 } from 'client/features/data-availability/mocks/search';
1313
import { domain1 } from 'client/features/name-services/domains/stubs/search';
1414

15-
export { blob1, domain1, metatag1, tacOperation1 };
16-
export { metatag2, metatag3 } from 'client/features/address-metadata/stubs/search';
17-
export { userOp1 } from 'client/features/user-ops/mocks/search';
18-
1915
export const token1: SearchResultToken = {
2016
address_hash: '0x377c5F2B300B25a534d4639177873b7fEAA56d4B',
2117
address_url: '/address/0x377c5F2B300B25a534d4639177873b7fEAA56d4B',

client/slices/search/pages/search-results/SearchResults.pw.tsx

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import React from 'react';
33

44
import * as searchMock from 'client/slices/search/mocks';
55

6+
import { metatag1, metatag2, metatag3 } from 'client/features/address-metadata/mocks/search';
7+
import { tacOperation1 } from 'client/features/chain-variants/tac/mocks/search';
8+
import { blob1 } from 'client/features/data-availability/mocks/search';
9+
import { domain1 } from 'client/features/name-services/domains/stubs/search';
10+
import { userOp1 } from 'client/features/user-ops/mocks/search';
11+
612
import { apps as appsMock } from 'mocks/apps/apps';
713
import { ENVS_MAP } from 'playwright/fixtures/mockEnvs';
814
import { test, expect } from 'playwright/lib';
@@ -48,7 +54,7 @@ test.describe('search by name', () => {
4854
searchMock.token2,
4955
searchMock.contract1,
5056
searchMock.address2,
51-
searchMock.metatag1,
57+
metatag1,
5258
searchMock.label1,
5359
],
5460
next_page_params: null,
@@ -90,7 +96,7 @@ test('search by meta tag +@mobile', async({ render, mockApiResponse, page }) =>
9096
},
9197
};
9298
const data = {
93-
items: [ searchMock.metatag1, searchMock.metatag2, searchMock.metatag3 ],
99+
items: [ metatag1, metatag2, metatag3 ],
94100
next_page_params: null,
95101
};
96102
await mockApiResponse('general:search', data, { queryParams: { q: 'utko' } });
@@ -156,14 +162,14 @@ test('search by tac operation hash +@mobile', async({ render, mockApiResponse, m
156162
await mockEnvs(ENVS_MAP.tac);
157163
const hooksConfig = {
158164
router: {
159-
query: { q: searchMock.tacOperation1.tac_operation.operation_id },
165+
query: { q: tacOperation1.tac_operation.operation_id },
160166
},
161167
};
162168
const data = {
163-
items: [ searchMock.tacOperation1 ],
169+
items: [ tacOperation1 ],
164170
next_page_params: null,
165171
};
166-
await mockApiResponse('general:search', data, { queryParams: { q: searchMock.tacOperation1.tac_operation.operation_id } });
172+
await mockApiResponse('general:search', data, { queryParams: { q: tacOperation1.tac_operation.operation_id } });
167173
const component = await render(<SearchResults/>, { hooksConfig });
168174
await resetScroll(page);
169175

@@ -173,15 +179,15 @@ test('search by tac operation hash +@mobile', async({ render, mockApiResponse, m
173179
test('search by blob hash +@mobile', async({ render, mockApiResponse, mockEnvs, page }) => {
174180
const hooksConfig = {
175181
router: {
176-
query: { q: searchMock.blob1.blob_hash },
182+
query: { q: blob1.blob_hash },
177183
},
178184
};
179185
const data = {
180-
items: [ searchMock.blob1 ],
186+
items: [ blob1 ],
181187
next_page_params: null,
182188
};
183189
await mockEnvs(ENVS_MAP.dataAvailability);
184-
await mockApiResponse('general:search', data, { queryParams: { q: searchMock.blob1.blob_hash } });
190+
await mockApiResponse('general:search', data, { queryParams: { q: blob1.blob_hash } });
185191
const component = await render(<SearchResults/>, { hooksConfig });
186192
await resetScroll(page);
187193

@@ -191,15 +197,15 @@ test('search by blob hash +@mobile', async({ render, mockApiResponse, mockEnvs,
191197
test('search by domain name +@mobile', async({ render, mockApiResponse, mockEnvs, page }) => {
192198
const hooksConfig = {
193199
router: {
194-
query: { q: searchMock.domain1.ens_info.name },
200+
query: { q: domain1.ens_info.name },
195201
},
196202
};
197203
const data = {
198-
items: [ searchMock.domain1 ],
204+
items: [ domain1 ],
199205
next_page_params: null,
200206
};
201207
await mockEnvs(ENVS_MAP.nameService);
202-
await mockApiResponse('general:search', data, { queryParams: { q: searchMock.domain1.ens_info.name } });
208+
await mockApiResponse('general:search', data, { queryParams: { q: domain1.ens_info.name } });
203209
const component = await render(<SearchResults/>, { hooksConfig });
204210
await resetScroll(page);
205211

@@ -209,15 +215,15 @@ test('search by domain name +@mobile', async({ render, mockApiResponse, mockEnvs
209215
test('search by user op hash +@mobile', async({ render, mockApiResponse, mockEnvs, page }) => {
210216
const hooksConfig = {
211217
router: {
212-
query: { q: searchMock.userOp1.user_operation_hash },
218+
query: { q: userOp1.user_operation_hash },
213219
},
214220
};
215221
const data = {
216-
items: [ searchMock.userOp1 ],
222+
items: [ userOp1 ],
217223
next_page_params: null,
218224
};
219225
await mockEnvs(ENVS_MAP.userOps);
220-
await mockApiResponse('general:search', data, { queryParams: { q: searchMock.userOp1.user_operation_hash } });
226+
await mockApiResponse('general:search', data, { queryParams: { q: userOp1.user_operation_hash } });
221227
const component = await render(<SearchResults/>, { hooksConfig });
222228
await resetScroll(page);
223229

0 commit comments

Comments
 (0)