Skip to content

Commit

Permalink
correct logic for validating connection modal (#7384)
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Whitten <[email protected]>
  • Loading branch information
beyackle and cwhitten authored Apr 26, 2021
1 parent d95eef8 commit fd7a2cf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const mockSchemas = {
default: 'Adapter.Full.Type.Mock',
},
},
required: ['exampleName'],
},
},
},
Expand Down Expand Up @@ -150,6 +151,21 @@ describe('ExternalAdapterSettings', () => {
});
});

it('does not proceed if required settings are missing', async () => {
const { getByTestId } = renderWithRecoilAndCustomDispatchers(
<ExternalAdapterSettings projectId={PROJECT_ID} />,
initRecoilState
);
const container = getByTestId('adapterSettings');
const configureButton = within(container).queryAllByText('Configure')[0];
act(() => {
fireEvent.click(configureButton);
});

const modal = getByTestId('adapterModal');
expect(within(modal).getByText('Configure')).toBeDisabled();
});

it('disables an adapter', async () => {
const initStateWithAdapter = {
runtimeSettings: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Props = {

export function hasRequired(testObject: { [key: string]: JSONSchema7Type | undefined }, fields?: string[]) {
if (fields == null || fields.length === 0) return true;
return fields.every((field: string) => field in testObject);
return fields.every((field: string) => field in testObject && testObject[field] != null);
}

function makeDefault(schema: JSONSchema7) {
Expand Down

0 comments on commit fd7a2cf

Please sign in to comment.