mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-08-04 05:40:58 +00:00
* feat(web-shell): add read-only GitHub pull requests panel Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com> * fix(web-shell): address review findings for GitHub PRs panel Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com> * fix(web-shell): clamp GitDialog view when PR capability is withdrawn mid-session Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com> * fix(web-shell): address review feedback for GitHub PRs panel (#7683) - Add workspace_github_prs to integration test baseline capabilities - Sanitize git root path in error responses to prevent path leakage when workspace is a repo subdirectory - Add NEUTRAL check-run conclusion test case - Add not.toContain path-leak assertion for sanitization test - Add pending checks indicator UI test - Add timeAgo utility unit test * fix(web-shell): address review feedback for GitHub PRs panel (#7683) - Sanitize workspace paths before truncating the error message so a path straddling the 512-char display boundary is redacted, not cut mid-token - Render a badge for the review_required decision instead of leaving it dead - Align PR row icon sizes (12px) with sibling git dialogs --------- Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com> Co-authored-by: qwen-code-dev-bot <qwen-code-dev@service.alibaba.com> Co-authored-by: qwen-code-ci-bot <qwen-code-ci-bot@users.noreply.github.com>
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright 2026 Qwen Team
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import { describe, expect, it } from 'vitest';
|
|
import { timeAgo } from './timeAgo';
|
|
|
|
const NOW = 1_800_000_000;
|
|
|
|
describe('timeAgo', () => {
|
|
it.each([
|
|
[0, 'en', 'now'],
|
|
[30, 'en', 'now'],
|
|
[60, 'en', '1 minute ago'],
|
|
[120, 'en', '2 minutes ago'],
|
|
[3600, 'en', '1 hour ago'],
|
|
[7200, 'en', '2 hours ago'],
|
|
[86_400, 'en', 'yesterday'],
|
|
[259_200, 'en', '3 days ago'],
|
|
[604_800, 'en', 'last week'],
|
|
[1_814_400, 'en', '3 weeks ago'],
|
|
[2_592_000, 'en', '4 weeks ago'],
|
|
[7_776_000, 'en', '3 months ago'],
|
|
[31_536_000, 'en', 'last year'],
|
|
[63_072_000, 'en', '2 years ago'],
|
|
])('%s seconds ago → "%s"', (seconds, lang, expected) => {
|
|
expect(timeAgo(NOW - seconds, NOW, lang)).toBe(expected);
|
|
});
|
|
|
|
it('uses weeks below the 5-week threshold and months at or above it', () => {
|
|
expect(timeAgo(NOW - 4 * 7 * 86_400, NOW, 'en')).toBe('4 weeks ago');
|
|
expect(timeAgo(NOW - 5 * 7 * 86_400, NOW, 'en')).toBe('last month');
|
|
});
|
|
|
|
it('uses months below 12 and years at or above 12', () => {
|
|
expect(timeAgo(NOW - 330 * 86_400, NOW, 'en')).toBe('11 months ago');
|
|
expect(timeAgo(NOW - 365 * 86_400, NOW, 'en')).toBe('last year');
|
|
});
|
|
|
|
it('clamps negative deltas to now', () => {
|
|
expect(timeAgo(NOW + 100, NOW, 'en')).toBe('now');
|
|
});
|
|
|
|
it('localizes output', () => {
|
|
expect(timeAgo(NOW - 120, NOW, 'zh-CN')).toBe('2分钟前');
|
|
});
|
|
});
|