Skip to content

Commit

Permalink
resolved merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Ajen07 committed May 11, 2024
2 parents 20fdf5b + fdbf79d commit fec3b07
Show file tree
Hide file tree
Showing 13 changed files with 128 additions and 41 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Another example [here](https://co-pilot.dev/changelog)
- Add new endpoints to select/reset team project ideation ([#136](https://github.com/chingu-x/chingu-dashboard-be/pull/136))
- Add CASL ability for Access control ([#141](https://github.com/chingu-x/chingu-dashboard-be/pull/141))
- Add sprint checkin form submission status for a user ([#149](https://github.com/chingu-x/chingu-dashboard-be/pull/149))
- new command to run both e2e and unit test ([#148](https://github.com/chingu-x/chingu-dashboard-be/pull/148))

### Changed

Expand All @@ -50,9 +51,14 @@ Another example [here](https://co-pilot.dev/changelog)
- updated meeting model schema to include optional description field [#135](https://github.com/chingu-x/chingu-dashboard-be/pull/135)
- Remove teamMeetings from response for getSprintDatesByTeamId [#139](https://github.com/chingu-x/chingu-dashboard-be/pull/139)
- Updated response for route GET sprints/meetings/{meetingId} to include updatedAt for agendas [#140](https://github.com/chingu-x/chingu-dashboard-be/pull/140)
- Updated response for route GET /sprints/teams/{teamId} to include voyage start and end dates [#147](https://github.com/chingu-x/chingu-dashboard-be/pull/147)
- Update test github actions workflow with timeout [#143](https://github.com/chingu-x/chingu-dashboard-be/pull/143)
- Refractor of all form title reference to use values from formTitle.ts [#145](https://github.com/chingu-x/chingu-dashboard-be/pull/145)
- Update/Add more form input types [#146](https://github.com/chingu-x/chingu-dashboard-be/pull/146)
- Update seed files (include a time for sprint end dates, add url input type) [#151](https://github.com/chingu-x/chingu-dashboard-be/pull/151)
- Update the deleteFeature method to use a DeleteFeatureResponse and return an object with a successful status and a message [#150](https://github.com/chingu-x/chingu-dashboard-be/pull/150)



### Fixed

Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ $ yarn start:prod
## Test<a name="tests"></a>

```bash
# all tests (unit and e2e for now)
$ yarn test

# unit tests
$ yarn test
$ yarn test:unit

# e2e tests
$ yarn test:e2e
Expand All @@ -96,8 +99,11 @@ $ yarn test:cov

If using the docker terminal the commands would be
```bash
# all tests (unit and e2e for now)
$ yarn test:docker

# unit tests
$ yarn test:docker
$ yarn test:unit:docker

# e2e tests
$ yarn test:e2e:docker
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"studio:test:docker": "dotenv -v DATABASE_URL=postgresql://chingu:chingu@postgres-test:5434/dashboard?schema=public prisma studio",
"seed": "prisma db seed",
"lint": "eslint \"{prisma/*seed,src,test}/**/*.ts\" --fix",
"test": "dotenv -e ./.env.test jest",
"test:docker": "dotenv -v NODE_ENV=test -v DATABASE_URL=postgresql://chingu:chingu@postgres-test:5434/dashboard?schema=public jest",
"test:unit": "dotenv -e ./.env.test jest",
"test:unit:docker": "dotenv -v NODE_ENV=test -v DATABASE_URL=postgresql://chingu:chingu@postgres-test:5434/dashboard?schema=public jest",
"test:watch": "dotenv -e ./.env.test jest --watch",
"test:watch:docker": "dotenv -v NODE_ENV=test -v DATABASE_URL=postgresql://chingu:chingu@postgres-test:5434/dashboard?schema=public jest --watch",
"test:cov": "dotenv -e ./.env.test jest --coverage",
Expand All @@ -37,7 +37,9 @@
"test:int": "dotenv -e ./.env.test -- jest -i --no-cache --verbose --config ./test/jest-int.json",
"test:int:docker": "dotenv -v NODE_ENV=test -v DATABASE_URL=postgresql://chingu:chingu@postgres-test:5434/dashboard?schema=public -- jest -i --no-cache --verbose --config ./test/jest-int.json",
"test:e2e": "dotenv -e ./.env.test -- jest --config ./test/jest-e2e.json --runInBand",
"test:e2e:docker": "dotenv -v NODE_ENV=test -v DATABASE_URL=postgresql://chingu:chingu@postgres-test:5434/dashboard?schema=public -- jest --config ./test/jest-e2e.json --runInBand"
"test:e2e:docker": "dotenv -v NODE_ENV=test -v DATABASE_URL=postgresql://chingu:chingu@postgres-test:5434/dashboard?schema=public -- jest --config ./test/jest-e2e.json --runInBand",
"test:docker": "yarn test:e2e:docker --silent && yarn test:unit:docker --silent",
"test": "yarn test:e2e --silent && yarn test:unit --silent"
},
"dependencies": {
"@casl/ability": "^6.7.1",
Expand Down
6 changes: 3 additions & 3 deletions prisma/seed/forms/voyage-project-submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const populateVoyageSubmissionForm = async () => {
order: 3,
inputType: {
connect: {
name: "text",
name: "url",
},
},
text: "Please link your Github repo:",
Expand All @@ -48,7 +48,7 @@ export const populateVoyageSubmissionForm = async () => {
order: 4,
inputType: {
connect: {
name: "text",
name: "url",
},
},
text: "Please link your deployed project:",
Expand All @@ -58,7 +58,7 @@ export const populateVoyageSubmissionForm = async () => {
order: 5,
inputType: {
connect: {
name: "text",
name: "url",
},
},
text: "If you have a project showcase video, please provide the public link:",
Expand Down
9 changes: 9 additions & 0 deletions prisma/seed/responses/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,15 @@ export const populateQuestionResponses = async (
});
break;
}
case "url": {
await prisma.response.create({
data: {
...data,
text: `https://www.randomUrl${question.id}.com`,
},
});
break;
}
default: {
throw new Error("Prisma seed: Unexpected question type");
}
Expand Down
48 changes: 42 additions & 6 deletions prisma/seed/sprints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,68 @@ export const populateSprints = async () => {
{
number: 1,
startDate: voyage.startDate,
endDate: addDays(voyage.startDate, 6),
endDate: new Date(
addDays(voyage.startDate, 6).setHours(
23,
59,
59,
),
),
},
{
number: 2,
startDate: addDays(voyage.startDate, 7),
endDate: addDays(voyage.startDate, 13),
endDate: new Date(
addDays(voyage.startDate, 13).setHours(
23,
59,
59,
),
),
},
{
number: 3,
startDate: addDays(voyage.startDate, 14),
endDate: addDays(voyage.startDate, 20),
endDate: new Date(
addDays(voyage.startDate, 20).setHours(
23,
59,
59,
),
),
},
{
number: 4,
startDate: addDays(voyage.startDate, 21),
endDate: addDays(voyage.startDate, 27),
endDate: new Date(
addDays(voyage.startDate, 27).setHours(
23,
59,
59,
),
),
},
{
number: 5,
startDate: addDays(voyage.startDate, 28),
endDate: addDays(voyage.startDate, 34),
endDate: new Date(
addDays(voyage.startDate, 34).setHours(
23,
59,
59,
),
),
},
{
number: 6,
startDate: addDays(voyage.startDate, 35),
endDate: addDays(voyage.startDate, 41),
endDate: new Date(
addDays(voyage.startDate, 41).setHours(
23,
59,
59,
),
),
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion prisma/seed/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { prisma } from "../prisma-client";

export const addDays = (date, days) => {
export const addDays = (date, days: number) => {
const newDate = new Date(date);
newDate.setDate(newDate.getDate() + days);
return newDate;
Expand Down
24 changes: 12 additions & 12 deletions prisma/seed/voyage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ export const populateVoyages = async () => {
},
},
startDate: new Date("2023-11-06"),
endDate: new Date("2023-12-17"),
soloProjectDeadline: new Date("2023-11-04"),
certificateIssueDate: new Date("2023-12-31"),
endDate: new Date("2023-12-17T23:59:59.000Z"),
soloProjectDeadline: new Date("2023-11-04T23:59:59.000Z"),
certificateIssueDate: new Date("2023-12-31T23:59:59.000Z"),
},
});

Expand All @@ -25,9 +25,9 @@ export const populateVoyages = async () => {
},
},
startDate: new Date("2024-01-08"),
endDate: new Date("2024-02-18"),
soloProjectDeadline: new Date("2023-12-31"),
certificateIssueDate: new Date("2024-02-25"),
endDate: new Date("2024-02-18T23:59:59.000Z"),
soloProjectDeadline: new Date("2023-12-31T23:59:59.000Z"),
certificateIssueDate: new Date("2024-02-25T23:59:59.000Z"),
},
});
await prisma.voyage.create({
Expand All @@ -39,9 +39,9 @@ export const populateVoyages = async () => {
},
},
startDate: new Date("2024-03-05"),
endDate: new Date("2024-04-14"),
soloProjectDeadline: new Date("2024-02-25"),
certificateIssueDate: new Date("2024-04-21"),
endDate: new Date("2024-04-14T23:59:59.000Z"),
soloProjectDeadline: new Date("2024-02-25T23:59:59.000Z"),
certificateIssueDate: new Date("2024-04-21T23:59:59.000Z"),
},
});
await prisma.voyage.create({
Expand All @@ -53,9 +53,9 @@ export const populateVoyages = async () => {
},
},
startDate: new Date("2024-05-06"),
endDate: new Date("2024-06-16"),
soloProjectDeadline: new Date("2024-04-28"),
certificateIssueDate: new Date("2024-06-23"),
endDate: new Date("2024-06-16T23:59:59.000Z"),
soloProjectDeadline: new Date("2024-04-28T23:59:59.000Z"),
certificateIssueDate: new Date("2024-06-23T23:59:59.000Z"),
},
});
};
2 changes: 2 additions & 0 deletions src/features/features.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
FeatureCategoriesResponse,
ExtendedFeaturesResponse,
FeatureResponse,
DeleteFeatureResponse,
} from "./features.response";
import { CustomRequest } from "../global/types/CustomRequest";

Expand Down Expand Up @@ -256,6 +257,7 @@ export class FeaturesController {
@ApiResponse({
status: HttpStatus.OK,
description: "Successfully deleted feature.",
type: DeleteFeatureResponse,
})
//Can only delete if loggedIn userId mataches addedBy userId
@Delete("/features/:featureId")
Expand Down
8 changes: 8 additions & 0 deletions src/features/features.response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,11 @@ export class ExtendedFeaturesResponse {
@ApiProperty()
addedBy: AddedBY;
}

export class DeleteFeatureResponse {
@ApiProperty({ example: "The feature was deleted successfully" })
message: string;

@ApiProperty({ example: 200 })
statusCode: number;
}
5 changes: 5 additions & 0 deletions src/features/features.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,11 @@ export class FeaturesService {
throw new NotFoundException(
`FeatureId (id: ${featureId}) does not exist.`,
);
} else {
return {
message: "Feature deleted successfully",
status: 200,
};
}
}

Expand Down
11 changes: 10 additions & 1 deletion src/sprints/sprints.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,16 @@ export class SprintsService {
select: {
id: true,
name: true,
endDate: true,
voyage: {
select: {
id: true,
number: true,
soloProjectDeadline: true,
certificateIssueDate: true,
showcasePublishDate: true,
startDate: true,
endDate: true,
sprints: {
select: {
id: true,
Expand All @@ -129,7 +135,10 @@ export class SprintsService {
if (!teamSprintDates) {
throw new NotFoundException(`Invalid teamId: ${teamId}`);
}
return teamSprintDates;
//copy teamVoyage endDate to voyage object
teamSprintDates.voyage.endDate = teamSprintDates.endDate;
delete teamSprintDates.endDate;
return teamSprintDates.voyage;
}

async getMeetingById(meetingId: number) {
Expand Down
30 changes: 17 additions & 13 deletions test/sprints.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,23 @@ describe("Sprints Controller (e2e)", () => {
expect(res.body).toEqual(
expect.objectContaining({
id: expect.any(Number),
name: expect.any(String),
voyage: expect.objectContaining({
id: expect.any(Number),
number: expect.any(String),
sprints: expect.arrayContaining([
expect.objectContaining({
id: expect.any(Number),
number: expect.any(Number),
startDate: expect.any(String),
endDate: expect.any(String),
}),
]),
}),
number: expect.any(String),
soloProjectDeadline: expect.any(String),
certificateIssueDate: expect.any(String),
showcasePublishDate: expect.toBeOneOf([
null,
expect.any(String),
]),
startDate: expect.any(String),
endDate: expect.any(String),
sprints: expect.arrayContaining([
expect.objectContaining({
id: expect.any(Number),
number: expect.any(Number),
startDate: expect.any(String),
endDate: expect.any(String),
}),
]),
}),
);
});
Expand Down

0 comments on commit fec3b07

Please sign in to comment.