From 8ee3571ce6502cf0ea426f9fe0263c6ffca7384f Mon Sep 17 00:00:00 2001 From: dzonidoo Date: Thu, 12 Oct 2023 10:47:38 +0200 Subject: [PATCH 1/3] coverage search for user --- .../EmbeddedCoverageForm.tsx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/client/components/fields/editor/EventRelatedPlannings/EmbeddedCoverageForm.tsx b/client/components/fields/editor/EventRelatedPlannings/EmbeddedCoverageForm.tsx index a394bce86..bbc0910f0 100644 --- a/client/components/fields/editor/EventRelatedPlannings/EmbeddedCoverageForm.tsx +++ b/client/components/fields/editor/EventRelatedPlannings/EmbeddedCoverageForm.tsx @@ -18,6 +18,7 @@ import {Row, SelectUserInput} from '../../../UI/Form'; import {EditorFieldNewsCoverageStatus} from '../NewsCoverageStatus'; import * as config from 'appConfig'; import {getLanguagesForTreeSelectInput} from '../../../../selectors/vocabs'; +import {SelectUser} from 'superdesk-core/scripts/core/ui/components/SelectUser'; const appConfig = config.appConfig as IPlanningConfig; @@ -172,13 +173,16 @@ export class EmbeddedCoverageFormComponent extends React.PureComponent { testId="user" noPadding={true} > - + + { + this.onUserChange(null, user); + }} + autoFocus={false} + horizontalSpacing={true} + clearable={true} + /> + From 0330d5b63b5429537b0fabc16ed3865de2c7bfe8 Mon Sep 17 00:00:00 2001 From: Petr Jasek Date: Tue, 24 Oct 2023 15:27:04 +0200 Subject: [PATCH 2/3] fix failing e2e test --- .../common/inputs/coverageUserSelectInput.ts | 30 +++++++++++++++++++ e2e/cypress/support/common/inputs/index.ts | 1 + .../planning/events/embeddedCoverageEditor.ts | 6 ++-- 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 e2e/cypress/support/common/inputs/coverageUserSelectInput.ts diff --git a/e2e/cypress/support/common/inputs/coverageUserSelectInput.ts b/e2e/cypress/support/common/inputs/coverageUserSelectInput.ts new file mode 100644 index 000000000..457339b68 --- /dev/null +++ b/e2e/cypress/support/common/inputs/coverageUserSelectInput.ts @@ -0,0 +1,30 @@ +import {Input} from './input'; +import {Popup} from '../ui'; + +/** + * Wrapper class for a searchable user select input field + * @extends Input + */ +export class CoverageUserSelectInput extends Input { + type(value) { + cy.log('Common.SearchableSelectInput.type'); + const popup = new Popup('.p-dropdown-panel'); + + this.element.click(); + popup.waitTillOpen(); + + popup.element.find('input') + .type(value); + + popup.element.find('li') + .first() + .click(); + + popup.waitTillClosed(); + } + + expect(value) { + cy.log('Common.SearchableSelectInput.expect'); + this.element.should('contain.text', value); + } +} diff --git a/e2e/cypress/support/common/inputs/index.ts b/e2e/cypress/support/common/inputs/index.ts index 24a542a53..28705f1ee 100644 --- a/e2e/cypress/support/common/inputs/index.ts +++ b/e2e/cypress/support/common/inputs/index.ts @@ -9,3 +9,4 @@ export {SpikeStateInput} from './spikeStateInput'; export {LocationInput} from './locationInput'; export {NewCheckboxInput} from './newCheckbox'; export {TreeSelect} from './treeSelect'; +export {CoverageUserSelectInput} from './coverageUserSelectInput'; diff --git a/e2e/cypress/support/planning/events/embeddedCoverageEditor.ts b/e2e/cypress/support/planning/events/embeddedCoverageEditor.ts index 732289f9c..cbc3ff221 100644 --- a/e2e/cypress/support/planning/events/embeddedCoverageEditor.ts +++ b/e2e/cypress/support/planning/events/embeddedCoverageEditor.ts @@ -1,5 +1,5 @@ import {EventEditor} from './eventEditor'; -import {SelectInput, NewCheckboxInput, UserSelectInput} from '../../common'; +import {SelectInput, NewCheckboxInput, CoverageUserSelectInput} from '../../common'; export class EmbeddedCoverageEditor { editor: EventEditor; @@ -36,7 +36,7 @@ export class EmbeddedCoverage { editor: EmbeddedCoverageEditor; planningIndex: number; coverageIndex: number; - fields: {[key: string]: SelectInput | NewCheckboxInput | UserSelectInput}; + fields: {[key: string]: SelectInput | NewCheckboxInput | CoverageUserSelectInput}; constructor(editor: EmbeddedCoverageEditor, planningIndex: number, coverageIndex: number) { this.editor = editor; @@ -48,7 +48,7 @@ export class EmbeddedCoverage { this.fields = { enabled: new NewCheckboxInput(getParent, '[data-test-id="enabled"]'), desk: new SelectInput(getParent, '[data-test-id="desk"] select'), - user: new UserSelectInput(getParent, '[data-test-id="user"]'), + user: new CoverageUserSelectInput(getParent, '[data-test-id="user"]'), status: new SelectInput(getParent, '[data-test-id="status"] select'), }; } From f2be00404b0ed87e78bd3088ca6bf063e0be2e1a Mon Sep 17 00:00:00 2001 From: dzonidoo Date: Wed, 25 Oct 2023 09:39:11 +0200 Subject: [PATCH 3/3] change import --- .../editor/EventRelatedPlannings/EmbeddedCoverageForm.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/components/fields/editor/EventRelatedPlannings/EmbeddedCoverageForm.tsx b/client/components/fields/editor/EventRelatedPlannings/EmbeddedCoverageForm.tsx index bbc0910f0..752b3ae61 100644 --- a/client/components/fields/editor/EventRelatedPlannings/EmbeddedCoverageForm.tsx +++ b/client/components/fields/editor/EventRelatedPlannings/EmbeddedCoverageForm.tsx @@ -18,7 +18,6 @@ import {Row, SelectUserInput} from '../../../UI/Form'; import {EditorFieldNewsCoverageStatus} from '../NewsCoverageStatus'; import * as config from 'appConfig'; import {getLanguagesForTreeSelectInput} from '../../../../selectors/vocabs'; -import {SelectUser} from 'superdesk-core/scripts/core/ui/components/SelectUser'; const appConfig = config.appConfig as IPlanningConfig; @@ -127,6 +126,7 @@ export class EmbeddedCoverageFormComponent extends React.PureComponent { render() { const {gettext} = superdeskApi.localization; const {coverage} = this.props; + const {SelectUser} = superdeskApi.components; const {allLanguages, language} = getLanguagesForCoverage( this.props.profile,