Skip to content

Commit

Permalink
avance con #196 y cambio en yml
Browse files Browse the repository at this point in the history
  • Loading branch information
aliciafp15 committed Apr 27, 2023
1 parent affdcc3 commit 60ce74f
Show file tree
Hide file tree
Showing 14 changed files with 168 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const ImageCommentCard = (props) => {
const classes = useStyles();
const {key, image} = props;
const [open, setOpen] = React.useState(false);
const posterWebId = image.posterWebId;
const posterWebId = image?.posterWebId;
//const friendUrl = friend.friendURL;
const parts = posterWebId.split("/");
const part = parts[2].split(".")[0];
const parts = posterWebId?.split("/");
const part = parts?.[2]?.split(".")[0];
const handleClickOpen = () => {
setOpen(true);
};
Expand All @@ -30,8 +30,8 @@ const ImageCommentCard = (props) => {
// console.log(friend.profilePicture);
return (
<div>
<CombinedDataProvider datasetUrl={posterWebId} thingUrl={posterWebId}>
<Card style={{margin: '25px', marginTop:'0px'}}>
<CombinedDataProvider data-testid="dataProvider" datasetUrl={posterWebId} thingUrl={posterWebId}>
<Card data-testid="imageCommentCard" style={{margin: '25px', marginTop:'0px'}}>
<CardHeader
component='div' style={{paddingBottom: '10px'}}
avatar={
Expand All @@ -53,7 +53,7 @@ const ImageCommentCard = (props) => {
// title={<Typography variant="h5" style={{ fontSize: "16px"}}>
// {imageURL.text}
// </Typography>}
title={<img src={image.text} style={{maxWidth: '100%', maxHeight: '30vh'}}/>}
title={<img src={image?.text} style={{maxWidth: '100%', maxHeight: '30vh'}}/>}
subheader={<Typography variant="h6" color="textSecondary" style={{fontSize: "16px"}}><Text property={VCARD.fn.iri.value} /> | {part}</Typography>}
/>
{/*<CardContent component="div" style={{paddingTop: '0px'}} >*/}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const RatingCommentCard = (props) => {
const classes = useStyles();
const {key, rating} = props;
const [open, setOpen] = React.useState(false);
const posterWebId = rating.posterWebId;
const posterWebId = rating?.posterWebId;
//const friendUrl = friend.friendURL;
const parts = posterWebId.split("/");
const part = parts[2].split(".")[0];
const parts = posterWebId?.split("/");
const part = parts?.[2]?.split(".")[0];
const handleClickOpen = () => {
setOpen(true);
};
Expand All @@ -39,7 +39,9 @@ const RatingCommentCard = (props) => {
height: "65px",
margin: 'auto',
marginBottom:'10px'}}
alt="Friend image profile">
alt="Friend image profile"
data-testid="avatarCard"
>
<Image property={VCARD.hasPhoto.iri.value} style={{maxHeight: '65px'}}/>
</Avatar>
}
Expand All @@ -56,7 +58,7 @@ const RatingCommentCard = (props) => {
title={
<Rating
name="simple-controlled"
value={rating.value}
value={rating?.value}
readOnly
/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ const TextCommentCard = (props) => {
const classes = useStyles();
const {key, comment} = props;
const [open, setOpen] = React.useState(false);
const posterWebId = comment.posterWebId;
const posterWebId = comment?.posterWebId;
//const friendUrl = friend.friendURL;
const parts = posterWebId.split("/");
const part = parts[2].split(".")[0];
const parts = posterWebId?.split("/");
const part = parts?.[2]?.split(".")[0];
const handleClickOpen = () => {
setOpen(true);
};
Expand Down Expand Up @@ -53,7 +53,7 @@ const TextCommentCard = (props) => {
// </>
// }
title={<Typography variant="h5" style={{ fontSize: "16px"}}>
{comment.text}
{comment?.text}
</Typography>}
subheader={<Typography variant="h6" color="textSecondary" style={{fontSize: "16px"}}><Text property={VCARD.fn.iri.value} /> | {part}</Typography>}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ const SplitButton = (props) => {
return (
<React.Fragment>
<ButtonGroup variant="contained" ref={anchorRef} aria-label="split button">
<Button onClick={()=>handleClickOpen(options[selectedIndex])}>{options[selectedIndex]}</Button>
<Button
<Button onClick={()=>handleClickOpen(options[selectedIndex])} data-testid="AddCommentBotton">{options[selectedIndex]} </Button>
<Button data-testid="botonMenuComment"
size="small"
aria-controls={open ? 'split-button-menu' : undefined}
aria-expanded={open ? 'true' : undefined}
Expand Down
10 changes: 9 additions & 1 deletion webapp/src/components/CommentsSidebar/CommentsSidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ const CommentsSidebar = (props) => {
const handleCommentTypeChange = (value) => {
setSelectedCommentType(value);
}

const options = [
{ value: 'text', label: 'Text comments' },
{ value: 'rating', label: 'Ratings' },
{ value: 'image', label: 'Images' },
];

return (
<>
<div style={{ height: '100%', marginLeft: '25px', marginRight: '25px', marginBottom: '5px', textAlign: 'center', display:'flex', flexDirection: 'column', gap: '25px'}}>
Expand All @@ -147,13 +154,14 @@ const CommentsSidebar = (props) => {
data-testid = "addCommentButton" />
</div>
<FormControl fullWidth>
<InputLabel id="demo-simple-select-label">Showing</InputLabel>
<InputLabel id="demo-simple-select-label" data-testid= "commentSidebarLabelShowing" >Showing</InputLabel>
<Select

labelId="demo-simple-select-label"
id="demo-simple-select"
value={selectedCommentType}
label="Type of comments to show"
data-testid= "Type of comments to show"
>
<MenuItem onClick={()=>handleCommentTypeChange("text")} value={"text"}>Text comments</MenuItem>
<MenuItem onClick={()=>handleCommentTypeChange("rating")} value={"rating"}>Ratings</MenuItem>
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/components/Map/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const Map = (props) => {
}

const showPlaces = () => {
if(selectedFilters.length === 0){
if(selectedFilters?.length === 0){
return showingPlaces?.map((place) => (
<Marker key={place.id} position={{lat: place.latitude, lng: place.longitude}} icon={blueIcon}>
<Popup>
Expand Down
16 changes: 16 additions & 0 deletions webapp/src/tests/CommentsCard/ImageCommentCard.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import MyPlacesSidebar from "../../components/MyPlacesSidebar/MyPlacesSidebar";
import {fireEvent, render, screen} from "@testing-library/react";
import userEvent from '@testing-library/user-event';
import App from "../../App";
import ImageCommentCard from "../../components/CommentCards/ImageCommentCard/ImageCommentCard";

test('testing ImageCommentCard', () => {

render(<ImageCommentCard />);

//ebusca el boton
//const dataProvider = screen.getByTestId("dataProvider")
//expect(dataProvider).toBeInTheDocument();

});

22 changes: 22 additions & 0 deletions webapp/src/tests/CommentsCard/RatingCommentCard.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import MyPlacesSidebar from "../../components/MyPlacesSidebar/MyPlacesSidebar";
import {fireEvent, render, screen} from "@testing-library/react";
import userEvent from '@testing-library/user-event';
import App from "../../App";
import RatingCommentCard from "../../components/CommentCards/RatingCommentCard/RatingCommentCard";

test('testing RatingCommentCard', () => {

render(<RatingCommentCard />);

/*
const avatarElement = screen.getByTestId('avatarCard');
const imageElement = screen.getByRole('img');
const typographyElement = screen.getByText(/@/i);
expect(avatarElement).toBeInTheDocument();
expect(imageElement).toBeInTheDocument();
expect(typographyElement).toBeInTheDocument();
*/

});

22 changes: 22 additions & 0 deletions webapp/src/tests/CommentsCard/TextCommentCard.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import MyPlacesSidebar from "../../components/MyPlacesSidebar/MyPlacesSidebar";
import {fireEvent, render, screen} from "@testing-library/react";
import userEvent from '@testing-library/user-event';
import App from "../../App";
import TextCommentCard from "../../components/CommentCards/TextCommentCard/TextCommentCard";

test('testing textCommentCard', () => {

render(<TextCommentCard />);

/*
const avatarElement = screen.getByTestId('avatarCard');
const imageElement = screen.getByRole('img');
const typographyElement = screen.getByText(/@/i);
expect(avatarElement).toBeInTheDocument();
expect(imageElement).toBeInTheDocument();
expect(typographyElement).toBeInTheDocument();
*/

});

14 changes: 0 additions & 14 deletions webapp/src/tests/CommentsSidebar.test.js

This file was deleted.

23 changes: 23 additions & 0 deletions webapp/src/tests/CommentsSidebar/AddCommentButton.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import MyPlacesSidebar from "../../components/MyPlacesSidebar/MyPlacesSidebar";
import {fireEvent, render, screen} from "@testing-library/react";
import userEvent from '@testing-library/user-event';
import App from "../../App";
import AddCommentButton from "../../components/CommentsSidebar/AddCommentButton/AddCommentButton";

test('testing AddCommentButton', () => {

render(<AddCommentButton />);

//ebusca el boton
const boton = screen.getByTestId("AddCommentBotton")
expect(boton).toBeInTheDocument();

// Comprueba que el texto del botón sea el esperado
expect(boton.textContent).toBe('Add a text comment ');


// Comprueba que el menú desplegable se ha renderizado
const menu = screen.getByTestId("botonMenuComment");
expect(menu).toBeInTheDocument();
});

28 changes: 28 additions & 0 deletions webapp/src/tests/CommentsSidebar/CommentsSidebar.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import MyPlacesSidebar from "../../components/MyPlacesSidebar/MyPlacesSidebar";
import {fireEvent, render, screen} from "@testing-library/react";
import userEvent from '@testing-library/user-event';
import App from "../../App";
import CommentsSidebar from "../../components/CommentsSidebar/CommentsSidebar";

test('testing CommentsSidebar', () => {

render(<CommentsSidebar />);

//busca el boton para añadir comentario
const addBotton = screen.getByRole("button", {name:'Add a text comment'});
expect(addBotton).toBeInTheDocument();

//etiqueta showing
const showing = screen.getByTestId("commentSidebarLabelShowing")
expect(showing).toBeInTheDocument();

//tipo de comentarios
const select = screen.getByTestId('Type of comments to show');
expect(select).toBeInTheDocument();





});

15 changes: 15 additions & 0 deletions webapp/src/tests/Map.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {fireEvent, render, screen} from "@testing-library/react";
import userEvent from '@testing-library/user-event';
import App from "../App";
import Map from "../components/Map/Map";

test('testing Map', () => {

const setSelectedPoint = {lat : -1.22222, lng:-3.564642};
//mismo problema: expected a string but got undefined
//render(<Map setSelectedPoint={setSelectedPoint} />);



});

13 changes: 13 additions & 0 deletions webapp/src/tests/MyPlacesSidebar.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {fireEvent, render, screen} from "@testing-library/react";
import userEvent from '@testing-library/user-event';
import App from "../App";
import MyPlacesSidebar from "../components/MyPlacesSidebar/MyPlacesSidebar";

test('testing MyPlacesSidebar', () => {

render(<MyPlacesSidebar />);



});

0 comments on commit 60ce74f

Please sign in to comment.