chore: enable more vitest lint rules

This commit is contained in:
Julian Sommer
2026-08-24 12:31:51 +10:00
parent c8aafa5de8
commit 71b94cd3c2
16 changed files with 51 additions and 43 deletions
@@ -113,10 +113,8 @@ export default defineConfig({
"typescript/no-unsafe-type-assertion": "off",
"unicorn/no-useless-undefined": "off",
"vitest/max-expects": "off",
"vitest/prefer-called-once": "off",
"vitest/prefer-called-with": "off",
"vitest/prefer-describe-function-title": "off",
"vitest/prefer-expect-resolves": "off",
"vitest/prefer-import-in-mock": "off",
"vitest/require-mock-type-parameters": "off",
},
@@ -40,7 +40,7 @@ describe("SystemImageRequired", () => {
await user.click(screen.getByRole("button", { name: "Copy command" }))
expect(await navigator.clipboard.readText()).toBe(importCommand)
await expect(navigator.clipboard.readText()).resolves.toBe(importCommand)
})
it("calls onRecheck when Recheck is clicked", async () => {
@@ -51,7 +51,7 @@ describe("create-key-pair route", () => {
await user.type(screen.getByLabelText("Key Pair Name"), "my-key")
await user.click(screen.getByRole("button", { name: "Create Key Pair" }))
await waitFor(() => expect(send).toHaveBeenCalledTimes(1))
await waitFor(() => expect(send).toHaveBeenCalledOnce())
expect(send.mock.calls[0]?.[0].input).toStrictEqual({
KeyName: "my-key",
KeyType: "rsa",
@@ -67,7 +67,7 @@ describe("create-key-pair route", () => {
await user.click(screen.getByRole("option", { name: "ED25519" }))
await user.click(screen.getByRole("button", { name: "Create Key Pair" }))
await waitFor(() => expect(send).toHaveBeenCalledTimes(1))
await waitFor(() => expect(send).toHaveBeenCalledOnce())
expect(send.mock.calls[0]?.[0].input).toStrictEqual({
KeyName: "my-key",
KeyType: "ed25519",
@@ -34,7 +34,7 @@ describe("CreateRepositoryDialog", () => {
expect(createButton).toBeEnabled()
fireEvent.click(createButton)
await waitFor(() => expect(send).toHaveBeenCalledTimes(1))
await waitFor(() => expect(send).toHaveBeenCalledOnce())
expect(send.mock.calls[0]![0].input).toStrictEqual({
repositoryName: "team/app",
})
@@ -51,8 +51,8 @@ describe("CreateRepositoryDialog", () => {
target: { value: "dupe" },
})
fireEvent.click(screen.getByRole("button", { name: "Create Repository" }))
expect(
await screen.findByText("RepositoryAlreadyExists"),
).toBeInTheDocument()
await expect(
screen.findByText("RepositoryAlreadyExists"),
).resolves.toBeInTheDocument()
})
})
@@ -23,8 +23,8 @@ describe("PushCommands", () => {
})
render(<PushCommands repositoryName="team/app" repositoryUri={URI} />)
fireEvent.click(screen.getByRole("button", { name: "Copy" }))
await waitFor(() => expect(writeText).toHaveBeenCalledTimes(1))
await waitFor(() => expect(writeText).toHaveBeenCalledOnce())
expect(writeText.mock.calls[0]![0]).toContain(`docker push ${URI}:latest`)
expect(await screen.findByText("Copied")).toBeInTheDocument()
await expect(screen.findByText("Copied")).resolves.toBeInTheDocument()
})
})
@@ -32,7 +32,7 @@ describe("CreateClusterDialog", () => {
expect(createButton).toBeEnabled()
fireEvent.click(createButton)
await waitFor(() => expect(send).toHaveBeenCalledTimes(1))
await waitFor(() => expect(send).toHaveBeenCalledOnce())
expect(send.mock.calls[0]![0].input).toStrictEqual({ clusterName: "web" })
await waitFor(() => expect(onOpenChange).toHaveBeenCalledWith(false))
})
@@ -47,6 +47,8 @@ describe("CreateClusterDialog", () => {
target: { value: "dupe" },
})
fireEvent.click(screen.getByRole("button", { name: "Create Cluster" }))
expect(await screen.findByText("ClusterAlreadyExists")).toBeInTheDocument()
await expect(
screen.findByText("ClusterAlreadyExists"),
).resolves.toBeInTheDocument()
})
})
@@ -135,9 +135,9 @@ describe("AttachedPoliciesPanel", () => {
fireEvent.click(screen.getByRole("button", { name: "Attach Policy" }))
fireEvent.click(screen.getByRole("button", { name: /AvailablePolicy/ }))
expect(
await screen.findByText("Failed to attach policy"),
).toBeInTheDocument()
await expect(
screen.findByText("Failed to attach policy"),
).resolves.toBeInTheDocument()
expect(screen.getByText("Select a policy to attach:")).toBeInTheDocument()
expect(
screen.getByRole("button", { name: /AvailablePolicy/ }),
@@ -152,9 +152,9 @@ describe("AttachedPoliciesPanel", () => {
)
fireEvent.click(screen.getByRole("button", { name: "Detach" }))
expect(
await screen.findByText("Failed to detach policy"),
).toBeInTheDocument()
await expect(
screen.findByText("Failed to detach policy"),
).resolves.toBeInTheDocument()
await waitFor(() =>
expect(screen.getByRole("button", { name: "Detach" })).toBeEnabled(),
)
@@ -132,9 +132,9 @@ describe("InlinePoliciesPanel", () => {
)
fireEvent.click(screen.getByRole("button", { name: "Edit" }))
expect(
await screen.findByText("Failed to load inline policy"),
).toBeInTheDocument()
await expect(
screen.findByText("Failed to load inline policy"),
).resolves.toBeInTheDocument()
})
it("edits an inline policy and saves via PutUserPolicy", async () => {
@@ -101,9 +101,9 @@ describe("CreateDBParameterGroupPage", () => {
screen.getByRole("button", { name: "Create Parameter Group" }),
)
expect(
await screen.findByText(/may not begin with "default\."/),
).toBeInTheDocument()
await expect(
screen.findByText(/may not begin with "default\."/),
).resolves.toBeInTheDocument()
expect(mockSend).not.toHaveBeenCalled()
})
@@ -117,9 +117,9 @@ describe("CreateDBParameterGroupPage", () => {
screen.getByRole("button", { name: "Create Parameter Group" }),
)
expect(
await screen.findByText("Description is required"),
).toBeInTheDocument()
await expect(
screen.findByText("Description is required"),
).resolves.toBeInTheDocument()
expect(mockSend).not.toHaveBeenCalled()
})
})
@@ -202,9 +202,9 @@ describe("ParametersEditor", () => {
})
fireEvent.click(screen.getByRole("button", { name: "Save Changes" }))
expect(
await screen.findByText(/parameter max_connections is static/),
).toBeInTheDocument()
await expect(
screen.findByText(/parameter max_connections is static/),
).resolves.toBeInTheDocument()
})
it("offers no control at all on a read-only group", () => {
@@ -80,7 +80,9 @@ describe("CreateDBSnapshotDialog opened from an instance", () => {
await user.clear(field)
await user.type(field, "rds:orders-db")
submit()
expect(await screen.findByText(/may not begin with/)).toBeInTheDocument()
await expect(
screen.findByText(/may not begin with/),
).resolves.toBeInTheDocument()
expect(mockSend).not.toHaveBeenCalled()
})
@@ -90,7 +92,9 @@ describe("CreateDBSnapshotDialog opened from an instance", () => {
)
render("orders-db")
submit()
expect(await screen.findByText(/is not available/)).toBeInTheDocument()
await expect(
screen.findByText(/is not available/),
).resolves.toBeInTheDocument()
})
})
@@ -60,9 +60,9 @@ describe("DeleteDBSnapshotDialog", () => {
const onDeleted = vi.fn()
render(onDeleted)
fireEvent.click(screen.getByRole("button", { name: "Delete" }))
expect(
await screen.findByText(/is in use by orders-db-restored/),
).toBeInTheDocument()
await expect(
screen.findByText(/is in use by orders-db-restored/),
).resolves.toBeInTheDocument()
expect(onDeleted).not.toHaveBeenCalled()
})
})
@@ -305,7 +305,9 @@ describe("RestoreDBSnapshotPage form", () => {
await selectInstanceClass(user)
fireEvent.click(screen.getByRole("button", { name: "Restore Snapshot" }))
expect(await screen.findByText(/already exists/)).toBeInTheDocument()
await expect(
screen.findByText(/already exists/),
).resolves.toBeInTheDocument()
})
it("builds a CLI command for the restore", () => {
@@ -134,7 +134,9 @@ describe("CreateDBSubnetGroupPage", () => {
fireEvent.click(subnetCheckbox("subnet-a1"))
fireEvent.click(screen.getByRole("button", { name: "Create Subnet Group" }))
expect(await screen.findByText(/the service reserves/)).toBeInTheDocument()
await expect(
screen.findByText(/the service reserves/),
).resolves.toBeInTheDocument()
expect(mockSend).not.toHaveBeenCalled()
})
})
@@ -51,8 +51,8 @@ describe("DeleteDBSubnetGroupDialog", () => {
)
render()
fireEvent.click(screen.getByRole("button", { name: "Delete" }))
expect(
await screen.findByText(/is still used by orders-db/),
).toBeInTheDocument()
await expect(
screen.findByText(/is still used by orders-db/),
).resolves.toBeInTheDocument()
})
})
@@ -538,8 +538,8 @@ describe("RDS cross-slice flow (mocked SDK)", () => {
expect(listed.DBInstances?.[0]?.Endpoint?.Port).toBe(5432)
// The poll the conditional refetchInterval drives, run by hand.
expect(await statusOf(qc)).toBe("creating")
expect(await statusOf(qc)).toBe("available")
await expect(statusOf(qc)).resolves.toBe("creating")
await expect(statusOf(qc)).resolves.toBe("available")
await result.current.modify.mutateAsync({
dbInstanceIdentifier: "orders-db",