Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into feature/horenso/758-conflict-on-new-map-wi…
Browse files Browse the repository at this point in the history
…th-taken-name
  • Loading branch information
chr-schr authored Apr 22, 2024
2 parents 8625be0 + 4bdb7ae commit c180740
Show file tree
Hide file tree
Showing 12 changed files with 238 additions and 37 deletions.
13 changes: 8 additions & 5 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ We will help you, but we cannot accept PRs that do not fulfill the basics.

<!--
For documentation fixes, spell checking, and similar none of these points below need to be checked.
Otherwise please check these points when getting a PR done:
Otherwise please check below points when getting a PR done.
If nothing is to be done, please check them, too.
-->

- [ ] I fully described what my PR does in the documentation
Expand Down Expand Up @@ -58,9 +59,11 @@ Also the checklist above can be used.
But also the PR creator should check these points when getting a PR done:
-->

- [ ] I've tested the code
- [ ] I've read through the whole code
- [ ] I've read through the whole documentation
- [ ] I've tested the code via issue description
- [ ] I've tested the code via requirements
- [ ] I've tested the code with concurrency (several browsers on the same map)
- [ ] I've read through the code
- [ ] I've read through the documentation
- [ ] I've checked conformity to guidelines
- [ ] I've checked conformity to requirements
- [ ] I've checked that the requirements are tested
- [ ] I've checked that the requirements are automatically tested
2 changes: 1 addition & 1 deletion ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def node_info() {

// Function duplicated in `Jenkinsfile.release` without the command parameter
def wait_for_db(String command) {
retry(6) {
retry(10) {
sleep(time: 5, unit: 'SECONDS')
sh "${command}"
}
Expand Down
3 changes: 2 additions & 1 deletion doc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
FROM rust:1.67.1-slim-bookworm AS builder

ENV MDBOOK_VERSION=0.4.23 \
MDBOOK_MERMAID_VERSION=0.12.6
MDBOOK_MERMAID_VERSION=0.12.6 \
CARGO_NET_RETRY=10

RUN apt-get update && \
apt-get install -y --no-install-recommends \
Expand Down
9 changes: 5 additions & 4 deletions doc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ Syntax: `- short text describing the change _(Your Name)_`

## UNRELEASED

- _()_
- Return 409 Conflict when creating a map with taken name _(Jannis Adamek)_
- _()_
- _()_
- Added Meeting Agenda&Notes for 15.04.2024 9:00 _(Markus Raab, Daniel)_
- _()_
- _()_
- _()_
- _()_
- _()_
- _()_
- _()_
- Add tests for hooks in frontend/layers _(Lukas Anton Lakits)_
- _()_
- Add warn signs to sizes for multi-selected plant-areas _(Lukas Anton Lakits)_
- _()_
- Return 409 Conflict when creating a map with taken name _(Jannis Adamek)_
- _()_
- _()_
- _()_
Expand All @@ -37,6 +37,7 @@ Syntax: `- short text describing the change _(Your Name)_`
- _()_
- _()_
- _()_
- Increase cargo net.retry configuration to handle random network errors during CI. _(Christoph Schreiner)_
- _()_
- _()_
- _()_
Expand Down
73 changes: 73 additions & 0 deletions doc/meetings/2024_04_15.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Meeting 15.04.2024

## Attendees

- Markus
- Yvonne
- Christoph
- Moritz
- Lukas
- Daniel
- Jannis

Not here:

- Filip

Sick:

- Andrei (Scrum Master)

## Buddies

- Daniel & Andrei
- Moritz & Christoph
- Jannis & Lukas

## Agenda

- 09:00 start
- protocol: Daniel
- release v0.4.0 done
- GitLab Tuwien migration
- https://github.com/supabase/index_advisor
- scrum with Andrei:
- issues
- reviews -> later
- (manual) e2e tests -> later Christoph+Filip
- create issues:
- rework notification system (Jannis+Andrei)
- Jannis: raw SQL
- [sprint plan](https://project.permaplant.net)

## Tasks for Everyone

To be done until **Friday 19.04.2024**:

- create or update TISS.txt in submissions repo
- buddy talk: scoping with mistakes
- approve [meeting PR](https://pull.permaplant.net/1284/files)
- request and approve for requested reviews [requested reviews](https://pulls.permaplant.net/?q=is%3Aopen+user-review-requested%3A%40me)
- do/update [sprint plan](https://project.permaplant.net)

## Individual Tasks

To be done until **Friday 19.04.2024**:

- Daniel: finish timeline, drawing
- Filip: GitLab migration
- Jannis: creation times, create issues: (1) tutorial for layer creation (creation/update metadata + (2) what interface should any layer have), (3) notification profilen (4) drawing layer db design, (5) unify layer design
- Christoph: SQL heatmap benchmark, hierarchy PR
- Lukas: documenting how to create+test layers, create issues: investigate performance (profile)
- Moritz: heatmap rebase, meeting refactoring, issues restructure, write if all stale branches can be removed
- Andrei: create issues

## Meeting Notes

- great job with release, please rebase your PRs
- christoph asked if properties should be able to get overwritten in child ranks of plants -> will be discussed in separate meeting. Christoph and Lukas should attend.
- automatic hierarchy based on unique name
- usually no new properties or plants (apart from adding to CSV)
- drawing layer PR will be created so that handling can be tested
- groupfolder for nextcloud images has to be implemented, so that images on one map can be shared between different users
- we shouldn't have to many different tasks in progress but always enough issues created to always have enough for next sprints
7 changes: 5 additions & 2 deletions doc/usecases/assigned/map_deletion.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
- **Precondition:**
The user has opened the app and is on the map management screen.
- **Main success scenario:**
- The user delete a map by selecting it from the list of maps and confirming the deletion.
- If the user decides to undo the deletion within one month, the map is restored.
- The user deletes a map by selecting it from the list of maps.
- The user confirms the deletion with the information:
- a warning that the whole map including all layers will be deleted, but
- it is possible to contact the PermaplanT service team within one month to restore the map.
- Within one month, the PermaplanT service team can restore the map via provided SQL commands.
- **Error scenario:**
There is an error in the map deletion process and the map is not deleted as intended.
In this case, the app displays an error message and allows the user to try again.
Expand Down
2 changes: 2 additions & 0 deletions doc/usecases/assigned/remember_viewing_state.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
He zooms into the map.
He scrolls/drags the map's viewport.
He sets layer _B_ invisible.
He sets layer _C_ with transparency.
He turns off the grid display.
He hides the plant labels.
He closes the browser, opens it again and logs in.
Expand All @@ -26,6 +27,7 @@
- zoomed-in on the map
- all plants visible on the map's viewport
- layer _B_ invisible
- layer _C_ has the same transparency
- grid display turned off
- plant labels hidden
- **Alternative scenario:**
Expand Down
35 changes: 34 additions & 1 deletion frontend/src/__test_utils__/msw_handlers/plants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { http, HttpResponse } from 'msw';
import { Page, PlantsSummaryDto } from '@/api_types/definitions';
import {
Page,
PlantsSummaryDto,
RelationDto,
RelationsDto,
RelationType,
} from '@/api_types/definitions';
import { baseApiUrl } from '@/config';

const allPlants: PlantsSummaryDto[] = [
Expand All @@ -20,6 +26,24 @@ const allPlants: PlantsSummaryDto[] = [
},
];

const allRelationPartners: RelationDto[] = [
{
id: 1,
relation: RelationType.Neutral,
},
{
id: 2,
relation: RelationType.Antagonist,
},
];

const allRelations: RelationsDto[] = [
{
id: 1,
relations: [allRelationPartners[0], allRelationPartners[1]],
},
];

export const handlers = [
http.get(`${baseApiUrl}/api/plants/:id`, () => {
return HttpResponse.json(allPlants[0]);
Expand All @@ -40,4 +64,13 @@ export const handlers = [

return HttpResponse.json(response);
}),

http.get(`${baseApiUrl}/api/:mapId/1/layers/plants/relations`, ({ request }) => {
const url = new URL(request.url);

const plantId = parseInt(url.searchParams.get('plant_id') ?? '-1');
return HttpResponse.json(allRelations[plantId - 1]);
}),
];

export const allPlantsForTesting = allPlants;
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ export function PlantLayerLeftToolbar() {
id: selectedPlanting.id,
x: selectedPlanting.x,
y: selectedPlanting.y,
sizeX: Math.round(sizeX),
sizeY: Math.round(sizeY),
sizeX: isNaN(sizeX) ? selectedPlanting.sizeX : Math.round(sizeX),
sizeY: isNaN(sizeY) ? selectedPlanting.sizeY : Math.round(sizeY),
rotation: selectedPlanting.rotation,
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const PlantingAttributeEditFormSchema = z
addDate: z.nullable(z.string()).transform((value) => value || undefined),
removeDate: z.nullable(z.string()).transform((value) => value || undefined),
plantingNotes: z.nullable(z.string()),
sizeX: z.optional(z.number().int()),
sizeY: z.optional(z.number().int()),
sizeX: z.optional(z.number().int().or(z.nan())),
sizeY: z.optional(z.number().int().or(z.nan())),
})
.refine((schema) => !schema.removeDate || !schema.addDate || schema.addDate < schema.removeDate, {
path: ['dateRelation'],
Expand Down Expand Up @@ -58,6 +58,8 @@ export type PlantingAttributeEditFormProps = EditPlantingAttributesProps & {
addDateShowDifferentValueWarning?: boolean;
removeDateShowDifferentValueWarning?: boolean;
plantingNoteShowDifferentValueWarning?: boolean;
sizeXDifferentValueWarning?: boolean;
sizeYDifferentValueWarning?: boolean;
removeDateDefaultValue: string;
plantingNotesDefaultValue: string;
widthDefaultValue: number | undefined;
Expand Down Expand Up @@ -164,6 +166,12 @@ export function MultiplePlantingsAttributeForm({
plantingNoteShowDifferentValueWarning={plantings.some(
(planting) => planting.plantingNotes !== getCommonPlantingNotes(),
)}
sizeXDifferentValueWarning={plantings.some(
(planting) => planting.sizeX !== getCommonWidth(),
)}
sizeYDifferentValueWarning={plantings.some(
(planting) => planting.sizeY !== getCommonHeight(),
)}
removeDateDefaultValue={getCommonRemoveDate() ?? ''}
plantingNotesDefaultValue={getCommonPlantingNotes() ?? ''}
widthDefaultValue={getCommonWidth()}
Expand All @@ -183,6 +191,8 @@ function PlantingAttributeEditForm({
addDateShowDifferentValueWarning,
removeDateShowDifferentValueWarning,
plantingNoteShowDifferentValueWarning,
sizeXDifferentValueWarning,
sizeYDifferentValueWarning,
removeDateDefaultValue,
plantingNotesDefaultValue,
onWidthChange,
Expand Down Expand Up @@ -264,25 +274,30 @@ function PlantingAttributeEditForm({
<span className="text-neutral-500">{plantCountInfo.total}</span>
</div>
)}
<DebouncedSimpleFormInput
onValid={onWidthChange}
type="number"
id="sizeX"
data-testid="planting-attribute-edit-form__size-x"
disabled={isReadOnlyMode}
labelContent={t('plantings:width')}
className="w-36"
/>

<DebouncedSimpleFormInput
onValid={onHeightChange}
type="number"
id="sizeY"
data-testid="planting-attribute-edit-form__size-y"
disabled={isReadOnlyMode}
labelContent={t('plantings:height')}
className="w-36"
/>
<div className="flex gap-2">
<DebouncedSimpleFormInput
onValid={onWidthChange}
type="number"
id="sizeX"
data-testid="planting-attribute-edit-form__size-x"
disabled={isReadOnlyMode}
labelContent={t('plantings:width')}
className="w-36"
/>
{sizeXDifferentValueWarning && <MultiplePlantingsDifferentValueAlert />}
</div>
<div className="flex gap-2">
<DebouncedSimpleFormInput
onValid={onHeightChange}
type="number"
id="sizeY"
data-testid="planting-attribute-edit-form__size-y"
disabled={isReadOnlyMode}
labelContent={t('plantings:height')}
className="w-36"
/>
{sizeYDifferentValueWarning && <MultiplePlantingsDifferentValueAlert />}
</div>
<hr className="my-4 border-neutral-700" />
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { renderHook, screen, waitFor } from '@testing-library/react';
import { expect } from 'vitest';
import { mockServerErrorOnce } from '@/__test_utils__/msw';
import '@/__test_utils__/setup';
import '@/__test_utils__/setupSessionStorageAuth';
import { createQueryHookWrapper } from '@/__test_utils__/utils';
import { RelationType } from '@/api_types/definitions';
import { useRelations } from '@/features/map_planning/layers/plant/hooks/relationsHookApi';

describe('useRelations', () => {
const renderUseRelations = () =>
renderHook(
() =>
useRelations({
mapId: 1,
plantId: 1,
enabled: true,
}),
{
wrapper: createQueryHookWrapper(),
},
);

it('should return the two relations for the plant', async () => {
const { result } = renderUseRelations();

await waitFor(() => expect(result.current.isSuccess).toBe(true));
expect(result.current.data).toBeDefined();
expect(result.current.data?.has(1));
expect(result.current.data?.has(2));
expect(result.current.data?.get(1)?.id == 1);
expect(result.current.data?.get(1)?.relation == RelationType.Neutral);
expect(result.current.data?.get(2)?.relation == RelationType.Antagonist);
});

it('should cause a toast to appear on failing hook', async () => {
mockServerErrorOnce();
const { result } = renderUseRelations();

await waitFor(() => expect(result.current.isError).toBe(true));
expect(result.current.error).toBeDefined();
await screen.findByRole('alert');
});
});
Loading

0 comments on commit c180740

Please sign in to comment.