Skip to content

Commit

Permalink
fix: v2 e2e tests (#14655)
Browse files Browse the repository at this point in the history
* fix: oauth-clients-users e2e -> auth was changed from access token to client secret header

* fix: Gcal e2e

* remove gcal module

* simplify gcal override
  • Loading branch information
supalarry committed Apr 18, 2024
1 parent 842be66 commit 8b2e46a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
17 changes: 17 additions & 0 deletions apps/api/v2/src/ee/gcal/gcal.controller.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { bootstrap } from "@/app";
import { AppModule } from "@/app.module";
import { CalendarsService } from "@/ee/calendars/services/calendars.service";
import { HttpExceptionFilter } from "@/filters/http-exception.filter";
import { PrismaExceptionFilter } from "@/filters/prisma-exception.filter";
import { PermissionsGuard } from "@/modules/auth/guards/permissions/permissions.guard";
Expand All @@ -18,6 +19,20 @@ import { UserRepositoryFixture } from "test/fixtures/repository/users.repository

const CLIENT_REDIRECT_URI = "http://localhost:5555";

class CalendarsServiceMock {
async getCalendars() {
return {
connectedCalendars: [
{
integration: {
type: "google_calendar",
},
},
],
};
}
}

describe("Platform Gcal Endpoints", () => {
let app: INestApplication;

Expand All @@ -42,6 +57,8 @@ describe("Platform Gcal Endpoints", () => {
.useValue({
canActivate: () => true,
})
.overrideProvider(CalendarsService)
.useClass(CalendarsServiceMock)
.compile();

app = moduleRef.createNestApplication();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ describe("OAuth Client Users Endpoints", () => {
it(`/GET/:id`, async () => {
const response = await request(app.getHttpServer())
.get(`/api/v2/oauth-clients/${oAuthClient.id}/users/${postResponseData.user.id}`)
.set("Authorization", `Bearer ${postResponseData.accessToken}`)
.set("x-cal-secret-key", oAuthClient.secret)
.set("Origin", `${CLIENT_REDIRECT_URI}`)
.expect(200);

Expand All @@ -216,7 +216,7 @@ describe("OAuth Client Users Endpoints", () => {

const response = await request(app.getHttpServer())
.patch(`/api/v2/oauth-clients/${oAuthClient.id}/users/${postResponseData.user.id}`)
.set("Authorization", `Bearer ${postResponseData.accessToken}`)
.set("x-cal-secret-key", oAuthClient.secret)
.set("Origin", `${CLIENT_REDIRECT_URI}`)
.send(body)
.expect(200);
Expand All @@ -231,7 +231,7 @@ describe("OAuth Client Users Endpoints", () => {
it(`/DELETE/:id`, () => {
return request(app.getHttpServer())
.delete(`/api/v2/oauth-clients/${oAuthClient.id}/users/${postResponseData.user.id}`)
.set("Authorization", `Bearer ${postResponseData.accessToken}`)
.set("x-cal-secret-key", oAuthClient.secret)
.set("Origin", `${CLIENT_REDIRECT_URI}`)
.expect(200);
});
Expand Down

0 comments on commit 8b2e46a

Please sign in to comment.