Commit e6b8cacb authored by tom's avatar tom

fix suggest item clashing

parent be1ef124
...@@ -162,23 +162,23 @@ test('search by tx hash +@mobile', async({ mount, page }) => { ...@@ -162,23 +162,23 @@ test('search by tx hash +@mobile', async({ mount, page }) => {
}); });
test('search with simple match', async({ mount, page }) => { test('search with simple match', async({ mount, page }) => {
const API_URL = buildApiUrl('search') + `?q=${ searchMock.tx1.tx_hash }`; const API_URL = buildApiUrl('search') + `?q=${ searchMock.token2.name }`;
const API_CHECK_REDIRECT_URL = buildApiUrl('search_check_redirect') + `?q=${ searchMock.tx1.tx_hash }`; const API_CHECK_REDIRECT_URL = buildApiUrl('search_check_redirect') + `?q=${ searchMock.token2.name }`;
await page.route(API_URL, (route) => route.fulfill({ await page.route(API_URL, (route) => route.fulfill({
status: 200, status: 200,
body: JSON.stringify({ body: JSON.stringify({
items: [ items: [
searchMock.tx1, searchMock.token2,
], ],
}), }),
})); }));
await page.route(API_CHECK_REDIRECT_URL, (route) => route.fulfill({ await page.route(API_CHECK_REDIRECT_URL, (route) => route.fulfill({
status: 200, status: 200,
body: JSON.stringify({ body: JSON.stringify({
parameter: searchMock.tx1.tx_hash, parameter: searchMock.token2.address,
redirect: true, redirect: true,
type: 'transaction', type: 'address',
}), }),
})); }));
...@@ -187,14 +187,18 @@ test('search with simple match', async({ mount, page }) => { ...@@ -187,14 +187,18 @@ test('search with simple match', async({ mount, page }) => {
<SearchBar/> <SearchBar/>
</TestApp>, </TestApp>,
); );
await page.getByPlaceholder(/search/i).type(searchMock.tx1.tx_hash); await page.getByPlaceholder(/search/i).type(searchMock.token2.name);
await page.waitForResponse(API_URL); await page.waitForResponse(API_URL);
await page.waitForResponse(API_CHECK_REDIRECT_URL);
const resultText = page.getByText('Found 2 matching result');
await expect(resultText).toBeVisible();
const resultText = page.getByText('Found 1 matching result'); const linkToToken = page.getByText(searchMock.token2.name);
expect(resultText).toBeTruthy(); await expect(linkToToken).toHaveCount(1);
const links = page.getByText(searchMock.tx1.tx_hash); const linkToAddress = page.getByText(searchMock.token2.address);
await expect(links).toHaveCount(1); await expect(linkToAddress).toHaveCount(2);
}); });
test('recent keywords suggest +@mobile', async({ mount, page }) => { test('recent keywords suggest +@mobile', async({ mount, page }) => {
......
...@@ -16,16 +16,16 @@ const getUniqueIdentifier = (item: SearchResultItem) => { ...@@ -16,16 +16,16 @@ const getUniqueIdentifier = (item: SearchResultItem) => {
switch (item.type) { switch (item.type) {
case 'contract': case 'contract':
case 'address': { case 'address': {
return item.address; return item.type + item.address;
} }
case 'transaction': { case 'transaction': {
return item.tx_hash; return item.type + item.tx_hash;
} }
case 'block': { case 'block': {
return item.block_hash || item.block_number; return item.type + (item.block_hash || item.block_number);
} }
case 'token': { case 'token': {
return item.address; return item.type + item.address;
} }
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment