-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(projects): can't update project info
Refs MARXAN-874, MARXAN-769
- Loading branch information
1 parent
d47e9cd
commit 241a23f
Showing
4 changed files
with
78 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { FixtureType } from '@marxan/utils/tests/fixture-type'; | ||
import { getFixtures } from './update-project.fixtures'; | ||
|
||
let fixtures: FixtureType<typeof getFixtures>; | ||
|
||
beforeEach(async () => { | ||
fixtures = await getFixtures(); | ||
}); | ||
|
||
afterEach(async () => { | ||
await fixtures?.cleanup(); | ||
}); | ||
|
||
test(`updating a project should work`, async () => { | ||
await fixtures.GivenProjectWasCreated(); | ||
|
||
await fixtures.WhenProjectIsUpdated(); | ||
|
||
await fixtures.ThenWhenReadingProjectItHasNewData(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { bootstrapApplication } from '../utils/api-application'; | ||
import { GivenUserIsLoggedIn } from '../steps/given-user-is-logged-in'; | ||
import { OrganizationsTestUtils } from '../utils/organizations.test.utils'; | ||
import { E2E_CONFIG } from '../e2e.config'; | ||
import { ProjectsTestUtils } from '../utils/projects.test.utils'; | ||
import * as request from 'supertest'; | ||
|
||
export const getFixtures = async () => { | ||
const app = await bootstrapApplication(); | ||
const token = await GivenUserIsLoggedIn(app); | ||
const organizationId = ( | ||
await OrganizationsTestUtils.createOrganization(app, token, { | ||
...E2E_CONFIG.organizations.valid.minimal(), | ||
name: `Org name ${Date.now()}`, | ||
}) | ||
).data.id; | ||
let projectId: string; | ||
return { | ||
cleanup: async () => { | ||
await ProjectsTestUtils.deleteProject(app, token, projectId); | ||
await OrganizationsTestUtils.deleteOrganization( | ||
app, | ||
token, | ||
organizationId, | ||
); | ||
await app.close(); | ||
}, | ||
GivenProjectWasCreated: async () => { | ||
projectId = ( | ||
await ProjectsTestUtils.createProject(app, token, { | ||
name: `Test`, | ||
organizationId, | ||
metadata: {}, | ||
}) | ||
).data.id; | ||
}, | ||
WhenProjectIsUpdated: async () => | ||
await request(app.getHttpServer()) | ||
.patch(`/api/v1/projects/${projectId}`) | ||
.set('Authorization', `Bearer ${token}`) | ||
.send({ | ||
name: 'Test updated', | ||
}), | ||
ThenWhenReadingProjectItHasNewData: async () => { | ||
const projectData = await request(app.getHttpServer()) | ||
.get(`/api/v1/projects/${projectId}`) | ||
.set('Authorization', `Bearer ${token}`); | ||
|
||
expect(projectData.body.data.attributes.name).toBe('Test updated'); | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -214,4 +214,4 @@ | |
"@marxan/planning-unit-features": "<rootDir>/libs/planning-unit-features/src" | ||
} | ||
} | ||
} | ||
} |