Skip to content

feat: UX - Initial create form flow #33

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

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
18dd18f
Add several dependencies needed for API routes
bryphe-coder Jan 19, 2022
7329cca
Add placeholder API and projectService
bryphe-coder Jan 19, 2022
6726f40
Create initial workspaces API
bryphe-coder Jan 19, 2022
3f932c2
Port over SafeHydrate component
bryphe-coder Jan 19, 2022
6fdb43f
Stub pages for workspace creation
bryphe-coder Jan 19, 2022
97b2383
Add missed favicons
bryphe-coder Jan 19, 2022
086d533
Formatting
bryphe-coder Jan 19, 2022
82989d3
Merge branch 'bryphe/fix/css-hydration-errors' into bryphe/feat/initi…
bryphe-coder Jan 19, 2022
c305c8d
Initial select page
bryphe-coder Jan 19, 2022
cc411d0
Flip to light theme
bryphe-coder Jan 19, 2022
907a523
Start pulling out AppPage/FormPage
bryphe-coder Jan 19, 2022
56f7515
Start stubbing out API
bryphe-coder Jan 19, 2022
0a5c48a
Start scaffolding project selection
bryphe-coder Jan 19, 2022
aea58ae
Add placeholder icon if none available
bryphe-coder Jan 19, 2022
c92e454
Revert prototyping changes
bryphe-coder Jan 19, 2022
be4c90f
Revert sum changes
bryphe-coder Jan 19, 2022
308de2b
Initial create form
bryphe-coder Jan 19, 2022
d0b0ef1
Rename project function
bryphe-coder Jan 19, 2022
797c82b
Add formik
bryphe-coder Jan 19, 2022
5016b9a
Stub create workspace API
bryphe-coder Jan 19, 2022
8da382b
Hook up formik to create form
bryphe-coder Jan 20, 2022
6fc0a54
Initial shared loading logic
bryphe-coder Jan 20, 2022
e57d1b6
Set up dynamic form components
bryphe-coder Jan 20, 2022
08010c3
Remove leftover buildmode pkg
bryphe-coder Jan 20, 2022
8800445
Add note in api that this is temporary
bryphe-coder Jan 20, 2022
496b42e
Factor ProjectName to separate file
bryphe-coder Jan 20, 2022
646206e
Fix useStyles naming
bryphe-coder Jan 20, 2022
4b6f1c5
Remove accidentally duplicated SafeHydrate
bryphe-coder Jan 20, 2022
961a44b
Remove addition of srverr package
bryphe-coder Jan 20, 2022
eb46f4c
Fix usage of render prop pattern
bryphe-coder Jan 20, 2022
840a796
Fix some compilation issues
bryphe-coder Jan 20, 2022
f20171f
Clean up imports
bryphe-coder Jan 20, 2022
03236df
Add some initial form tests
bryphe-coder Jan 20, 2022
61cd37f
Add smoke test for ProjectIcon
bryphe-coder Jan 20, 2022
99d0a95
Add AppPage smoke test
bryphe-coder Jan 20, 2022
d52bd38
Fix up formatting
bryphe-coder Jan 20, 2022
76d11d4
Remove api from collection metrics since it is temporary
bryphe-coder Jan 20, 2022
ffac475
Clean up unused import
bryphe-coder Jan 20, 2022
e95d75f
Remove and consolidate form ty pes
bryphe-coder Jan 22, 2022
3e8069b
Formatting
bryphe-coder Jan 22, 2022
9492e8e
Merge master
bryphe-coder Jan 22, 2022
e5e02f9
Clean-up utilities
bryphe-coder Jan 22, 2022
5e4a44f
Revert "Remove and consolidate form ty pes"
bryphe-coder Jan 22, 2022
6fe7141
Merge branch 'main' into bryphe/feat/initial-create-form
bryphe-coder Jan 22, 2022
8343ef0
First round of lint failures
bryphe-coder Jan 22, 2022
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 some initial form tests
  • Loading branch information
bryphe-coder committed Jan 20, 2022
commit 03236dfc39970735c22c94464641dfadbe812adc
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"@material-ui/core": "4.9.4",
"@material-ui/icons": "4.5.1",
"@material-ui/lab": "4.0.0-alpha.42",
"@testing-library/jest-dom": "5.16.1",
"@testing-library/react": "12.1.2",
"@testing-library/user-event": "13.5.0",
"@types/express": "4.17.13",
"@types/jest": "27.4.0",
"@types/node": "14.18.4",
Expand All @@ -35,7 +37,8 @@
"ts-jest": "27.1.2",
"ts-loader": "9.2.6",
"ts-node": "10.4.0",
"typescript": "4.5.4"
"typescript": "4.5.4",
"yup": "0.32.11"
},
"dependencies": {}
}
77 changes: 77 additions & 0 deletions site/components/Form/FormTextField.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { act, fireEvent, render, screen } from "@testing-library/react"
import { useFormik } from "formik"
import React from "react"
import * as yup from "yup"
import { formTextFieldFactory, FormTextFieldProps } from "./FormTextField"

namespace Helpers {
export interface FormValues {
name: string
}

export const requiredValidationMsg = "required"

const FormTextField = formTextFieldFactory<FormValues>()

export const Component: React.FC<Omit<FormTextFieldProps<FormValues>, "form" | "formFieldName">> = (props) => {
const form = useFormik<FormValues>({
initialValues: {
name: "",
},
onSubmit: (values, helpers) => {
return helpers.setSubmitting(false)
},
validationSchema: yup.object({
name: yup.string().required(requiredValidationMsg),
}),
})

return <FormTextField {...props} form={form} formFieldName="name" />
}
}

describe("FormTextField", () => {
describe("helperText", () => {
it("uses helperText prop when there are no errors", () => {
// Given
const props = {
helperText: "testing",
}

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

// Then
expect(queryByText(props.helperText)).toBeDefined()
})

it("uses validation message when there are errors", () => {
// Given
const props = {}

// When
const { container } = render(<Helpers.Component {...props} />)
const el = container.firstChild

// Then
expect(el).toBeDefined()
expect(screen.queryByText(Helpers.requiredValidationMsg)).toBeNull()

// When
act(() => {
fireEvent.focus(el as Element)
})

// Then
expect(screen.queryByText(Helpers.requiredValidationMsg)).toBeNull()

// When
act(() => {
fireEvent.blur(el as Element)
})

// Then
expect(screen.queryByText(Helpers.requiredValidationMsg)).toBeDefined()
})
})
})
Loading