User search (#1468)

* Initial

* Search users from API

* Better feeling search

* Fix TODO

* Search via url, discord id & id

* Load initial user

* UserSearch on admin page

* UserSearch on tournaments page

* UserSearch for badges

* Plus suggestions

* Vod page

* Remove unused code

* Fix test
This commit is contained in:
Kalle
2023-08-26 22:10:01 +03:00
committed by GitHub
parent 9b746969cd
commit fd7d1ea2dc
21 changed files with 397 additions and 193 deletions

44
app/utils/users.test.ts Normal file
View File

@@ -0,0 +1,44 @@
import { suite } from "uvu";
import * as assert from "uvu/assert";
import { queryToUserIdentifier } from "./users";
const QueryToUserIdentifier = suite("queryToUserIdentifier()");
QueryToUserIdentifier("returns null if no match", () => {
assert.equal(queryToUserIdentifier("foo"), null);
});
QueryToUserIdentifier("gets custom url from url", () => {
assert.equal(queryToUserIdentifier("https://sendou.ink/u/sendou"), {
customUrl: "sendou",
});
});
QueryToUserIdentifier("gets discord id from url", () => {
assert.equal(
queryToUserIdentifier("https://sendou.ink/u/79237403620945920"),
{
discordId: "79237403620945920",
}
);
});
QueryToUserIdentifier("gets custom url from url (without https://)", () => {
assert.equal(queryToUserIdentifier("sendou.ink/u/sendou"), {
customUrl: "sendou",
});
});
QueryToUserIdentifier("gets discord id", () => {
assert.equal(queryToUserIdentifier("79237403620945920"), {
discordId: "79237403620945920",
});
});
QueryToUserIdentifier("gets id", () => {
assert.equal(queryToUserIdentifier("1"), {
id: 1,
});
});
QueryToUserIdentifier.run();