diff --git a/workbench/src/renderer/components/SettingsModal/MetadataForm/index.jsx b/workbench/src/renderer/components/SettingsModal/MetadataForm/index.jsx
index 096bcf6d3..dba308450 100644
--- a/workbench/src/renderer/components/SettingsModal/MetadataForm/index.jsx
+++ b/workbench/src/renderer/components/SettingsModal/MetadataForm/index.jsx
@@ -22,7 +22,7 @@ function FormRow(label, value, handler) {
handler(e.currentTarget.value)}
/>
diff --git a/workbench/tests/renderer/app.test.js b/workbench/tests/renderer/app.test.js
index 558379ea3..ffc1d6e77 100644
--- a/workbench/tests/renderer/app.test.js
+++ b/workbench/tests/renderer/app.test.js
@@ -12,7 +12,8 @@ import {
getSpec,
fetchValidation,
fetchDatastackFromFile,
- getSupportedLanguages
+ getSupportedLanguages,
+ getGeoMetaMakerProfile,
} from '../../src/renderer/server_requests';
import InvestJob from '../../src/renderer/InvestJob';
import {
@@ -377,6 +378,8 @@ describe('Display recently executed InVEST jobs on Home tab', () => {
});
test('Recent Jobs: cleared by button', async () => {
+ // we need this mock because the settings dialog is opened
+ getGeoMetaMakerProfile.mockResolvedValue({});
const job1 = new InvestJob({
modelRunName: MOCK_MODEL_RUN_NAME,
modelHumanName: 'Carbon Sequestration',
@@ -419,6 +422,7 @@ describe('InVEST global settings: dialog interactions', () => {
beforeEach(async () => {
getInvestModelNames.mockResolvedValue({});
getSupportedLanguages.mockResolvedValue({ en: 'english', es: 'spanish' });
+ getGeoMetaMakerProfile.mockResolvedValue({});
});
test('Invest settings save on change', async () => {
@@ -477,4 +481,17 @@ describe('InVEST global settings: dialog interactions', () => {
.toBeInTheDocument();
expect(queryByText('Settings')).toBeNull();
});
+
+ test('Access metadata form from settings', async () => {
+ const { findByRole } = render();
+
+ const settingsBtn = await findByRole('button', { name: 'settings' });
+ await userEvent.click(settingsBtn);
+ await userEvent.click(
+ await findByRole('button', { name: 'Configure Metadata' })
+ );
+
+ expect(await findByRole('button', { name: 'Save Metadata' }))
+ .toBeInTheDocument();
+ });
});
diff --git a/workbench/tests/renderer/metadataform.test.js b/workbench/tests/renderer/metadataform.test.js
new file mode 100644
index 000000000..59ffc8310
--- /dev/null
+++ b/workbench/tests/renderer/metadataform.test.js
@@ -0,0 +1,63 @@
+import React from 'react';
+import { render, waitFor } from '@testing-library/react';
+import '@testing-library/jest-dom';
+import userEvent from '@testing-library/user-event';
+
+import MetadataForm from '../../src/renderer/components/SettingsModal/MetadataForm';
+import {
+ getGeoMetaMakerProfile,
+ setGeoMetaMakerProfile,
+} from '../../src/renderer/server_requests';
+
+jest.mock('../../src/renderer/server_requests');
+
+test('Metadata form interact and submit', async () => {
+ const startingName = 'Alice';
+ const startingLicense = '';
+ getGeoMetaMakerProfile.mockResolvedValue({
+ contact: {
+ individual_name: startingName,
+ email: '',
+ organization: '',
+ position_name: '',
+ },
+ license: {
+ title: startingLicense,
+ path: '',
+ },
+ });
+ setGeoMetaMakerProfile.mockResolvedValue({
+ message: 'Metadata profile saved',
+ error: false,
+ });
+
+ const user = userEvent.setup();
+ const { findByRole, getByLabelText, getByRole } = render(
+
+ );
+ // The form should render with content from an existing profile
+ const nameInput = getByLabelText('Full name');
+ await waitFor(() => {
+ expect(nameInput).toHaveValue(startingName);
+ });
+ const licenseInput = getByLabelText('Title');
+ await waitFor(() => {
+ expect(licenseInput).toHaveValue(startingLicense);
+ });
+
+ const name = 'Bob';
+ const license = 'CC-BY-4.0';
+ await user.clear(nameInput);
+ await user.clear(licenseInput);
+ await user.type(nameInput, name);
+ await user.type(licenseInput, license);
+ const submit = getByRole('button', { name: 'Save Metadata' });
+ await user.click(submit);
+
+ expect(await findByRole('alert'))
+ .toHaveTextContent('Metadata profile saved');
+ const payload = setGeoMetaMakerProfile.mock.calls[0][0];
+ expect(Object.keys(payload)).toEqual(['contact', 'license']);
+ expect(payload['contact']['individual_name']).toEqual(name);
+ expect(payload['license']['title']).toEqual(license);
+});