mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-09 11:28:14 +08:00
Add tests for PlotImportance & PlotIntermediateValues
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import * as Optuna from "@optuna/types"
|
||||
import { render, screen } from "@testing-library/react"
|
||||
import React from "react"
|
||||
import { describe, expect, test } from "vitest"
|
||||
import { PlotImportance } from "../src/components/PlotImportance"
|
||||
|
||||
describe("PlotImportance Tests", async () => {
|
||||
const setup = ({
|
||||
study,
|
||||
importance,
|
||||
dataTestId,
|
||||
}: {
|
||||
study: Optuna.Study
|
||||
importance: Optuna.ParamImportance[][]
|
||||
dataTestId: string
|
||||
}) => {
|
||||
const Wrapper = ({
|
||||
dataTestId,
|
||||
children,
|
||||
}: {
|
||||
dataTestId: string
|
||||
children: React.ReactNode
|
||||
}) => <div data-testid={dataTestId}>{children}</div>
|
||||
return render(
|
||||
<Wrapper dataTestId={dataTestId}>
|
||||
<PlotImportance study={study} importance={importance} />
|
||||
</Wrapper>
|
||||
)
|
||||
}
|
||||
|
||||
for (const study of window.mockStudies) {
|
||||
test(`PlotImportance (study name: ${study.study_name})`, () => {
|
||||
const importance = window.mockImportances[study.study_name] ?? []
|
||||
setup({
|
||||
study,
|
||||
importance,
|
||||
dataTestId: `plot-importance-${study.study_id}`,
|
||||
})
|
||||
expect(
|
||||
screen.getByTestId(`plot-importance-${study.study_id}`)
|
||||
).toBeInTheDocument()
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,38 @@
|
||||
import * as Optuna from "@optuna/types"
|
||||
import { render, screen } from "@testing-library/react"
|
||||
import React from "react"
|
||||
import { describe, expect, test } from "vitest"
|
||||
import { PlotIntermediateValues } from "../src/components/PlotIntermediateValues"
|
||||
|
||||
describe("PlotIntermediateValues Tests", async () => {
|
||||
const setup = ({
|
||||
study,
|
||||
dataTestId,
|
||||
}: { study: Optuna.Study; dataTestId: string }) => {
|
||||
const Wrapper = ({
|
||||
dataTestId,
|
||||
children,
|
||||
}: {
|
||||
dataTestId: string
|
||||
children: React.ReactNode
|
||||
}) => <div data-testid={dataTestId}>{children}</div>
|
||||
return render(
|
||||
<Wrapper dataTestId={dataTestId}>
|
||||
<PlotIntermediateValues
|
||||
trials={study.trials}
|
||||
includePruned={false}
|
||||
logScale={false}
|
||||
/>
|
||||
</Wrapper>
|
||||
)
|
||||
}
|
||||
|
||||
for (const study of window.mockStudies) {
|
||||
test(`PlotIntermediateValues (study name: ${study.study_name})`, () => {
|
||||
setup({ study, dataTestId: `plot-intermediatevalues-${study.study_id}` })
|
||||
expect(
|
||||
screen.getByTestId(`plot-intermediatevalues-${study.study_id}`)
|
||||
).toBeInTheDocument()
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user