Skip to content

Commit

Permalink
a test to cover a previously uncaught exception in RecentInvestJobs. n…
Browse files Browse the repository at this point in the history
  • Loading branch information
davemfish committed Dec 5, 2022
1 parent 5171d42 commit dcee66e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
1 change: 0 additions & 1 deletion workbench/src/renderer/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ export default class App extends React.Component {
}

render() {
throw new Error('help')
const {
investList,
investSettings,
Expand Down
1 change: 1 addition & 0 deletions workbench/src/renderer/components/HomeTab/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class RecentInvestJobs extends React.Component {
const recentButtons = [];
const { recentJobs } = this.props;
recentJobs.forEach((job) => {
if (!job.argsValues) { return; }
recentButtons.push(
<Card
className="text-left recent-job-card"
Expand Down
24 changes: 24 additions & 0 deletions workbench/tests/renderer/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,30 @@ describe('Display recently executed InVEST jobs on Home tab', () => {
});
});

test('Recent Jobs: a job with incomplete data is skipped', async () => {
const job1 = new InvestJob({
modelRunName: 'carbon',
modelHumanName: 'invest A',
argsValues: {
workspace_dir: 'dir',
},
status: 'success',
});
const job2 = new InvestJob({
// argsValues is missing
modelRunName: 'sdr',
modelHumanName: 'invest B',
status: 'success',
});
await InvestJob.saveJob(job1);
await InvestJob.saveJob(job2);

const { findByText, queryByText } = render(<App />);

expect(await findByText(job1.modelHumanName)).toBeInTheDocument();
expect(queryByText(job2.modelHumanName)).toBeNull();
});

test('Recent Jobs: placeholder if there are no recent jobs', async () => {
const { findByText } = render(
<App />
Expand Down

0 comments on commit dcee66e

Please sign in to comment.