mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-10-31 22:41:03 +00:00 
			
		
		
		
	The repository contributors graph received the stats for each author for each week, these weeks are stored as unix milis values, `Object.entries` converted these values to strings and `sort()` would thus sort them as strings - this worked without a problem for most repository. If a repository has commits from before 'Sun Sep 9 03:46:40 AM CEST 2001', it meant that the weeks when those commits were made would be sorted towards the end because "1000000000" > "999999999" (when compared as strings) and would thus be silently cut from the data. This edge-case was seen by the curl repository (https://mastodon.social/@bagder/115018271785548165) Sort them as numbers to avoid this problem, it being stored as strings is otherwise not a problem. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8882 Reviewed-by: Beowulf <beowulf@beocode.eu> Reviewed-by: Michael Kriese <michael.kriese@gmx.de> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-committed-by: Gusted <postmaster@gusted.xyz>
		
			
				
	
	
		
			76 lines
		
	
	
	
		
			1.8 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			76 lines
		
	
	
	
		
			1.8 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| import {flushPromises, mount} from '@vue/test-utils';
 | |
| import RepoContributors from './RepoContributors.vue';
 | |
| 
 | |
| test('has commits from before 2001', async () => {
 | |
|   vi.spyOn(global, 'fetch').mockResolvedValue({
 | |
|     json: vi.fn().mockResolvedValue({
 | |
|       'daniel@haxx.se': {
 | |
|         name: 'Daniel Stenberg',
 | |
|         total_commits: 13,
 | |
|         weeks: {
 | |
|           1754179200000: {
 | |
|             week: 1754179200000,
 | |
|             additions: 4330,
 | |
|             deletions: 47,
 | |
|             commits: 10,
 | |
|           },
 | |
|           946166400000: {
 | |
|             week: 946166400000,
 | |
|             additions: 37273,
 | |
|             deletions: 0,
 | |
|             commits: 1,
 | |
|           },
 | |
|         },
 | |
|       },
 | |
|       total: {
 | |
|         name: 'Total',
 | |
|         total_commits: 11,
 | |
|         weeks: {
 | |
|           1754179200000: {
 | |
|             week: 1754179200000,
 | |
|             additions: 4330,
 | |
|             deletions: 47,
 | |
|             commits: 10,
 | |
|           },
 | |
|           946166400000: {
 | |
|             week: 946166400000,
 | |
|             additions: 37273,
 | |
|             deletions: 0,
 | |
|             commits: 1,
 | |
|           },
 | |
|         },
 | |
|       },
 | |
|     }),
 | |
|     ok: true,
 | |
|   });
 | |
| 
 | |
|   const repoContributorsGraph = mount(RepoContributors, {
 | |
|     global: {
 | |
|       stubs: {
 | |
|         'relative-time': {
 | |
|           template: '<span>relative time</span>',
 | |
|         },
 | |
|       },
 | |
|     },
 | |
|     props: {
 | |
|       repoLink: '',
 | |
|       repoDefaultBranchName: '',
 | |
|       locale: {
 | |
|         filterLabel: '',
 | |
|         contributionType: {
 | |
|           commits: '',
 | |
|           additions: '',
 | |
|           deletions: '',
 | |
|         },
 | |
| 
 | |
|         loadingTitle: '',
 | |
|         loadingTitleFailed: '',
 | |
|         loadingInfo: '',
 | |
|       },
 | |
|     },
 | |
|   });
 | |
|   await flushPromises();
 | |
| 
 | |
|   expect(repoContributorsGraph.componentVM.xAxisStart).toBe(946166400000);
 | |
|   expect(repoContributorsGraph.componentVM.contributorsStats['daniel@haxx.se'].weeks[0].week).toBe(946166400000);
 | |
| });
 |