diff --git a/client/dist/styles.css b/client/dist/styles.css index 7f23cb1..a186ad7 100644 --- a/client/dist/styles.css +++ b/client/dist/styles.css @@ -548,9 +548,15 @@ input:checked+.slider:before { margin-top: 20px; border-bottom: solid grey 2px; } + +.question-helpful-div { + display: inline-flex; + flex-direction: row; + font-size: 15px; +} /* .question-list { width: auto; - height: 40vh; + height: 50vh; overflow-y: scroll; } */ .question-control { diff --git a/client/src/QA/QAcomponents/AddQuestion.jsx b/client/src/QA/QAcomponents/AddQuestion.jsx index 814d41b..b762781 100644 --- a/client/src/QA/QAcomponents/AddQuestion.jsx +++ b/client/src/QA/QAcomponents/AddQuestion.jsx @@ -12,7 +12,7 @@ const AddQuestion = ({ productId, handleModalClose, openModal, prodName }) => { }; const regexVerifyEmail = (email) => { - const characterTest = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; + const characterTest = /^(([^<>()[\]\\.,;:\s@']+(\.[^<>()[\]\\.,;:\s@']+)*)|('.+'))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return characterTest.test(email); }; @@ -31,7 +31,9 @@ const AddQuestion = ({ productId, handleModalClose, openModal, prodName }) => { body: questionBody, name: name, email: email, + /* eslint-disable */ product_id: productId + /* eslint-enable */ }) .then((response) => { console.log('succesful question post', response.data); @@ -43,7 +45,7 @@ const AddQuestion = ({ productId, handleModalClose, openModal, prodName }) => { : null; }; const QuestionModalForm = ( -
selectModal(event)} > @@ -66,11 +68,11 @@ const AddQuestion = ({ productId, handleModalClose, openModal, prodName }) => { { dataFill(event); }} - placeholder="Example: jack@email.com" - type="email" + placeholder='Example: jack@email.com' + type='email' name='email' - maxLength="60" - autoComplete="off" + maxLength='60' + autoComplete='off' value={email} required > @@ -83,11 +85,11 @@ const AddQuestion = ({ productId, handleModalClose, openModal, prodName }) => { { dataFill(event); }} - placeholder="Examples: jackson11!" - type="text" + placeholder='Examples: jackson11!' + type='text' name='name' - maxLength="60" - autoComplete="off" + maxLength='60' + autoComplete='off' value={name} required > @@ -100,12 +102,12 @@ const AddQuestion = ({ productId, handleModalClose, openModal, prodName }) => { diff --git a/client/src/QA/QAcomponents/AnswerHelpful.jsx b/client/src/QA/QAcomponents/AnswerHelpful.jsx index ea42b64..50a35ab 100644 --- a/client/src/QA/QAcomponents/AnswerHelpful.jsx +++ b/client/src/QA/QAcomponents/AnswerHelpful.jsx @@ -33,7 +33,7 @@ const AnswerHelpful = ({ answerHelpfulness, answerDate, answerId, answerName }) : null; }; return ( -
+
<>by {answerName}, {convertDate(answerDate)} |  Helpful? 

{ ); return ( -

+
( -
+
A: {answer.body}
{answer.photos.length ? answer.photos.map((photo, id) => ( diff --git a/client/src/QA/QAcomponents/MoreAnswers.jsx b/client/src/QA/QAcomponents/MoreAnswers.jsx index afef56f..f7ea939 100644 --- a/client/src/QA/QAcomponents/MoreAnswers.jsx +++ b/client/src/QA/QAcomponents/MoreAnswers.jsx @@ -5,7 +5,7 @@ const MoreAnswers = ({ answer, answerList }) => { const [collapseAnswers, setCollapseAnswers] = useState(true); return ( -
+
{ collapseAnswers ? <> diff --git a/client/src/QA/QAcomponents/MoreQuestions.jsx b/client/src/QA/QAcomponents/MoreQuestions.jsx index 018feda..00b7cbe 100644 --- a/client/src/QA/QAcomponents/MoreQuestions.jsx +++ b/client/src/QA/QAcomponents/MoreQuestions.jsx @@ -5,7 +5,7 @@ const MoreQuestions = ({ questions }) => { const [collapseQuestions, setCollapseQuestions] = useState(true); return ( -
+
{ collapseQuestions ? <> diff --git a/client/src/QA/QAcomponents/Question.jsx b/client/src/QA/QAcomponents/Question.jsx index 9a1f50d..8e65d08 100644 --- a/client/src/QA/QAcomponents/Question.jsx +++ b/client/src/QA/QAcomponents/Question.jsx @@ -8,7 +8,7 @@ const Question = ({ question, productId }) => { let answerList = answerKey.map(Ans => question.answers[Ans]); return ( -
+
Q: {question.question_body} -
-
); return ( -
+
Helpful? 

( -

+
{ searchInput === null ? diff --git a/client/src/QA/QAcomponents/Search.jsx b/client/src/QA/QAcomponents/Search.jsx index 6d66a28..5661e9f 100644 --- a/client/src/QA/QAcomponents/Search.jsx +++ b/client/src/QA/QAcomponents/Search.jsx @@ -9,7 +9,7 @@ const Search = ({ handleSearch, searchInput }) => { }; return ( -
+
{ + cleanup(); +}); // npm test -- -t 'render Q&A Search without crashing' -it ('render Q&A Search without crashing', () => { - const div = document.createElement('div'); - ReactDOM.render(, div); +test ('render Q&A Search without crashing', () => { + render(); + const searchElement = screen.getByTestId('search-test'); + expect(searchElement).toBeInTheDocument(); }); + // npm test -- -t 'render Question List without crashing' -it ('render Question List without crashing', () => { - const div = document.createElement('div'); - ReactDOM.render( { + render(, div); + productId={13023}/>); + const questionListElement = screen.getByTestId('qa-list-test'); + expect(questionListElement).toBeInTheDocument(); }); + // npm test -- -t 'render Add Question Button Modal crashing' -it ('render Add Question Button Modal crashing', () => { - const div = document.createElement('div'); - ReactDOM.render(, div); +test ('render Add Question Button Modal crashing', () => { + render(); + const addQuestionElement = screen.getByTestId('add-question-test'); + expect(addQuestionElement).toBeInTheDocument(); }); + // npm test -- -t 'render Answer Helpfulness without crashing' -it ('render Answer Helpfulness without crashing', () => { - const div = document.createElement('div'); - ReactDOM.render( { + render(, div); + answerName={sample.questions.results[0].answers.answerer_name}/>); + const answerHelpfulElement = screen.getByTestId('answer-helpful-test'); + expect(answerHelpfulElement).toBeInTheDocument(); }); + // npm test -- -t 'render Answer Photos without crashing' -it ('render Answer Photos without crashing', () => { - const div = document.createElement('div'); - ReactDOM.render( { + render(, div); + key={1}/>); + const answerPhotosElement = screen.getByTestId('answer-photo-test'); + expect(answerPhotosElement).toBeInTheDocument(); }); + // npm test -- -t 'render Answer List without crashing' -it ('render Answer List without crashing', () => { - const div = document.createElement('div'); - ReactDOM.render( { + render(); + const answerListElement = screen.getByTestId('answer-list-test'); + expect(answerListElement).toBeInTheDocument(); +}); + +// npm test -- -t 'render More Answer button without crashing' +test ('render More Answer button without crashing', () => { + render(, div); + id: 1992060, + photos: [{ + 'id': 1, + 'url': 'urlplaceholder/answer_5_photo_number_1.jpg' + }] + } + }]} + answer={{ + /* eslint-disable */ + answerer_name: 'notKathy!', + /* eslint-enable */ + body: 'This is a an answer!', + date: '2021-06-19T00:00:00.000Z', + helpfulness: 0, + id: 1992060, + photos: [{ + 'id': 1, + 'url': 'urlplaceholder/answer_5_photo_number_1.jpg' + }] + }}/>); + const moreAnswersElement = screen.getByTestId('more-answer-test'); + expect(moreAnswersElement).toBeInTheDocument(); }); -// it ('render More Answer button without crashing', () => { -// const div = document.createElement('div'); -// ReactDOM.render(, div); -// }); +// npm test -- -t 'render Individual Questions without crashing' +test ('render Individual Questions without crashing', () => { + render(); + const individualQuestionElement = screen.getByTestId('individual-question-test'); + expect(individualQuestionElement).toBeInTheDocument(); +}); -// it ('render Individual Questions without crashing', () => { -// const div = document.createElement('div'); -// ReactDOM.render(, div); -// }); +// npm test -- -t 'render Question Helpfulness section without crashing' +test ('render Question Helpfulness section without crashing', () => { + render(); + const questionHelpfulElement = screen.getByTestId('question-helpful-test'); + expect(questionHelpfulElement).toBeInTheDocument(); +}); -// it ('render Question Helpfulness section without crashing', () => { -// const div = document.createElement('div'); -// ReactDOM.render(, div); -// }); +// npm test -- -t 'render More Questions without crashing' +test ('render More Questions without crashing', () => { + render(); + const moreQuestionsElement = screen.getByTestId('more-questions-test'); + expect(moreQuestionsElement).toBeInTheDocument(); +}); \ No newline at end of file diff --git a/client/src/QA/Test /sampleData.js b/client/src/QA/Test /sampleData.js index f9a24c0..7d0433e 100644 --- a/client/src/QA/Test /sampleData.js +++ b/client/src/QA/Test /sampleData.js @@ -1,3 +1,4 @@ +/* eslint-disable */ var sample = { "questions": { "product_id": "5", @@ -83,6 +84,7 @@ var sample = { ] } }; +/* eslint-enable */ module.exports = sample; \ No newline at end of file