mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(post options): link sage warning to FAQ
This commit is contained in:
@@ -14,7 +14,7 @@ describe('post-options-utils', () => {
|
||||
|
||||
it('supports nonoko while keeping sage unsupported', () => {
|
||||
expect(getUnsupportedPostOptionsMessage('nonoko', undefined)).toBeNull();
|
||||
expect(getUnsupportedPostOptionsMessage('sage', 'b')).toBe('Unsupported options: sage.');
|
||||
expect(getUnsupportedPostOptionsMessage('sage', 'b')).toBe('Unsupported options: sage [learn why].');
|
||||
expect(hasNonokoOption('fortune nonoko')).toBe(true);
|
||||
expect(hasNonokoOption('nonokosage')).toBe(false);
|
||||
});
|
||||
@@ -25,7 +25,7 @@ describe('post-options-utils', () => {
|
||||
supportedDirectoryCodesByOption: [{ option: 'fortune', directoryCodes: ['b', 's5s'] }],
|
||||
});
|
||||
expect(getUnsupportedPostOptionsMessage('fortune', 'mu')).toBe('Unsupported options: fortune. Option "fortune" is supported on: /b/, /s5s/.');
|
||||
expect(getUnsupportedPostOptionsMessage('sage fortune', 'pol')).toBe('Unsupported options: sage, fortune. Option "fortune" is supported on: /b/, /s5s/.');
|
||||
expect(getUnsupportedPostOptionsMessage('sage fortune', 'pol')).toBe('Unsupported options: sage [learn why], fortune. Option "fortune" is supported on: /b/, /s5s/.');
|
||||
expect(getPostOptionsValidationError('fortune dice+1d6', 'mu')).toEqual({
|
||||
unsupportedOptions: ['fortune', 'dice+1d6'],
|
||||
supportedDirectoryCodesByOption: [
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
export const POST_OPTIONS_VALIDATION_DELAY_MS = 700;
|
||||
export const SAGE_FAQ_LINK_LABEL = 'learn why';
|
||||
export const SAGE_FAQ_PATH = '/faq#sage';
|
||||
export const SAGE_OPTION = 'sage';
|
||||
const FORTUNE_DIRECTORY_CODES = new Set(['b', 's5s']);
|
||||
const DICE_DIRECTORY_CODES = new Set(['qst', 'tg']);
|
||||
const POST_OPTION_ROUTE_DIRECTORY_CODES = new Set([...FORTUNE_DIRECTORY_CODES, ...DICE_DIRECTORY_CODES]);
|
||||
@@ -150,7 +153,8 @@ export const getUnsupportedPostOptionsMessage = (value: string, directoryCode: s
|
||||
return null;
|
||||
}
|
||||
|
||||
let message = `Unsupported options: ${error.unsupportedOptions.join(', ')}.`;
|
||||
const unsupportedOptionsLabel = error.unsupportedOptions.map((option) => (option === SAGE_OPTION ? `${option} [${SAGE_FAQ_LINK_LABEL}]` : option)).join(', ');
|
||||
let message = `Unsupported options: ${unsupportedOptionsLabel}.`;
|
||||
|
||||
for (const { option, directoryCodes } of error.supportedDirectoryCodesByOption) {
|
||||
message += ` Option "${option}" is supported on: ${directoryCodes.map((code) => `/${code}/`).join(', ')}.`;
|
||||
|
||||
Reference in New Issue
Block a user