Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add global nock setup #28479

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const mockUpdateToken = (valid: boolean) => {

describe("LicenseAndBilling", () => {
afterEach(() => {
nock.cleanAll();
jest.restoreAllMocks();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ const setup = ({
describe("EditSandboxingModal", () => {
afterEach(() => {
jest.clearAllMocks();
nock.cleanAll();
});

describe("EditSandboxingModal", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ const LABEL = {
};

describe("SnippetCollectionFormModal", () => {
afterEach(() => {
nock.cleanAll();
});

describe("new folder", () => {
it("displays correct blank state", async () => {
await setup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ function setupExecutionEndpoint(expectedBody: any) {
}

describe("Actions > ActionViz > ActionComponent", () => {
afterEach(() => {
nock.cleanAll();
});

// button actions are just a modal trigger around forms
describe("Button actions", () => {
it("should render an empty state for a button with no action", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ const setup = (
};

describe("ActionViz > ActionDashcardSettings", () => {
afterEach(() => {
nock.cleanAll();
});

it("shows the action dashcard settings component", () => {
setup();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import nock from "nock";
import userEvent from "@testing-library/user-event";

import { screen } from "__support__/ui";
Expand All @@ -19,10 +18,6 @@ async function setup({
}

describe("ActionCreator > Common", () => {
afterEach(() => {
nock.cleanAll();
});

describe.each([
["query", createMockQueryAction],
["implicit", createMockImplicitQueryAction],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import nock from "nock";

import { screen, queryIcon } from "__support__/ui";

import {
Expand All @@ -18,10 +16,6 @@ async function setup({
}

describe("ActionCreator > Implicit Actions", () => {
afterEach(() => {
nock.cleanAll();
});

it("renders correctly", async () => {
const { action } = await setup();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import nock from "nock";

import { screen, getIcon, queryIcon } from "__support__/ui";

import {
Expand All @@ -10,10 +8,6 @@ import {
import { setup } from "./common";

describe("ActionCreator > Query Actions", () => {
afterEach(() => {
nock.cleanAll();
});

describe("new action", () => {
it("renders correctly", async () => {
await setup();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import nock from "nock";
import userEvent from "@testing-library/user-event";

import { screen, waitFor } from "__support__/ui";
Expand All @@ -19,10 +18,6 @@ async function setup({
}

describe("ActionCreator > Sharing", () => {
afterEach(() => {
nock.cleanAll();
});

describe.each([
["query", createMockQueryAction],
["implicit", createMockImplicitQueryAction],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ function setupPrefetch() {
}

describe("Actions > ActionParametersInputForm", () => {
afterEach(() => {
nock.cleanAll();
});

it("should render an action form", async () => {
await setup();
expect(screen.getByTestId("action-form")).toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const setup = async ({
describe("DeleteDatabaseModal", () => {
afterEach(() => {
jest.clearAllMocks();
nock.cleanAll();
});

it("should allow deleting database without content after confirming its name", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ const setup = ({
};

describe("GroupMappingsWidget", () => {
afterEach(() => {
nock.cleanAll();
});

describe("when a mapping is set for admin group", () => {
const settingBody = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ describe("CreateCollectionForm", () => {
nock(location.origin).get("/api/collection").reply(200, [ROOT_COLLECTION]);
});

afterEach(() => {
nock.cleanAll();
});

it("displays correct blank state", () => {
setup();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ const productVendorField = new Field({
});

describe("CategoryFieldPicker", () => {
afterEach(() => {
nock.cleanAll();
});

describe("given a few distinct values", () => {
beforeEach(() => {
nock(location.origin)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import nock from "nock";

import { screen } from "__support__/ui";

import { setup, SAMPLE_DATABASE, SAMPLE_TABLE } from "./common";
Expand All @@ -9,10 +7,6 @@ describe("DataPicker", () => {
window.HTMLElement.prototype.scrollIntoView = jest.fn();
});

afterEach(() => {
nock.cleanAll();
});

it("shows data type picker by default", async () => {
await setup();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import userEvent from "@testing-library/user-event";
import nock from "nock";

import { screen, waitForElementToBeRemoved } from "__support__/ui";

Expand Down Expand Up @@ -30,10 +29,6 @@ describe("DataPicker — picking models", () => {
window.HTMLElement.prototype.scrollIntoView = jest.fn();
});

afterEach(() => {
nock.cleanAll();
});

it("opens the picker", async () => {
await setup();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import userEvent from "@testing-library/user-event";
import nock from "nock";

import { screen, waitForElementToBeRemoved } from "__support__/ui";

Expand Down Expand Up @@ -28,10 +27,6 @@ describe("DataPicker — picking questions", () => {
window.HTMLElement.prototype.scrollIntoView = jest.fn();
});

afterEach(() => {
nock.cleanAll();
});

it("opens the picker", async () => {
await setup();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import userEvent from "@testing-library/user-event";
import nock from "nock";

import { screen, waitForElementToBeRemoved } from "__support__/ui";

Expand All @@ -21,10 +20,6 @@ describe("DataPicker — picking raw data", () => {
window.HTMLElement.prototype.scrollIntoView = jest.fn();
});

afterEach(() => {
nock.cleanAll();
});

it("opens the picker", async () => {
await setup();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,6 @@ async function openCollection(itemName) {
}

describe("ItemPicker", () => {
afterEach(() => {
nock.cleanAll();
});

it("displays items from the root collection by default", async () => {
await setup();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ function setup({
}

describe("NewItemMenu", () => {
afterEach(() => {
nock.cleanAll();
});

describe("New Action", () => {
it("should open action editor on click", async () => {
setup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ describe("CreateDashboardModal", () => {
nock(location.origin).get("/api/collection").reply(200, [ROOT_COLLECTION]);
});

afterEach(() => {
nock.cleanAll();
});

it("displays empty form fields", () => {
setup();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,6 @@ function openActionMenu(action: WritebackAction) {
}

describe("ModelDetailPage", () => {
afterEach(() => {
nock.cleanAll();
});

[
{ type: "structured", getModel: getStructuredModel },
{ type: "native", getModel: getNativeModel },
Expand Down
4 changes: 0 additions & 4 deletions frontend/src/metabase/nav/components/RecentsList.unit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ async function setup(recents = recentsData) {
}

describe("RecentsList", () => {
afterEach(() => {
nock.cleanAll();
});

it("shows list of recents", async () => {
await setup();
await screen.findByText("Question I visited");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ describe("AppBar", () => {

afterEach(() => {
jest.clearAllMocks();
nock.cleanAll();
restoreMockEmbedding();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,6 @@ async function setupCollectionPage({
}

describe("nav > containers > MainNavbar", () => {
afterEach(() => {
nock.cleanAll();
});

describe("homepage link", () => {
it("should render", async () => {
await setup();
Expand Down
4 changes: 0 additions & 4 deletions frontend/src/metabase/nav/containers/Navbar.unit.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ async function setup({
}

describe("nav > containers > Navbar > Core App", () => {
afterEach(() => {
nock.cleanAll();
});

it("should be open when isOpen is true", async () => {
await setup({ isOpen: true });
const navbar = screen.getByTestId("main-navbar-root");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ import { createMockUiParameter } from "metabase-lib/parameters/mock";
import ValuesSourceModal from "./ValuesSourceModal";

describe("ValuesSourceModal", () => {
afterEach(() => {
nock.cleanAll();
});

describe("fields source", () => {
it("should show a message about not connected fields", () => {
setup();
Expand Down Expand Up @@ -243,8 +239,7 @@ describe("ValuesSourceModal", () => {

await waitFor(() => {
expect(screen.getByRole("textbox")).toHaveValue("A\nB\nC");
}),
{ timeout: 3000 };
});
});

it("should display a message when the user has no access to the card", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ async function setup({
}

describe("PublicAction", () => {
beforeEach(() => {
nock.cleanAll();
});

it("shows acton form", async () => {
await setup();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ describe("QB Actions > initializeQB", () => {
});

afterEach(() => {
nock.cleanAll();
jest.restoreAllMocks();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ describe("SavedQuestionPicker", () => {
window.HTMLElement.prototype.scrollIntoView = jest.fn();
});

afterEach(() => {
nock.cleanAll();
});

it("shows the current user personal collection on the top after the root", async () => {
await setup();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,6 @@ describe.skip("Notebook Editor > Join Step", () => {
});
});

afterEach(() => {
nock.cleanAll();
});

it("displays a source table and suggests to pick a join table", async () => {
await setup();
expect(screen.getByText("Orders")).toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ const LABEL = {
};

describe("SnippetFormModal", () => {
afterEach(() => {
nock.cleanAll();
});

describe("new snippet", () => {
it("displays correct blank state", async () => {
await setup();
Expand Down
Loading