Skip to content

Commit 47b61c4

Browse files
BrunoQuaresmapull[bot]
authored andcommitted
chore: Remove unused test files and code (#5130)
1 parent 21e497a commit 47b61c4

File tree

6 files changed

+11
-66
lines changed

6 files changed

+11
-66
lines changed

site/jest.config.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@ module.exports = {
1818
coverageReporters: ["text", "lcov"],
1919
displayName: "test",
2020
preset: "ts-jest",
21-
2221
roots: ["<rootDir>"],
2322
setupFilesAfterEnv: ["./jest.setup.ts"],
2423
transform: {
2524
"^.+\\.tsx?$": "ts-jest",
2625
},
2726
testEnvironment: "jsdom",
2827
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
29-
testPathIgnorePatterns: ["/node_modules/", "/__tests__/fakes", "/e2e/"],
28+
testPathIgnorePatterns: ["/node_modules/", "/e2e/"],
3029
moduleDirectories: ["node_modules", "<rootDir>/src"],
3130
moduleNameMapper: {
3231
"\\.css$": "<rootDir>/src/testHelpers/styleMock.ts",
@@ -63,15 +62,4 @@ module.exports = {
6362
"!<rootDir>/out/**/*.*",
6463
"!<rootDir>/storybook-static/**/*.*",
6564
],
66-
reporters: [
67-
"default",
68-
[
69-
"jest-junit",
70-
{
71-
suiteName: "Front-end Jest Tests",
72-
outputDirectory: "./test-results",
73-
outputName: "junit.xml",
74-
},
75-
],
76-
],
7765
}

site/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
"react-syntax-highlighter": "15.5.0",
6363
"remark-gfm": "3.0.1",
6464
"sourcemapped-stacktrace": "1.1.11",
65-
"swr": "1.3.0",
6665
"tzdata": "1.0.30",
6766
"ua-parser-js": "1.0.2",
6867
"uuid": "9.0.0",
@@ -104,7 +103,7 @@
104103
"eslint-import-resolver-alias": "1.1.2",
105104
"eslint-import-resolver-typescript": "3.5.0",
106105
"eslint-plugin-compat": "4.0.2",
107-
"eslint-plugin-eslint-comments": "^3.2.0",
106+
"eslint-plugin-eslint-comments": "3.2.0",
108107
"eslint-plugin-import": "2.26.0",
109108
"eslint-plugin-jest": "27.0.1",
110109
"eslint-plugin-jsx-a11y": "6.6.1",
@@ -114,7 +113,6 @@
114113
"eslint-plugin-unicorn": "44.0.0",
115114
"jest": "27.5.1",
116115
"jest-canvas-mock": "2.4.0",
117-
"jest-junit": "14.0.0",
118116
"jest-runner-eslint": "1.1.0",
119117
"jest-websocket-mock": "2.4.0",
120118
"msw": "0.47.0",

site/src/pages/WorkspacePage/WorkspacePage.test.tsx

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-floating-promises -- TODO look into this */
21
import { fireEvent, screen, waitFor, within } from "@testing-library/react"
32
import userEvent from "@testing-library/user-event"
43
import EventSourceMock from "eventsourcemock"
@@ -25,6 +24,7 @@ import {
2524
MockWorkspaceBuild,
2625
MockWorkspaceResource2,
2726
renderWithAuth,
27+
waitForLoaderToBeRemoved,
2828
} from "../../testHelpers/renderHelpers"
2929
import { server } from "../../testHelpers/server"
3030
import { WorkspacePage } from "./WorkspacePage"
@@ -33,15 +33,12 @@ const { t } = i18next
3333

3434
// It renders the workspace page and waits for it be loaded
3535
const renderWorkspacePage = async () => {
36-
const getTemplateMock = jest
37-
.spyOn(api, "getTemplate")
38-
.mockResolvedValueOnce(MockTemplate)
36+
jest.spyOn(api, "getTemplate").mockResolvedValueOnce(MockTemplate)
3937
renderWithAuth(<WorkspacePage />, {
4038
route: `/@${MockWorkspace.owner_name}/${MockWorkspace.name}`,
4139
path: "/@:username/:workspace",
4240
})
43-
await screen.findByText(MockWorkspace.name)
44-
expect(getTemplateMock).toBeCalled()
41+
await waitForLoaderToBeRemoved()
4542
}
4643

4744
/**
@@ -50,12 +47,9 @@ const renderWorkspacePage = async () => {
5047
* We don't need to test the UI exhaustively because Storybook does that; just enough to prove that the
5148
* workspaceStatus was calculated correctly.
5249
*/
53-
5450
const testButton = async (label: string, actionMock: jest.SpyInstance) => {
5551
await renderWorkspacePage()
56-
// REMARK: exact here because the "Start" button and "START" label for
57-
// workspace schedule could otherwise conflict.
58-
const button = await screen.findByText(label, { exact: true })
52+
const button = await screen.findByRole("button", { name: label })
5953
fireEvent.click(button)
6054
expect(actionMock).toBeCalled()
6155
}
@@ -318,11 +312,7 @@ describe("WorkspacePage", () => {
318312
),
319313
)
320314

321-
renderWithAuth(<WorkspacePage />, {
322-
route: `/@${MockWorkspace.owner_name}/${MockWorkspace.name}`,
323-
path: "/@:username/:workspace",
324-
})
325-
315+
await renderWorkspacePage()
326316
const agent1Names = await screen.findAllByText(MockWorkspaceAgent.name)
327317
expect(agent1Names.length).toEqual(1)
328318
const agent2Names = await screen.findAllByText(
@@ -351,4 +341,3 @@ describe("WorkspacePage", () => {
351341
})
352342
})
353343
})
354-
/* eslint-enable @typescript-eslint/no-floating-promises -- TODO look into this */

site/src/testHelpers/handlers.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ export const handlers = [
8383
}),
8484
)
8585
}),
86+
rest.post("/api/v2/users", async (req, res, ctx) => {
87+
return res(ctx.status(200), ctx.json(M.MockUser))
88+
}),
8689
rest.get("/api/v2/users/me/organizations", (req, res, ctx) => {
8790
return res(ctx.status(200), ctx.json([M.MockOrganization]))
8891
}),

site/yarn.lock

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6421,7 +6421,7 @@ eslint-plugin-compat@4.0.2:
64216421
lodash.memoize "4.1.2"
64226422
semver "7.3.5"
64236423

6424-
eslint-plugin-eslint-comments@^3.2.0:
6424+
eslint-plugin-eslint-comments@3.2.0:
64256425
version "3.2.0"
64266426
resolved "https://registry.yarnpkg.com/eslint-plugin-eslint-comments/-/eslint-plugin-eslint-comments-3.2.0.tgz#9e1cd7b4413526abb313933071d7aba05ca12ffa"
64276427
integrity sha512-0jkOl0hfojIHHmEHgmNdqv4fmh7300NdpA9FFpF7zaoLvB/QeXOGNLIo86oAveJFrfB1p05kC8hpEMHM8DwWVQ==
@@ -8745,16 +8745,6 @@ jest-jasmine2@^27.5.1:
87458745
pretty-format "^27.5.1"
87468746
throat "^6.0.1"
87478747

8748-
jest-junit@14.0.0:
8749-
version "14.0.0"
8750-
resolved "https://registry.yarnpkg.com/jest-junit/-/jest-junit-14.0.0.tgz#f69fc31bab32224848f443480c2c808fccb2a802"
8751-
integrity sha512-kALvBDegstTROfDGXH71UGD7k5g7593Y1wuX1wpWT+QTYcBbmtuGOA8UlAt56zo/B2eMIOcaOVEON3j0VXVa4g==
8752-
dependencies:
8753-
mkdirp "^1.0.4"
8754-
strip-ansi "^6.0.1"
8755-
uuid "^8.3.2"
8756-
xml "^1.0.1"
8757-
87588748
jest-leak-detector@^27.5.1:
87598749
version "27.5.1"
87608750
resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-27.5.1.tgz#6ec9d54c3579dd6e3e66d70e3498adf80fde3fb8"
@@ -12902,11 +12892,6 @@ supports-preserve-symlinks-flag@^1.0.0:
1290212892
resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09"
1290312893
integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==
1290412894

12905-
swr@1.3.0:
12906-
version "1.3.0"
12907-
resolved "https://registry.yarnpkg.com/swr/-/swr-1.3.0.tgz#c6531866a35b4db37b38b72c45a63171faf9f4e8"
12908-
integrity sha512-dkghQrOl2ORX9HYrMDtPa7LTVHJjCTeZoB1dqTbnnEDlSvN8JEKpYIYurDfvbQFUUS8Cg8PceFVZNkW0KNNYPw==
12909-
1291012895
symbol-tree@^3.2.4:
1291112896
version "3.2.4"
1291212897
resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2"
@@ -13730,11 +13715,6 @@ uuid@^3.3.2:
1373013715
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
1373113716
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
1373213717

13733-
uuid@^8.3.2:
13734-
version "8.3.2"
13735-
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
13736-
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
13737-
1373813718
uvu@^0.5.0:
1373913719
version "0.5.6"
1374013720
resolved "https://registry.yarnpkg.com/uvu/-/uvu-0.5.6.tgz#2754ca20bcb0bb59b64e9985e84d2e81058502df"
@@ -14199,11 +14179,6 @@ xml-name-validator@^3.0.0:
1419914179
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a"
1420014180
integrity sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==
1420114181

14202-
xml@^1.0.1:
14203-
version "1.0.1"
14204-
resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5"
14205-
integrity sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw==
14206-
1420714182
xmlchars@^2.2.0:
1420814183
version "2.2.0"
1420914184
resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb"

yarn.lock

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)