From b2d7ae389bac43c8dbc9b617600151b3717c75a9 Mon Sep 17 00:00:00 2001
From: Anthony Geourjon <anthony.geourjon@tetras-libre.fr>
Date: Thu, 2 Mar 2023 15:52:57 +0100
Subject: [PATCH] WIP fixing test

---
 .../src/components/CanvasAnnotations.test.js  |  4 +--
 setup-expect-timeout.js                       |  2 ++
 .../AnnotationManifestsAccordion.js           | 34 ++++++++++---------
 src/components/CanvasAnnotations.js           | 11 ++----
 .../WindowSideBarAnnotationsPanel.js          |  4 +--
 5 files changed, 26 insertions(+), 29 deletions(-)

diff --git a/__tests__/src/components/CanvasAnnotations.test.js b/__tests__/src/components/CanvasAnnotations.test.js
index a51a744c9..843d02f37 100644
--- a/__tests__/src/components/CanvasAnnotations.test.js
+++ b/__tests__/src/components/CanvasAnnotations.test.js
@@ -46,8 +46,8 @@ describe('CanvasAnnotations', () => {
 
     expect(wrapper.find(Typography).length).toBe(1);
     let heading = wrapper.find(Typography).props().children;
-    expect(heading.key).toEqual('annotationCanvasLabel');
-    expect(heading.args.label).toEqual('A Canvas Label');
+    console.log(heading);
+    expect(heading.key).toEqual('showingNumAnnotations');
     expect(heading.args.context).toEqual('1/1');
 
     wrapper = createWrapper({ annotations, index: 1, totalSize: 2 });
diff --git a/setup-expect-timeout.js b/setup-expect-timeout.js
index 12c8b982d..a1cd3440d 100644
--- a/setup-expect-timeout.js
+++ b/setup-expect-timeout.js
@@ -1,2 +1,4 @@
+// eslint-disable-next-line import/no-extraneous-dependencies
 const { setDefaultOptions } = require('expect-puppeteer');
+
 setDefaultOptions({ timeout: 2000 });
diff --git a/src/components/AnnotationManifestsAccordion.js b/src/components/AnnotationManifestsAccordion.js
index 95cb2f11e..ebebc7a04 100644
--- a/src/components/AnnotationManifestsAccordion.js
+++ b/src/components/AnnotationManifestsAccordion.js
@@ -1,4 +1,4 @@
-import React, { Component } from 'react';
+import { Component } from 'react';
 import Accordion from '@material-ui/core/Accordion';
 import AccordionSummary from '@material-ui/core/AccordionSummary';
 import ExpandMoreIcon from '@material-ui/icons/ExpandMoreSharp';
@@ -6,11 +6,10 @@ import Typography from '@material-ui/core/Typography';
 import AccordionDetails from '@material-ui/core/AccordionDetails';
 import PropTypes from 'prop-types';
 import {
-  Card, CardActionArea, CardActions, CardContent, CardMedia, Fab,
+  Card, CardActionArea, CardActions, CardContent,
 } from '@material-ui/core';
 import Button from '@material-ui/core/Button';
 import Tooltip from '@material-ui/core/Tooltip';
-import { removeDuplicates } from '../helper/utils';
 
 /**
  * AnnotationManifestsAccordion
@@ -89,8 +88,6 @@ export class AnnotationManifestsAccordion extends Component {
       classes, t, i18n,
     } = this.props;
 
-    const language = i18n.language;
-
     const { annotation } = this.state;
 
     if (annotation.manifests === null || annotation.manifests.length === 0) {
@@ -104,17 +101,17 @@ export class AnnotationManifestsAccordion extends Component {
             expandIcon={<ExpandMoreIcon />}
             onClick={(e) => this.handleOpenAccordion(e)}
           >
-            <Typography className={classes.heading}>{t('manifestFound')}</Typography>
+            <Typography>{t('manifestFound')}</Typography>
 
           </AccordionSummary>
           <AccordionDetails className={classes.manifestContainer}>
             {annotation.manifests.map(manifest => (
-              <Typography >
-                <Card className={classes.root}>
+              <Typography>
+                <Card>
                   <CardActionArea>
                     <CardContent>
                       <Typography>
-                        { manifest.label ? manifest.label[language] : manifest.id }
+                        { manifest.label ? manifest.label[i18n.language] : manifest.id }
                       </Typography>
                     </CardContent>
                   </CardActionArea>
@@ -144,18 +141,23 @@ export class AnnotationManifestsAccordion extends Component {
 AnnotationManifestsAccordion.propsTypes = {
   addResource: PropTypes.func.isRequired,
   addWindow: PropTypes.func.isRequired,
-  annotation: PropTypes.shape(
-    {
-      content: PropTypes.string,
-      id: PropTypes.string,
-      manifests: PropTypes.arrayOf(PropTypes.string),
-    },
-  ),
+  annotation: PropTypes.shape({
+    content: PropTypes.string,
+    id: PropTypes.string,
+    manifests: PropTypes.shape({
+      id: PropTypes.string.isRequired,
+      label: PropTypes.string.isRequired,
+    }),
+  }),
   classes: PropTypes.objectOf(PropTypes.string),
+  i18n: PropTypes.shape({
+    language: PropTypes.string,
+  }),
   t: PropTypes.func.isRequired,
 };
 
 AnnotationManifestsAccordion.defaultProps = {
+  annotation: [],
   classes: {},
   htmlSanitizationRuleSet: 'iiif',
   listContainerComponent: 'li',
diff --git a/src/components/CanvasAnnotations.js b/src/components/CanvasAnnotations.js
index a45baead1..107ca2978 100644
--- a/src/components/CanvasAnnotations.js
+++ b/src/components/CanvasAnnotations.js
@@ -7,8 +7,6 @@ import MenuItem from '@material-ui/core/MenuItem';
 import ListItemText from '@material-ui/core/ListItemText';
 import Typography from '@material-ui/core/Typography';
 import SearchIcon from '@material-ui/icons/SearchSharp';
-import InputBase from '@material-ui/core/InputBase';
-import CircularProgress from '@material-ui/core/CircularProgress';
 import TextField from '@material-ui/core/TextField';
 import SanitizedHtml from '../containers/SanitizedHtml';
 import { ScrollTo } from './ScrollTo';
@@ -73,7 +71,7 @@ export class CanvasAnnotations extends Component {
   */
   render() {
     const {
-      autoScroll, classes, index, label, selectedAnnotationId, t, totalSize,
+      autoScroll, classes, selectedAnnotationId, t,
       listContainerComponent, htmlSanitizationRuleSet, hoveredAnnotationIds,
       containerRef,
     } = this.props;
@@ -84,7 +82,7 @@ export class CanvasAnnotations extends Component {
 
     const { inputSearch } = this.state;
 
-    if (inputSearch != undefined && inputSearch !== '') {
+    if (inputSearch !== undefined && inputSearch !== '') {
       annotations = filterAnnotation(annotations, inputSearch);
     }
 
@@ -156,7 +154,7 @@ export class CanvasAnnotations extends Component {
               </ScrollTo>
             ))
           }
-          {annotations.length == 0
+          {annotations.length === 0
             && (
             <MenuItem>
               <Typography>
@@ -190,13 +188,10 @@ CanvasAnnotations.propTypes = {
   hoverAnnotation: PropTypes.func.isRequired,
   hoveredAnnotationIds: PropTypes.arrayOf(PropTypes.string),
   htmlSanitizationRuleSet: PropTypes.string,
-  index: PropTypes.number.isRequired,
-  label: PropTypes.string.isRequired,
   listContainerComponent: PropTypes.elementType,
   selectAnnotation: PropTypes.func.isRequired,
   selectedAnnotationId: PropTypes.string,
   t: PropTypes.func.isRequired,
-  totalSize: PropTypes.number.isRequired,
   windowId: PropTypes.string.isRequired,
 };
 CanvasAnnotations.defaultProps = {
diff --git a/src/components/WindowSideBarAnnotationsPanel.js b/src/components/WindowSideBarAnnotationsPanel.js
index 0a4436e7a..8841af1ed 100644
--- a/src/components/WindowSideBarAnnotationsPanel.js
+++ b/src/components/WindowSideBarAnnotationsPanel.js
@@ -21,7 +21,7 @@ export class WindowSideBarAnnotationsPanel extends Component {
   */
   render() {
     const {
-      annotationCount, classes, canvasIds, t, windowId, id,
+      canvasIds, t, windowId, id,
     } = this.props;
     return (
       <CompanionWindow
@@ -49,9 +49,7 @@ export class WindowSideBarAnnotationsPanel extends Component {
 }
 
 WindowSideBarAnnotationsPanel.propTypes = {
-  annotationCount: PropTypes.number.isRequired,
   canvasIds: PropTypes.arrayOf(PropTypes.string),
-  classes: PropTypes.objectOf(PropTypes.string).isRequired,
   id: PropTypes.string.isRequired,
   t: PropTypes.func,
   windowId: PropTypes.string.isRequired,
-- 
GitLab