Skip to content

Commit

Permalink
Clean up some warnings for project.test.js
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Smock <[email protected]>
  • Loading branch information
tsmock committed Feb 8, 2024
1 parent 1eff085 commit 11d2735
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 23 deletions.
22 changes: 19 additions & 3 deletions frontend/src/components/projectDetail/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,21 @@ export const ProjectDetail = (props) => {
);
};

const GeometryPropType = PropTypes.shape({
type: PropTypes.oneOf(['Point', 'MultiPoint', 'LineString', 'MultiLineString', 'Polygon', 'MultiPolygon', 'GeometryCollection']),
coordinates: PropTypes.array,
geometries: PropTypes.array
});
const FeaturePropType = PropTypes.shape({
type: PropTypes.oneOf(['Feature']),
geometry: GeometryPropType,
properties: PropTypes.object,
});
const FeatureCollectionPropType = PropTypes.shape({
type: PropTypes.oneOf(['FeatureCollection']),
features: PropTypes.arrayOf(FeaturePropType).isRequired
});

ProjectDetail.propTypes = {
project: PropTypes.shape({
projectId: PropTypes.number,
Expand All @@ -393,10 +408,11 @@ ProjectDetailMap.propTypes = {
areaOfInterest: PropTypes.object,
priorityAreas: PropTypes.arrayOf(PropTypes.object),
}).isRequired,
tasks: PropTypes.arrayOf(PropTypes.object),
// Tasks are a GeoJSON FeatureCollection
tasks: FeatureCollectionPropType,
navigate: PropTypes.func,
type: PropTypes.string,
tasksError: PropTypes.string,
tasksError: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
projectLoading: PropTypes.bool,
};

Expand All @@ -406,7 +422,7 @@ ProjectDetailLeft.propTypes = {
shortDescription: PropTypes.string,
}),
projectId: PropTypes.number,
tasks: PropTypes.arrayOf(PropTypes.object),
tasks: FeatureCollectionPropType,
}).isRequired,
contributors: PropTypes.arrayOf(PropTypes.object),
className: PropTypes.string,
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/network/tests/mockData/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ export const taskDetail = (taskId) => ({
export const projectComments = {
chat: [
{
id: 1,
message:
"<p>@happy_me we do want 'significant' roads that lead to houses. Rule of thumb I use for picking classification is the usage over condition/what it looks like. If it's the main 'path' to one or maybe several homes, I would pick service; even if a vehicle can't drive it, that can be reflected with additional tags, but the road still functions as access to the home(s).</p>",
pictureUrl:
Expand All @@ -331,20 +332,23 @@ export const projectComments = {
username: 'helnershingthapa',
},
{
id: 2,
message: '<p>hello world</p>',
pictureUrl:
'https://www.openstreetmap.org/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBNXQ2Q3c9PSIsImV4cCI6bnVsbCwicHVyIjoiYmxvYl9pZCJ9fQ==--fe41f1b2a5d6cf492a7133f15c81f105dec06ff7/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCem9MWm05eWJXRjBPZ2h3Ym1jNkZISmxjMmw2WlY5MGIxOXNhVzFwZEZzSGFXbHBhUT09IiwiZXhwIjpudWxsLCJwdXIiOiJ2YXJpYXRpb24ifX0=--058ac785867b32287d598a314311e2253bd879a3/unnamed.webp',
timestamp: '2023-01-03T10:54:25.805150Z',
username: 'helnershingthapa',
},
{
id: 3,
message: '<p>asdadadasdasdasd</p>',
pictureUrl:
'https://www.openstreetmap.org/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBeFJheFE9PSIsImV4cCI6bnVsbCwicHVyIjoiYmxvYl9pZCJ9fQ==--a765e2377a288bccae85da6604300251d9de6d39/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCem9MWm05eWJXRjBTU0lJYW5CbkJqb0dSVlE2RkhKbGMybDZaVjkwYjE5c2FXMXBkRnNIYVdscGFRPT0iLCJleHAiOm51bGwsInB1ciI6InZhcmlhdGlvbiJ9fQ==--1d22b8d446683a272d1a9ff04340453ca7c374b4/bitmoji.jpg',
timestamp: '2022-10-19T09:32:52.231545Z',
username: 'Hel Nershing Thapa',
},
{
id: 4,
message:
'<p><code>test of \ncode block\nhmmm\npreview showed it as a block\nand monospace font\nbut not indented</code></p>',
pictureUrl:
Expand All @@ -353,6 +357,7 @@ export const projectComments = {
username: 'wireguy',
},
{
id: 5,
message:
'<p><code>this is a code\nblock\nshould it\nbe indented\nby 4 space?\nminor...</code></p>',
pictureUrl:
Expand Down
42 changes: 22 additions & 20 deletions frontend/src/views/tests/project.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,27 +221,13 @@ describe('Project Detail Page', () => {
Line: () => null,
}));

it('should render component details', async () => {
act(() => {
store.dispatch({ type: 'SET_LOCALE', locale: 'es-AR' });
});
renderWithRouter(
<QueryClientProviders>
<ReduxIntlProviders>
<ProjectDetailPage />
</ReduxIntlProviders>
</QueryClientProviders>,
);
await waitFor(() => {
expect(screen.getByText(/sample project/i)).toBeInTheDocument();
expect(screen.getByText(/hello world/i)).toBeInTheDocument();
});
});

it('should display private project error message', async () => {
setupFaultyHandlers();
/**
* Set up a ProjectDetailPage given an initial entry; this avoids issues where there is no project id.
* @param {Array<string>} initialEntries The initial entries. This should be in the form of `[projects/:id]`.
*/
function setup(initialEntries) {
render(
<MemoryRouter initialEntries={['/projects/123']}>
<MemoryRouter initialEntries={initialEntries}>
<Routes>
<Route
path="projects/:id"
Expand All @@ -256,6 +242,22 @@ describe('Project Detail Page', () => {
</Routes>
</MemoryRouter>,
);
}

it('should render component details', async () => {
act(() => {
store.dispatch({ type: 'SET_LOCALE', locale: 'es-AR' });
});
setup(['/projects/123']);
await waitFor(() => {
expect(screen.getByText(/sample project/i)).toBeInTheDocument();
expect(screen.getByText(/hello world/i)).toBeInTheDocument();
});
});

it('should display private project error message', async () => {
setupFaultyHandlers();
setup(['/projects/123']);

await waitFor(() =>
expect(
Expand Down

0 comments on commit 11d2735

Please sign in to comment.