From cdb40818a8e8f395b48c9dc2b1195365acedb6f8 Mon Sep 17 00:00:00 2001 From: Tom <144813356+ttalty@users.noreply.github.com> Date: Mon, 9 Sep 2024 16:58:56 -0400 Subject: [PATCH] [AC-2614] Member access test fix (#10969) * Initial setup and modifications for member access report api implementation * Adding the permissions logic for getting the permissions text * fixing the test cases * Some refactoring on async calls * Comments on the model * Resolving the mock issue * messages * Localization of text * One more file to fix merge * Fixing test case localization lookup * Fixed permissions lookup --- .../member-access-report.service.spec.ts | 16 ++++++++++------ .../services/member-access-report.service.ts | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/bitwarden_license/bit-web/src/app/tools/reports/member-access-report/services/member-access-report.service.spec.ts b/bitwarden_license/bit-web/src/app/tools/reports/member-access-report/services/member-access-report.service.spec.ts index 20d33e314a..6aab54f77d 100644 --- a/bitwarden_license/bit-web/src/app/tools/reports/member-access-report/services/member-access-report.service.spec.ts +++ b/bitwarden_license/bit-web/src/app/tools/reports/member-access-report/services/member-access-report.service.spec.ts @@ -10,13 +10,17 @@ describe("ImportService", () => { const mockOrganizationId = "mockOrgId" as OrganizationId; const reportApiService = mock(); let memberAccessReportService: MemberAccessReportService; - const i18nService = mock(); + const i18nMock = mock({ + t(key) { + return key; + }, + }); beforeEach(() => { reportApiService.getMemberAccessData.mockImplementation(() => Promise.resolve(memberAccessReportsMock), ); - memberAccessReportService = new MemberAccessReportService(reportApiService, i18nService); + memberAccessReportService = new MemberAccessReportService(reportApiService, i18nMock); }); describe("generateMemberAccessReportView", () => { @@ -92,16 +96,16 @@ describe("ImportService", () => { expect.objectContaining({ email: "sjohnson@email.com", name: "Sarah Johnson", - twoStepLogin: "On", - accountRecovery: "On", + twoStepLogin: "memberAccessReportTwoFactorEnabledTrue", + accountRecovery: "memberAccessReportAuthenticationEnabledTrue", group: "Group 1", totalItems: "20", }), expect.objectContaining({ email: "jlull@email.com", name: "James Lull", - twoStepLogin: "Off", - accountRecovery: "Off", + twoStepLogin: "memberAccessReportTwoFactorEnabledFalse", + accountRecovery: "memberAccessReportAuthenticationEnabledFalse", group: "Group 4", totalItems: "5", }), diff --git a/bitwarden_license/bit-web/src/app/tools/reports/member-access-report/services/member-access-report.service.ts b/bitwarden_license/bit-web/src/app/tools/reports/member-access-report/services/member-access-report.service.ts index 0548841e8c..3616893e23 100644 --- a/bitwarden_license/bit-web/src/app/tools/reports/member-access-report/services/member-access-report.service.ts +++ b/bitwarden_license/bit-web/src/app/tools/reports/member-access-report/services/member-access-report.service.ts @@ -82,7 +82,7 @@ export class MemberAccessReportService { : this.i18nService.t("memberAccessReportNoCollection"), collectionPermission: detail.collectionId ? this.getPermissionText(detail) - : this.i18nService.t("memberAccessReportNoCollection"), + : this.i18nService.t("memberAccessReportNoCollectionPermission"), totalItems: detail.itemCount.toString(), }; });