Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

task/WG-253 - File Listing Component using Chonky #230

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions react/jest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ jest.mock('@hazmapper/hooks/environment/getLocalAppConfiguration', () => ({
getLocalAppConfiguration: jest.fn(() => testDevConfiguration),
}));

jest.mock('react-jss', () => ({
createUseStyles: () => () => ({}),
}));

/***** B) Ignore some known warnings/errors *****/

// List of `console.warn` messages that can be ignored
Expand Down
1,702 changes: 1,018 additions & 684 deletions react/package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"@turf/turf": "^7.2.0",
"antd": "^5.23.1",
"axios": "^1.7.9",
"chonky": "^2.3.2",
"dompurify": "^3.2.3",
"formik": "^2.4.6",
"jwt-decode": "^4.0.0",
Expand Down
74 changes: 74 additions & 0 deletions react/src/__fixtures__/fileFixture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { File } from '../types/file';

export const filesMock: File[] = [
{
name: 'Folder 3',
path: 'user/Folder_2/Folder_3',
lastModified: '2024-02-22T17:04:04.000-06:00',
size: 31000,
nativePermissions: 'ALL',
mimeType: 'text/directory',
type: 'dir',
url: 'https://designsafe-ci.org/data/browser/user/Folder_2/Folder_3/',
},
{
name: 'Test Map 3.hazmapper',
path: 'user/Folder_2/Folder_3/Test Map 3.hazmapper',
lastModified: '2024-02-22T17:04:04.000-06:00',
size: 7000,
nativePermissions: 'READ_WRITE',
mimeType: 'application/octet-stream',
type: 'file',
url: 'https://designsafe-ci.org/data/browser/user/Folder_2/Folder_3/Test%20Map%203.hazmapper',
},
{
name: 'Folder_1',
path: 'user/Folder_1',
lastModified: '2024-02-22T17:04:04.000-06:00',
size: 31,
nativePermissions: 'ALL',
mimeType: 'text/directory',
type: 'dir',
url: 'https://designsafe-ci.org/data/browser/user/Folder_1/',
},
{
name: 'Folder_2',
path: 'user/Folder_2',
lastModified: '2024-02-22T17:04:04.000-06:00',
size: 4096,
nativePermissions: 'ALL',
mimeType: 'text/directory',
type: 'dir',
url: 'https://designsafe-ci.org/data/browser/user/Folder_2/',
},
{
name: 'New Map.hazmapper',
path: 'user/New Map.hazmapper',
lastModified: '2024-02-22T17:04:04.000-06:00',
size: 70,
nativePermissions: 'READ_WRITE',
mimeType: 'application/octet-stream',
type: 'file',
url: 'https://designsafe-ci.org/data/browser/user/New%20Map.hazmapper',
},
{
name: 'Test Map.hazmapper',
path: 'user/Test Map.hazmapper',
lastModified: '2024-02-22T17:04:04.000-06:00',
size: 70,
nativePermissions: 'READ_WRITE',
mimeType: 'application/octet-stream',
type: 'file',
url: 'https://designsafe-ci.org/data/browser/user/Test%20Map.hazmapper',
},
{
name: 'Test Map 2.hazmapper',
path: 'user/Folder_2/Test Map 2.hazmapper',
lastModified: '2024-02-22T17:04:04.000-06:00',
size: 70,
nativePermissions: 'READ_WRITE',
mimeType: 'application/octet-stream',
type: 'file',
url: 'https://designsafe-ci.org/data/browser/user/Folder_2/Test%20Map%202.hazmapper',
},
];
15 changes: 15 additions & 0 deletions react/src/components/CreateMapModal/CreateMapModal.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,18 @@
width: 115%;
}
}

.section {
height: 55vh;
}

.link-heading {
border-bottom: 0;
padding-bottom: 0.5rem;
}

.link-subheading {
font-style: italic;
font-weight: 100;
padding-bottom: 2rem;
}
20 changes: 20 additions & 0 deletions react/src/components/CreateMapModal/CreateMapModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { QueryClientProvider } from '@tanstack/react-query';
import { testQueryClient, server } from '@hazmapper/test/testUtil';
import { testDevConfiguration } from '@hazmapper/__fixtures__/appConfigurationFixture';
import { projectMock } from '@hazmapper/__fixtures__/projectFixtures';
import { filesMock } from '@hazmapper/__fixtures__/fileFixture';

jest.mock('@hazmapper/hooks/user/useAuthenticatedUser', () => ({
__esModule: true,
Expand All @@ -20,13 +21,32 @@ jest.mock('@hazmapper/hooks/user/useAuthenticatedUser', () => ({
}),
}));

jest.mock('@hazmapper/hooks/files/useFiles', () => ({
__esModule: true,
useFiles: jest.fn(() => ({
data: filesMock,
refetch: jest.fn(),
})),
}));

const mockNavigate = jest.fn();

jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useNavigate: () => mockNavigate,
}));

jest.mock('chonky', () => {
const actualChonky = jest.requireActual('chonky');
return {
...actualChonky,
FileBrowser: jest.fn(() => <div>Mock FileBrowser</div>),
FileNavbar: jest.fn(() => <div>Mock FileNavbar</div>),
FileList: jest.fn(() => <div>Mock FileList</div>),
ChonkyActions: actualChonky.ChonkyActions,
};
});

const toggleMock = jest.fn();

const renderComponent = async (isOpen = true) => {
Expand Down
Loading
Loading