Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coverage search for user #1863

Merged
merged 4 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be ideal not to directly import anything from superdesk-core, instead we can import components from the SuperdeskAPI (see: https://github.com/superdesk/superdesk-client-core/blob/develop/scripts/core/superdesk-api.d.ts#L1810).


const appConfig = config.appConfig as IPlanningConfig;

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
Loading