Skip to content

Commit

Permalink
test: accounts of deleted identities are remove on app startup
Browse files Browse the repository at this point in the history
  • Loading branch information
Milena-Czierlinski committed Dec 13, 2024
1 parent 822a2eb commit c08f8a0
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions packages/app-runtime/test/runtime/Startup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,35 +70,37 @@ describe("Start Accounts", function () {

let sessionA: LocalAccountSession;

let errorSpy: jest.SpyInstance<void, [message?: any, ...optionalParams: any[]], any>;

beforeAll(async function () {
runtime = await TestUtil.createRuntime();
await runtime.start();

const accounts = await TestUtil.provideAccounts(runtime, 1);
sessionA = await runtime.selectAccount(accounts[0].id);

errorSpy = jest.spyOn(console, "error").mockImplementation(() => {});
});

afterEach(() => errorSpy.mockRestore());

afterAll(async () => await runtime.stop());

test("should run startAccounts for an active Identity", async function () {
await runtime["startAccounts"]();
expect(errorSpy).not.toHaveBeenCalled();
await expect(runtime.selectAccount(sessionA.account.id)).rejects.not.toThrow();
});

test("should run startAccounts for an Identity with expired grace period", async function () {
await sessionA.transportServices.identityDeletionProcesses["initiateIdentityDeletionProcessUseCase"]["identityDeletionProcessController"].initiateIdentityDeletionProcess(
0
);

await runtime["startAccounts"]();
await expect(runtime.selectAccount(sessionA.account.id)).rejects.toThrow("error.transport.recordNotFound");
});

test.only("should run startAccounts for a deleted Identity", async function () {
test("should run startAccounts for a deleted Identity", async function () {
await sessionA.transportServices.identityDeletionProcesses["initiateIdentityDeletionProcessUseCase"]["identityDeletionProcessController"].initiateIdentityDeletionProcess(
0
);
// await TestUtil.runDeletionJob();
await TestUtil.runDeletionJob();

await runtime["startAccounts"]();
// TODO: check for error message
expect(errorSpy).toHaveBeenCalled();
await expect(runtime.selectAccount(sessionA.account.id)).rejects.toThrow("error.transport.recordNotFound");
});
});

0 comments on commit c08f8a0

Please sign in to comment.