1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-19 17:53:39 +00:00

[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
This commit is contained in:
Tom
2024-09-09 16:58:56 -04:00
committed by GitHub
parent 124b4ce822
commit cdb40818a8
2 changed files with 11 additions and 7 deletions

View File

@@ -10,13 +10,17 @@ describe("ImportService", () => {
const mockOrganizationId = "mockOrgId" as OrganizationId; const mockOrganizationId = "mockOrgId" as OrganizationId;
const reportApiService = mock<MemberAccessReportApiService>(); const reportApiService = mock<MemberAccessReportApiService>();
let memberAccessReportService: MemberAccessReportService; let memberAccessReportService: MemberAccessReportService;
const i18nService = mock<I18nService>(); const i18nMock = mock<I18nService>({
t(key) {
return key;
},
});
beforeEach(() => { beforeEach(() => {
reportApiService.getMemberAccessData.mockImplementation(() => reportApiService.getMemberAccessData.mockImplementation(() =>
Promise.resolve(memberAccessReportsMock), Promise.resolve(memberAccessReportsMock),
); );
memberAccessReportService = new MemberAccessReportService(reportApiService, i18nService); memberAccessReportService = new MemberAccessReportService(reportApiService, i18nMock);
}); });
describe("generateMemberAccessReportView", () => { describe("generateMemberAccessReportView", () => {
@@ -92,16 +96,16 @@ describe("ImportService", () => {
expect.objectContaining({ expect.objectContaining({
email: "sjohnson@email.com", email: "sjohnson@email.com",
name: "Sarah Johnson", name: "Sarah Johnson",
twoStepLogin: "On", twoStepLogin: "memberAccessReportTwoFactorEnabledTrue",
accountRecovery: "On", accountRecovery: "memberAccessReportAuthenticationEnabledTrue",
group: "Group 1", group: "Group 1",
totalItems: "20", totalItems: "20",
}), }),
expect.objectContaining({ expect.objectContaining({
email: "jlull@email.com", email: "jlull@email.com",
name: "James Lull", name: "James Lull",
twoStepLogin: "Off", twoStepLogin: "memberAccessReportTwoFactorEnabledFalse",
accountRecovery: "Off", accountRecovery: "memberAccessReportAuthenticationEnabledFalse",
group: "Group 4", group: "Group 4",
totalItems: "5", totalItems: "5",
}), }),

View File

@@ -82,7 +82,7 @@ export class MemberAccessReportService {
: this.i18nService.t("memberAccessReportNoCollection"), : this.i18nService.t("memberAccessReportNoCollection"),
collectionPermission: detail.collectionId collectionPermission: detail.collectionId
? this.getPermissionText(detail) ? this.getPermissionText(detail)
: this.i18nService.t("memberAccessReportNoCollection"), : this.i18nService.t("memberAccessReportNoCollectionPermission"),
totalItems: detail.itemCount.toString(), totalItems: detail.itemCount.toString(),
}; };
}); });