Skip to content

feat: add success modal with token value to create token page #7170

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 2 commits into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
added a test for new modal
  • Loading branch information
Kira-Pilot committed Apr 17, 2023
commit 685f06a020868d65f67fa62168cdbf999c1517ad
32 changes: 32 additions & 0 deletions site/src/pages/CreateTokenPage/CreateTokenPage.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {
renderWithAuth,
waitForLoaderToBeRemoved,
} from "testHelpers/renderHelpers"
import { CreateTokenPage } from "pages/CreateTokenPage/CreateTokenPage"
import * as API from "api/api"
import { screen, within } from "@testing-library/react"
import userEvent from "@testing-library/user-event"

describe("TokenPage", () => {
it("shows the success modal", async () => {
jest.spyOn(API, "createToken").mockResolvedValueOnce({
key: "abcd",
})

// When
const { container } = renderWithAuth(<CreateTokenPage />, {
route: "/settings/tokens/new",
path: "/settings/tokens/new",
})
await waitForLoaderToBeRemoved()

const form = container.querySelector("form") as HTMLFormElement
await userEvent.type(screen.getByLabelText(/Name/), "my-token")
await userEvent.click(
within(form).getByRole("button", { name: /create token/i }),
)

// Then
expect(screen.getByText("abcd")).toBeInTheDocument()
})
})
2 changes: 1 addition & 1 deletion site/src/pages/CreateTokenPage/CreateTokenPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const initialValues: CreateTokenData = {
lifetime: 30,
}

const CreateTokenPage: FC = () => {
export const CreateTokenPage: FC = () => {
const { t } = useTranslation("tokensPage")
const styles = useStyles()
const navigate = useNavigate()
Expand Down