fix: only count something as a directory if it has children (#4595)

* fix: only count something as a directory if it has children

* fix: playwright tests

* fix: return 0 if you cant find the projectfolder

* fix: remove folder count from e2e tests since it is unused currently

---------

Co-authored-by: Tom Pridham <pridham.tom@gmail.com>
This commit is contained in:
Jonathan Tran
2024-12-02 15:16:43 -05:00
committed by GitHub
parent 3cbedcd3e7
commit 51f0b669a4
4 changed files with 28 additions and 9 deletions

View File

@ -46,9 +46,21 @@ describe('desktop utilities', () => {
'project-without-kcl-files',
'another-valid-project',
],
'/test/projects/valid-project': ['file1.kcl', 'file2.stp'],
'/test/projects/valid-project': [
'file1.kcl',
'file2.stp',
'file3.kcl',
'directory1',
],
'/test/projects/valid-project/directory1': [],
'/test/projects/project-without-kcl-files': ['file3.glb'],
'/test/projects/another-valid-project': ['file4.kcl'],
'/test/projects/another-valid-project': [
'file4.kcl',
'directory2',
'directory3',
],
'/test/projects/another-valid-project/directory2': [],
'/test/projects/another-valid-project/directory3': [],
}
beforeEach(() => {
@ -119,6 +131,15 @@ describe('desktop utilities', () => {
)
})
it('correctly counts directories and files', async () => {
const projects = await listProjects(mockConfig)
// Verify that directories and files are counted correctly
expect(projects[0].directory_count).toEqual(1)
expect(projects[0].kcl_file_count).toEqual(2)
expect(projects[1].directory_count).toEqual(2)
expect(projects[1].kcl_file_count).toEqual(1)
})
it('handles empty project directory', async () => {
// Adjust mockFileSystem to simulate empty directory
mockFileSystem['/test/projects'] = []