Skip to content
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

Tests/question answers #805

Draft
wants to merge 26 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3288e18
feat: add initial tab section for survey page
satyam73 Nov 29, 2023
d66d48e
feat: add ask-question-modal component
satyam73 Dec 1, 2023
0c03377
feat: create answer reply modal
satyam73 Dec 1, 2023
c396356
refactor: make question modal responsive
satyam73 Dec 1, 2023
4fb362b
refactor: answer and question modal code
satyam73 Dec 1, 2023
5694cd9
merge: develop-ember into feat/question-answers
satyam73 Dec 10, 2023
52830dd
Merge branch 'develop-ember' of https://github.com/Real-Dev-Squad/web…
satyam73 Dec 13, 2023
f93c94c
feat: added question and answers api
satyam73 Dec 15, 2023
0d85c33
feat: add word cloud with api
satyam73 Dec 18, 2023
1cad94f
styles: improve styles of survey page
satyam73 Dec 18, 2023
6160147
feat: add filter to answers
satyam73 Dec 18, 2023
afea8d1
merge: develop-ember into feat/question-answers
satyam73 Dec 24, 2023
2d924ac
feat: add min length for answer and handle max_characters null case
satyam73 Dec 24, 2023
87bad2d
feat: add wordCloud feature flag
satyam73 Dec 24, 2023
9931a71
chore: remove unnecessary code
satyam73 Dec 24, 2023
9e9b96a
feat: add toast messages for error cases in approving rejecting answers
satyam73 Dec 24, 2023
5c02d53
feat: add word cloud feature flag to word-cloud component
satyam73 Dec 24, 2023
89749a9
tests: fix failing tests
satyam73 Dec 24, 2023
051bf85
Merge branch 'develop' of https://github.com/Real-Dev-Squad/website-w…
satyam73 Dec 28, 2023
affd37f
tests: add initial test case for word cloud component
satyam73 Dec 28, 2023
2e43f58
Merge branch 'develop' into tests/question-answers
satyam73 Jan 4, 2024
9640bf0
tests: add initial tests for answer-reply-modal
satyam73 Jan 11, 2024
e7db45d
Merge branch 'tests/question-answers' of https://github.com/Real-Dev-…
satyam73 Jan 11, 2024
ea42c6c
Merge branch 'develop' of https://github.com/Real-Dev-Squad/website-w…
satyam73 Jan 11, 2024
b2959bb
tests: add test for read more formatter util function
satyam73 Jan 11, 2024
0190ab8
Merge branch 'develop' into tests/question-answers
satyam73 Jan 12, 2024
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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = {
},
rules: {
'qunit/require-expect': [1, 'except-simple'],
'no-self-assign': ['warn'],
},
overrides: [
// node files
Expand Down
46 changes: 46 additions & 0 deletions app/components/answer-reply-modal.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<BaseModal
@closeModal={{@closeModal}}
@openModal={{@openModal}}
@isOpen={{@isOpen}}
>
<div data-test-answer-reply-modal class="answer-reply-modal">
<h4 class="answer-reply-modal__heading">Host asked you a question😀</h4>
<form>
<Reusables::InputBox
@field={{@questionAsked.question}}
@name="answer"
@type="text"
@placeHolder="Enter your answer"
@required={{true}}
@isError={{@validationDetails.isError}}
@helperText={{@validationDetails.helperText}}
@variant="input--full-width"
@value={{@answerValue}}
@shouldShowHelperText={{@validationDetails.isHelperTextVisible}}
@onInput={{@inputHandler}}
/>
<p class="answer-reply-modal__info-text">
<span class="answer-reply-modal__info-icon">&iexcl;</span>
Do not use abusive words, this event is moderated!</p>
<div class="answer-reply-modal__actions">
<Reusables::Button
@text="Cancel"
@type="button"
@variant="dark btn--sm btn-light answer-reply-modal__cancel-button"
@test="question-modal-cancel"
@onClick={{@closeModal}}
/>
<Reusables::Button
@type="button"
@text="Submit"
@variant="dark btn--sm btn-pink answer-reply-modal__submit-button"
@test="question-modal-cancel"
@disabled={{@submitButtonState.isDisabled}}
@isLoading={{@submitButtonState.isLoading}}
@onClick={{@onSubmit}}
/>
</div>
</form>
</div>

</BaseModal>
39 changes: 39 additions & 0 deletions app/components/answer-view-card.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<div
class="answer-view-card
{{if this.isApproved 'answer-view-card--approved' ''}}
{{if this.isPending 'answer-view-card--pending' ''}}
{{if this.isRejected 'answer-view-card--rejected' ''}}
"
>
<p class="answer-view-card__text">
{{this.answerText}}

{{#if this.isTextMoreThanMaxCharacters}}
<button
class="answer-view-card__read-more-button"
{{on "click" this.toggleReadMore}}
type="button"
>{{this.readMoreOrLessText}}</button>
{{/if}}
</p>

<div class="answer-view-card__buttons">
<Reusables::IconButton
{{! template-lint-disable no-duplicate-id}}
@id={{@id}}
@class="icon-button--sm icon-button--red-outlined"
@title="Reject Answer"
@onClick={{@onReject}}
@icon="material-symbols:close-small-outline-rounded"
/>
<Reusables::IconButton
{{! TODO- fix this unique id eslint problem }}
{{! template-lint-disable no-duplicate-id}}
@id={{@id}}
@class="icon-button--sm icon-button--green"
@title="Approve Answer"
@onClick={{@onApprove}}
@icon="material-symbols:done-rounded"
/>
</div>
</div>
36 changes: 36 additions & 0 deletions app/components/answer-view-card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { readMoreFormatter } from '../utils/common-utils';
import { action } from '@ember/object';
import { ANSWER_STATUS } from '../constants/live';

const maxCharactersToShow = 70;
export default class AnswerViewCardComponent extends Component {
@tracked answerText = readMoreFormatter(
this.args.answerObject.answer,
maxCharactersToShow,
);

@tracked isTextMoreThanMaxCharacters =
this.args.answerObject.answer?.length > maxCharactersToShow;
@tracked isReadMoreEnabled = false;
@tracked readMoreOrLessText = this.isReadMoreEnabled ? 'Less' : 'More';
@tracked isApproved =
this.args.answerObject.status === ANSWER_STATUS.APPROVED;
@tracked isPending = this.args.answerObject.status === ANSWER_STATUS.PENDING;
@tracked isRejected =
this.args.answerObject.status === ANSWER_STATUS.REJECTED;

@action toggleReadMore() {
this.isReadMoreEnabled = !this.isReadMoreEnabled;
this.readMoreOrLessText = this.isReadMoreEnabled ? 'Less' : 'More';
if (this.isReadMoreEnabled) {
this.answerText = this.args.answerObject.answer;
} else {
this.answerText = readMoreFormatter(
this.args.answerObject.answer,
maxCharactersToShow,
);
}
}
}
62 changes: 62 additions & 0 deletions app/components/ask-question-modal.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<BaseModal
@closeModal={{@closeModal}}
@openModal={{@openModal}}
@isOpen={{@isOpen}}
>
<div class="ask-question-modal">
<h4 class="ask-question-modal__heading">Ask Question</h4>
<textarea
class="ask-question-modal__textarea"
name="question"
id="question"
placeholder="Enter your question here"
{{on "input" @onInput}}
value={{@question}}
></textarea>
<div class="ask-question-modal__checkbox-container">
<input
{{on "change" @toggleMaxCharacterChecked}}
class="ask-question-modal__checkbox"
type="checkbox"
name="is-max-characters-checked"
id="is-max-characters-checked"
checked={{@isMaxCharactersChecked}}
/>
<label
class="ask-question-modal__checkbox-label"
for="is-max-characters-checked"
>Do you want answer to be of limited characters?</label>
</div>
<input
type="number"
name="max-characters"
id="max-characters"
min="1"
class="ask-question-modal__max-characters-input
{{if
@isMaxCharactersChecked
'visibility--visible'
'visibility--hidden'
}}"
value={{@maxCharacters}}
placeholder="Enter your characters limit"
{{on "input" @onCharacterLimitInput}}
/>
<div class="ask-question-modal__actions">
<Reusables::Button
@text="Cancel"
@variant="dark btn--sm btn-light ask-question-modal__cancel-button"
@test="question-modal-cancel"
@onClick={{@closeModal}}
/>
<Reusables::Button
@text="Submit"
@variant="dark btn--sm btn-pink ask-question-modal__submit-button"
@test="question-modal-cancel"
@onClick={{@onSubmit}}
@disabled={{(or @isSubmitButtonDisabled @isQuestionApiLoading)}}
@isLoading={{@isQuestionApiLoading}}
/>
</div>
</div>
</BaseModal>
68 changes: 68 additions & 0 deletions app/components/events/survey-page.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<div class="survey-page">
<AskQuestionModal
@isOpen={{this.isAskQuestionModalOpen}}
@closeModal={{this.closeAskQuestionModal}}
@openModal={{this.openAskQuestionModal}}
@onSubmit={{this.onQuestionSubmit}}
@toggleMaxCharacterChecked={{this.toggleMaxCharacterChecked}}
@isMaxCharactersChecked={{this.isMaxCharactersChecked}}
@maxCharacters={{this.maxCharacters}}
@onCharacterLimitInput={{this.onCharacterLimitInput}}
@onInput={{this.onQuestionInput}}
@isSubmitButtonDisabled={{this.isQuestionSubmitButtonDisabled}}
@question={{this.question}}
@isQuestionApiLoading={{this.isQuestionApiLoading}}
/>
<div class="survey-page__question-container">
<Reusables::Button
@text="Ask Question"
@variant="dark btn--sm btn-pink"
@test="ask-question"
@onClick={{this.openAskQuestionModal}}
@disabled={{this.isAskQuestionButtonDisabled}}
@title={{if
this.isAskQuestionButtonDisabled
"This is a host only feature"
""
}}
/>
<div class="survey-page__recent-question">
<h3 class="survey-page__recent-question-heading">Recent Question</h3>
<p class="survey-page__recent-question-text">{{(or
@questionAsked.question "No recent question"
)}}</p>
</div>
</div>
<div class="survey-page__answers-container">
<h2 class="survey-page__answers-heading">
Answers
</h2>
<div class="survey-page__filter">
<label for="answer-status">Filter: </label>
<select
name="answer-status"
id="answer-status"
{{on "change" this.onAnswerFilterChange}}
>
{{#each this.ANSWER_STATUS_FILTERS as |status|}}
<option value={{status}}>{{status}}</option>
{{/each}}
</select>
</div>
<div class="survey-page__answers">
{{#if this.isAnswersPresent}}
{{#each this.answers as |answer|}}
<AnswerViewCard
@id={{answer.id}}
@answerObject={{answer}}
@onReject={{@onAnswerReject}}
@onApprove={{@onAnswerApprove}}
/>
{{/each}}
{{else}}
<div>No answers present currently!</div>
{{/if}}

</div>
</div>
</div>
Loading
Loading