path filename

pull/2092/head
filip mertens 3 years ago
parent 3631fbbe4a
commit de42bcbc97
  1. 17
      apps/remix-ide-e2e/src/tests/search.test.ts
  2. 6
      libs/remix-ui/search/src/lib/components/results/ResultFileName.tsx

@ -12,7 +12,8 @@ module.exports = {
browser.waitForElementVisible('*[data-id="remixIdeSidePanel"]') browser.waitForElementVisible('*[data-id="remixIdeSidePanel"]')
.click('*[plugin="search"]').waitForElementVisible('*[id="search_input"]') .click('*[plugin="search"]').waitForElementVisible('*[id="search_input"]')
.setValue('*[id="search_input"]', 'read').pause(1000) .setValue('*[id="search_input"]', 'read').pause(1000)
.waitForElementContainsText('*[data-id="search_results"]', 'CONTRACTS/3_BALLOT.SOL', 60000) .waitForElementContainsText('*[data-id="search_results"]', '3_BALLOT.SOL', 60000)
.waitForElementContainsText('*[data-id="search_results"]', 'contracts', 60000)
.waitForElementContainsText('*[data-id="search_results"]', 'README.TXT', 60000) .waitForElementContainsText('*[data-id="search_results"]', 'README.TXT', 60000)
.waitForElementContainsText('*[data-id="search_results"]', 'file must') .waitForElementContainsText('*[data-id="search_results"]', 'file must')
.waitForElementContainsText('*[data-id="search_results"]', 'be compiled') .waitForElementContainsText('*[data-id="search_results"]', 'be compiled')
@ -29,10 +30,11 @@ module.exports = {
.waitForElementVisible('*[id="search_input"]') .waitForElementVisible('*[id="search_input"]')
.clearValue('*[id="search_input"]') .clearValue('*[id="search_input"]')
.setValue('*[id="search_input"]', '^contract').pause(1000) .setValue('*[id="search_input"]', '^contract').pause(1000)
.waitForElementContainsText('*[data-id="search_results"]', 'CONTRACTS/3_BALLOT.SOL', 60000) .waitForElementContainsText('*[data-id="search_results"]', '3_BALLOT.SOL', 60000)
.waitForElementContainsText('*[data-id="search_results"]', 'CONTRACTS/2_OWNER.SOL', 60000) .waitForElementContainsText('*[data-id="search_results"]', '2_OWNER.SOL', 60000)
.waitForElementContainsText('*[data-id="search_results"]', 'CONTRACTS/1_STORAGE.SOL', 60000) .waitForElementContainsText('*[data-id="search_results"]', '1_STORAGE.SOL', 60000)
.waitForElementContainsText('*[data-id="search_results"]', 'TESTS/4_BALLOT_TEST.SOL', 60000) .waitForElementContainsText('*[data-id="search_results"]', '4_BALLOT_TEST.SOL', 60000)
.waitForElementContainsText('*[data-id="search_results"]', 'tests', 60000)
.elements('css selector','.search_line', (res) => { .elements('css selector','.search_line', (res) => {
Array.isArray(res.value) && browser.assert.equal(res.value.length, 4) Array.isArray(res.value) && browser.assert.equal(res.value.length, 4)
}) })
@ -49,8 +51,9 @@ module.exports = {
.elements('css selector','.search_line', (res) => { .elements('css selector','.search_line', (res) => {
Array.isArray(res.value) && browser.assert.equal(res.value.length, 6) Array.isArray(res.value) && browser.assert.equal(res.value.length, 6)
}) })
.waitForElementContainsText('*[data-id="search_results"]', 'SCRIPTS/DEPLOY_ETHERS.JS', 60000) .waitForElementContainsText('*[data-id="search_results"]', 'DEPLOY_ETHERS.JS', 60000)
.waitForElementContainsText('*[data-id="search_results"]', 'SCRIPTS/DEPLOY_WEB3.JS', 60000) .waitForElementContainsText('*[data-id="search_results"]', 'DEPLOY_WEB3.JS', 60000)
.waitForElementContainsText('*[data-id="search_results"]', 'scripts', 60000)
}, },
'Should find matchword': function (browser: NightwatchBrowser) { 'Should find matchword': function (browser: NightwatchBrowser) {
browser browser

@ -1,6 +1,7 @@
import React, { useEffect, useState } from 'react' import React, { useEffect, useState } from 'react'
import { SearchResult } from '../../types' import { SearchResult } from '../../types'
import { getPathIcon } from '@remix-ui/helper' import { getPathIcon } from '@remix-ui/helper'
import * as path from 'path'
interface ResultItemProps { interface ResultItemProps {
file: SearchResult file: SearchResult
} }
@ -12,13 +13,16 @@ export const ResultFileName = (props: ResultItemProps) => {
if (props.file && props.file.path) { if (props.file && props.file.path) {
setIcon(getPathIcon(props.file.path)) setIcon(getPathIcon(props.file.path))
} }
// remove path from string
// const path = props.file.path.split('/').slice(0, -1).join('/')
}, [props.file]) }, [props.file])
return ( return (
<> <>
{icon ? <div className={`${icon} caret caret_tv`}></div> : null} {icon ? <div className={`${icon} caret caret_tv`}></div> : null}
<div title={props.file.filename} className="search_file_name ml-2"> <div title={props.file.filename} className="search_file_name ml-2">
{props.file.filename} {path.basename(props.file.path)}
<span className='dirname pl-1 text-muted text-lowercase'>{path.dirname(props.file.path)}</span>
</div> </div>
</> </>
) )

Loading…
Cancel
Save