Skip to content

feat: Initial Project Create Form ('/projects/create') #60

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 16 commits into from
Jan 26, 2022
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
Next Next commit
Add smoke test for CreateProjectForm
  • Loading branch information
bryphe-coder committed Jan 25, 2022
commit 9036e600440186a0cca5ea49ae554bd48af63c37
29 changes: 29 additions & 0 deletions site/forms/CreateProjectForm.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { render, screen } from "@testing-library/react"
import React from "react"
import { CreateProjectForm } from "./CreateProjectForm"
import { MockProvisioner, MockOrganization, MockProject } from "./../test_helpers"

describe("CreateProjectForm", () => {
it("renders", async () => {
// Given
const provisioners = [MockProvisioner]
const organizations = [MockOrganization]
const onSubmit = () => Promise.resolve(MockProject)
const onCancel = () => Promise.resolve()

// When
render(
<CreateProjectForm
provisioners={provisioners}
organizations={organizations}
onSubmit={onSubmit}
onCancel={onCancel}
/>,
)

// Then
// Simple smoke test to verify form renders
const element = await screen.findByText("Create Project")
expect(element).toBeDefined()
})
})
2 changes: 1 addition & 1 deletion site/test_helpers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export const render = (component: React.ReactElement): RenderResult => {
return wrappedRender(<WrapperComponent>{component}</WrapperComponent>)
}

export * from "./user"
export * from "./mocks"
31 changes: 31 additions & 0 deletions site/test_helpers/mocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { User } from "../contexts/UserContext"
import { Provisioner, Organization, Project } from "../api"

export const MockUser: User = {
id: "test-user-id",
username: "TestUser",
email: "test@coder.com",
created_at: "",
}

export const MockProject: Project = {
id: "project-id",
created_at: "",
updated_at: "",
organization_id: "test-org",
name: "Test Project",
provisioner: "test-provisioner",
active_version_id: "",
}

export const MockProvisioner: Provisioner = {
id: "test-provisioner",
name: "Test Provisioner",
}

export const MockOrganization: Organization = {
id: "test-org",
name: "Test Organization",
created_at: "",
updated_at: "",
}
8 changes: 0 additions & 8 deletions site/test_helpers/user.ts

This file was deleted.