Skip to content
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

Fix#143: Enable ability to edit org if website or github isn't provided #150

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 4 additions & 2 deletions src/components/form/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import { FormField } from './utils';

const strValidator = Yup.string().trim().required('Required');
const optionalValidator = Yup.string().trim().nullable();
const strValidatorNotRequired = Yup.string().trim();
const badgeObjectStrValidator = Yup.object().shape({
value: strValidator
Expand Down Expand Up @@ -823,7 +824,7 @@ export const organizationSchema: FormField[] = [
name: 'website',
label: 'Website',
type: 'text',
validator: strValidator,
validator: optionalValidator,
style: {
gridArea: '2 / 1 / 3 / 2',
height: '85px'
Expand All @@ -837,7 +838,7 @@ export const organizationSchema: FormField[] = [
label: 'Github repo',
type: 'text',
prepend: 'https://github.com/',
validator: strValidator,
validator: optionalValidator,
style: {
gridArea: '3 / 1 / 4 / 2',
height: '85px'
Expand All @@ -850,6 +851,7 @@ export const organizationSchema: FormField[] = [
name: 'description',
label: 'Description',
type: 'textarea',
validator: Yup.string().optional(),
style: {
height: '202px',
gridArea: '1 / 2 / 4 / 3'
Expand Down
23 changes: 22 additions & 1 deletion src/people/widgetViews/__tests__/EditOrgModal.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '@testing-library/jest-dom';
import React from 'react';
import { render, screen } from '@testing-library/react';
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import { Organization } from 'store/main';
import EditOrgModal from '../organization/EditOrgModal';

Expand Down Expand Up @@ -65,4 +65,25 @@ describe('EditOrgModal Component', () => {
render(<EditOrgModal {...props} />);
expect(screen.getByText(/Delete Organization/i)).toBeInTheDocument();
});

test('Save button is enabled if name have a value, and website, github, logo, description are empty', async () => {
render(<EditOrgModal {...props} />);

fireEvent.change(screen.getByLabelText(/Organization Name/i) as HTMLInputElement, {
target: { value: 'Updated Org' }
});

await waitFor(() => {
fireEvent.change(screen.getByLabelText(/Description/i) as HTMLInputElement, {
target: { value: '' }
});
fireEvent.change(screen.getByLabelText(/Website/i) as HTMLInputElement, {
target: { value: '' }
});
fireEvent.change(screen.getByLabelText(/Github repo/i) as HTMLInputElement, {
target: { value: '' }
});
expect(screen.getByText(/Save changes/i)).toBeEnabled();
});
});
});
6 changes: 3 additions & 3 deletions src/people/widgetViews/organization/EditOrgModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ const EditOrgModal = (props: EditOrgModalProps) => {
name: body.name || org.name,
owner_pubkey: org.owner_pubkey,
img: img || org.img,
description: body.description || org?.description,
github: body.github || org?.github,
website: body.website || org?.website,
description: body.description !== undefined ? body.description : org?.description || null,
github: body.github !== undefined ? body.github : org?.github || null,
website: body.website !== undefined ? body.website : org?.website || null,
created: org.created,
updated: org.updated,
show: body?.show !== undefined ? body.show : org.show,
Expand Down
Loading