diff --git a/packages/jaeger-ui/.babelrc b/packages/jaeger-ui/.babelrc new file mode 100644 index 0000000000..bfae0a2f9e --- /dev/null +++ b/packages/jaeger-ui/.babelrc @@ -0,0 +1,16 @@ +{ + "env": { + "production": { + "plugins": [ + [ + "babel-plugin-react-remove-properties", + { + "properties": [ + "data-testid" + ] + } + ] + ] + } + } +} \ No newline at end of file diff --git a/packages/jaeger-ui/package.json b/packages/jaeger-ui/package.json index 9cf2b10a86..1e2281d3f9 100644 --- a/packages/jaeger-ui/package.json +++ b/packages/jaeger-ui/package.json @@ -27,6 +27,7 @@ "@wojtekmaj/enzyme-adapter-react-17": "^0.8.0", "babel-jest": "^29.5.0", "babel-plugin-inline-react-svg": "^2.0.2", + "babel-plugin-react-remove-properties": "^0.3.0", "enzyme": "^3.8.0", "enzyme-to-json": "^3.6.2", "jest": "^28.1.3", diff --git a/packages/jaeger-ui/src/components/App/TraceIDSearchInput.test.js b/packages/jaeger-ui/src/components/App/TraceIDSearchInput.test.js index 682a00ff34..210e583e26 100644 --- a/packages/jaeger-ui/src/components/App/TraceIDSearchInput.test.js +++ b/packages/jaeger-ui/src/components/App/TraceIDSearchInput.test.js @@ -15,42 +15,40 @@ */ import React from 'react'; -import { mount } from 'enzyme'; - import { createMemoryHistory } from 'history'; import { Router } from 'react-router-dom'; +import { render, screen, fireEvent } from '@testing-library/react'; +import '@testing-library/jest-dom'; import TraceIDSearchInput from './TraceIDSearchInput'; describe('', () => { - let wrapper; let history; beforeEach(() => { history = createMemoryHistory(); - wrapper = mount( + render( - ).find('form'); + ); }); it('renders as expected', () => { - expect(wrapper).toMatchSnapshot(); + expect(screen.getByTestId('idInput')).toBeInTheDocument(); }); it('pushes input id to history', () => { - const idInput = wrapper.find('input'); const traceId = 'MOCK-TRACE-ID'; - idInput.instance().value = traceId; - - wrapper.simulate('submit'); + const idInput = screen.getByPlaceholderText('Lookup by Trace ID...'); + fireEvent.change(idInput, { target: { value: traceId } }); + fireEvent.submit(screen.getByTestId('TraceIDSearchInput--form')); expect(history.length).toEqual(2); expect(history.location.pathname).toEqual(`/trace/${traceId}`); }); it('does not push to history on falsy input value', () => { - wrapper.simulate('submit'); + fireEvent.submit(screen.getByTestId('TraceIDSearchInput--form')); expect(history.length).toEqual(1); }); diff --git a/packages/jaeger-ui/src/components/App/TraceIDSearchInput.tsx b/packages/jaeger-ui/src/components/App/TraceIDSearchInput.tsx index d2cdb64927..3c752a2857 100644 --- a/packages/jaeger-ui/src/components/App/TraceIDSearchInput.tsx +++ b/packages/jaeger-ui/src/components/App/TraceIDSearchInput.tsx @@ -36,8 +36,18 @@ class TraceIDSearchInput extends React.PureComponent { render() { return ( -
- } /> + + } + />
); } diff --git a/packages/jaeger-ui/src/components/App/__snapshots__/TraceIDSearchInput.test.js.snap b/packages/jaeger-ui/src/components/App/__snapshots__/TraceIDSearchInput.test.js.snap deleted file mode 100644 index f9ddb8d428..0000000000 --- a/packages/jaeger-ui/src/components/App/__snapshots__/TraceIDSearchInput.test.js.snap +++ /dev/null @@ -1,48 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[` renders as expected 1`] = ` -
- - - - - - - - -
-`; diff --git a/packages/jaeger-ui/vite.config.ts b/packages/jaeger-ui/vite.config.ts index d5980afbcc..2486425ee4 100644 --- a/packages/jaeger-ui/vite.config.ts +++ b/packages/jaeger-ui/vite.config.ts @@ -42,7 +42,11 @@ export default defineConfig({ }, }, plugins: [ - react(), + react({ + babel: { + babelrc: true, + }, + }), legacy({ targets: ['>0.5%', 'not dead', 'not ie <= 11', 'not op_mini all'], }), diff --git a/yarn.lock b/yarn.lock index 8e92301639..af86bc6564 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3657,6 +3657,11 @@ babel-plugin-polyfill-regenerator@^0.5.2: dependencies: "@babel/helper-define-polyfill-provider" "^0.4.2" +babel-plugin-react-remove-properties@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/babel-plugin-react-remove-properties/-/babel-plugin-react-remove-properties-0.3.0.tgz#7b623fb3c424b6efb4edc9b1ae4cc50e7154b87f" + integrity sha512-vbxegtXGyVcUkCvayLzftU95vuvpYFV85pRpeMpohMHeEY46Qe0VNWfkVVcCbaZ12CXHzDFOj0esumATcW83ng== + babel-plugin-transform-react-remove-prop-types@0.4.24: version "0.4.24" resolved "https://registry.yarnpkg.com/babel-plugin-transform-react-remove-prop-types/-/babel-plugin-transform-react-remove-prop-types-0.4.24.tgz#f2edaf9b4c6a5fbe5c1d678bfb531078c1555f3a"