mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-15 01:56:18 +08:00
impr(config): validation on layoutFluid and polyglot (@fehmer) (#6844)
This commit is contained in:
parent
cd99d5af16
commit
ced5dc1920
3 changed files with 6 additions and 5 deletions
|
@ -1089,8 +1089,9 @@ describe("Config", () => {
|
|||
expect(Config.setQuoteLength([-4 as any, 5 as any])).toBe(false);
|
||||
});
|
||||
it("setCustomLayoutfluid", () => {
|
||||
expect(Config.setCustomLayoutfluid(["qwerty"])).toBe(true);
|
||||
expect(Config.setCustomLayoutfluid(["qwerty", "qwertz"])).toBe(true);
|
||||
|
||||
expect(Config.setCustomLayoutfluid(["qwerty"])).toBe(false);
|
||||
expect(Config.setCustomLayoutfluid([])).toBe(false);
|
||||
expect(Config.setCustomLayoutfluid("qwerty#qwertz" as any)).toBe(false);
|
||||
expect(Config.setCustomLayoutfluid("invalid" as any)).toBe(false);
|
||||
|
|
|
@ -607,7 +607,7 @@ async function fillSettingsPage(): Promise<void> {
|
|||
customLayoutFluidSelect = new SlimSelect({
|
||||
select:
|
||||
".pageSettings .section[data-config-name='customLayoutfluid'] select",
|
||||
settings: { keepOrder: true, minSelected: 1 },
|
||||
settings: { keepOrder: true, minSelected: 2 },
|
||||
events: {
|
||||
afterChange: (newVal): void => {
|
||||
const customLayoutfluid = newVal.map(
|
||||
|
@ -625,7 +625,7 @@ async function fillSettingsPage(): Promise<void> {
|
|||
|
||||
customPolyglotSelect = new SlimSelect({
|
||||
select: ".pageSettings .section[data-config-name='customPolyglot'] select",
|
||||
settings: { minSelected: 1 },
|
||||
settings: { minSelected: 2 },
|
||||
data: getLanguageDropdownData((language) =>
|
||||
Config.customPolyglot.includes(language)
|
||||
),
|
||||
|
|
|
@ -211,11 +211,11 @@ export type CustomBackgroundFilter = z.infer<
|
|||
|
||||
export const CustomLayoutFluidSchema = z
|
||||
.array(Layouts.LayoutNameSchema)
|
||||
.min(1)
|
||||
.min(2)
|
||||
.max(15);
|
||||
export type CustomLayoutFluid = z.infer<typeof CustomLayoutFluidSchema>;
|
||||
|
||||
export const CustomPolyglotSchema = z.array(LanguageSchema).min(1);
|
||||
export const CustomPolyglotSchema = z.array(LanguageSchema).min(2);
|
||||
export type CustomPolyglot = z.infer<typeof CustomPolyglotSchema>;
|
||||
|
||||
export const MonkeyPowerLevelSchema = z.enum(["off", "1", "2", "3", "4"]);
|
||||
|
|
Loading…
Add table
Reference in a new issue