Skip to content

Commit

Permalink
uncertaintynarrative and test
Browse files Browse the repository at this point in the history
  • Loading branch information
tevko committed Dec 13, 2024
1 parent 78707a6 commit 85f1c01
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 16 deletions.
12 changes: 2 additions & 10 deletions client-report/src/components/app.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
// Copyright (C) 2012-present, The Authors. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License, version 3, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

import React from "react";
// import { connect } from "react-redux";
// import probabilities from "../sampleData/probabilities";
// import covariance from "../sampleData/covariance";
// import correlation from "../sampleData/correlation";
// import correlationHClust from "../sampleData/correlationHClust"
import _ from "lodash";

import * as globals from "./globals";
import URLs from "../util/url";
import DataUtils from "../util/dataUtils";
// import Matrix from "./correlationMatrix/matrix";
import Heading from "./framework/heading.jsx";
import Footer from "./framework/Footer.jsx";
import Overview from "./overview";
import MajorityStrict from "./lists/majorityStrict.jsx";
import Uncertainty from "./lists/uncertainty";
import UncertaintyNarrative from "./lists/uncertaintyNarrative";
import Uncertainty from "./lists/uncertainty.jsx";
import UncertaintyNarrative from "./lists/uncertaintyNarrative.jsx";
import AllCommentsModeratedIn from "./lists/allCommentsModeratedIn.jsx";
import ParticipantGroups from "./lists/participantGroups.jsx";
// import CommentsGraph from "./commentsGraph/commentsGraph";
import ParticipantsGraph from "./participantsGraph/participantsGraph";
// import BoxPlot from "./boxPlot/boxPlot";
import Beeswarm from "./beeswarm/beeswarm.jsx";
import Controls from "./controls/controls.jsx";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import React from "react";
import CommentList from "./commentList.jsx";
import * as globals from "../globals";
import * as globals from "../globals.js";
// import style from "../../util/style";
import Narrative from "../narrative";
import Narrative from "../narrative/index.js";

const Uncertainty = ({
conversation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

import React from "react";
import CommentList from "./commentList.jsx";
import * as globals from "../globals";
// import style from "../../util/style";
import Narrative from "../narrative";
import * as globals from "../globals.js";
import Narrative from "../narrative/index.js";

const UncertaintyNarrative = ({
conversation,
comments,
ptptCount,
uncertainty,
formatTid,
math,
voteColors,
Expand Down
49 changes: 49 additions & 0 deletions client-report/src/components/lists/uncertaintyNarrative.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import UncertaintyNarrative from './uncertaintyNarrative';
import * as globals from '../globals.js'; // Mock globals if necessary
jest.mock('../narrative/index.js', () => ({ model }) => <div data-testid={`mock-narrative-${model}`} /> ); // Mock Narrative
jest.mock('./commentList.jsx', () => () => <div data-testid="mock-comment-list" />);
import '@testing-library/jest-dom';

describe('UncertaintyNarrative Component', () => {
const mockProps = {
conversation: {},
comments: {},
ptptCount: 100,
formatTid: jest.fn((tid) => `TID${tid}`),
math: {},
voteColors: {},
narrative: {
uncertainty: {
responseClaude: { content: [{ text: '"paragraphs":[{"sentences":[{"clauses":[{"citations":["T1","T2"]}]}]}]}' }] },
responseGemini: '{"paragraphs":[{"sentences":[{"clauses":[{"citations":["T3"]}]}]}]}'
}
},
model: 'claude'
};

it('renders loading message when data is missing', () => {
render(<UncertaintyNarrative conversation={null} />);
expect(screen.getByText('Loading Uncertainty...')).toBeInTheDocument();
});

it('renders component with narrative and comment list when data is present (Claude model)', () => {
render(<UncertaintyNarrative {...mockProps} />);

expect(screen.getByText('Uncertainty Narrative')).toBeInTheDocument();
expect(screen.getByText('This narrative summary may contain hallucinations. Check each clause.')).toBeInTheDocument();
expect(screen.getByTestId('mock-narrative-claude')).toBeInTheDocument();
expect(screen.getByTestId('mock-comment-list')).toBeInTheDocument();
});

it('renders component with narrative and comment list when data is present (Gemini model)', () => {
render(<UncertaintyNarrative {...mockProps} model="gemini" />);

expect(screen.getByText('Uncertainty Narrative')).toBeInTheDocument();
expect(screen.getByText('This narrative summary may contain hallucinations. Check each clause.')).toBeInTheDocument();
expect(screen.getByTestId('mock-narrative-gemini')).toBeInTheDocument();
expect(screen.getByTestId('mock-comment-list')).toBeInTheDocument();
});

});

0 comments on commit 85f1c01

Please sign in to comment.