chore(site): remove some eslint-disables (#4265)

* fix: await promises in WorkspacePage.test.tsx

* chore: add eventsourcemock to cspell words

* fix: clean up UsersPage.test.tsx

* refactor: clean up eventsource mock

* revert: remove changes from WorkspacePage.test.tsx
This commit is contained in:
Joe Previte 2022-10-13 16:09:04 -07:00 committed by GitHub
parent 4e57b9fbdc
commit 94db085b51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 8 deletions

View File

@ -25,6 +25,7 @@
"drpcserver",
"Dsts",
"enablements",
"eventsourcemock",
"fatih",
"Formik",
"gitsshkey",

View File

@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-floating-promises */
import { fireEvent, screen, waitFor, within } from "@testing-library/react"
import userEvent from "@testing-library/user-event"
import { i18n } from "i18n"
@ -428,8 +427,7 @@ describe("UsersPage", () => {
}),
)
// eslint-disable-next-line @typescript-eslint/no-empty-function
await updateUserRole(() => {}, MockAuditorRole)
await updateUserRole(() => null, MockAuditorRole)
// Check if the error message is displayed
const errorMessage = await screen.findByText("message from the backend")

View File

@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-floating-promises */
import { fireEvent, screen, waitFor } from "@testing-library/react"
import userEvent from "@testing-library/user-event"
import EventSource from "eventsourcemock"
import EventSourceMock from "eventsourcemock"
import i18next from "i18next"
import { rest } from "msw"
import * as api from "../../api/api"
@ -75,13 +75,20 @@ const testStatus = async (ws: Workspace, label: string) => {
expect(status).toHaveTextContent(label)
}
let originalEventSource: typeof window.EventSource
beforeAll(() => {
originalEventSource = window.EventSource
// mocking out EventSource for SSE
window.EventSource = EventSourceMock
})
beforeEach(() => {
jest.resetAllMocks()
})
// mocking out EventSource for SSE
Object.defineProperty(window, "EventSource", {
value: EventSource,
})
afterAll(() => {
window.EventSource = originalEventSource
})
describe("WorkspacePage", () => {