reduce minimum search term length to 2 chars
closes FOO-397 flag = none test plan: - go to `/courses/:id/users` - type two characters into the search box and wait a moment - your search should go through - do the same at `/accounts/:id/users` Change-Id: Ia9951ef6e9c8e642a41afb6e557397a909d0b4d2 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/244941 Reviewed-by: Cody Cutrer <cody@instructure.com> Reviewed-by: Charley Kline <ckline@instructure.com> QA-Review: Charley Kline <ckline@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Product-Review: Jonathan Fenton <jfenton@instructure.com>
This commit is contained in:
parent
3a6857318c
commit
ec8f425a5d
|
@ -30,7 +30,7 @@ import SearchMessage from './SearchMessage'
|
||||||
import SRSearchMessage from './SRSearchMessage'
|
import SRSearchMessage from './SRSearchMessage'
|
||||||
import {SEARCH_DEBOUNCE_TIME} from './UsersPane'
|
import {SEARCH_DEBOUNCE_TIME} from './UsersPane'
|
||||||
|
|
||||||
const MIN_SEARCH_LENGTH = 3
|
const MIN_SEARCH_LENGTH = 2
|
||||||
const stores = [CoursesStore, TermsStore, AccountsTreeStore]
|
const stores = [CoursesStore, TermsStore, AccountsTreeStore]
|
||||||
|
|
||||||
const defaultFilters = {
|
const defaultFilters = {
|
||||||
|
|
|
@ -27,7 +27,7 @@ import SearchMessage from './SearchMessage'
|
||||||
import SRSearchMessage from './SRSearchMessage'
|
import SRSearchMessage from './SRSearchMessage'
|
||||||
import UserActions from '../actions/UserActions'
|
import UserActions from '../actions/UserActions'
|
||||||
|
|
||||||
const MIN_SEARCH_LENGTH = 3
|
const MIN_SEARCH_LENGTH = 2
|
||||||
export const SEARCH_DEBOUNCE_TIME = 750
|
export const SEARCH_DEBOUNCE_TIME = 750
|
||||||
|
|
||||||
export default class UsersPane extends React.Component {
|
export default class UsersPane extends React.Component {
|
||||||
|
|
|
@ -57,7 +57,7 @@ const rolesCollection = new RolesCollection(
|
||||||
Array.from(ENV.ALL_ROLES).map(attributes => new Role(attributes))
|
Array.from(ENV.ALL_ROLES).map(attributes => new Role(attributes))
|
||||||
)
|
)
|
||||||
const course = new Model(ENV.course)
|
const course = new Model(ENV.course)
|
||||||
const inputFilterView = new InputFilterView({collection: users})
|
const inputFilterView = new InputFilterView({collection: users, minLength: 2})
|
||||||
const usersView = new PaginatedCollectionView({
|
const usersView = new PaginatedCollectionView({
|
||||||
collection: users,
|
collection: users,
|
||||||
itemView: RosterUserView,
|
itemView: RosterUserView,
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
module SearchTermHelper
|
module SearchTermHelper
|
||||||
MIN_SEARCH_TERM_LENGTH = 3
|
MIN_SEARCH_TERM_LENGTH = 2
|
||||||
|
|
||||||
module ClassMethods
|
module ClassMethods
|
||||||
def search_by_attribute(scope, attr, search_term)
|
def search_by_attribute(scope, attr, search_term)
|
||||||
|
@ -67,4 +67,4 @@ module SearchTermHelper
|
||||||
def matches_attribute?(attr, search_term)
|
def matches_attribute?(attr, search_term)
|
||||||
self[attr].to_s.downcase.include?(search_term.downcase)
|
self[attr].to_s.downcase.include?(search_term.downcase)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2688,10 +2688,10 @@ describe CoursesController, type: :request do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns an error when search_term is fewer than 3 characters" do
|
it "returns an error when search_term is fewer than 2 characters" do
|
||||||
json = api_call(:get, api_url, api_route, {:search_term => 'ab'}, {}, :expected_status => 400)
|
json = api_call(:get, api_url, api_route, {:search_term => 'a'}, {}, :expected_status => 400)
|
||||||
error = json["errors"].first
|
error = json["errors"].first
|
||||||
verify_json_error(error, "search_term", "invalid", "3 or more characters is required")
|
verify_json_error(error, "search_term", "invalid", "2 or more characters is required")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns a list of users" do
|
it "returns a list of users" do
|
||||||
|
|
|
@ -109,10 +109,10 @@ describe "Group Categories API", type: :request do
|
||||||
expect(response.code).to eq '401'
|
expect(response.code).to eq '401'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns an error when search_term is fewer than 3 characters" do
|
it "returns an error when search_term is fewer than 2 characters" do
|
||||||
json = api_call(:get, api_url, api_route, {:search_term => 'ab'}, {}, :expected_status => 400)
|
json = api_call(:get, api_url, api_route, {:search_term => 'a'}, {}, :expected_status => 400)
|
||||||
error = json["errors"].first
|
error = json["errors"].first
|
||||||
verify_json_error(error, "search_term", "invalid", "3 or more characters is required")
|
verify_json_error(error, "search_term", "invalid", "2 or more characters is required")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns a list of users" do
|
it "returns a list of users" do
|
||||||
|
|
|
@ -913,10 +913,10 @@ describe "Groups API", type: :request do
|
||||||
expect(response.code).to eq '401'
|
expect(response.code).to eq '401'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns an error when search_term is fewer than 3 characters" do
|
it "returns an error when search_term is fewer than 2 characters" do
|
||||||
json = api_call(:get, api_url, api_route, {:search_term => 'ab'}, {}, :expected_status => 400)
|
json = api_call(:get, api_url, api_route, {:search_term => 'a'}, {}, :expected_status => 400)
|
||||||
error = json["errors"].first
|
error = json["errors"].first
|
||||||
verify_json_error(error, "search_term", "invalid", "3 or more characters is required")
|
verify_json_error(error, "search_term", "invalid", "2 or more characters is required")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns a list of users" do
|
it "returns a list of users" do
|
||||||
|
|
|
@ -175,12 +175,12 @@ describe "Pages API", type: :request do
|
||||||
expect(urls).to eq new_pages.sort_by(&:id).collect(&:url)
|
expect(urls).to eq new_pages.sort_by(&:id).collect(&:url)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should return an error if the search term is fewer than 3 characters" do
|
it "should return an error if the search term is fewer than 2 characters" do
|
||||||
json = api_call(:get, "/api/v1/courses/#{@course.id}/pages?search_term=aa",
|
json = api_call(:get, "/api/v1/courses/#{@course.id}/pages?search_term=a",
|
||||||
{:controller=>'wiki_pages_api', :action=>'index', :format=>'json', :course_id=>@course.to_param, :search_term => "aa"},
|
{:controller=>'wiki_pages_api', :action=>'index', :format=>'json', :course_id=>@course.to_param, :search_term => "a"},
|
||||||
{}, {}, {:expected_status => 400})
|
{}, {}, {:expected_status => 400})
|
||||||
error = json["errors"].first
|
error = json["errors"].first
|
||||||
verify_json_error(error, "search_term", "invalid", "3 or more characters is required")
|
verify_json_error(error, "search_term", "invalid", "2 or more characters is required")
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "sorting" do
|
describe "sorting" do
|
||||||
|
|
|
@ -922,11 +922,11 @@ describe "Users API", type: :request do
|
||||||
expect(response.code).to eql "401"
|
expect(response.code).to eql "401"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns an error when search_term is fewer than 3 characters" do
|
it "returns an error when search_term is fewer than 2 characters" do
|
||||||
@account = Account.default
|
@account = Account.default
|
||||||
json = api_call(:get, "/api/v1/accounts/#{@account.id}/users", { :controller => 'users', :action => "api_index", :format => 'json', :account_id => @account.id.to_param }, {:search_term => 'ab'}, {}, :expected_status => 400)
|
json = api_call(:get, "/api/v1/accounts/#{@account.id}/users", { :controller => 'users', :action => "api_index", :format => 'json', :account_id => @account.id.to_param }, {:search_term => 'a'}, {}, :expected_status => 400)
|
||||||
error = json["errors"].first
|
error = json["errors"].first
|
||||||
verify_json_error(error, "search_term", "invalid", "3 or more characters is required")
|
verify_json_error(error, "search_term", "invalid", "2 or more characters is required")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns a list of users filtered by search_term" do
|
it "returns a list of users filtered by search_term" do
|
||||||
|
|
Loading…
Reference in New Issue