Skip to content

End to end testing of various posts, sites, and media #655

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

Open
wants to merge 19 commits into
base: beta-master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 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
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ export default function assistantApiCalls() {
}
}
}

const callSourceCredibilityService = async (urlList) => {
return await callAsyncWithNumRetries(
MAX_NUM_RETRIES,
async () => {
if (urlList.length === 0) return null;

let urls = urlList.join(" ");

const result = await axios.post(
Expand All @@ -114,7 +114,7 @@ export default function assistantApiCalls() {
},
);
};

const callNewsFramingService = async (text) => {
return await callAsyncWithNumRetries(
MAX_NUM_RETRIES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ const AssistantNEResult = () => {
<Box key={index}>
<ListItemButton
key={index}
data-testid={value["category"] + "-dropdown"}
onClick={() => handleCollapse(index)}
>
<ListItemText
Expand Down Expand Up @@ -176,6 +177,7 @@ const AssistantNEResult = () => {
}
rel="noopener noreferrer"
target={"_blank"}
data-testid={v.value}
>
{v.value} &nbsp;
</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ const DbkfMediaResults = () => {
const dbkfImageMatch = useSelector((state) => state.assistant.dbkfImageMatch);
const dbkfVideoMatch = useSelector((state) => state.assistant.dbkfVideoMatch);

console.log(dbkfImageMatch);
console.log(dbkfVideoMatch);

return (
<List disablePadding={true}>
{dbkfImageMatch
Expand All @@ -34,8 +37,10 @@ const DbkfMediaResults = () => {
color={"textPrimary"}
component={"div"}
align={"left"}
data-testid={"dbkf_image_warning_" + value.claimUrl}
>
{keyword("dbkf_image_warning") +
" " +
parseFloat(value.similarity).toFixed(2)}
</Typography>
<Box mb={0.5} />
Expand Down Expand Up @@ -76,8 +81,10 @@ const DbkfMediaResults = () => {
color={"textPrimary"}
component={"div"}
align={"left"}
data-testid={"dbkf_video_warning_" + value.claimUrl}
>
{keyword("dbkf_video_warning") +
" " +
parseFloat(value.similarity).toFixed(2)}
</Typography>
<Box mb={0.5} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ const SourceCredibilityResult = (props) => {
const iconColor = props.iconColor;

return (
<List disablePadding={true}>
<List disablePadding={true} data-testid={props["data-testid"]}>
{sourceCredibilityResults
? sourceCredibilityResults.map((value, key) => (
<ListItem key={key}>
<ListItem
key={key}
data-testid={"source-" + value.credibilitySource}
>
<ListItemAvatar>
<Icon fontSize={"large"} color={iconColor} />
</ListItemAvatar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ const AssistantCredSignals = () => {
onChange={handleChange(newsFramingTitle)}
disabled={newsFramingLoading || newsFramingFail}
disableGutters
data-testid="topic-accordion"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These will be changing from Accordion to CustomTabPanel for genre, topic, persuasion and subjectivity.

>
<AccordionSummary
expandIcon={getExpandIcon(newsFramingLoading, newsFramingFail)}
Expand All @@ -288,7 +289,10 @@ const AssistantCredSignals = () => {
</Typography>
)}
{newsFramingDone && (
<Typography sx={{ color: "text.secondary", align: "start" }}>
<Typography
sx={{ color: "text.secondary", align: "start" }}
data-testid="topic-result"
>
{renderEntityKeys(newsFramingResult.entities, keyword)}
</Typography>
)}
Expand Down Expand Up @@ -335,6 +339,7 @@ const AssistantCredSignals = () => {
onChange={handleChange(newsGenreTitle)}
disabled={newsGenreLoading || newsGenreFail}
disableGutters
data-testid="genre-accordion"
>
<AccordionSummary
expandIcon={getExpandIcon(newsGenreLoading, newsGenreFail)}
Expand All @@ -353,12 +358,18 @@ const AssistantCredSignals = () => {
<Skeleton variant="rounded" width="50%" height={40} />
)}
{newsGenreFail && (
<Typography sx={{ color: "text.secondary", align: "start" }}>
<Typography
sx={{ color: "text.secondary", align: "start" }}
data-testid="genre-result"
>
{keyword("failed_to_load")}
</Typography>
)}
{newsGenreDone && (
<Typography sx={{ color: "text.secondary", align: "start" }}>
<Typography
sx={{ color: "text.secondary", align: "start" }}
data-testid="genre-result"
>
{renderEntityKeys(newsGenreResult.entities, keyword)}
</Typography>
)}
Expand Down Expand Up @@ -411,6 +422,7 @@ const AssistantCredSignals = () => {
Object.keys(persuasionResult.entities).length < 1)
}
disableGutters
data-testid="persuasionTechniques-accordion"
>
<AccordionSummary
expandIcon={getExpandIcon(
Expand Down Expand Up @@ -439,14 +451,18 @@ const AssistantCredSignals = () => {
</Typography>
)}
{persuasionDone && (
<Typography sx={{ color: "text.secondary", align: "start" }}>
<Typography
sx={{ color: "text.secondary", align: "start" }}
data-testid="persuasionTechniques-result"
>
{renderEntityKeys(persuasionResult.entities, keyword)}
</Typography>
)}
{persuasionDone &&
Object.keys(persuasionResult.entities).length < 1 && (
<Typography
sx={{ color: "text.secondary", align: "start" }}
data-testid="persuasionTechniques-result"
>
{keyword("none_detected")}
</Typography>
Expand Down Expand Up @@ -499,6 +515,7 @@ const AssistantCredSignals = () => {
Object.keys(subjectivityResult.entities).length < 1)
}
disableGutters
data-testid="subjectivity-accordion"
>
<AccordionSummary
expandIcon={getExpandIcon(
Expand All @@ -519,14 +536,18 @@ const AssistantCredSignals = () => {
<Skeleton variant="rounded" width="50%" height={40} />
)}
{subjectivityFail && (
<Typography sx={{ color: "text.secondary", align: "start" }}>
<Typography
sx={{ color: "text.secondary", align: "start" }}
data-testid="subjectivity-result"
>
{keyword("failed_to_load")}
</Typography>
)}
{subjectivityDone &&
Object.keys(subjectivityResult.entities).length >= 1 && (
<Typography
sx={{ color: "text.secondary", align: "start" }}
data-testid="subjectivity-result"
>
{keyword("subjective_sentences_detected")}{" "}
{calculateSubjectivity(subjectivityResult.sentences)}
Expand All @@ -536,6 +557,7 @@ const AssistantCredSignals = () => {
Object.keys(subjectivityResult.entities).length < 1 && (
<Typography
sx={{ color: "text.secondary", align: "start" }}
data-testid="subjectivity-result"
>
{keyword("none_detected")}
</Typography>
Expand Down Expand Up @@ -592,6 +614,7 @@ const AssistantCredSignals = () => {
(prevFactChecksDone && prevFactChecksResult.length < 1)
}
disableGutters
data-testid="previousFactChecks-accordion"
>
<AccordionSummary
expandIcon={getExpandIcon(
Expand Down Expand Up @@ -636,6 +659,7 @@ const AssistantCredSignals = () => {
!prevFactChecksResult && (
<Typography
sx={{ color: "text.secondary", align: "start" }}
data-testid="previousFactChecks-result"
>
{keyword("reanalyse_url")}
{/* should now be obselete as saga is re run */}
Expand All @@ -647,7 +671,10 @@ const AssistantCredSignals = () => {
</Typography>
)}
{prevFactChecksDone && prevFactChecksResult.length < 1 && (
<Typography sx={{ color: "text.secondary", align: "start" }}>
<Typography
sx={{ color: "text.secondary", align: "start" }}
data-testid="previousFactChecks-result"
>
{keyword("none_detected")}
</Typography>
)}
Expand Down Expand Up @@ -721,6 +748,7 @@ const AssistantCredSignals = () => {
!role.includes(ROLES.BETA_TESTER)
}
disableGutters
data-testid="machineGeneratedText-accordion"
>
<AccordionSummary
expandIcon={getExpandIcon(
Expand Down Expand Up @@ -758,6 +786,7 @@ const AssistantCredSignals = () => {
machineGeneratedTextResult && (
<Typography
sx={{ color: "text.secondary", align: "start" }}
data-testid="machineGeneratedText-result"
>
{keyword(machineGeneratedTextResult.pred)}
{/* {round(machineGeneratedTextResult.score, 4)} */}
Expand All @@ -770,6 +799,7 @@ const AssistantCredSignals = () => {
!machineGeneratedTextResult && (
<Typography
sx={{ color: "text.secondary", align: "start" }}
data-testid="machineGeneratedText-result"
>
{keyword("reanalyse_url")}
{/* should now be obselete as saga is re run */}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ const ExtractedUrl = (
? extractedSourceCred[link].urlColor
: "inherit"
}
href={
extractedSourceCred
? extractedSourceCred[link].resolvedLink
: link
}
href={href}
>
{extractedSourceCred
? extractedSourceCred[link].resolvedLink
Expand Down Expand Up @@ -121,7 +117,7 @@ const ExtractedUrlList = (
);
}
return (
<div>
<div data-testid="url-domain-analysis">
{links
? links.map((link, index) =>
ExtractedUrl(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const AssistantSCResults = () => {

<IconButton
className={classes.assistantIconRight}
data-testid="url-domain-analysis-button"
onClick={() => dispatch(setAssuranceExpanded(!assuranceExpanded))}
>
<ExpandMoreIcon color={"primary"} />
Expand All @@ -84,6 +85,7 @@ const AssistantSCResults = () => {
scResultFiltered={positiveSourCred}
icon={CheckCircleOutlineIcon}
iconColor="primary"
data-testid="sourceCred-factChecker"
/>
</div>
) : null}
Expand All @@ -100,6 +102,7 @@ const AssistantSCResults = () => {
scResultFiltered={cautionSourceCred}
icon={ErrorOutlineOutlinedIcon}
iconColor="error"
data-testid="sourceCred-warning"
/>
</div>
) : null}
Expand All @@ -116,6 +119,7 @@ const AssistantSCResults = () => {
scResultFiltered={mixedSourceCred}
icon={SentimentSatisfied}
iconColor="action"
data-testid="sourceCred-mentions"
/>
</div>
) : null}
Expand Down
Loading