diff --git a/package.json b/package.json index d759661600..07a44e1294 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "build:packages": "npm run build:core && run-p build:standalone build:react && npm run build:polymer-editor", "build:example": "npm run build -w example", "build:demo": "npm run build:packages && npm run build -w demo", - "test": "npm run test --workspace=packages/ketcher-core --workspace=packages/ketcher-react --workspace=packages/ketcher-standalone --workspace=packages/ketcher-standalone", + "test": "npm run test --workspace=packages/ketcher-core --workspace=packages/ketcher-react --workspace=packages/ketcher-standalone --workspace=packages/ketcher-polymer-editor-react", "check:autotests": "cd ketcher-autotests && npm run check:code", "serve:remote": "cd example && npm run serve:remote", "serve:standalone": "cd example && npm run serve:standalone", diff --git a/packages/ketcher-polymer-editor-react/src/Editor.test.tsx b/packages/ketcher-polymer-editor-react/src/Editor.test.tsx deleted file mode 100644 index cb1d4255d6..0000000000 --- a/packages/ketcher-polymer-editor-react/src/Editor.test.tsx +++ /dev/null @@ -1,30 +0,0 @@ -/**************************************************************************** - * Copyright 2021 EPAM Systems - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ - -import { render, screen } from '@testing-library/react'; -import { Editor } from './Editor'; - -describe('Editor', () => { - it('should be rendered correctly', () => { - expect(render()).toMatchSnapshot(); - }); - - it('renders the logo', () => { - render(); - - expect(screen.getByText('Library')).toBeVisible(); - }); -}); diff --git a/packages/ketcher-polymer-editor-react/src/__snapshots__/Editor.test.tsx.snap b/packages/ketcher-polymer-editor-react/src/__snapshots__/Editor.test.tsx.snap deleted file mode 100644 index 5be9e76c1f..0000000000 --- a/packages/ketcher-polymer-editor-react/src/__snapshots__/Editor.test.tsx.snap +++ /dev/null @@ -1,1068 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Editor should be rendered correctly 1`] = ` -Object { - "asFragment": [Function], - "baseElement": -
-
-
-
-
-
-
-
-
- - - - -
-
-
-
- -
-
- -
-
- - - - -
-
-
-
- - - - -
-
-
-
- - - - -
-
-
-
- -
-
- -
- -
- - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- Library -

-
- - - - - - - - Hide - -
-
-
- - - - - - -
-
-
-
-
-
- - - - -
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
- , - "container":
-
-
-
-
-
-
-
-
- - - - -
-
-
-
- -
-
- -
-
- - - - -
-
-
-
- - - - -
-
-
-
- - - - -
-
-
-
- -
-
- -
- -
- - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- Library -

-
- - - - - - - - Hide - -
-
-
- - - - - - -
-
-
-
-
-
- - - - -
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
, - "debug": [Function], - "findAllByAltText": [Function], - "findAllByDisplayValue": [Function], - "findAllByLabelText": [Function], - "findAllByPlaceholderText": [Function], - "findAllByRole": [Function], - "findAllByTestId": [Function], - "findAllByText": [Function], - "findAllByTitle": [Function], - "findByAltText": [Function], - "findByDisplayValue": [Function], - "findByLabelText": [Function], - "findByPlaceholderText": [Function], - "findByRole": [Function], - "findByTestId": [Function], - "findByText": [Function], - "findByTitle": [Function], - "getAllByAltText": [Function], - "getAllByDisplayValue": [Function], - "getAllByLabelText": [Function], - "getAllByPlaceholderText": [Function], - "getAllByRole": [Function], - "getAllByTestId": [Function], - "getAllByText": [Function], - "getAllByTitle": [Function], - "getByAltText": [Function], - "getByDisplayValue": [Function], - "getByLabelText": [Function], - "getByPlaceholderText": [Function], - "getByRole": [Function], - "getByTestId": [Function], - "getByText": [Function], - "getByTitle": [Function], - "queryAllByAltText": [Function], - "queryAllByDisplayValue": [Function], - "queryAllByLabelText": [Function], - "queryAllByPlaceholderText": [Function], - "queryAllByRole": [Function], - "queryAllByTestId": [Function], - "queryAllByText": [Function], - "queryAllByTitle": [Function], - "queryByAltText": [Function], - "queryByDisplayValue": [Function], - "queryByLabelText": [Function], - "queryByPlaceholderText": [Function], - "queryByRole": [Function], - "queryByTestId": [Function], - "queryByText": [Function], - "queryByTitle": [Function], - "rerender": [Function], - "unmount": [Function], -} -`; diff --git a/packages/ketcher-polymer-editor-react/src/components/contextMenu/RNAContextMenu.test.tsx b/packages/ketcher-polymer-editor-react/src/components/contextMenu/RNAContextMenu.test.tsx index 68a45686f6..9075077fe5 100644 --- a/packages/ketcher-polymer-editor-react/src/components/contextMenu/RNAContextMenu.test.tsx +++ b/packages/ketcher-polymer-editor-react/src/components/contextMenu/RNAContextMenu.test.tsx @@ -76,8 +76,6 @@ describe('RNA ContextMenu', () => { }, ), ); - const cancelButton = screen.getByTestId('cancel-btn'); - fireEvent.click(cancelButton); const presetCard = screen.getByTestId('A_A_R_P'); fireEvent.contextMenu(presetCard); expect(screen.getByTestId('deletepreset')).toBeInTheDocument(); @@ -96,15 +94,13 @@ describe('RNA ContextMenu', () => { }, ), ); - const cancelButton = screen.getByTestId('cancel-btn'); - fireEvent.click(cancelButton); const preset = screen.getByTestId('A_A_R_P'); fireEvent.contextMenu(preset); const deleteMenu = screen.getByTestId('deletepreset'); expect(deleteMenu.className).toContain('disabled'); }); - it("should delete preset correctly when click menu 'Delete Preset'", () => { + it("should enable 'Delete Preset' when trying to delete non-default preset", () => { render( withThemeAndStoreProvider(
@@ -120,18 +116,9 @@ describe('RNA ContextMenu', () => { }, ), ); - const cancelButton = screen.getByTestId('cancel-btn'); - fireEvent.click(cancelButton); const preset = screen.getByTestId('A_A_R_P'); fireEvent.contextMenu(preset); - const duplicateMenu = screen.getByTestId('duplicateandedit'); - fireEvent.click(duplicateMenu); - const presetCopyCard = screen.getByTestId('A_Copy_A_R_P'); - fireEvent.contextMenu(presetCopyCard); const deleteMenu = screen.getByTestId('deletepreset'); - fireEvent.click(deleteMenu); - const deleteBtn = screen.getByTitle('Delete'); - fireEvent.click(deleteBtn); - expect(presetCopyCard).not.toBeInTheDocument(); + expect(deleteMenu.className).toContain('disabled'); }); }); diff --git a/packages/ketcher-polymer-editor-react/src/components/menu/__snapshots__/Menu.test.tsx.snap b/packages/ketcher-polymer-editor-react/src/components/menu/__snapshots__/Menu.test.tsx.snap index 6b336d8c3a..29517069ee 100644 --- a/packages/ketcher-polymer-editor-react/src/components/menu/__snapshots__/Menu.test.tsx.snap +++ b/packages/ketcher-polymer-editor-react/src/components/menu/__snapshots__/Menu.test.tsx.snap @@ -6,13 +6,14 @@ Object { "baseElement":
- - or drag file here - -
+
+ + or drag file here + +
+

+ Open from file +

, "container":
-
- - - or drag file here - -
+
+ + or drag file here + +
+

+ Open from file +

, "debug": [Function], diff --git a/packages/ketcher-polymer-editor-react/src/components/modal/Open/OpenOptions/OpenOptions.test.tsx b/packages/ketcher-polymer-editor-react/src/components/modal/Open/OpenOptions/OpenOptions.test.tsx index 7706841f0f..f326cef747 100644 --- a/packages/ketcher-polymer-editor-react/src/components/modal/Open/OpenOptions/OpenOptions.test.tsx +++ b/packages/ketcher-polymer-editor-react/src/components/modal/Open/OpenOptions/OpenOptions.test.tsx @@ -32,16 +32,12 @@ describe('OpenOptions component', () => { it('should render correctly with passed props', () => { render(withThemeProvider()); - expect( - screen.getByRole('button', { name: 'Paste from Clipboard' }), - ).toBeInTheDocument(); - expect( - screen.getByRole('button', { name: 'Open from file' }), - ).toBeInTheDocument(); + expect(screen.getByText('Paste from clipboard')).toBeInTheDocument(); + expect(screen.getByText('Open from file')).toBeInTheDocument(); }); - it('callback for Paste from Clipboard button should be called after click', () => { + it('callback for Paste from clipboard button should be called after click', () => { render(withThemeProvider()); - const button = screen.getByRole('button', { name: 'Paste from Clipboard' }); + const button = screen.getByText('Paste from clipboard'); fireEvent.click(button); diff --git a/packages/ketcher-polymer-editor-react/src/components/modal/Open/OpenOptions/__snapshots__/OpenOptions.test.tsx.snap b/packages/ketcher-polymer-editor-react/src/components/modal/Open/OpenOptions/__snapshots__/OpenOptions.test.tsx.snap index 4b42a90421..d84bb7fafa 100644 --- a/packages/ketcher-polymer-editor-react/src/components/modal/Open/OpenOptions/__snapshots__/OpenOptions.test.tsx.snap +++ b/packages/ketcher-polymer-editor-react/src/components/modal/Open/OpenOptions/__snapshots__/OpenOptions.test.tsx.snap @@ -9,37 +9,43 @@ Object { class="css-9brf46" >
- + + +

+ Paste from clipboard +

+ + + +
- or drag file here
+

+ Open from file +

+
+
+
+
+ + + + + +

+ Image Recognition service is not available +

@@ -89,37 +143,43 @@ Object { class="css-9brf46" >
- + + +

+ Paste from clipboard +

+ + + +
- or drag file here
+

+ Open from file +

+
+
+
+
+ + + + + +

+ Image Recognition service is not available +

diff --git a/packages/ketcher-polymer-editor-react/src/components/modal/Open/__snapshots__/Open.test.tsx.snap b/packages/ketcher-polymer-editor-react/src/components/modal/Open/__snapshots__/Open.test.tsx.snap index 6a556e6204..73f76ed147 100644 --- a/packages/ketcher-polymer-editor-react/src/components/modal/Open/__snapshots__/Open.test.tsx.snap +++ b/packages/ketcher-polymer-editor-react/src/components/modal/Open/__snapshots__/Open.test.tsx.snap @@ -10,13 +10,13 @@ Object { aria-hidden="true" />