Skip to content

Commit

Permalink
coverage search for user (#1863)
Browse files Browse the repository at this point in the history
  • Loading branch information
dzonidoo authored Oct 25, 2023
1 parent 9a422ae commit 1efa363
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export class EmbeddedCoverageFormComponent extends React.PureComponent<IProps> {
render() {
const {gettext} = superdeskApi.localization;
const {coverage} = this.props;
const {SelectUser} = superdeskApi.components;

const {allLanguages, language} = getLanguagesForCoverage(
this.props.profile,
Expand Down Expand Up @@ -172,13 +173,16 @@ export class EmbeddedCoverageFormComponent extends React.PureComponent<IProps> {
testId="user"
noPadding={true}
>
<SelectUserInput
field="user"
placeholder={gettext('Search users')}
value={coverage.user}
onChange={this.onUserChange}
users={coverage.filteredUsers}
/>
<Row style={{padding: '2rem 0'}}>
<SelectUser
onSelect={(user) => {
this.onUserChange(null, user);
}}
autoFocus={false}
horizontalSpacing={true}
clearable={true}
/>
</Row>
</Row>
</List.Row>
<List.Row>
Expand Down
30 changes: 30 additions & 0 deletions e2e/cypress/support/common/inputs/coverageUserSelectInput.ts
Original file line number Diff line number Diff line change
@@ -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);
}
}
1 change: 1 addition & 0 deletions e2e/cypress/support/common/inputs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export {SpikeStateInput} from './spikeStateInput';
export {LocationInput} from './locationInput';
export {NewCheckboxInput} from './newCheckbox';
export {TreeSelect} from './treeSelect';
export {CoverageUserSelectInput} from './coverageUserSelectInput';
6 changes: 3 additions & 3 deletions e2e/cypress/support/planning/events/embeddedCoverageEditor.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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'),
};
}
Expand Down

0 comments on commit 1efa363

Please sign in to comment.