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

Fix project urls #383

Merged
merged 1 commit into from
Mar 27, 2023
Merged
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
10 changes: 5 additions & 5 deletions e2e/test/project.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async function createProject(page: Page, project: InvestmentProject) {
// Go to the new project page
await page.getByRole('button', { name: 'Luo uusi hanke' }).click();
await page.getByRole('menuitem', { name: 'Uusi investointihanke' }).click();
await expect(page).toHaveURL('https://localhost:1443/hanke/luo');
await expect(page).toHaveURL('https://localhost:1443/investointihanke/luo');

// Fill in the project data and save the project
await page.locator('input[name="projectName"]').fill(project.projectName);
Expand All @@ -70,7 +70,7 @@ async function createProject(page: Page, project: InvestmentProject) {
await page.getByRole('button', { name: 'Lisää hanke' }).click();

// URL should include the newly created project ID, parse it from the URL
await expect(page).toHaveURL(/https:\/\/localhost:1443\/hanke\/[0-9a-f-]+/);
await expect(page).toHaveURL(/https:\/\/localhost:1443\/investointihanke\/[0-9a-f-]+/);
const projectId = page.url().split('/').at(-1);

await client.project.updateGeometry.mutate(geometryPayload(projectId, keskustoriGeom));
Expand All @@ -88,15 +88,15 @@ async function createProject(page: Page, project: InvestmentProject) {

async function deleteProject(page: Page, projectId: string) {
// Go to the project page
await page.goto(`https://localhost:1443/hanke/${projectId}`);
await page.goto(`https://localhost:1443/investointihanke/${projectId}`);

// Delete the project
await page.getByRole('button', { name: 'Poista hanke' }).click();
await page.getByRole('button', { name: 'Poista' }).click();
await expect(page).toHaveURL('https://localhost:1443/hankkeet');

// Expect the project page to not exist anymore
await page.goto(`https://localhost:1443/hanke/${projectId}`);
await page.goto(`https://localhost:1443/investointihanke/${projectId}`);
await expect(page.getByText('Hanketta ei löytynyt')).toBeVisible();
await page.goto('https://localhost:1443/hankkeet');
}
Expand All @@ -118,7 +118,7 @@ test.describe('Projects', () => {

// Click on the new project button to go back to the project page
await page.locator(`text=${project.projectName}`).click();
await expect(page).toHaveURL(`https://localhost:1443/hanke/${project.id}`);
await expect(page).toHaveURL(`https://localhost:1443/investointihanke/${project.id}`);

// Check that all fields still have the same values
await expect(page.locator('input[name="projectName"]')).toHaveValue(project.projectName);
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ const router = createBrowserRouter(
<Route path="/" element={<Layout />}>
<Route index element={<ProjectsPage />} />
<Route path="hankkeet" element={<ProjectsPage />} />
<Route path="hanke/luo" element={<InvestmentProject />} />
<Route path="hanke/:projectId" element={<InvestmentProject />} />
<Route path="investointihanke/luo" element={<InvestmentProject />} />
<Route path="investointihanke/:projectId" element={<InvestmentProject />} />
<Route
path="hanke/:projectId/uusi-kohde"
path="investointihanke/:projectId/uusi-kohde"
element={<ProjectObject projectType="investointihanke" />}
/>
<Route path="hanke/:projectId/:tabView" element={<InvestmentProject />} />
<Route path="investointihanke/:projectId/:tabView" element={<InvestmentProject />} />
<Route
path="hanke/:projectId/kohde/:projectObjectId"
path="investointihanke/:projectId/kohde/:projectObjectId"
element={<ProjectObject projectType="investointihanke" />}
/>
<Route
path="hanke/:projectId/kohde/:projectObjectId/:tabView"
path="investointihanke/:projectId/kohde/:projectObjectId/:tabView"
element={<ProjectObject projectType="investointihanke" />}
/>
<Route path="asemakaavahanke/luo" element={<DetailplanProject />} />
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/views/Project/InvestmentProject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,25 @@ function projectTabs(projectId: string) {
return [
{
tabView: 'default',
url: `/hanke/${projectId}`,
url: `/investointihanke/${projectId}`,
label: 'project.mapTabLabel',
icon: <Map fontSize="small" />,
},
{
tabView: 'talous',
url: `/hanke/${projectId}/talous`,
url: `/investointihanke/${projectId}/talous`,
label: 'project.financeTabLabel',
icon: <Euro fontSize="small" />,
},
{
tabView: 'kohteet',
url: `/hanke/${projectId}/kohteet`,
url: `/investointihanke/${projectId}/kohteet`,
label: 'project.projectObjectsTabLabel',
icon: <ListAlt fontSize="small" />,
},
{
tabView: 'sidoshankkeet',
url: `/hanke/${projectId}/sidoshankkeet`,
url: `/investointihanke/${projectId}/sidoshankkeet`,
label: 'project.relatedProjectsTabLabel',
icon: <AccountTree fontSize="small" />,
},
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/Project/InvestmentProjectForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export function InvestmentProjectForm(props: InvestmentProjectFormProps) {
onSuccess: (data) => {
// Navigate to new url if we are creating a new project
if (!props.project && data.id) {
navigate(`/hanke/${data.id}`);
navigate(`/investointihanke/${data.id}`);
} else {
queryClient.invalidateQueries({
queryKey: [['project', 'get'], { input: { id: data.id } }],
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/views/Project/Projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function Toolbar() {
horizontal: 'right',
}}
>
<MenuItem component={Link} to="/hanke/luo">
<MenuItem component={Link} to="/investointihanke/luo">
<ListItemIcon>
<Add />
</ListItemIcon>
Expand Down Expand Up @@ -99,7 +99,7 @@ const projectCardStyle = css`

const projectTypeRootUrl = {
detailplanProject: '/asemakaavahanke',
investmentProject: '/hanke',
investmentProject: '/investointihanke',
};

function ProjectCard({ result }: { result: DbProject }) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/Project/RelationsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export function RelationsContainer({
objectOfRelation.projectName
)}
>
<Link css={linkStyle} to={`/hanke/${objectOfRelation.projectId}`}>
<Link css={linkStyle} to={`/investointihanke/${objectOfRelation.projectId}`}>
{objectOfRelation.projectName}
</Link>
</Tooltip>
Expand Down