Skip to content

chore: Remove unused test files and code #5130

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

Merged
merged 4 commits into from
Nov 18, 2022
Merged
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
14 changes: 1 addition & 13 deletions site/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ module.exports = {
coverageReporters: ["text", "lcov"],
displayName: "test",
preset: "ts-jest",

roots: ["<rootDir>"],
setupFilesAfterEnv: ["./jest.setup.ts"],
transform: {
"^.+\\.tsx?$": "ts-jest",
},
testEnvironment: "jsdom",
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
testPathIgnorePatterns: ["/node_modules/", "/__tests__/fakes", "/e2e/"],
testPathIgnorePatterns: ["/node_modules/", "/e2e/"],
moduleDirectories: ["node_modules", "<rootDir>/src"],
moduleNameMapper: {
"\\.css$": "<rootDir>/src/testHelpers/styleMock.ts",
Expand Down Expand Up @@ -63,15 +62,4 @@ module.exports = {
"!<rootDir>/out/**/*.*",
"!<rootDir>/storybook-static/**/*.*",
],
reporters: [
"default",
[
"jest-junit",
{
suiteName: "Front-end Jest Tests",
outputDirectory: "./test-results",
outputName: "junit.xml",
},
],
],
}
4 changes: 1 addition & 3 deletions site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
"react-syntax-highlighter": "15.5.0",
"remark-gfm": "3.0.1",
"sourcemapped-stacktrace": "1.1.11",
"swr": "1.3.0",
"tzdata": "1.0.30",
"ua-parser-js": "1.0.2",
"uuid": "9.0.0",
Expand Down Expand Up @@ -104,7 +103,7 @@
"eslint-import-resolver-alias": "1.1.2",
"eslint-import-resolver-typescript": "3.5.0",
"eslint-plugin-compat": "4.0.2",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-eslint-comments": "3.2.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-jest": "27.0.1",
"eslint-plugin-jsx-a11y": "6.6.1",
Expand All @@ -114,7 +113,6 @@
"eslint-plugin-unicorn": "44.0.0",
"jest": "27.5.1",
"jest-canvas-mock": "2.4.0",
"jest-junit": "14.0.0",
"jest-runner-eslint": "1.1.0",
"jest-websocket-mock": "2.4.0",
"msw": "0.47.0",
Expand Down
21 changes: 5 additions & 16 deletions site/src/pages/WorkspacePage/WorkspacePage.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-floating-promises -- TODO look into this */
import { fireEvent, screen, waitFor, within } from "@testing-library/react"
import userEvent from "@testing-library/user-event"
import EventSourceMock from "eventsourcemock"
Expand All @@ -25,6 +24,7 @@ import {
MockWorkspaceBuild,
MockWorkspaceResource2,
renderWithAuth,
waitForLoaderToBeRemoved,
} from "../../testHelpers/renderHelpers"
import { server } from "../../testHelpers/server"
import { WorkspacePage } from "./WorkspacePage"
Expand All @@ -33,15 +33,12 @@ const { t } = i18next

// It renders the workspace page and waits for it be loaded
const renderWorkspacePage = async () => {
const getTemplateMock = jest
.spyOn(api, "getTemplate")
.mockResolvedValueOnce(MockTemplate)
jest.spyOn(api, "getTemplate").mockResolvedValueOnce(MockTemplate)
renderWithAuth(<WorkspacePage />, {
route: `/@${MockWorkspace.owner_name}/${MockWorkspace.name}`,
path: "/@:username/:workspace",
})
await screen.findByText(MockWorkspace.name)
expect(getTemplateMock).toBeCalled()
await waitForLoaderToBeRemoved()
}

/**
Expand All @@ -50,12 +47,9 @@ const renderWorkspacePage = async () => {
* We don't need to test the UI exhaustively because Storybook does that; just enough to prove that the
* workspaceStatus was calculated correctly.
*/

const testButton = async (label: string, actionMock: jest.SpyInstance) => {
await renderWorkspacePage()
// REMARK: exact here because the "Start" button and "START" label for
// workspace schedule could otherwise conflict.
const button = await screen.findByText(label, { exact: true })
const button = await screen.findByRole("button", { name: label })
fireEvent.click(button)
expect(actionMock).toBeCalled()
}
Expand Down Expand Up @@ -318,11 +312,7 @@ describe("WorkspacePage", () => {
),
)

renderWithAuth(<WorkspacePage />, {
route: `/@${MockWorkspace.owner_name}/${MockWorkspace.name}`,
path: "/@:username/:workspace",
})

await renderWorkspacePage()
const agent1Names = await screen.findAllByText(MockWorkspaceAgent.name)
expect(agent1Names.length).toEqual(1)
const agent2Names = await screen.findAllByText(
Expand Down Expand Up @@ -351,4 +341,3 @@ describe("WorkspacePage", () => {
})
})
})
/* eslint-enable @typescript-eslint/no-floating-promises -- TODO look into this */
3 changes: 3 additions & 0 deletions site/src/testHelpers/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ export const handlers = [
}),
)
}),
rest.post("/api/v2/users", async (req, res, ctx) => {
return res(ctx.status(200), ctx.json(M.MockUser))
}),
rest.get("/api/v2/users/me/organizations", (req, res, ctx) => {
return res(ctx.status(200), ctx.json([M.MockOrganization]))
}),
Expand Down
27 changes: 1 addition & 26 deletions site/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6421,7 +6421,7 @@ eslint-plugin-compat@4.0.2:
lodash.memoize "4.1.2"
semver "7.3.5"

eslint-plugin-eslint-comments@^3.2.0:
eslint-plugin-eslint-comments@3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-eslint-comments/-/eslint-plugin-eslint-comments-3.2.0.tgz#9e1cd7b4413526abb313933071d7aba05ca12ffa"
integrity sha512-0jkOl0hfojIHHmEHgmNdqv4fmh7300NdpA9FFpF7zaoLvB/QeXOGNLIo86oAveJFrfB1p05kC8hpEMHM8DwWVQ==
Expand Down Expand Up @@ -8745,16 +8745,6 @@ jest-jasmine2@^27.5.1:
pretty-format "^27.5.1"
throat "^6.0.1"

jest-junit@14.0.0:
version "14.0.0"
resolved "https://registry.yarnpkg.com/jest-junit/-/jest-junit-14.0.0.tgz#f69fc31bab32224848f443480c2c808fccb2a802"
integrity sha512-kALvBDegstTROfDGXH71UGD7k5g7593Y1wuX1wpWT+QTYcBbmtuGOA8UlAt56zo/B2eMIOcaOVEON3j0VXVa4g==
dependencies:
mkdirp "^1.0.4"
strip-ansi "^6.0.1"
uuid "^8.3.2"
xml "^1.0.1"

jest-leak-detector@^27.5.1:
version "27.5.1"
resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-27.5.1.tgz#6ec9d54c3579dd6e3e66d70e3498adf80fde3fb8"
Expand Down Expand Up @@ -12902,11 +12892,6 @@ supports-preserve-symlinks-flag@^1.0.0:
resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09"
integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==

swr@1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/swr/-/swr-1.3.0.tgz#c6531866a35b4db37b38b72c45a63171faf9f4e8"
integrity sha512-dkghQrOl2ORX9HYrMDtPa7LTVHJjCTeZoB1dqTbnnEDlSvN8JEKpYIYurDfvbQFUUS8Cg8PceFVZNkW0KNNYPw==

symbol-tree@^3.2.4:
version "3.2.4"
resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2"
Expand Down Expand Up @@ -13730,11 +13715,6 @@ uuid@^3.3.2:
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==

uuid@^8.3.2:
version "8.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==

uvu@^0.5.0:
version "0.5.6"
resolved "https://registry.yarnpkg.com/uvu/-/uvu-0.5.6.tgz#2754ca20bcb0bb59b64e9985e84d2e81058502df"
Expand Down Expand Up @@ -14199,11 +14179,6 @@ xml-name-validator@^3.0.0:
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a"
integrity sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==

xml@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5"
integrity sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw==

xmlchars@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb"
Expand Down
8 changes: 0 additions & 8 deletions yarn.lock

This file was deleted.