Copilot commented on code in PR #741:
URL:
https://github.com/apache/hugegraph-toolchain/pull/741#discussion_r3566000858
##########
hugegraph-hubble/hubble-fe/src/utils/rules.test.js:
##########
@@ -140,6 +143,25 @@ describe('rules i18n defaults', () => {
expect(await validate(rules.isAccountName('custom
account'))).toBe('custom account');
});
+ it('rejects invalid account names with an Error object', async () => {
+ await expect(rules.isAccountName().validator(null,
'name_too_long_123'))
+ .rejects.toBeInstanceOf(Error);
+ });
+
+ it('accepts only backend-compatible favorite names', async () => {
+ await i18n.changeLanguage('en-US');
+ await expect(rules.isFavoriteName().validator(null, 'query_2026'))
+ .resolves.toBeUndefined();
+ await expect(rules.isFavoriteName().validator(null, '我的查询_123'))
+ .resolves.toBeUndefined();
+ await expect(rules.isFavoriteName().validator(null, 'query-2026'))
+ .rejects.toThrow('Use Chinese characters, letters, numbers, or
underscores only, up to 48 characters');
+ await expect(rules.isFavoriteName().validator(null, undefined))
+ .rejects.toThrow('Use Chinese characters, letters, numbers, or
underscores only, up to 48 characters');
+ await expect(rules.isFavoriteName().validator(null, null))
+ .rejects.toThrow('Use Chinese characters, letters, numbers, or
underscores only, up to 48 characters');
+ });
Review Comment:
The new favorite-name validation test only asserts the English i18n message,
but this PR also introduces the zh-CN translation. Adding a zh-CN assertion
here would guard against regressions where the rule uses the wrong language or
the translation key changes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]