From fa32dfdab3e64ff082a1c0138d3c360c8df3418a Mon Sep 17 00:00:00 2001 From: Bree Hall Date: Tue, 18 Apr 2023 15:25:40 -0400 Subject: [PATCH 01/16] Added Cypress tests for EuiInlineEdit functionality --- .../inline_edit/inline_edit.spec.tsx | 148 ++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 src/components/inline_edit/inline_edit.spec.tsx diff --git a/src/components/inline_edit/inline_edit.spec.tsx b/src/components/inline_edit/inline_edit.spec.tsx new file mode 100644 index 00000000000..c24dad137f5 --- /dev/null +++ b/src/components/inline_edit/inline_edit.spec.tsx @@ -0,0 +1,148 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +/// + +import React from 'react'; +import { EuiInlineEditText } from './inline_edit_text'; + +describe('EuiInlineEditText', () => { + describe('Editing text', () => { + it('saves text edits', () => { + cy.realMount( + + ); + + cy.get('button').contains('Hello World!').realClick(); + cy.get('input[aria-label="textEditInput"]').clear().type('New message'); + cy.get('button[aria-label="saveEditButton"]') + .realClick() + .then(() => { + expect(cy.get('button').contains('New message')); + }); + }); + + it('cancels text edits', () => { + cy.realMount( + + ); + + cy.get('button').contains('Hello World!').realClick(); + cy.get('input[aria-label="textEditInput"]').clear().type('New message'); + cy.get('button[aria-label="cancelEditButton"]') + .realClick() + .then(() => { + expect(cy.get('button').contains('Hello World!')); + }); + }); + }); + + describe('Validation and Loading', () => { + it('should not save empty text', () => { + cy.realMount( + + ); + + cy.get('button').contains('Hello World!').realClick(); + cy.get('input[aria-label="textEditInput"]').clear(); + cy.get('button[aria-label="saveEditButton"]') + .realClick() + .then(() => { + expect(cy.get('button').contains('Hello World!')); + }); + }); + + it('should obey user generated validation rules', () => { + cy.realMount( + + ); + + cy.get('input[aria-label="textEditInput"]').should( + 'have.attr', + 'aria-invalid' + ); + cy.get('button[aria-label="saveEditButton"]').should('be.disabled'); + }); + + it('should not be able to save when component is loading', () => { + cy.realMount( + + ); + + cy.get('input[aria-label="textEditInput"]').should( + 'have.class', + 'euiFieldText-isLoading' + ); + cy.get('button[aria-label="saveEditButton"]').should('not.exist'); + cy.get('button[aria-label="cancelEditButton"]').should('not.exist'); + }); + }); + + describe('onConfirm Property', () => { + it('should return to edit mode when the onConfirm flag is false', () => { + cy.realMount( + { + return false; + }} + /> + ); + + cy.get('button[aria-label="saveEditButton"]').realClick(); + cy.get('input[aria-label="textEditInput"]').should('exist'); + cy.get('button').contains('Hello World!').should('not.exist'); + }); + + it('should return to read mode when the onConfirm flag is true', () => { + cy.realMount( + { + return true; + }} + /> + ); + + cy.get('button[aria-label="saveEditButton"]').realClick(); + cy.get('input[aria-label="textEditInput"]').should('not.exist'); + cy.get('button').contains('Hello World!').should('exist'); + }); + }); +}); From 283f8a056455e16807f7f62489276faf6129962b Mon Sep 17 00:00:00 2001 From: Bree Hall Date: Tue, 18 Apr 2023 16:08:58 -0400 Subject: [PATCH 02/16] Added snapshots for read mode and edit mode for the Text and Title variations for EuiInlineEdit --- .../inline_edit_text.test.tsx.snap | 1526 ++++++++- .../inline_edit_title.test.tsx.snap | 2916 ++++++++++++++++- .../inline_edit/inline_edit_text.test.tsx | 74 +- .../inline_edit/inline_edit_title.test.tsx | 72 +- 4 files changed, 4561 insertions(+), 27 deletions(-) diff --git a/src/components/inline_edit/__snapshots__/inline_edit_text.test.tsx.snap b/src/components/inline_edit/__snapshots__/inline_edit_text.test.tsx.snap index 345679c9b9a..d79e18eeba8 100644 --- a/src/components/inline_edit/__snapshots__/inline_edit_text.test.tsx.snap +++ b/src/components/inline_edit/__snapshots__/inline_edit_text.test.tsx.snap @@ -1,6 +1,1530 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`EuiInlineEditText props renders as text 1`] = ` +exports[`EuiInlineEditTitle props sizes m is rendered in editMode 1`] = ` +Object { + "asFragment": [Function], + "baseElement": +
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+ , + "container":
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByTestSubject": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByTestSubject": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByTestSubject": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByTestSubject": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByTestSubject": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByTestSubject": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`EuiInlineEditTitle props sizes m is rendered in readMode 1`] = ` +Object { + "asFragment": [Function], + "baseElement": +
+
+ +
+
+ , + "container":
+
+ +
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByTestSubject": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByTestSubject": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByTestSubject": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByTestSubject": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByTestSubject": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByTestSubject": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`EuiInlineEditTitle props sizes s is rendered in editMode 1`] = ` +Object { + "asFragment": [Function], + "baseElement": +
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+ , + "container":
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByTestSubject": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByTestSubject": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByTestSubject": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByTestSubject": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByTestSubject": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByTestSubject": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`EuiInlineEditTitle props sizes s is rendered in readMode 1`] = ` +Object { + "asFragment": [Function], + "baseElement": +
+
+ +
+
+ , + "container":
+
+ +
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByTestSubject": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByTestSubject": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByTestSubject": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByTestSubject": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByTestSubject": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByTestSubject": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`EuiInlineEditTitle props sizes xs is rendered in editMode 1`] = ` +Object { + "asFragment": [Function], + "baseElement": +
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+ , + "container":
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByTestSubject": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByTestSubject": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByTestSubject": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByTestSubject": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByTestSubject": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByTestSubject": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`EuiInlineEditTitle props sizes xs is rendered in readMode 1`] = ` +Object { + "asFragment": [Function], + "baseElement": +
+
+ +
+
+ , + "container":
+
+ +
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByTestSubject": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByTestSubject": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByTestSubject": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByTestSubject": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByTestSubject": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByTestSubject": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`EuiInlineEditTitle renders as title in editMode 1`] = ` +
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+`; + +exports[`EuiInlineEditTitle renders as title in readMode 1`] = `
diff --git a/src/components/inline_edit/__snapshots__/inline_edit_title.test.tsx.snap b/src/components/inline_edit/__snapshots__/inline_edit_title.test.tsx.snap index 87e2784f989..9abecb81cba 100644 --- a/src/components/inline_edit/__snapshots__/inline_edit_title.test.tsx.snap +++ b/src/components/inline_edit/__snapshots__/inline_edit_title.test.tsx.snap @@ -1,6 +1,2916 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`EuiInlineEditTitle props renders as title 1`] = ` +exports[`EuiInlineEditTitle props sizes l is rendered in editMode 1`] = ` +Object { + "asFragment": [Function], + "baseElement": +
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+ , + "container":
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByTestSubject": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByTestSubject": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByTestSubject": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByTestSubject": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByTestSubject": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByTestSubject": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`EuiInlineEditTitle props sizes l is rendered in readMode 1`] = ` +Object { + "asFragment": [Function], + "baseElement": +
+
+ +
+
+ , + "container":
+
+ +
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByTestSubject": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByTestSubject": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByTestSubject": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByTestSubject": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByTestSubject": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByTestSubject": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`EuiInlineEditTitle props sizes m is rendered in editMode 1`] = ` +Object { + "asFragment": [Function], + "baseElement": +
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+ , + "container":
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByTestSubject": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByTestSubject": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByTestSubject": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByTestSubject": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByTestSubject": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByTestSubject": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`EuiInlineEditTitle props sizes m is rendered in readMode 1`] = ` +Object { + "asFragment": [Function], + "baseElement": +
+
+ +
+
+ , + "container":
+
+ +
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByTestSubject": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByTestSubject": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByTestSubject": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByTestSubject": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByTestSubject": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByTestSubject": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`EuiInlineEditTitle props sizes s is rendered in editMode 1`] = ` +Object { + "asFragment": [Function], + "baseElement": +
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+ , + "container":
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByTestSubject": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByTestSubject": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByTestSubject": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByTestSubject": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByTestSubject": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByTestSubject": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`EuiInlineEditTitle props sizes s is rendered in readMode 1`] = ` +Object { + "asFragment": [Function], + "baseElement": +
+
+ +
+
+ , + "container":
+
+ +
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByTestSubject": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByTestSubject": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByTestSubject": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByTestSubject": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByTestSubject": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByTestSubject": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`EuiInlineEditTitle props sizes xs is rendered in editMode 1`] = ` +Object { + "asFragment": [Function], + "baseElement": +
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+ , + "container":
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByTestSubject": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByTestSubject": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByTestSubject": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByTestSubject": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByTestSubject": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByTestSubject": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`EuiInlineEditTitle props sizes xs is rendered in readMode 1`] = ` +Object { + "asFragment": [Function], + "baseElement": +
+
+ +
+
+ , + "container":
+
+ +
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByTestSubject": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByTestSubject": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByTestSubject": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByTestSubject": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByTestSubject": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByTestSubject": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`EuiInlineEditTitle props sizes xxs is rendered in editMode 1`] = ` +Object { + "asFragment": [Function], + "baseElement": +
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+ , + "container":
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByTestSubject": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByTestSubject": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByTestSubject": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByTestSubject": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByTestSubject": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByTestSubject": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`EuiInlineEditTitle props sizes xxs is rendered in readMode 1`] = ` +Object { + "asFragment": [Function], + "baseElement": +
+
+ +
+
+ , + "container":
+
+ +
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByTestSubject": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByTestSubject": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByTestSubject": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByTestSubject": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByTestSubject": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByTestSubject": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`EuiInlineEditTitle props sizes xxxs is rendered in editMode 1`] = ` +Object { + "asFragment": [Function], + "baseElement": +
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+ , + "container":
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByTestSubject": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByTestSubject": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByTestSubject": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByTestSubject": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByTestSubject": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByTestSubject": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`EuiInlineEditTitle props sizes xxxs is rendered in readMode 1`] = ` +Object { + "asFragment": [Function], + "baseElement": +
+
+ +
+
+ , + "container":
+
+ +
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByTestSubject": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByTestSubject": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByTestSubject": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByTestSubject": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByTestSubject": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByTestSubject": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`EuiInlineEditTitle renders as title in editMode 1`] = ` +
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+`; + +exports[`EuiInlineEditTitle renders as title in readMode 1`] = `
@@ -19,11 +2929,11 @@ exports[`EuiInlineEditTitle props renders as title 1`] = ` -

hello world -

+
diff --git a/src/components/inline_edit/inline_edit_text.test.tsx b/src/components/inline_edit/inline_edit_text.test.tsx index eb47d25e5b8..5c470b98f52 100644 --- a/src/components/inline_edit/inline_edit_text.test.tsx +++ b/src/components/inline_edit/inline_edit_text.test.tsx @@ -10,20 +10,70 @@ import React from 'react'; import { render } from '../../test/rtl'; import { requiredProps } from '../../test/required_props'; -import { EuiInlineEditText } from './inline_edit_text'; +import { EuiInlineEditText, EuiInlineEditTextProps } from './inline_edit_text'; +import { TEXT_SIZES } from '../text/text'; + +describe('EuiInlineEditTitle', () => { + test('renders as title in readMode', () => { + const { container } = render( + + ); + + expect(container.firstChild).toMatchSnapshot(); + }); + + test('renders as title in editMode', () => { + const { container } = render( + + ); + + expect(container.firstChild).toMatchSnapshot(); + }); -describe('EuiInlineEditText', () => { describe('props', () => { - test('renders as text', () => { - const { container } = render( - - ); - - expect(container.firstChild).toMatchSnapshot(); + describe('sizes', () => { + // Remove 'relative' from text sizes available for EuiInlineEditText + const usedTextSizes = TEXT_SIZES.filter((size) => size !== 'relative'); + + usedTextSizes.forEach((size: string) => { + test(`${size} is rendered in readMode`, () => { + const component = render( + + ); + + expect(component).toMatchSnapshot(); + }); + }); + + usedTextSizes.forEach((size: string) => { + test(`${size} is rendered in editMode`, () => { + const component = render( + + ); + + expect(component).toMatchSnapshot(); + }); + }); }); }); }); diff --git a/src/components/inline_edit/inline_edit_title.test.tsx b/src/components/inline_edit/inline_edit_title.test.tsx index 9104347af45..0d085e3bcc5 100644 --- a/src/components/inline_edit/inline_edit_title.test.tsx +++ b/src/components/inline_edit/inline_edit_title.test.tsx @@ -11,20 +11,70 @@ import { render } from '../../test/rtl'; import { requiredProps } from '../../test/required_props'; import { EuiInlineEditTitle } from './inline_edit_title'; +import { TITLE_SIZES } from '../title/title'; describe('EuiInlineEditTitle', () => { + test('renders as title in readMode', () => { + const { container } = render( + + ); + + expect(container.firstChild).toMatchSnapshot(); + }); + + test('renders as title in editMode', () => { + const { container } = render( + + ); + + expect(container.firstChild).toMatchSnapshot(); + }); + describe('props', () => { - test('renders as title', () => { - const { container } = render( - - ); - - expect(container.firstChild).toMatchSnapshot(); + describe('sizes', () => { + TITLE_SIZES.forEach((size) => { + test(`${size} is rendered in readMode`, () => { + const component = render( + + ); + + expect(component).toMatchSnapshot(); + }); + }); + + TITLE_SIZES.forEach((size) => { + test(`${size} is rendered in editMode`, () => { + const component = render( + + ); + + expect(component).toMatchSnapshot(); + }); + }); }); }); }); From 1ab44957b512496a50f475352c46219eb61abbb6 Mon Sep 17 00:00:00 2001 From: Bree Hall Date: Wed, 19 Apr 2023 11:26:05 -0400 Subject: [PATCH 03/16] Use RTL render method for snapshots --- .../inline_edit_text.test.tsx.snap | 1554 ++------ .../inline_edit_title.test.tsx.snap | 3120 ++++------------- .../inline_edit/inline_edit_text.test.tsx | 8 +- .../inline_edit/inline_edit_title.test.tsx | 8 +- 4 files changed, 1022 insertions(+), 3668 deletions(-) diff --git a/src/components/inline_edit/__snapshots__/inline_edit_text.test.tsx.snap b/src/components/inline_edit/__snapshots__/inline_edit_text.test.tsx.snap index d79e18eeba8..fd2d719e01e 100644 --- a/src/components/inline_edit/__snapshots__/inline_edit_text.test.tsx.snap +++ b/src/components/inline_edit/__snapshots__/inline_edit_text.test.tsx.snap @@ -1,1389 +1,507 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`EuiInlineEditTitle props sizes m is rendered in editMode 1`] = ` -Object { - "asFragment": [Function], - "baseElement": -
+
+
+
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
+
-
- , - "container":
-
-
- -
+ Loaded
-
-
-
-
-
-
-
-
- Loaded -
- - -
+ aria-atomic="true" + aria-hidden="true" + aria-live="off" + role="status" + />
+
+
+
+
+
-
-
- Loaded -
- - + Loaded
+ +
-
, - "debug": [Function], - "findAllByAltText": [Function], - "findAllByDisplayValue": [Function], - "findAllByLabelText": [Function], - "findAllByPlaceholderText": [Function], - "findAllByRole": [Function], - "findAllByTestId": [Function], - "findAllByTestSubject": [Function], - "findAllByText": [Function], - "findAllByTitle": [Function], - "findByAltText": [Function], - "findByDisplayValue": [Function], - "findByLabelText": [Function], - "findByPlaceholderText": [Function], - "findByRole": [Function], - "findByTestId": [Function], - "findByTestSubject": [Function], - "findByText": [Function], - "findByTitle": [Function], - "getAllByAltText": [Function], - "getAllByDisplayValue": [Function], - "getAllByLabelText": [Function], - "getAllByPlaceholderText": [Function], - "getAllByRole": [Function], - "getAllByTestId": [Function], - "getAllByTestSubject": [Function], - "getAllByText": [Function], - "getAllByTitle": [Function], - "getByAltText": [Function], - "getByDisplayValue": [Function], - "getByLabelText": [Function], - "getByPlaceholderText": [Function], - "getByRole": [Function], - "getByTestId": [Function], - "getByTestSubject": [Function], - "getByText": [Function], - "getByTitle": [Function], - "queryAllByAltText": [Function], - "queryAllByDisplayValue": [Function], - "queryAllByLabelText": [Function], - "queryAllByPlaceholderText": [Function], - "queryAllByRole": [Function], - "queryAllByTestId": [Function], - "queryAllByTestSubject": [Function], - "queryAllByText": [Function], - "queryAllByTitle": [Function], - "queryByAltText": [Function], - "queryByDisplayValue": [Function], - "queryByLabelText": [Function], - "queryByPlaceholderText": [Function], - "queryByRole": [Function], - "queryByTestId": [Function], - "queryByTestSubject": [Function], - "queryByText": [Function], - "queryByTitle": [Function], - "rerender": [Function], - "unmount": [Function], -} +
+
`; exports[`EuiInlineEditTitle props sizes m is rendered in readMode 1`] = ` -Object { - "asFragment": [Function], - "baseElement": -
-
- -
-
- , - "container":
-
+ -
-
, - "debug": [Function], - "findAllByAltText": [Function], - "findAllByDisplayValue": [Function], - "findAllByLabelText": [Function], - "findAllByPlaceholderText": [Function], - "findAllByRole": [Function], - "findAllByTestId": [Function], - "findAllByTestSubject": [Function], - "findAllByText": [Function], - "findAllByTitle": [Function], - "findByAltText": [Function], - "findByDisplayValue": [Function], - "findByLabelText": [Function], - "findByPlaceholderText": [Function], - "findByRole": [Function], - "findByTestId": [Function], - "findByTestSubject": [Function], - "findByText": [Function], - "findByTitle": [Function], - "getAllByAltText": [Function], - "getAllByDisplayValue": [Function], - "getAllByLabelText": [Function], - "getAllByPlaceholderText": [Function], - "getAllByRole": [Function], - "getAllByTestId": [Function], - "getAllByTestSubject": [Function], - "getAllByText": [Function], - "getAllByTitle": [Function], - "getByAltText": [Function], - "getByDisplayValue": [Function], - "getByLabelText": [Function], - "getByPlaceholderText": [Function], - "getByRole": [Function], - "getByTestId": [Function], - "getByTestSubject": [Function], - "getByText": [Function], - "getByTitle": [Function], - "queryAllByAltText": [Function], - "queryAllByDisplayValue": [Function], - "queryAllByLabelText": [Function], - "queryAllByPlaceholderText": [Function], - "queryAllByRole": [Function], - "queryAllByTestId": [Function], - "queryAllByTestSubject": [Function], - "queryAllByText": [Function], - "queryAllByTitle": [Function], - "queryByAltText": [Function], - "queryByDisplayValue": [Function], - "queryByLabelText": [Function], - "queryByPlaceholderText": [Function], - "queryByRole": [Function], - "queryByTestId": [Function], - "queryByTestSubject": [Function], - "queryByText": [Function], - "queryByTitle": [Function], - "rerender": [Function], - "unmount": [Function], -} + Hello World! +
+ + + +
`; exports[`EuiInlineEditTitle props sizes s is rendered in editMode 1`] = ` -Object { - "asFragment": [Function], - "baseElement": -
+
+
+
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
+
-
- , - "container":
-
-
- -
+ Loaded
-
-
-
-
-
-
-
-
- Loaded -
- - -
+ aria-atomic="true" + aria-hidden="true" + aria-live="off" + role="status" + />
+
+
+
+
+
-
-
- Loaded -
- - + Loaded
+ +
-
, - "debug": [Function], - "findAllByAltText": [Function], - "findAllByDisplayValue": [Function], - "findAllByLabelText": [Function], - "findAllByPlaceholderText": [Function], - "findAllByRole": [Function], - "findAllByTestId": [Function], - "findAllByTestSubject": [Function], - "findAllByText": [Function], - "findAllByTitle": [Function], - "findByAltText": [Function], - "findByDisplayValue": [Function], - "findByLabelText": [Function], - "findByPlaceholderText": [Function], - "findByRole": [Function], - "findByTestId": [Function], - "findByTestSubject": [Function], - "findByText": [Function], - "findByTitle": [Function], - "getAllByAltText": [Function], - "getAllByDisplayValue": [Function], - "getAllByLabelText": [Function], - "getAllByPlaceholderText": [Function], - "getAllByRole": [Function], - "getAllByTestId": [Function], - "getAllByTestSubject": [Function], - "getAllByText": [Function], - "getAllByTitle": [Function], - "getByAltText": [Function], - "getByDisplayValue": [Function], - "getByLabelText": [Function], - "getByPlaceholderText": [Function], - "getByRole": [Function], - "getByTestId": [Function], - "getByTestSubject": [Function], - "getByText": [Function], - "getByTitle": [Function], - "queryAllByAltText": [Function], - "queryAllByDisplayValue": [Function], - "queryAllByLabelText": [Function], - "queryAllByPlaceholderText": [Function], - "queryAllByRole": [Function], - "queryAllByTestId": [Function], - "queryAllByTestSubject": [Function], - "queryAllByText": [Function], - "queryAllByTitle": [Function], - "queryByAltText": [Function], - "queryByDisplayValue": [Function], - "queryByLabelText": [Function], - "queryByPlaceholderText": [Function], - "queryByRole": [Function], - "queryByTestId": [Function], - "queryByTestSubject": [Function], - "queryByText": [Function], - "queryByTitle": [Function], - "rerender": [Function], - "unmount": [Function], -} +
+
`; exports[`EuiInlineEditTitle props sizes s is rendered in readMode 1`] = ` -Object { - "asFragment": [Function], - "baseElement": -
-
- -
-
- , - "container":
-
+ -
-
, - "debug": [Function], - "findAllByAltText": [Function], - "findAllByDisplayValue": [Function], - "findAllByLabelText": [Function], - "findAllByPlaceholderText": [Function], - "findAllByRole": [Function], - "findAllByTestId": [Function], - "findAllByTestSubject": [Function], - "findAllByText": [Function], - "findAllByTitle": [Function], - "findByAltText": [Function], - "findByDisplayValue": [Function], - "findByLabelText": [Function], - "findByPlaceholderText": [Function], - "findByRole": [Function], - "findByTestId": [Function], - "findByTestSubject": [Function], - "findByText": [Function], - "findByTitle": [Function], - "getAllByAltText": [Function], - "getAllByDisplayValue": [Function], - "getAllByLabelText": [Function], - "getAllByPlaceholderText": [Function], - "getAllByRole": [Function], - "getAllByTestId": [Function], - "getAllByTestSubject": [Function], - "getAllByText": [Function], - "getAllByTitle": [Function], - "getByAltText": [Function], - "getByDisplayValue": [Function], - "getByLabelText": [Function], - "getByPlaceholderText": [Function], - "getByRole": [Function], - "getByTestId": [Function], - "getByTestSubject": [Function], - "getByText": [Function], - "getByTitle": [Function], - "queryAllByAltText": [Function], - "queryAllByDisplayValue": [Function], - "queryAllByLabelText": [Function], - "queryAllByPlaceholderText": [Function], - "queryAllByRole": [Function], - "queryAllByTestId": [Function], - "queryAllByTestSubject": [Function], - "queryAllByText": [Function], - "queryAllByTitle": [Function], - "queryByAltText": [Function], - "queryByDisplayValue": [Function], - "queryByLabelText": [Function], - "queryByPlaceholderText": [Function], - "queryByRole": [Function], - "queryByTestId": [Function], - "queryByTestSubject": [Function], - "queryByText": [Function], - "queryByTitle": [Function], - "rerender": [Function], - "unmount": [Function], -} + Hello World! +
+ + + +
`; exports[`EuiInlineEditTitle props sizes xs is rendered in editMode 1`] = ` -Object { - "asFragment": [Function], - "baseElement": -
+
+
+
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
+
-
- , - "container":
-
-
- -
+ Loaded
-
-
-
-
-
-
-
-
- Loaded -
- - -
+ aria-atomic="true" + aria-hidden="true" + aria-live="off" + role="status" + />
+
+
+
+
+
-
-
- Loaded -
- - + Loaded
+ +
-
, - "debug": [Function], - "findAllByAltText": [Function], - "findAllByDisplayValue": [Function], - "findAllByLabelText": [Function], - "findAllByPlaceholderText": [Function], - "findAllByRole": [Function], - "findAllByTestId": [Function], - "findAllByTestSubject": [Function], - "findAllByText": [Function], - "findAllByTitle": [Function], - "findByAltText": [Function], - "findByDisplayValue": [Function], - "findByLabelText": [Function], - "findByPlaceholderText": [Function], - "findByRole": [Function], - "findByTestId": [Function], - "findByTestSubject": [Function], - "findByText": [Function], - "findByTitle": [Function], - "getAllByAltText": [Function], - "getAllByDisplayValue": [Function], - "getAllByLabelText": [Function], - "getAllByPlaceholderText": [Function], - "getAllByRole": [Function], - "getAllByTestId": [Function], - "getAllByTestSubject": [Function], - "getAllByText": [Function], - "getAllByTitle": [Function], - "getByAltText": [Function], - "getByDisplayValue": [Function], - "getByLabelText": [Function], - "getByPlaceholderText": [Function], - "getByRole": [Function], - "getByTestId": [Function], - "getByTestSubject": [Function], - "getByText": [Function], - "getByTitle": [Function], - "queryAllByAltText": [Function], - "queryAllByDisplayValue": [Function], - "queryAllByLabelText": [Function], - "queryAllByPlaceholderText": [Function], - "queryAllByRole": [Function], - "queryAllByTestId": [Function], - "queryAllByTestSubject": [Function], - "queryAllByText": [Function], - "queryAllByTitle": [Function], - "queryByAltText": [Function], - "queryByDisplayValue": [Function], - "queryByLabelText": [Function], - "queryByPlaceholderText": [Function], - "queryByRole": [Function], - "queryByTestId": [Function], - "queryByTestSubject": [Function], - "queryByText": [Function], - "queryByTitle": [Function], - "rerender": [Function], - "unmount": [Function], -} +
+
`; exports[`EuiInlineEditTitle props sizes xs is rendered in readMode 1`] = ` -Object { - "asFragment": [Function], - "baseElement": -
-
- -
-
- , - "container":
-
+ -
-
, - "debug": [Function], - "findAllByAltText": [Function], - "findAllByDisplayValue": [Function], - "findAllByLabelText": [Function], - "findAllByPlaceholderText": [Function], - "findAllByRole": [Function], - "findAllByTestId": [Function], - "findAllByTestSubject": [Function], - "findAllByText": [Function], - "findAllByTitle": [Function], - "findByAltText": [Function], - "findByDisplayValue": [Function], - "findByLabelText": [Function], - "findByPlaceholderText": [Function], - "findByRole": [Function], - "findByTestId": [Function], - "findByTestSubject": [Function], - "findByText": [Function], - "findByTitle": [Function], - "getAllByAltText": [Function], - "getAllByDisplayValue": [Function], - "getAllByLabelText": [Function], - "getAllByPlaceholderText": [Function], - "getAllByRole": [Function], - "getAllByTestId": [Function], - "getAllByTestSubject": [Function], - "getAllByText": [Function], - "getAllByTitle": [Function], - "getByAltText": [Function], - "getByDisplayValue": [Function], - "getByLabelText": [Function], - "getByPlaceholderText": [Function], - "getByRole": [Function], - "getByTestId": [Function], - "getByTestSubject": [Function], - "getByText": [Function], - "getByTitle": [Function], - "queryAllByAltText": [Function], - "queryAllByDisplayValue": [Function], - "queryAllByLabelText": [Function], - "queryAllByPlaceholderText": [Function], - "queryAllByRole": [Function], - "queryAllByTestId": [Function], - "queryAllByTestSubject": [Function], - "queryAllByText": [Function], - "queryAllByTitle": [Function], - "queryByAltText": [Function], - "queryByDisplayValue": [Function], - "queryByLabelText": [Function], - "queryByPlaceholderText": [Function], - "queryByRole": [Function], - "queryByTestId": [Function], - "queryByTestSubject": [Function], - "queryByText": [Function], - "queryByTitle": [Function], - "rerender": [Function], - "unmount": [Function], -} + Hello World! +
+ + + +
`; exports[`EuiInlineEditTitle renders as title in editMode 1`] = ` diff --git a/src/components/inline_edit/__snapshots__/inline_edit_title.test.tsx.snap b/src/components/inline_edit/__snapshots__/inline_edit_title.test.tsx.snap index 9abecb81cba..70638bba9bb 100644 --- a/src/components/inline_edit/__snapshots__/inline_edit_title.test.tsx.snap +++ b/src/components/inline_edit/__snapshots__/inline_edit_title.test.tsx.snap @@ -1,2775 +1,1011 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`EuiInlineEditTitle props sizes l is rendered in editMode 1`] = ` -Object { - "asFragment": [Function], - "baseElement": -
+
+
+
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
+
-
- , - "container":
-
-
- -
+ Loaded
-
-
-
-
-
-
-
-
- Loaded -
- - -
+ aria-atomic="true" + aria-hidden="true" + aria-live="off" + role="status" + />
+
+
+
+
+
-
-
- Loaded -
- - + Loaded
+ +
-
, - "debug": [Function], - "findAllByAltText": [Function], - "findAllByDisplayValue": [Function], - "findAllByLabelText": [Function], - "findAllByPlaceholderText": [Function], - "findAllByRole": [Function], - "findAllByTestId": [Function], - "findAllByTestSubject": [Function], - "findAllByText": [Function], - "findAllByTitle": [Function], - "findByAltText": [Function], - "findByDisplayValue": [Function], - "findByLabelText": [Function], - "findByPlaceholderText": [Function], - "findByRole": [Function], - "findByTestId": [Function], - "findByTestSubject": [Function], - "findByText": [Function], - "findByTitle": [Function], - "getAllByAltText": [Function], - "getAllByDisplayValue": [Function], - "getAllByLabelText": [Function], - "getAllByPlaceholderText": [Function], - "getAllByRole": [Function], - "getAllByTestId": [Function], - "getAllByTestSubject": [Function], - "getAllByText": [Function], - "getAllByTitle": [Function], - "getByAltText": [Function], - "getByDisplayValue": [Function], - "getByLabelText": [Function], - "getByPlaceholderText": [Function], - "getByRole": [Function], - "getByTestId": [Function], - "getByTestSubject": [Function], - "getByText": [Function], - "getByTitle": [Function], - "queryAllByAltText": [Function], - "queryAllByDisplayValue": [Function], - "queryAllByLabelText": [Function], - "queryAllByPlaceholderText": [Function], - "queryAllByRole": [Function], - "queryAllByTestId": [Function], - "queryAllByTestSubject": [Function], - "queryAllByText": [Function], - "queryAllByTitle": [Function], - "queryByAltText": [Function], - "queryByDisplayValue": [Function], - "queryByLabelText": [Function], - "queryByPlaceholderText": [Function], - "queryByRole": [Function], - "queryByTestId": [Function], - "queryByTestSubject": [Function], - "queryByText": [Function], - "queryByTitle": [Function], - "rerender": [Function], - "unmount": [Function], -} +
+
`; exports[`EuiInlineEditTitle props sizes l is rendered in readMode 1`] = ` -Object { - "asFragment": [Function], - "baseElement": -
-
- -
-
- , - "container":
-
+ -
-
, - "debug": [Function], - "findAllByAltText": [Function], - "findAllByDisplayValue": [Function], - "findAllByLabelText": [Function], - "findAllByPlaceholderText": [Function], - "findAllByRole": [Function], - "findAllByTestId": [Function], - "findAllByTestSubject": [Function], - "findAllByText": [Function], - "findAllByTitle": [Function], - "findByAltText": [Function], - "findByDisplayValue": [Function], - "findByLabelText": [Function], - "findByPlaceholderText": [Function], - "findByRole": [Function], - "findByTestId": [Function], - "findByTestSubject": [Function], - "findByText": [Function], - "findByTitle": [Function], - "getAllByAltText": [Function], - "getAllByDisplayValue": [Function], - "getAllByLabelText": [Function], - "getAllByPlaceholderText": [Function], - "getAllByRole": [Function], - "getAllByTestId": [Function], - "getAllByTestSubject": [Function], - "getAllByText": [Function], - "getAllByTitle": [Function], - "getByAltText": [Function], - "getByDisplayValue": [Function], - "getByLabelText": [Function], - "getByPlaceholderText": [Function], - "getByRole": [Function], - "getByTestId": [Function], - "getByTestSubject": [Function], - "getByText": [Function], - "getByTitle": [Function], - "queryAllByAltText": [Function], - "queryAllByDisplayValue": [Function], - "queryAllByLabelText": [Function], - "queryAllByPlaceholderText": [Function], - "queryAllByRole": [Function], - "queryAllByTestId": [Function], - "queryAllByTestSubject": [Function], - "queryAllByText": [Function], - "queryAllByTitle": [Function], - "queryByAltText": [Function], - "queryByDisplayValue": [Function], - "queryByLabelText": [Function], - "queryByPlaceholderText": [Function], - "queryByRole": [Function], - "queryByTestId": [Function], - "queryByTestSubject": [Function], - "queryByText": [Function], - "queryByTitle": [Function], - "rerender": [Function], - "unmount": [Function], -} + Hello World! + + + + +
`; exports[`EuiInlineEditTitle props sizes m is rendered in editMode 1`] = ` -Object { - "asFragment": [Function], - "baseElement": -
+
+
+
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
+
-
- , - "container":
-
-
- -
+ Loaded
-
-
-
-
-
-
-
-
- Loaded -
- - -
+ aria-atomic="true" + aria-hidden="true" + aria-live="off" + role="status" + />
+
+
+
+
+
-
-
- Loaded -
- - + Loaded
+ -
+ +
-
, - "debug": [Function], - "findAllByAltText": [Function], - "findAllByDisplayValue": [Function], - "findAllByLabelText": [Function], - "findAllByPlaceholderText": [Function], - "findAllByRole": [Function], - "findAllByTestId": [Function], - "findAllByTestSubject": [Function], - "findAllByText": [Function], - "findAllByTitle": [Function], - "findByAltText": [Function], - "findByDisplayValue": [Function], - "findByLabelText": [Function], - "findByPlaceholderText": [Function], - "findByRole": [Function], - "findByTestId": [Function], - "findByTestSubject": [Function], - "findByText": [Function], - "findByTitle": [Function], - "getAllByAltText": [Function], - "getAllByDisplayValue": [Function], - "getAllByLabelText": [Function], - "getAllByPlaceholderText": [Function], - "getAllByRole": [Function], - "getAllByTestId": [Function], - "getAllByTestSubject": [Function], - "getAllByText": [Function], - "getAllByTitle": [Function], - "getByAltText": [Function], - "getByDisplayValue": [Function], - "getByLabelText": [Function], - "getByPlaceholderText": [Function], - "getByRole": [Function], - "getByTestId": [Function], - "getByTestSubject": [Function], - "getByText": [Function], - "getByTitle": [Function], - "queryAllByAltText": [Function], - "queryAllByDisplayValue": [Function], - "queryAllByLabelText": [Function], - "queryAllByPlaceholderText": [Function], - "queryAllByRole": [Function], - "queryAllByTestId": [Function], - "queryAllByTestSubject": [Function], - "queryAllByText": [Function], - "queryAllByTitle": [Function], - "queryByAltText": [Function], - "queryByDisplayValue": [Function], - "queryByLabelText": [Function], - "queryByPlaceholderText": [Function], - "queryByRole": [Function], - "queryByTestId": [Function], - "queryByTestSubject": [Function], - "queryByText": [Function], - "queryByTitle": [Function], - "rerender": [Function], - "unmount": [Function], -} +
+
`; exports[`EuiInlineEditTitle props sizes m is rendered in readMode 1`] = ` -Object { - "asFragment": [Function], - "baseElement": -
-
- -
-
- , - "container":
-
+ -
-
, - "debug": [Function], - "findAllByAltText": [Function], - "findAllByDisplayValue": [Function], - "findAllByLabelText": [Function], - "findAllByPlaceholderText": [Function], - "findAllByRole": [Function], - "findAllByTestId": [Function], - "findAllByTestSubject": [Function], - "findAllByText": [Function], - "findAllByTitle": [Function], - "findByAltText": [Function], - "findByDisplayValue": [Function], - "findByLabelText": [Function], - "findByPlaceholderText": [Function], - "findByRole": [Function], - "findByTestId": [Function], - "findByTestSubject": [Function], - "findByText": [Function], - "findByTitle": [Function], - "getAllByAltText": [Function], - "getAllByDisplayValue": [Function], - "getAllByLabelText": [Function], - "getAllByPlaceholderText": [Function], - "getAllByRole": [Function], - "getAllByTestId": [Function], - "getAllByTestSubject": [Function], - "getAllByText": [Function], - "getAllByTitle": [Function], - "getByAltText": [Function], - "getByDisplayValue": [Function], - "getByLabelText": [Function], - "getByPlaceholderText": [Function], - "getByRole": [Function], - "getByTestId": [Function], - "getByTestSubject": [Function], - "getByText": [Function], - "getByTitle": [Function], - "queryAllByAltText": [Function], - "queryAllByDisplayValue": [Function], - "queryAllByLabelText": [Function], - "queryAllByPlaceholderText": [Function], - "queryAllByRole": [Function], - "queryAllByTestId": [Function], - "queryAllByTestSubject": [Function], - "queryAllByText": [Function], - "queryAllByTitle": [Function], - "queryByAltText": [Function], - "queryByDisplayValue": [Function], - "queryByLabelText": [Function], - "queryByPlaceholderText": [Function], - "queryByRole": [Function], - "queryByTestId": [Function], - "queryByTestSubject": [Function], - "queryByText": [Function], - "queryByTitle": [Function], - "rerender": [Function], - "unmount": [Function], -} + Hello World! + + + + +
`; exports[`EuiInlineEditTitle props sizes s is rendered in editMode 1`] = ` -Object { - "asFragment": [Function], - "baseElement": -
+
+
+
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
+
-
- , - "container":
-
-
- -
+ Loaded
-
-
-
-
-
-
-
-
- Loaded -
- - -
+ aria-atomic="true" + aria-hidden="true" + aria-live="off" + role="status" + />
+
+
+
+
+
-
-
- Loaded -
- - + Loaded
+ +
-
, - "debug": [Function], - "findAllByAltText": [Function], - "findAllByDisplayValue": [Function], - "findAllByLabelText": [Function], - "findAllByPlaceholderText": [Function], - "findAllByRole": [Function], - "findAllByTestId": [Function], - "findAllByTestSubject": [Function], - "findAllByText": [Function], - "findAllByTitle": [Function], - "findByAltText": [Function], - "findByDisplayValue": [Function], - "findByLabelText": [Function], - "findByPlaceholderText": [Function], - "findByRole": [Function], - "findByTestId": [Function], - "findByTestSubject": [Function], - "findByText": [Function], - "findByTitle": [Function], - "getAllByAltText": [Function], - "getAllByDisplayValue": [Function], - "getAllByLabelText": [Function], - "getAllByPlaceholderText": [Function], - "getAllByRole": [Function], - "getAllByTestId": [Function], - "getAllByTestSubject": [Function], - "getAllByText": [Function], - "getAllByTitle": [Function], - "getByAltText": [Function], - "getByDisplayValue": [Function], - "getByLabelText": [Function], - "getByPlaceholderText": [Function], - "getByRole": [Function], - "getByTestId": [Function], - "getByTestSubject": [Function], - "getByText": [Function], - "getByTitle": [Function], - "queryAllByAltText": [Function], - "queryAllByDisplayValue": [Function], - "queryAllByLabelText": [Function], - "queryAllByPlaceholderText": [Function], - "queryAllByRole": [Function], - "queryAllByTestId": [Function], - "queryAllByTestSubject": [Function], - "queryAllByText": [Function], - "queryAllByTitle": [Function], - "queryByAltText": [Function], - "queryByDisplayValue": [Function], - "queryByLabelText": [Function], - "queryByPlaceholderText": [Function], - "queryByRole": [Function], - "queryByTestId": [Function], - "queryByTestSubject": [Function], - "queryByText": [Function], - "queryByTitle": [Function], - "rerender": [Function], - "unmount": [Function], -} +
+
`; exports[`EuiInlineEditTitle props sizes s is rendered in readMode 1`] = ` -Object { - "asFragment": [Function], - "baseElement": -
-
- -
-
- , - "container":
-
+ -
-
, - "debug": [Function], - "findAllByAltText": [Function], - "findAllByDisplayValue": [Function], - "findAllByLabelText": [Function], - "findAllByPlaceholderText": [Function], - "findAllByRole": [Function], - "findAllByTestId": [Function], - "findAllByTestSubject": [Function], - "findAllByText": [Function], - "findAllByTitle": [Function], - "findByAltText": [Function], - "findByDisplayValue": [Function], - "findByLabelText": [Function], - "findByPlaceholderText": [Function], - "findByRole": [Function], - "findByTestId": [Function], - "findByTestSubject": [Function], - "findByText": [Function], - "findByTitle": [Function], - "getAllByAltText": [Function], - "getAllByDisplayValue": [Function], - "getAllByLabelText": [Function], - "getAllByPlaceholderText": [Function], - "getAllByRole": [Function], - "getAllByTestId": [Function], - "getAllByTestSubject": [Function], - "getAllByText": [Function], - "getAllByTitle": [Function], - "getByAltText": [Function], - "getByDisplayValue": [Function], - "getByLabelText": [Function], - "getByPlaceholderText": [Function], - "getByRole": [Function], - "getByTestId": [Function], - "getByTestSubject": [Function], - "getByText": [Function], - "getByTitle": [Function], - "queryAllByAltText": [Function], - "queryAllByDisplayValue": [Function], - "queryAllByLabelText": [Function], - "queryAllByPlaceholderText": [Function], - "queryAllByRole": [Function], - "queryAllByTestId": [Function], - "queryAllByTestSubject": [Function], - "queryAllByText": [Function], - "queryAllByTitle": [Function], - "queryByAltText": [Function], - "queryByDisplayValue": [Function], - "queryByLabelText": [Function], - "queryByPlaceholderText": [Function], - "queryByRole": [Function], - "queryByTestId": [Function], - "queryByTestSubject": [Function], - "queryByText": [Function], - "queryByTitle": [Function], - "rerender": [Function], - "unmount": [Function], -} + Hello World! + + + + +
`; exports[`EuiInlineEditTitle props sizes xs is rendered in editMode 1`] = ` -Object { - "asFragment": [Function], - "baseElement": -
+
+
+
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
+
-
- , - "container":
-
-
- -
+ Loaded
-
-
-
-
-
-
-
-
- Loaded -
- - -
+ aria-atomic="true" + aria-hidden="true" + aria-live="off" + role="status" + />
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
+
-
-
, - "debug": [Function], - "findAllByAltText": [Function], - "findAllByDisplayValue": [Function], - "findAllByLabelText": [Function], - "findAllByPlaceholderText": [Function], - "findAllByRole": [Function], - "findAllByTestId": [Function], - "findAllByTestSubject": [Function], - "findAllByText": [Function], - "findAllByTitle": [Function], - "findByAltText": [Function], - "findByDisplayValue": [Function], - "findByLabelText": [Function], - "findByPlaceholderText": [Function], - "findByRole": [Function], - "findByTestId": [Function], - "findByTestSubject": [Function], - "findByText": [Function], - "findByTitle": [Function], - "getAllByAltText": [Function], - "getAllByDisplayValue": [Function], - "getAllByLabelText": [Function], - "getAllByPlaceholderText": [Function], - "getAllByRole": [Function], - "getAllByTestId": [Function], - "getAllByTestSubject": [Function], - "getAllByText": [Function], - "getAllByTitle": [Function], - "getByAltText": [Function], - "getByDisplayValue": [Function], - "getByLabelText": [Function], - "getByPlaceholderText": [Function], - "getByRole": [Function], - "getByTestId": [Function], - "getByTestSubject": [Function], - "getByText": [Function], - "getByTitle": [Function], - "queryAllByAltText": [Function], - "queryAllByDisplayValue": [Function], - "queryAllByLabelText": [Function], - "queryAllByPlaceholderText": [Function], - "queryAllByRole": [Function], - "queryAllByTestId": [Function], - "queryAllByTestSubject": [Function], - "queryAllByText": [Function], - "queryAllByTitle": [Function], - "queryByAltText": [Function], - "queryByDisplayValue": [Function], - "queryByLabelText": [Function], - "queryByPlaceholderText": [Function], - "queryByRole": [Function], - "queryByTestId": [Function], - "queryByTestSubject": [Function], - "queryByText": [Function], - "queryByTitle": [Function], - "rerender": [Function], - "unmount": [Function], -} -`; - -exports[`EuiInlineEditTitle props sizes xs is rendered in readMode 1`] = ` -Object { - "asFragment": [Function], - "baseElement": -
- -
-
- , - "container":
-
- -
-
, - "debug": [Function], - "findAllByAltText": [Function], - "findAllByDisplayValue": [Function], - "findAllByLabelText": [Function], - "findAllByPlaceholderText": [Function], - "findAllByRole": [Function], - "findAllByTestId": [Function], - "findAllByTestSubject": [Function], - "findAllByText": [Function], - "findAllByTitle": [Function], - "findByAltText": [Function], - "findByDisplayValue": [Function], - "findByLabelText": [Function], - "findByPlaceholderText": [Function], - "findByRole": [Function], - "findByTestId": [Function], - "findByTestSubject": [Function], - "findByText": [Function], - "findByTitle": [Function], - "getAllByAltText": [Function], - "getAllByDisplayValue": [Function], - "getAllByLabelText": [Function], - "getAllByPlaceholderText": [Function], - "getAllByRole": [Function], - "getAllByTestId": [Function], - "getAllByTestSubject": [Function], - "getAllByText": [Function], - "getAllByTitle": [Function], - "getByAltText": [Function], - "getByDisplayValue": [Function], - "getByLabelText": [Function], - "getByPlaceholderText": [Function], - "getByRole": [Function], - "getByTestId": [Function], - "getByTestSubject": [Function], - "getByText": [Function], - "getByTitle": [Function], - "queryAllByAltText": [Function], - "queryAllByDisplayValue": [Function], - "queryAllByLabelText": [Function], - "queryAllByPlaceholderText": [Function], - "queryAllByRole": [Function], - "queryAllByTestId": [Function], - "queryAllByTestSubject": [Function], - "queryAllByText": [Function], - "queryAllByTitle": [Function], - "queryByAltText": [Function], - "queryByDisplayValue": [Function], - "queryByLabelText": [Function], - "queryByPlaceholderText": [Function], - "queryByRole": [Function], - "queryByTestId": [Function], - "queryByTestSubject": [Function], - "queryByText": [Function], - "queryByTitle": [Function], - "rerender": [Function], - "unmount": [Function], -} -`; - -exports[`EuiInlineEditTitle props sizes xxs is rendered in editMode 1`] = ` -Object { - "asFragment": [Function], - "baseElement": -
-
-
-
- -
-
+ Loaded
-
-
-
-
-
-
-
- Loaded -
- - -
-
+ aria-atomic="true" + aria-hidden="true" + aria-live="off" + role="status" + />
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
+
- , - "container":
+
+
+`; + +exports[`EuiInlineEditTitle props sizes xs is rendered in readMode 1`] = ` +
+ +
+`; + +exports[`EuiInlineEditTitle props sizes xxs is rendered in editMode 1`] = ` +
+
-
-
- -
-
+
+
+
+
+
-
-
- Loaded -
- - + Loaded
+ +
+
+
+
+
-
-
- Loaded -
- - + Loaded
+ +
-
, - "debug": [Function], - "findAllByAltText": [Function], - "findAllByDisplayValue": [Function], - "findAllByLabelText": [Function], - "findAllByPlaceholderText": [Function], - "findAllByRole": [Function], - "findAllByTestId": [Function], - "findAllByTestSubject": [Function], - "findAllByText": [Function], - "findAllByTitle": [Function], - "findByAltText": [Function], - "findByDisplayValue": [Function], - "findByLabelText": [Function], - "findByPlaceholderText": [Function], - "findByRole": [Function], - "findByTestId": [Function], - "findByTestSubject": [Function], - "findByText": [Function], - "findByTitle": [Function], - "getAllByAltText": [Function], - "getAllByDisplayValue": [Function], - "getAllByLabelText": [Function], - "getAllByPlaceholderText": [Function], - "getAllByRole": [Function], - "getAllByTestId": [Function], - "getAllByTestSubject": [Function], - "getAllByText": [Function], - "getAllByTitle": [Function], - "getByAltText": [Function], - "getByDisplayValue": [Function], - "getByLabelText": [Function], - "getByPlaceholderText": [Function], - "getByRole": [Function], - "getByTestId": [Function], - "getByTestSubject": [Function], - "getByText": [Function], - "getByTitle": [Function], - "queryAllByAltText": [Function], - "queryAllByDisplayValue": [Function], - "queryAllByLabelText": [Function], - "queryAllByPlaceholderText": [Function], - "queryAllByRole": [Function], - "queryAllByTestId": [Function], - "queryAllByTestSubject": [Function], - "queryAllByText": [Function], - "queryAllByTitle": [Function], - "queryByAltText": [Function], - "queryByDisplayValue": [Function], - "queryByLabelText": [Function], - "queryByPlaceholderText": [Function], - "queryByRole": [Function], - "queryByTestId": [Function], - "queryByTestSubject": [Function], - "queryByText": [Function], - "queryByTitle": [Function], - "rerender": [Function], - "unmount": [Function], -} +
+
`; exports[`EuiInlineEditTitle props sizes xxs is rendered in readMode 1`] = ` -Object { - "asFragment": [Function], - "baseElement": -
-
- -
-
- , - "container":
-
+ -
-
, - "debug": [Function], - "findAllByAltText": [Function], - "findAllByDisplayValue": [Function], - "findAllByLabelText": [Function], - "findAllByPlaceholderText": [Function], - "findAllByRole": [Function], - "findAllByTestId": [Function], - "findAllByTestSubject": [Function], - "findAllByText": [Function], - "findAllByTitle": [Function], - "findByAltText": [Function], - "findByDisplayValue": [Function], - "findByLabelText": [Function], - "findByPlaceholderText": [Function], - "findByRole": [Function], - "findByTestId": [Function], - "findByTestSubject": [Function], - "findByText": [Function], - "findByTitle": [Function], - "getAllByAltText": [Function], - "getAllByDisplayValue": [Function], - "getAllByLabelText": [Function], - "getAllByPlaceholderText": [Function], - "getAllByRole": [Function], - "getAllByTestId": [Function], - "getAllByTestSubject": [Function], - "getAllByText": [Function], - "getAllByTitle": [Function], - "getByAltText": [Function], - "getByDisplayValue": [Function], - "getByLabelText": [Function], - "getByPlaceholderText": [Function], - "getByRole": [Function], - "getByTestId": [Function], - "getByTestSubject": [Function], - "getByText": [Function], - "getByTitle": [Function], - "queryAllByAltText": [Function], - "queryAllByDisplayValue": [Function], - "queryAllByLabelText": [Function], - "queryAllByPlaceholderText": [Function], - "queryAllByRole": [Function], - "queryAllByTestId": [Function], - "queryAllByTestSubject": [Function], - "queryAllByText": [Function], - "queryAllByTitle": [Function], - "queryByAltText": [Function], - "queryByDisplayValue": [Function], - "queryByLabelText": [Function], - "queryByPlaceholderText": [Function], - "queryByRole": [Function], - "queryByTestId": [Function], - "queryByTestSubject": [Function], - "queryByText": [Function], - "queryByTitle": [Function], - "rerender": [Function], - "unmount": [Function], -} + Hello World! + + + + +
`; exports[`EuiInlineEditTitle props sizes xxxs is rendered in editMode 1`] = ` -Object { - "asFragment": [Function], - "baseElement": -
+
+
+
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
+
-
- , - "container":
-
-
- -
+ Loaded
-
-
-
-
-
-
-
-
- Loaded -
- - -
+ aria-atomic="true" + aria-hidden="true" + aria-live="off" + role="status" + />
+
+
+
+
+
-
-
- Loaded -
- - + Loaded
+ +
-
, - "debug": [Function], - "findAllByAltText": [Function], - "findAllByDisplayValue": [Function], - "findAllByLabelText": [Function], - "findAllByPlaceholderText": [Function], - "findAllByRole": [Function], - "findAllByTestId": [Function], - "findAllByTestSubject": [Function], - "findAllByText": [Function], - "findAllByTitle": [Function], - "findByAltText": [Function], - "findByDisplayValue": [Function], - "findByLabelText": [Function], - "findByPlaceholderText": [Function], - "findByRole": [Function], - "findByTestId": [Function], - "findByTestSubject": [Function], - "findByText": [Function], - "findByTitle": [Function], - "getAllByAltText": [Function], - "getAllByDisplayValue": [Function], - "getAllByLabelText": [Function], - "getAllByPlaceholderText": [Function], - "getAllByRole": [Function], - "getAllByTestId": [Function], - "getAllByTestSubject": [Function], - "getAllByText": [Function], - "getAllByTitle": [Function], - "getByAltText": [Function], - "getByDisplayValue": [Function], - "getByLabelText": [Function], - "getByPlaceholderText": [Function], - "getByRole": [Function], - "getByTestId": [Function], - "getByTestSubject": [Function], - "getByText": [Function], - "getByTitle": [Function], - "queryAllByAltText": [Function], - "queryAllByDisplayValue": [Function], - "queryAllByLabelText": [Function], - "queryAllByPlaceholderText": [Function], - "queryAllByRole": [Function], - "queryAllByTestId": [Function], - "queryAllByTestSubject": [Function], - "queryAllByText": [Function], - "queryAllByTitle": [Function], - "queryByAltText": [Function], - "queryByDisplayValue": [Function], - "queryByLabelText": [Function], - "queryByPlaceholderText": [Function], - "queryByRole": [Function], - "queryByTestId": [Function], - "queryByTestSubject": [Function], - "queryByText": [Function], - "queryByTitle": [Function], - "rerender": [Function], - "unmount": [Function], -} +
+
`; exports[`EuiInlineEditTitle props sizes xxxs is rendered in readMode 1`] = ` -Object { - "asFragment": [Function], - "baseElement": -
-
- -
-
- , - "container":
-
+ -
-
, - "debug": [Function], - "findAllByAltText": [Function], - "findAllByDisplayValue": [Function], - "findAllByLabelText": [Function], - "findAllByPlaceholderText": [Function], - "findAllByRole": [Function], - "findAllByTestId": [Function], - "findAllByTestSubject": [Function], - "findAllByText": [Function], - "findAllByTitle": [Function], - "findByAltText": [Function], - "findByDisplayValue": [Function], - "findByLabelText": [Function], - "findByPlaceholderText": [Function], - "findByRole": [Function], - "findByTestId": [Function], - "findByTestSubject": [Function], - "findByText": [Function], - "findByTitle": [Function], - "getAllByAltText": [Function], - "getAllByDisplayValue": [Function], - "getAllByLabelText": [Function], - "getAllByPlaceholderText": [Function], - "getAllByRole": [Function], - "getAllByTestId": [Function], - "getAllByTestSubject": [Function], - "getAllByText": [Function], - "getAllByTitle": [Function], - "getByAltText": [Function], - "getByDisplayValue": [Function], - "getByLabelText": [Function], - "getByPlaceholderText": [Function], - "getByRole": [Function], - "getByTestId": [Function], - "getByTestSubject": [Function], - "getByText": [Function], - "getByTitle": [Function], - "queryAllByAltText": [Function], - "queryAllByDisplayValue": [Function], - "queryAllByLabelText": [Function], - "queryAllByPlaceholderText": [Function], - "queryAllByRole": [Function], - "queryAllByTestId": [Function], - "queryAllByTestSubject": [Function], - "queryAllByText": [Function], - "queryAllByTitle": [Function], - "queryByAltText": [Function], - "queryByDisplayValue": [Function], - "queryByLabelText": [Function], - "queryByPlaceholderText": [Function], - "queryByRole": [Function], - "queryByTestId": [Function], - "queryByTestSubject": [Function], - "queryByText": [Function], - "queryByTitle": [Function], - "rerender": [Function], - "unmount": [Function], -} + Hello World! + + + + +
`; exports[`EuiInlineEditTitle renders as title in editMode 1`] = ` diff --git a/src/components/inline_edit/inline_edit_text.test.tsx b/src/components/inline_edit/inline_edit_text.test.tsx index 5c470b98f52..1e7c322c5bd 100644 --- a/src/components/inline_edit/inline_edit_text.test.tsx +++ b/src/components/inline_edit/inline_edit_text.test.tsx @@ -46,7 +46,7 @@ describe('EuiInlineEditTitle', () => { usedTextSizes.forEach((size: string) => { test(`${size} is rendered in readMode`, () => { - const component = render( + const { container } = render( { /> ); - expect(component).toMatchSnapshot(); + expect(container.firstChild).toMatchSnapshot(); }); }); usedTextSizes.forEach((size: string) => { test(`${size} is rendered in editMode`, () => { - const component = render( + const { container } = render( { /> ); - expect(component).toMatchSnapshot(); + expect(container.firstChild).toMatchSnapshot(); }); }); }); diff --git a/src/components/inline_edit/inline_edit_title.test.tsx b/src/components/inline_edit/inline_edit_title.test.tsx index 0d085e3bcc5..c430fd86576 100644 --- a/src/components/inline_edit/inline_edit_title.test.tsx +++ b/src/components/inline_edit/inline_edit_title.test.tsx @@ -45,7 +45,7 @@ describe('EuiInlineEditTitle', () => { describe('sizes', () => { TITLE_SIZES.forEach((size) => { test(`${size} is rendered in readMode`, () => { - const component = render( + const { container } = render( { /> ); - expect(component).toMatchSnapshot(); + expect(container.firstChild).toMatchSnapshot(); }); }); TITLE_SIZES.forEach((size) => { test(`${size} is rendered in editMode`, () => { - const component = render( + const { container } = render( { /> ); - expect(component).toMatchSnapshot(); + expect(container.firstChild).toMatchSnapshot(); }); }); }); From c405805e3a13fef7a162ba719fb5980ae2cc722e Mon Sep 17 00:00:00 2001 From: Bree Hall Date: Wed, 19 Apr 2023 16:07:54 -0400 Subject: [PATCH 04/16] [InlineEditForm] - Add data-test-subj to EuiInlineEditForm buttons and inputs - Removed opinionated save logic that prevented users from being able to save empty strings in editMode --- .../inline_edit/inline_edit_form.tsx | 115 ++++++++++-------- 1 file changed, 62 insertions(+), 53 deletions(-) diff --git a/src/components/inline_edit/inline_edit_form.tsx b/src/components/inline_edit/inline_edit_form.tsx index f256b1dfa7e..e9600bcd291 100644 --- a/src/components/inline_edit/inline_edit_form.tsx +++ b/src/components/inline_edit/inline_edit_form.tsx @@ -6,7 +6,12 @@ * Side Public License, v 1. */ -import React, { ReactNode, FunctionComponent, useState } from 'react'; +import React, { + ReactNode, + FunctionComponent, + useState, + HTMLAttributes, +} from 'react'; import classNames from 'classnames'; import { CommonProps } from '../common'; @@ -27,53 +32,54 @@ import { useEuiI18n } from '../i18n'; import { useGeneratedHtmlId } from '../../services/accessibility'; // Props shared between the internal form component as well as consumer-facing components -export type EuiInlineEditCommonProps = CommonProps & { - defaultValue: string; - /** - * Allow users to pass in a function that is called when the confirm button is clicked - * The function should return a boolean flag that will determine if the value will be saved. - * When the flag is true, the value will be saved. When the flag is false, the user will be - * returned to editMode. - */ - onConfirm?: () => boolean; - /** - * Form label that appears above the form control - * This is required for accessibility because there is no visual label on the input - */ - inputAriaLabel: string; - /** - * Aria-label for save button in editMode - */ - saveButtonAriaLabel?: string; - /** - * Aria-label for cancel button in editMode - */ - cancelButtonAriaLabel?: string; - /** - * Start in editMode - */ - startWithEditOpen?: boolean; - /** - * Props that will be applied directly to the EuiEmptyButton displayed in readMode - */ - readModeProps?: Omit; - /** - * Props that will be applied directly to the `EuiFormRow` and `EuiFieldText` input displayed in editMode - */ - editModeProps?: { - formRowProps?: Partial; - inputProps?: Partial; - }; - /** - * Loading state when changes are saved in editMode - */ - isLoading?: boolean; +export type EuiInlineEditCommonProps = HTMLAttributes & + CommonProps & { + defaultValue: string; + /** + * Allow users to pass in a function that is called when the confirm button is clicked + * The function should return a boolean flag that will determine if the value will be saved. + * When the flag is true, the value will be saved. When the flag is false, the user will be + * returned to editMode. + */ + onConfirm?: (editModeValue: string) => boolean; + /** + * Form label that appears above the form control + * This is required for accessibility because there is no visual label on the input + */ + inputAriaLabel: string; + /** + * Aria-label for save button in editMode + */ + saveButtonAriaLabel?: string; + /** + * Aria-label for cancel button in editMode + */ + cancelButtonAriaLabel?: string; + /** + * Start in editMode + */ + startWithEditOpen?: boolean; + /** + * Props that will be applied directly to the EuiEmptyButton displayed in readMode + */ + readModeProps?: Omit; + /** + * Props that will be applied directly to the `EuiFormRow` and `EuiFieldText` input displayed in editMode + */ + editModeProps?: { + formRowProps?: Partial; + inputProps?: Partial; + }; + /** + * Loading state when changes are saved in editMode + */ + isLoading?: boolean; - /** - * Validation for the form control used to edit text in editMode - */ - isInvalid?: boolean; -}; + /** + * Validation for the form control used to edit text in editMode + */ + isInvalid?: boolean; + }; // Internal-only props, passed by the consumer-facing components export type EuiInlineEditFormProps = EuiInlineEditCommonProps & { @@ -147,15 +153,12 @@ export const EuiInlineEditForm: FunctionComponent = ({ }; const saveInlineEditValue = () => { - if (editModeValue && onConfirm && !onConfirm()) { - // If there is text, an onConfirm method is present, and it has returned false, cancel the action + if (onConfirm && !onConfirm(editModeValue)) { + // If an onConfirm method is present, and it has returned false, cancel the action return; - } else if (editModeValue) { + } else { setReadModeValue(editModeValue); setIsEditing(!isEditing); - } else { - // If there's no text, cancel the action, reset the input text, and return to readMode - cancelInlineEdit(); } }; @@ -179,6 +182,7 @@ export const EuiInlineEditForm: FunctionComponent = ({ compressed={sizes.compressed} isInvalid={isInvalid} isLoading={isLoading} + data-test-subj="euiInlineEditModeInput" {...editModeProps?.inputProps} /> @@ -191,6 +195,7 @@ export const EuiInlineEditForm: FunctionComponent = ({ height={loadingSkeletonSize} width={loadingSkeletonSize} borderRadius="m" + data-test-subj="euiInlineEditModeSaveLoading" > = ({ size={sizes.buttonSize} iconSize={sizes.iconSize} disabled={isInvalid} + data-test-subj="euiInlineEditModeSaveButton" /> @@ -213,6 +219,7 @@ export const EuiInlineEditForm: FunctionComponent = ({ height={loadingSkeletonSize} width={loadingSkeletonSize} borderRadius="m" + data-test-subj="euiInlineEditModeCancelLoading" > = ({ display="base" size={sizes.buttonSize} iconSize={sizes.iconSize} + data-test-subj="euiInlineEditModeCancelButton" /> @@ -244,6 +252,7 @@ export const EuiInlineEditForm: FunctionComponent = ({ onClick={() => { setIsEditing(!isEditing); }} + data-test-subj="euiInlineReadModeButton" {...readModeProps} > {children(readModeValue)} From 9208180640be60e5dec9882c6b70e240a8958263 Mon Sep 17 00:00:00 2001 From: Bree Hall Date: Wed, 19 Apr 2023 16:11:27 -0400 Subject: [PATCH 05/16] Created test cases for EuiInlineEditForm. These test cases handle the functional and prop testing for both the Text and Title variations of the component --- .../inline_edit_form.test.tsx.snap | 904 ++++++++++++++++++ .../inline_edit/inline_edit_form.test.tsx | 284 ++++++ 2 files changed, 1188 insertions(+) create mode 100644 src/components/inline_edit/__snapshots__/inline_edit_form.test.tsx.snap create mode 100644 src/components/inline_edit/inline_edit_form.test.tsx diff --git a/src/components/inline_edit/__snapshots__/inline_edit_form.test.tsx.snap b/src/components/inline_edit/__snapshots__/inline_edit_form.test.tsx.snap new file mode 100644 index 00000000000..6edc4f713cc --- /dev/null +++ b/src/components/inline_edit/__snapshots__/inline_edit_form.test.tsx.snap @@ -0,0 +1,904 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`EuiInlineEditForm Edit Mode disables the save button when input is invalid 1`] = ` +
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+`; + +exports[`EuiInlineEditForm Edit Mode renders 1`] = ` +
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+`; + +exports[`EuiInlineEditForm Edit Mode renders EuiSkeletonRectangles in place of editMode buttons when loading 1`] = ` +
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`; + +exports[`EuiInlineEditForm Edit Mode renders editModeProps.formRowProps 1`] = ` +
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+`; + +exports[`EuiInlineEditForm Edit Mode renders editModeProps.inputProps 1`] = ` +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+`; + +exports[`EuiInlineEditForm Edit Mode renders save button and cancel button aria-labels 1`] = ` +
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+
+
+
+ Loaded +
+ + +
+
+
+
+
+
+
+`; + +exports[`EuiInlineEditForm Read Mode renders 1`] = ` +
+ +
+`; + +exports[`EuiInlineEditForm Read Mode renders readModeProps onto the button 1`] = ` +
+ +
+`; + +exports[`EuiInlineEditForm Read Mode renders small size 1`] = ` +
+ +
+`; diff --git a/src/components/inline_edit/inline_edit_form.test.tsx b/src/components/inline_edit/inline_edit_form.test.tsx new file mode 100644 index 00000000000..ec2f9ac4a4e --- /dev/null +++ b/src/components/inline_edit/inline_edit_form.test.tsx @@ -0,0 +1,284 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import React from 'react'; +import { render } from '../../test/rtl'; +import { requiredProps } from '../../test/required_props'; +import { fireEvent } from '@testing-library/dom'; + +import { + EuiInlineEditForm, + EuiInlineEditFormProps, + SMALL_SIZE_FORM, + MEDIUM_SIZE_FORM, +} from './inline_edit_form'; + +describe('EuiInlineEditForm', () => { + const commonInlineEditFormProps: EuiInlineEditFormProps = { + ...requiredProps, + defaultValue: 'Hello World!', + inputAriaLabel: 'Edit inline', + sizes: MEDIUM_SIZE_FORM, + isLoading: false, // TODO: Remove once EUI loading components are fixed + children: (readModeValue) => readModeValue, + }; + + describe('Read Mode', () => { + it('renders', () => { + const { container } = render( + + ); + + expect(container.firstChild).toMatchSnapshot(); + }); + + it('renders readModeProps onto the button', () => { + const { container, getByTestSubject } = render( + + ); + + expect(container.firstChild).toMatchSnapshot(); + expect(getByTestSubject('euiInlineReadModeButton')).toBeTruthy(); + }); + + it('renders small size', () => { + const { container } = render( + + ); + + expect(container.firstChild).toMatchSnapshot(); + }); + }); + + describe('Edit Mode', () => { + it('renders', () => { + const { container } = render( + + ); + + expect(container.firstChild).toMatchSnapshot(); + }); + + it('renders editModeProps.inputProps', () => { + const { container, getByTestSubject } = render( + + ); + + expect(container.firstChild).toMatchSnapshot(); + expect(getByTestSubject('customInput')).toBeTruthy(); + }); + + it('renders editModeProps.formRowProps', () => { + const { container, getByTestSubject } = render( + + ); + + expect(container.firstChild).toMatchSnapshot(); + expect(getByTestSubject('customErrorText')).toBeTruthy(); + }); + + it('renders save button and cancel button aria-labels', () => { + const { container, getByLabelText } = render( + + ); + + expect(container.firstChild).toMatchSnapshot(); + expect(getByLabelText("Yes! Let's save.")).toBeTruthy(); + expect(getByLabelText('Uh no. Do not save.')).toBeTruthy(); + }); + + it('renders EuiSkeletonRectangles in place of editMode buttons when loading', () => { + const { container, getByTestSubject, queryByTestSubject } = render( + + ); + + expect(container.firstChild).toMatchSnapshot(); + + expect(getByTestSubject('euiInlineEditModeSaveLoading')).toBeTruthy(); + expect(getByTestSubject('euiInlineEditModeCancelLoading')).toBeTruthy(); + + expect(queryByTestSubject('euiInlineEditModeSaveButton')).toBeFalsy(); + expect(queryByTestSubject('euiInlineEditModeCancelButton')).toBeFalsy(); + }); + + it('disables the save button when input is invalid ', () => { + const { container, getByTestSubject } = render( + + ); + + expect(container.firstChild).toMatchSnapshot(); + + expect( + getByTestSubject('euiInlineEditModeInput').hasAttribute('aria-invalid') + ).toBeTruthy(); + + expect(getByTestSubject('euiInlineEditModeSaveButton')).toBeDisabled(); + expect(getByTestSubject('euiInlineEditModeCancelButton')).toBeTruthy(); + }); + }); + + describe('Toggling between readMode and editMode', () => { + it('clicking on the readModeButton takes us to editMode', () => { + const { getByTestSubject, queryByTestSubject } = render( + + ); + + fireEvent.click(getByTestSubject('euiInlineReadModeButton')); + expect(getByTestSubject('euiInlineEditModeInput')).toBeTruthy(); + expect(queryByTestSubject('euiInlineReadModeButton')).toBeFalsy(); + }); + + it('saves text and returns to readMode', () => { + const { getByTestSubject, getByText } = render( + + ); + + fireEvent.change(getByTestSubject('euiInlineEditModeInput'), { + target: { value: 'New message!' }, + }); + expect( + getByTestSubject('euiInlineEditModeInput').getAttribute('value') + ).toEqual('New message!'); + fireEvent.click(getByTestSubject('euiInlineEditModeSaveButton')); + + expect(getByTestSubject('euiInlineReadModeButton')).toBeTruthy(); + expect(getByText('New message!')).toBeTruthy(); + }); + + it('cancels text and returns to readMode', () => { + const { getByTestSubject, getByText } = render( + + ); + + fireEvent.change(getByTestSubject('euiInlineEditModeInput'), { + target: { value: 'New message!' }, + }); + expect( + getByTestSubject('euiInlineEditModeInput').getAttribute('value') + ).toEqual('New message!'); + fireEvent.click(getByTestSubject('euiInlineEditModeCancelButton')); + + expect(getByTestSubject('euiInlineReadModeButton')).toBeTruthy(); + expect(getByText('Hello World!')).toBeTruthy(); + }); + + describe('onConfirm behavior on save', () => { + it('returns to readMode with updated text when onConfirm returns true', () => { + const { getByTestSubject, getByText } = render( + true} + /> + ); + + fireEvent.change(getByTestSubject('euiInlineEditModeInput'), { + target: { value: 'New message!' }, + }); + fireEvent.click(getByTestSubject('euiInlineEditModeSaveButton')); + + expect(getByTestSubject('euiInlineReadModeButton')).toBeTruthy(); + expect(getByText('New message!')).toBeTruthy(); + }); + + it('stays in editMode when onConfirm returns false', () => { + const { getByTestSubject, queryByTestSubject } = render( + false} + /> + ); + + fireEvent.change(getByTestSubject('euiInlineEditModeInput'), { + target: { value: 'New message!' }, + }); + fireEvent.click(getByTestSubject('euiInlineEditModeSaveButton')); + + expect(queryByTestSubject('euiInlineReadModeButton')).toBeFalsy(); + expect(getByTestSubject('euiInlineEditModeInput')).toBeTruthy(); + }); + + it('sends the editMode text to the onConfirm callback', () => { + const { getByText, getByTestSubject } = render( + { + return editModeValue === '' ? false : true; + }} + /> + ); + + fireEvent.change(getByTestSubject('euiInlineEditModeInput'), { + target: { value: '' }, + }); + fireEvent.click(getByTestSubject('euiInlineEditModeSaveButton')); + + expect(getByTestSubject('euiInlineEditModeInput')).toBeTruthy(); + + fireEvent.change(getByTestSubject('euiInlineEditModeInput'), { + target: { value: 'hey there' }, + }); + fireEvent.click(getByTestSubject('euiInlineEditModeSaveButton')); + + expect(getByTestSubject('euiInlineReadModeButton')).toBeTruthy(); + expect(getByText('hey there')).toBeTruthy(); + }); + }); + }); +}); From 34a11efe224787dfbd2b8b830bd82a96d8124996 Mon Sep 17 00:00:00 2001 From: Bree Hall Date: Wed, 19 Apr 2023 16:12:12 -0400 Subject: [PATCH 06/16] Updated InlineEdit Text and Title test suites to only include basic render tests and snapshots of their sizing in both readMode and editMode --- .../inline_edit_text.test.tsx.snap | 68 ++++--- .../inline_edit_title.test.tsx.snap | 190 ++++++++++-------- .../inline_edit/inline_edit_text.test.tsx | 87 ++++---- .../inline_edit/inline_edit_title.test.tsx | 88 ++++---- 4 files changed, 234 insertions(+), 199 deletions(-) diff --git a/src/components/inline_edit/__snapshots__/inline_edit_text.test.tsx.snap b/src/components/inline_edit/__snapshots__/inline_edit_text.test.tsx.snap index fd2d719e01e..cb2f72a223f 100644 --- a/src/components/inline_edit/__snapshots__/inline_edit_text.test.tsx.snap +++ b/src/components/inline_edit/__snapshots__/inline_edit_text.test.tsx.snap @@ -1,8 +1,8 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`EuiInlineEditTitle props sizes m is rendered in editMode 1`] = ` +exports[`EuiInlineEditText Text Sizes renders in m in editMode 1`] = `
@@ -577,6 +590,7 @@ exports[`EuiInlineEditTitle renders as title in editMode 1`] = `
diff --git a/src/components/inline_edit/__snapshots__/inline_edit_title.test.tsx.snap b/src/components/inline_edit/__snapshots__/inline_edit_title.test.tsx.snap index 70638bba9bb..e59e816407e 100644 --- a/src/components/inline_edit/__snapshots__/inline_edit_title.test.tsx.snap +++ b/src/components/inline_edit/__snapshots__/inline_edit_title.test.tsx.snap @@ -1,8 +1,39 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`EuiInlineEditTitle props sizes l is rendered in editMode 1`] = ` +exports[`EuiInlineEditTitle Title Sizes renders in size l in readMode 1`] = `
+ +
+`; + +exports[`EuiInlineEditTitle Title Sizes renders in size l in readMode 2`] = ` +
`; -exports[`EuiInlineEditTitle props sizes m is rendered in editMode 1`] = ` +exports[`EuiInlineEditTitle Title Sizes renders in size m in readMode 2`] = `
`; -exports[`EuiInlineEditTitle props sizes s is rendered in editMode 1`] = ` +exports[`EuiInlineEditTitle Title Sizes renders in size s in readMode 2`] = `
`; -exports[`EuiInlineEditTitle props sizes xs is rendered in editMode 1`] = ` +exports[`EuiInlineEditTitle Title Sizes renders in size xs in readMode 2`] = `
`; -exports[`EuiInlineEditTitle props sizes xxs is rendered in editMode 1`] = ` +exports[`EuiInlineEditTitle Title Sizes renders in size xxs in readMode 2`] = `
`; -exports[`EuiInlineEditTitle props sizes xxxs is rendered in editMode 1`] = ` +exports[`EuiInlineEditTitle Title Sizes renders in size xxxs in readMode 2`] = `
-
-`; - -exports[`EuiInlineEditTitle renders as title in editMode 1`] = ` +exports[`EuiInlineEditTitle renders in editMode 1`] = `
@@ -1036,11 +1060,12 @@ exports[`EuiInlineEditTitle renders as title in editMode 1`] = ` >
@@ -1081,6 +1106,7 @@ exports[`EuiInlineEditTitle renders as title in editMode 1`] = ` -
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-`; - -exports[`EuiInlineEditText Text Sizes renders in m in readMode 1`] = ` +exports[`EuiInlineEditText renders 1`] = `
@@ -172,153 +31,12 @@ exports[`EuiInlineEditText Text Sizes renders in m in readMode 1`] = `
`; -exports[`EuiInlineEditText Text Sizes renders in s in editMode 1`] = ` -
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-`; - -exports[`EuiInlineEditText Text Sizes renders in s in readMode 1`] = ` +exports[`EuiInlineEditText text sizes renders m 1`] = `
`; -exports[`EuiInlineEditText Text Sizes renders in xs in editMode 1`] = ` -
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-`; - -exports[`EuiInlineEditText Text Sizes renders in xs in readMode 1`] = ` +exports[`EuiInlineEditText text sizes renders s 1`] = `
`; -exports[`EuiInlineEditText renders in editMode 1`] = ` -
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-`; - -exports[`EuiInlineEditText renders in readMode 1`] = ` +exports[`EuiInlineEditText text sizes renders xs 1`] = `
`; -exports[`EuiInlineEditTitle Title Sizes renders in size l in readMode 2`] = ` +exports[`EuiInlineEditTitle title sizes renders size l 1`] = `
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-`; - -exports[`EuiInlineEditTitle Title Sizes renders in size m in readMode 1`] = ` -
`; -exports[`EuiInlineEditTitle Title Sizes renders in size m in readMode 2`] = ` +exports[`EuiInlineEditTitle title sizes renders size m 1`] = `
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-`; - -exports[`EuiInlineEditTitle Title Sizes renders in size s in readMode 1`] = ` -
`; -exports[`EuiInlineEditTitle Title Sizes renders in size s in readMode 2`] = ` +exports[`EuiInlineEditTitle title sizes renders size s 1`] = `
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-`; - -exports[`EuiInlineEditTitle Title Sizes renders in size xs in readMode 1`] = ` -
`; -exports[`EuiInlineEditTitle Title Sizes renders in size xs in readMode 2`] = ` +exports[`EuiInlineEditTitle title sizes renders size xs 1`] = `
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-`; - -exports[`EuiInlineEditTitle Title Sizes renders in size xxs in readMode 1`] = ` -
`; -exports[`EuiInlineEditTitle Title Sizes renders in size xxs in readMode 2`] = ` +exports[`EuiInlineEditTitle title sizes renders size xxs 1`] = `
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-`; - -exports[`EuiInlineEditTitle Title Sizes renders in size xxxs in readMode 1`] = ` -
`; -exports[`EuiInlineEditTitle Title Sizes renders in size xxxs in readMode 2`] = ` +exports[`EuiInlineEditTitle title sizes renders size xxxs 1`] = `
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-`; - -exports[`EuiInlineEditTitle renders in editMode 1`] = ` -
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-
-
-
- Loaded -
- - -
-
-
-
-
-
-
-`; - -exports[`EuiInlineEditTitle renders in readMode 1`] = ` -