Skip to content

Commit

Permalink
Add Integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
mcayuelas-ledger committed Jun 7, 2024
1 parent c9d1d50 commit c2e6a1f
Showing 1 changed file with 72 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/**
* @jest-environment jsdom
*/
import "@testing-library/jest-dom";
import { describe, it, expect, jest } from "@jest/globals";

import React from "react";
import { render, screen, waitFor } from "tests/testUtils";
import WalletSyncRow from "~/renderer/screens/settings/sections/General/WalletSync";
import { Flow, Step } from "~/renderer/reducers/walletSync";

const WalletSyncTestApp = () => (
<>
<div id="modals"></div>
<WalletSyncRow />
</>
);

jest.mock(
"electron",
() => ({ ipcRenderer: { on: jest.fn(), send: jest.fn(), invoke: jest.fn() } }),
{ virtual: true },
);

describe("manageSynchronizedInstances", () => {
it("should open drawer and display Wallet Sync ManageSynchronizedInstances flow and delete your instance", async () => {
const { user } = render(<WalletSyncTestApp />, {
initialState: {
walletSync: {
activated: true,
flow: Flow.Activation,
step: Step.CreateOrSynchronize,
instances: [
{
id: "1",
name: "macOS",
typeOfDevice: "desktop",
},
{
id: "2",
name: "Ipone 15",
typeOfDevice: "mobile",
},
],
},
},
});

//Open drawer
const button = screen.getByRole("button", { name: "Manage" });
await user.click(button);

const row = screen.getByTestId("walletSync-manage-instances");

await waitFor(() => expect(row).toBeDefined());

expect(screen.getByText("2 synchronized instances")).toBeDefined();

await user.click(row);

//Manage Synch Instances Step

await waitFor(() => expect(screen.getByText("Manage synchronized instances")).toBeDefined());

const instance = screen.getByTestId("walletSync-manage-instance-2");
expect(instance).toBeDefined();

await user.click(screen.getAllByText("Remove")[1]);

//Need to fake device action
});
});

0 comments on commit c2e6a1f

Please sign in to comment.