mirror of https://github.com/coder/coder.git
Fix a few tests
This commit is contained in:
parent
d6c6a4863b
commit
51b6f71188
|
@ -1,6 +1,6 @@
|
|||
import { screen, within } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { vi , expect, describe, it } from "vitest"
|
||||
import { vi, describe, it } from "vitest";
|
||||
import * as API from "api/api";
|
||||
import {
|
||||
renderWithAuth,
|
||||
|
@ -27,7 +27,6 @@ describe("TokenPage", () => {
|
|||
within(form).getByRole("button", { name: /create token/i }),
|
||||
);
|
||||
|
||||
// Then
|
||||
expect(screen.getByText("abcd")).toBeInTheDocument();
|
||||
await screen.findByText("abcd");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -49,6 +49,6 @@ test("Users can fill the parameters and copy the open in coder url", async () =>
|
|||
const copyButton = screen.getByRole("button", { name: /copy/i });
|
||||
await userEvent.click(copyButton);
|
||||
expect(window.navigator.clipboard.writeText).toBeCalledWith(
|
||||
`[![Open in Coder](http://localhost/open-in-coder.svg)](http://localhost/templates/test-template/workspace?mode=manual¶m.first_parameter=firstParameterValue¶m.second_parameter=123456)`,
|
||||
`[![Open in Coder](http://localhost:3000/open-in-coder.svg)](http://localhost:3000/templates/test-template/workspace?mode=manual¶m.first_parameter=firstParameterValue¶m.second_parameter=123456)`,
|
||||
);
|
||||
});
|
||||
|
|
|
@ -5,11 +5,11 @@ import {
|
|||
vi,
|
||||
beforeAll,
|
||||
afterAll,
|
||||
beforeEach,
|
||||
test,
|
||||
expect,
|
||||
describe,
|
||||
it,
|
||||
type MockInstance,
|
||||
} from "vitest";
|
||||
import * as api from "api/api";
|
||||
import type { TemplateVersionParameter, Workspace } from "api/typesGenerated";
|
||||
|
@ -64,7 +64,7 @@ const renderWorkspacePage = async (workspace: Workspace) => {
|
|||
const testButton = async (
|
||||
workspace: Workspace,
|
||||
name: string | RegExp,
|
||||
actionMock: vi.SpyInstance,
|
||||
actionMock: MockInstance,
|
||||
) => {
|
||||
await renderWorkspacePage(workspace);
|
||||
const workspaceActions = screen.getByTestId("workspace-actions");
|
||||
|
@ -72,7 +72,9 @@ const testButton = async (
|
|||
|
||||
const user = userEvent.setup();
|
||||
await user.click(button);
|
||||
expect(actionMock).toBeCalled();
|
||||
await waitFor(() => {
|
||||
expect(actionMock).toBeCalled();
|
||||
});
|
||||
};
|
||||
|
||||
let originalEventSource: typeof window.EventSource;
|
||||
|
@ -83,10 +85,6 @@ beforeAll(() => {
|
|||
window.EventSource = EventSourceMock;
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
window.EventSource = originalEventSource;
|
||||
});
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { vi } from "vitest"
|
||||
|
||||
/**
|
||||
* Necessary for MSW
|
||||
*
|
||||
|
@ -11,7 +13,6 @@
|
|||
*/
|
||||
const { TextDecoder, TextEncoder } = require("node:util");
|
||||
const { ReadableStream } = require("node:stream/web");
|
||||
const { vi } = require("vitest")
|
||||
|
||||
Object.defineProperties(globalThis, {
|
||||
TextDecoder: { value: TextDecoder },
|
||||
|
|
Loading…
Reference in New Issue