Skip to content

Commit 73e6cd1

Browse files
Fix failing tests
1 parent c24f5bf commit 73e6cd1

5 files changed

Lines changed: 68 additions & 21 deletions

File tree

src/application/App.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Cache } from "./components/Cache/Cache";
99
import { clients, currentClient } from ".";
1010

1111
export const reloadStatus = makeVar<boolean>(false);
12+
console.log(Screens)
1213

1314
const screens = {
1415
[Screens.Explorer]: Explorer,
@@ -69,8 +70,8 @@ export const App = (): JSX.Element => {
6970
<Screen
7071
isVisible={undefined}
7172
navigationProps={{
72-
queriesCount: data?.client?.watchedQueries?.count,
73-
mutationsCount: data?.client?.mutationLog?.count,
73+
queriesCount: data?.client?.watchedQueries?.count ?? 0,
74+
mutationsCount: data?.client?.mutationLog?.count ?? 0,
7475
}}
7576
embeddedExplorerProps={{
7677
embeddedExplorerIFrame,

src/application/__tests__/App.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe("<App />", () => {
3737

3838
test("after reload, renders the Queries screen", async () => {
3939
currentScreen(Screens.Mutations);
40-
const { getByText, debug } = renderWithApolloClient(<App />);
40+
const { getByText } = renderWithApolloClient(<App />);
4141
const element = getByText("Mutations (0)");
4242
expect(element).toBeInTheDocument();
4343
await waitFor(() => {

src/application/components/Cache/__tests__/Cache.test.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { within, waitFor, fireEvent } from "@testing-library/react";
33

44
import { Cache } from "../Cache";
55
import { renderWithApolloClient } from "../../../utilities/testing/renderWithApolloClient";
6-
import { client, writeData } from "../../../index";
6+
import { client, currentClient, writeData } from "../../../index";
77

88
const CACHE_DATA = {
99
"Result:1": {
@@ -66,8 +66,10 @@ describe("Cache component tests", () => {
6666
describe("With cache data", () => {
6767
beforeEach(() => {
6868
client.resetStore();
69-
69+
const clientId = "client-1"
70+
currentClient(clientId)
7071
writeData({
72+
id: clientId,
7173
queries: [],
7274
mutations: [],
7375
cache: JSON.stringify(CACHE_DATA),
@@ -122,7 +124,10 @@ describe("Cache component tests", () => {
122124
const selectedMainStyles = "background-color: yellow";
123125

124126
beforeEach(() => {
127+
const clientId = "client-1";
128+
currentClient(clientId)
125129
writeData({
130+
id: clientId,
126131
queries: [],
127132
mutations: [],
128133
cache: JSON.stringify(CACHE_DATA),

src/application/components/Mutations/__tests__/Mutations.test.tsx

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,27 @@ import { within, waitFor } from "@testing-library/react";
33
import user from "@testing-library/user-event";
44

55
import { renderWithApolloClient } from "../../../utilities/testing/renderWithApolloClient";
6-
import { client, GET_MUTATIONS } from "../../../index";
6+
import { client, currentClient, GET_MUTATIONS } from "../../../index";
77
import { Mutations } from "../Mutations";
88

99
jest.mock("../MutationViewer", () => ({
1010
MutationViewer: () => null,
1111
}));
1212

13+
14+
const clientId = "client-1";
15+
1316
describe("<Mutations />", () => {
1417
const mutations = [
1518
{
1619
id: 0,
20+
clientId,
1721
__typename: "Mutation",
1822
name: null,
1923
},
2024
{
2125
id: 1,
26+
clientId,
2227
__typename: "Mutation",
2328
name: "AddColorToFavorites",
2429
},
@@ -34,14 +39,22 @@ describe("<Mutations />", () => {
3439
});
3540

3641
test("queries render in the sidebar", async () => {
42+
currentClient(clientId);
3743
client.writeQuery({
3844
query: GET_MUTATIONS,
3945
data: {
40-
mutationLog: {
41-
mutations,
42-
count: mutations.length,
43-
},
46+
client: {
47+
id: clientId,
48+
__typename: "Client",
49+
mutationLog: {
50+
mutations,
51+
count: mutations.length,
52+
},
53+
}
4454
},
55+
variables: {
56+
clientId
57+
}
4558
});
4659

4760
const { getByTestId } = renderWithApolloClient(
@@ -63,14 +76,22 @@ describe("<Mutations />", () => {
6376
});
6477

6578
test("renders query name", async () => {
79+
currentClient(clientId)
6680
client.writeQuery({
6781
query: GET_MUTATIONS,
6882
data: {
69-
mutationLog: {
70-
mutations,
71-
count: mutations.length,
72-
},
83+
client: {
84+
id: clientId,
85+
__typename: "Client",
86+
mutationLog: {
87+
mutations,
88+
count: mutations.length,
89+
}
90+
}
7391
},
92+
variables: {
93+
clientId
94+
}
7495
});
7596

7697
const { getByTestId } = renderWithApolloClient(

src/application/components/Queries/__tests__/Queries.test.tsx

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,27 @@ import { within, waitFor } from "@testing-library/react";
33
import user from "@testing-library/user-event";
44

55
import { renderWithApolloClient } from "../../../utilities/testing/renderWithApolloClient";
6-
import { client, GET_QUERIES } from "../../../index";
6+
import { client, currentClient, GET_QUERIES } from "../../../index";
77
import { Queries } from "../Queries";
88

99
jest.mock("../QueryViewer", () => ({
1010
QueryViewer: () => null,
1111
}));
1212

13+
const clientId = "client-1";
14+
1315
describe("<Queries />", () => {
1416
const queries = [
1517
{
1618
id: 0,
1719
__typename: "WatchedQuery",
20+
clientId,
1821
name: null,
1922
},
2023
{
2124
id: 1,
2225
__typename: "WatchedQuery",
26+
clientId,
2327
name: "GetColors",
2428
},
2529
];
@@ -34,14 +38,22 @@ describe("<Queries />", () => {
3438
});
3539

3640
test("queries render in the sidebar", async () => {
41+
currentClient(clientId);
3742
client.writeQuery({
3843
query: GET_QUERIES,
3944
data: {
40-
watchedQueries: {
41-
queries,
42-
count: queries.length,
45+
client: {
46+
id: clientId,
47+
__typename: "Client",
48+
watchedQueries: {
49+
queries,
50+
count: queries.length,
51+
},
4352
},
4453
},
54+
variables: {
55+
clientId,
56+
},
4557
});
4658

4759
const { getByTestId } = renderWithApolloClient(
@@ -61,14 +73,22 @@ describe("<Queries />", () => {
6173
});
6274

6375
test("renders query name", async () => {
76+
currentClient(clientId);
6477
client.writeQuery({
6578
query: GET_QUERIES,
6679
data: {
67-
watchedQueries: {
68-
queries,
69-
count: queries.length,
80+
client: {
81+
id: clientId,
82+
__typename: "Client",
83+
watchedQueries: {
84+
queries,
85+
count: queries.length,
86+
},
7087
},
7188
},
89+
variables: {
90+
clientId,
91+
},
7292
});
7393

7494
const { getByTestId } = renderWithApolloClient(

0 commit comments

Comments
 (0)