提交 4c10fc90 编写于 作者: B Boris Sekachev

Fixed test, improved code

上级 c2479dff
......@@ -61,18 +61,29 @@ export default function UserSelector(props: Props): JSX.Element {
setUsers(initialUsers);
}, [initialUsers]);
const handleSearch = (searchValue: string): void => {
if (searchValue) {
searchUsers(searchValue, setUsers);
useEffect(() => {
if (searchPhrase) {
searchUsers(searchPhrase, setUsers);
} else {
setUsers(initialUsers);
}
}, [searchPhrase]);
const handleSearch = (searchValue: string): void => {
setSearchPhrase(searchValue);
};
const onBlur = (): void => {
if (!searchPhrase && value) {
onSelect(null);
} else if (searchPhrase) {
const potentialUsers = users.filter((_user) => _user.username.includes(searchPhrase));
if (potentialUsers.length === 1) {
setSearchPhrase(potentialUsers[0].username);
onSelect(potentialUsers[0]);
} else {
setSearchPhrase(value?.username || '');
}
}
};
......
......@@ -37,10 +37,10 @@ context('Value must be a user instance.', () => {
// Before fix:
// The following error originated from your application code, not from Cypress.
// > Value must be a user instance
cy.get('.cvat-spinner').should('exist');
cy.get('.cvat-spinner', { timeout: 500 }).should('not.exist');
// Remove the user's assignment for next tests.
cy.get('.cvat-task-details-user-block').within(() => {
cy.get('[type="text"]').click().clear().type('{Enter}');
cy.get('[type="search"]').click().clear().type('{Enter}');
});
});
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册