Skip to content

chore(site): Try to fix flake test #6848

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 9 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from 7 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
11 changes: 11 additions & 0 deletions site/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ plugins:
- react-hooks
- jest
- unicorn
- testing-library
overrides:
- files: ["**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)"]
extends: ["plugin:testing-library/react", "plugin:testing-library/dom"]
rules:
# These rules are disabled because they can degrade test speed a bit since
# sometimes we need to access the directly in a lower scope to prevent the
# library to fetch a bunch of element
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't understand this comment. Could you try to explain a little differently?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, gotcha. Maybe we could link those docs and phrase it slightly differently:
"Occasionally, we must traverse the DOM when querying for an element to avoid the performance costs that come with using selectors like ByRole. You can read more about these performance costs here."

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loved, ty!

testing-library/no-node-access: off
testing-library/no-container: off
root: true
rules:
"@typescript-eslint/brace-style":
Expand Down Expand Up @@ -145,6 +155,7 @@ rules:
message: "Default React import not allowed",
},
]

settings:
react:
version: detect
Expand Down
5 changes: 3 additions & 2 deletions site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"date-fns": "2.29.3",
"dayjs": "1.11.4",
"emoji-mart": "5.4.0",
"eslint-plugin-testing-library": "^5.10.2",
"eventsourcemock": "2.0.0",
"formik": "2.2.9",
"front-matter": "4.0.2",
Expand Down Expand Up @@ -97,8 +98,8 @@
"@storybook/react": "6.5.12",
"@swc/core": "1.3.38",
"@swc/jest": "0.2.24",
"@testing-library/jest-dom": "5.16.4",
"@testing-library/react": "13.4.0",
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "14.0.0",
"@testing-library/user-event": "14.4.3",
"@types/jest": "29.4.0",
"@types/node": "14.18.22",
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/AppLink/AppLink.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
MockWorkspace,
MockWorkspaceAgent,
MockWorkspaceApp,
} from "testHelpers/renderHelpers"
} from "testHelpers/entities"
import { AppLink, AppLinkProps } from "./AppLink"

export default {
Expand Down
30 changes: 15 additions & 15 deletions site/src/components/Dialogs/ConfirmDialog/ConfirmDialog.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fireEvent, render } from "@testing-library/react"
import { fireEvent, render, screen } from "@testing-library/react"
import { FC } from "react"
import { WrapperComponent } from "../../../testHelpers/renderHelpers"
import { ConfirmDialog, ConfirmDialogProps } from "./ConfirmDialog"
Expand Down Expand Up @@ -26,10 +26,10 @@ describe("ConfirmDialog", () => {
}

// When
const { getByRole } = render(<Helpers.Component {...props} />)
render(<Helpers.Component {...props} />)

// Then
expect(getByRole("dialog")).toBeDefined()
expect(screen.getByRole("dialog")).toBeDefined()
})

it("does not display cancel for info dialogs", () => {
Expand All @@ -43,10 +43,10 @@ describe("ConfirmDialog", () => {
}

// When
const { queryByText } = render(<Helpers.Component {...props} />)
render(<Helpers.Component {...props} />)

// Then
expect(queryByText("CANCEL")).toBeNull()
expect(screen.queryByText("CANCEL")).toBeNull()
})

it("can display cancel when normally hidden", () => {
Expand All @@ -61,10 +61,10 @@ describe("ConfirmDialog", () => {
}

// When
const { getByText } = render(<Helpers.Component {...props} />)
render(<Helpers.Component {...props} />)

// Then
expect(getByText("CANCEL")).toBeDefined()
expect(screen.getByText("CANCEL")).toBeDefined()
})

it("displays cancel for delete dialogs", () => {
Expand All @@ -79,10 +79,10 @@ describe("ConfirmDialog", () => {
}

// When
const { getByText } = render(<Helpers.Component {...props} />)
render(<Helpers.Component {...props} />)

// Then
expect(getByText("CANCEL")).toBeDefined()
expect(screen.getByText("CANCEL")).toBeDefined()
})

it("can hide cancel when normally visible", () => {
Expand All @@ -98,10 +98,10 @@ describe("ConfirmDialog", () => {
}

// When
const { queryByText } = render(<Helpers.Component {...props} />)
render(<Helpers.Component {...props} />)

// Then
expect(queryByText("CANCEL")).toBeNull()
expect(screen.queryByText("CANCEL")).toBeNull()
})

it("onClose is called when cancelled", () => {
Expand All @@ -116,8 +116,8 @@ describe("ConfirmDialog", () => {
}

// When
const { getByText } = render(<Helpers.Component {...props} />)
fireEvent.click(getByText("CANCEL"))
render(<Helpers.Component {...props} />)
fireEvent.click(screen.getByText("CANCEL"))

// Then
expect(onCloseMock).toBeCalledTimes(1)
Expand All @@ -138,8 +138,8 @@ describe("ConfirmDialog", () => {
}

// When
const { getByText } = render(<Helpers.Component {...props} />)
fireEvent.click(getByText("CONFIRM"))
render(<Helpers.Component {...props} />)
fireEvent.click(screen.getByText("CONFIRM"))

// Then
expect(onCloseMock).toBeCalledTimes(0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { action } from "@storybook/addon-actions"
import { Story } from "@storybook/react"
import { MockUser } from "../../../testHelpers/renderHelpers"
import { MockUser } from "testHelpers/entities"

import {
ResetPasswordDialog,
ResetPasswordDialogProps,
Expand Down
77 changes: 0 additions & 77 deletions site/src/components/FormTextField/FormTextField.test.tsx

This file was deleted.

163 changes: 0 additions & 163 deletions site/src/components/FormTextField/FormTextField.tsx

This file was deleted.

Loading