Skip to content

Commit

Permalink
Fix tests because of new gql enums (PublishType, AscentType).
Browse files Browse the repository at this point in the history
  • Loading branch information
salamca committed Sep 10, 2024
1 parent bd5dc17 commit c103dbd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
14 changes: 11 additions & 3 deletions test/e2e/activity.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import { MailService } from '../../src/notification/services/mail.service';
import { initializeDbConn, prepareEnvironment, seedDatabase } from './helpers';
import { UsersModule } from '../../src/users/users.module';
import { CragsModule } from '../../src/crags/crags.module';
import { AscentType } from '../../src/activities/entities/activity-route.entity';
import {
AscentType,
PublishType,
} from '../../src/activities/entities/activity-route.entity';
import {
Activity,
ActivityType,
Expand Down Expand Up @@ -304,13 +307,18 @@ describe('Activity', () => {
const numOfNonPublicActivityRoutes =
response.body.data.activities.items.filter(
(a) =>
a.routes.filter((ar) => !['public'].includes(ar.publish)).length > 0,
a.routes.filter(
(ar) => ![PublishType.PUBLIC].includes(ar.publish.toLowerCase()),
).length > 0,
).length;
expect(numOfNonPublicActivityRoutes).toEqual(0);

const numOfActivitiesWithNoPublicActivityRoutes =
response.body.data.activities.items.filter(
(a) => !a.routes.some((ar) => ['public'].includes(ar.publish)),
(a) =>
!a.routes.some((ar) =>
[PublishType.PUBLIC].includes(ar.publish.toLowerCase()),
),
).length;
expect(numOfActivitiesWithNoPublicActivityRoutes).toEqual(0);

Expand Down
26 changes: 17 additions & 9 deletions test/e2e/activityRoutes.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ describe('Activity', () => {
queryResponse.body.data.activity.routes.filter(
(r) =>
r.route.id == mockRoutes[0].id &&
!(r.ascentType == AscentType.REPEAT),
!(r.ascentType.toLowerCase() == AscentType.REPEAT),
)[0].orderScore,
).toBe(mockRoutes[0].difficulty + 100);
expect(
Expand All @@ -207,27 +207,31 @@ describe('Activity', () => {
expect(
queryResponse.body.data.activity.routes.filter(
(r) =>
r.route.id == mockRoutes[2].id && r.AscentType != AscentType.REPEAT,
r.route.id == mockRoutes[2].id &&
r.ascentType.toLowerCase() != AscentType.REPEAT,
)[0].orderScore,
).toBe(mockRoutes[2].difficulty);
expect(
queryResponse.body.data.activity.routes.filter(
(r) =>
r.route.id == mockRoutes[2].id && r.AscentType != AscentType.REPEAT,
r.route.id == mockRoutes[2].id &&
r.ascentType.toLowerCase() != AscentType.REPEAT,
)[0].rankingScore,
).toBe(mockRoutes[2].difficulty);

// check repeat scores
expect(
queryResponse.body.data.activity.routes.filter(
(r) =>
r.route.id == mockRoutes[2].id && r.ascentType == AscentType.REPEAT,
r.route.id == mockRoutes[2].id &&
r.ascentType.toLowerCase() == AscentType.REPEAT,
)[0].orderScore,
).toBe(mockRoutes[2].difficulty - 10);
expect(
queryResponse.body.data.activity.routes.filter(
(r) =>
r.route.id == mockRoutes[2].id && r.ascentType == AscentType.REPEAT,
r.route.id == mockRoutes[2].id &&
r.ascentType.toLowerCase() == AscentType.REPEAT,
)[0].rankingScore,
).toBe(0);

Expand Down Expand Up @@ -295,27 +299,31 @@ describe('Activity', () => {
expect(
queryResponse.body.data.activity.routes.filter(
(r) =>
r.route.id == mockRoutes[8].id && r.AscentType != AscentType.T_REPEAT,
r.route.id == mockRoutes[8].id &&
r.ascentType.toLowerCase() != AscentType.T_REPEAT,
)[0].orderScore,
).toBe(mockRoutes[8].difficulty * 0.0001);
expect(
queryResponse.body.data.activity.routes.filter(
(r) =>
r.route.id == mockRoutes[8].id && r.AscentType != AscentType.T_REPEAT,
r.route.id == mockRoutes[8].id &&
r.ascentType.toLowerCase() != AscentType.T_REPEAT,
)[0].rankingScore,
).toBe(0);

// check tr repeat scores
expect(
queryResponse.body.data.activity.routes.filter(
(r) =>
r.route.id == mockRoutes[8].id && r.ascentType == AscentType.T_REPEAT,
r.route.id == mockRoutes[8].id &&
r.ascentType.toLowerCase() == AscentType.T_REPEAT,
)[0].orderScore,
).toBe((mockRoutes[8].difficulty - 10) * 0.0001);
expect(
queryResponse.body.data.activity.routes.filter(
(r) =>
r.route.id == mockRoutes[8].id && r.ascentType == AscentType.T_REPEAT,
r.route.id == mockRoutes[8].id &&
r.ascentType.toLowerCase() == AscentType.T_REPEAT,
)[0].rankingScore,
).toBe(0);

Expand Down

0 comments on commit c103dbd

Please sign in to comment.