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

Release - 0.7.0 #90

Merged
merged 31 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3c0fd42
[CHORE] Bump version to 0.7.0
manh-t Jul 19, 2023
c671ad8
Merge pull request #81 from manh-t/chore/bump-version-to-0.7.0
manh-t Sep 8, 2023
6fad3d6
[#24] Create NPS component
manh-t Jul 20, 2023
2b7ff1c
[#24] Use fabricator for test data
manh-t Sep 7, 2023
bd8c056
[#24] Remove redundant flex-row
manh-t Sep 7, 2023
ff160bc
[#24] Add comment to explain the verification in the test
manh-t Sep 8, 2023
d4c4f30
Merge pull request #82 from manh-t/feature/24-ui-nps-component
manh-t Sep 8, 2023
22f79e6
[#31] Implement the backend POST submit survey
manh-t Jul 20, 2023
cd0f75b
[#30] Fill the data into the Question page
manh-t Jul 21, 2023
0df20fe
[#30] Add more test cases
manh-t Jul 22, 2023
c68c7a7
[#30] Fix convert string to enum for question displayType and update …
manh-t Sep 8, 2023
9d2af08
[#30] Remove redundant code
manh-t Sep 8, 2023
40ba64a
[#30] Remove useEffect in components
manh-t Sep 11, 2023
6991c5f
[#30] Create a function to handle onValueChanged and onValuesChanged
manh-t Sep 11, 2023
37bf717
Merge pull request #83 from manh-t/feature/31-backend-submit-survey
manh-t Sep 11, 2023
29a92e8
[#30] Fix CI failed
manh-t Sep 12, 2023
7551322
Merge pull request #84 from manh-t/feature/30-integrate-question-page
manh-t Sep 12, 2023
b7da4c6
[#32] Navigate to survey completion screen after submitting the surve…
manh-t Jul 24, 2023
a71d26a
[#32] Update after rebasing
manh-t Sep 11, 2023
dba62af
[#32] Optimize code a bit
manh-t Sep 12, 2023
f968500
[#32] Create function inside useEffect
manh-t Sep 13, 2023
7ac6657
[#32] Create a reusable function for toast error
manh-t Sep 13, 2023
11d2ddf
[#33] Implement Question Complete page
manh-t Jul 24, 2023
fd2de21
Merge pull request #85 from manh-t/feature/32-submit-answers-for-the-…
manh-t Sep 13, 2023
5f2ba6f
Merge pull request #87 from manh-t/feature/33-ui-question-complete-page
manh-t Sep 14, 2023
b194256
[#22] Create a confirm dialog
manh-t Jul 25, 2023
69db1d3
[#38] Implement integration test for Question page and Question Compl…
manh-t Jul 25, 2023
7716683
[#22] Apply code review
manh-t Sep 14, 2023
3c85d61
[#38] Remove redundant text
manh-t Sep 14, 2023
3d76c07
Merge pull request #88 from manh-t/feature/22-confirm-dialog
manh-t Sep 14, 2023
d493c4b
Merge pull request #89 from manh-t/feature/38-integration-test-questi…
manh-t Sep 14, 2023
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
30 changes: 30 additions & 0 deletions cypress/e2e/Question/Complete/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
describe('Question Complete screen', () => {
context('given the Question Complete screen is opened', () => {
beforeEach(() => {
cy.signIn();
cy.interceptWithDelay('GET', '**/api/v1/surveys/*', 200, {
statusCode: 200,
fixture: 'Survey/Detail/valid.json',
});
cy.interceptWithDelay('GET', '**/api/v1/surveys*', 200, {
statusCode: 200,
fixture: 'Survey/List/valid.json',
});
cy.interceptWithDelay('GET', '**/api/v1/me', 200, {
statusCode: 200,
fixture: 'User/valid.json',
});
cy.interceptWithDelay('POST', '**/responses', 200, {
statusCode: 201,
fixture: 'Survey/Submit/valid.json',
});
});
it('navigates to the Home screen', () => {
cy.visit('/surveys/d5de6a8f8f5f1cfe51bc/questions/complete');

cy.location().should((location) => {
expect(location.pathname).to.equal('/');
});
});
});
});
86 changes: 86 additions & 0 deletions cypress/e2e/Question/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
const questionTestIds = {
questionIndex: 'question__index',
questionTitle: 'question__title',
questionAnswer: 'question__answer',
questionCloseButton: 'question__close-button',
questionNextButton: 'question__next-button',
questionSubmitButton: 'question__submit-button',
confirmDialogPositiveButton: 'confirm-dialog__positive-button',
surveyStartSurveyButton: 'survey__start-survey-button',
};

describe('Question screen', () => {
context('given the submit button is clicked', () => {
context('given the API responses returns success result', () => {
beforeEach(() => {
cy.signIn();
cy.interceptWithDelay('GET', '**/api/v1/surveys/*', 200, {
statusCode: 200,
fixture: 'Survey/Detail/valid.json',
});
cy.interceptWithDelay('GET', '**/api/v1/surveys*', 200, {
statusCode: 200,
fixture: 'Survey/List/valid.json',
});
cy.interceptWithDelay('GET', '**/api/v1/me', 200, {
statusCode: 200,
fixture: 'User/valid.json',
});
cy.interceptWithDelay('POST', '**/responses', 200, {
statusCode: 201,
fixture: 'Survey/Submit/valid.json',
});
});

it('navigates to the Question Complete screen', () => {
cy.visit('/');
cy.visit('/surveys/d5de6a8f8f5f1cfe51bc');

// Go to Question screen
cy.findByTestId(questionTestIds.surveyStartSurveyButton).click();

cy.findByTestId(questionTestIds.questionNextButton).click();
cy.findByTestId(questionTestIds.questionSubmitButton).click();

cy.location({ timeout: 1000 }).should((location) => {
expect(location.pathname).to.equal('/surveys/d5de6a8f8f5f1cfe51bc/questions/complete');
});
});
});
});

context('given the close button is clicked', () => {
context('given the Positive button of the confirm dialog is clicked', () => {
beforeEach(() => {
cy.signIn();
cy.interceptWithDelay('GET', '**/api/v1/surveys/*', 200, {
statusCode: 200,
fixture: 'Survey/Detail/valid.json',
});
cy.interceptWithDelay('GET', '**/api/v1/surveys*', 200, {
statusCode: 200,
fixture: 'Survey/List/valid.json',
});
cy.interceptWithDelay('GET', '**/api/v1/me', 200, {
statusCode: 200,
fixture: 'User/valid.json',
});
});

it('navigates back to Home', () => {
cy.visit('/');
cy.visit('/surveys/d5de6a8f8f5f1cfe51bc');

// Go to Question screen
cy.findByTestId(questionTestIds.surveyStartSurveyButton).click();

cy.findByTestId(questionTestIds.questionCloseButton).click();
cy.findByTestId(questionTestIds.confirmDialogPositiveButton).click();

cy.location().should((location) => {
expect(location.pathname).to.equal('/');
});
});
});
});
});
40 changes: 0 additions & 40 deletions cypress/fixtures/Survey/Detail/valid.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,46 +24,6 @@
{
"id": "940d229e4cd87cd1e202",
"type": "question"
},
{
"id": "ea0555f328b3b0124127",
"type": "question"
},
{
"id": "16e68f5610ef0e0fa4db",
"type": "question"
},
{
"id": "bab38ad82eaf22afcdfe",
"type": "question"
},
{
"id": "85275a0bf28a6f3b1e63",
"type": "question"
},
{
"id": "642770376f7cd0c87d3c",
"type": "question"
},
{
"id": "b093a6ad9a6a466fa787",
"type": "question"
},
{
"id": "e593b2fa2f81891a2b1e",
"type": "question"
},
{
"id": "c3a9b8ce5c2356010703",
"type": "question"
},
{
"id": "fbf5d260de1ee6195473",
"type": "question"
},
{
"id": "4372463ce56db58c0983",
"type": "question"
}
]
}
Expand Down
7 changes: 7 additions & 0 deletions cypress/fixtures/Survey/Submit/invalid.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"errors": [
{
"detail": "The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client."
}
]
}
1 change: 1 addition & 0 deletions cypress/fixtures/Survey/Submit/valid.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
53 changes: 51 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "manh-react-survey",
"version": "0.6.0",
"version": "0.7.0",
"private": true,
"dependencies": {
"@lottiefiles/react-lottie-player": "3.5.3",
"@reduxjs/toolkit": "1.9.5",
"@travelperksl/fabricator": "7.0.1",
"@types/lodash": "4.14.195",
Expand Down Expand Up @@ -75,6 +76,7 @@
"danger": "11.2.6",
"danger-plugin-istanbul-coverage": "1.6.2",
"eslint": "8.12.0",
"jest-canvas-mock": "2.5.2",
"postcss": "8.4.24",
"postcss-import": "15.1.0",
"prettier": "2.6.0",
Expand Down
25 changes: 15 additions & 10 deletions src/adapters/Survey/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import { getAuth } from 'adapters/BaseAuth';
import { getAuth, postAuth } from 'adapters/BaseAuth';
import { surveySubmitRequestFabricator } from 'tests/fabricator';
import { SurveySubmitRequest } from 'types/request/surveySubmitRequest';

import { getSurvey, getSurveys } from '.';
import { getSurvey, getSurveys, submitSurvey } from '.';

jest.mock('adapters/BaseAuth');

describe('SurveyAdapter', () => {
beforeEach(() => {
(getAuth as jest.Mock).mockImplementation(() => jest.fn());
});

afterEach(() => {
jest.clearAllMocks();
});

describe('getSurveys', () => {
it('calls the get method from the base adapter', () => {
const expectedPath = 'surveys?page[number]=1&page[size]=10';
Expand All @@ -33,4 +27,15 @@ describe('SurveyAdapter', () => {
expect(getAuth).toHaveBeenCalledWith(expectedPath);
});
});

describe('submitSurvey', () => {
it('calls the post method from the base adapter', () => {
const payload: SurveySubmitRequest = surveySubmitRequestFabricator();
const expectedPath = 'responses';

submitSurvey(payload);

expect(postAuth).toHaveBeenCalledWith(expectedPath, payload);
});
});
});
7 changes: 6 additions & 1 deletion src/adapters/Survey/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { getAuth } from 'adapters/BaseAuth';
import { getAuth, postAuth } from 'adapters/BaseAuth';
import { JSONObject } from 'helpers/json';
import { SurveySubmitRequest } from 'types/request/surveySubmitRequest';

export const getSurveys = () => getAuth('surveys?page[number]=1&page[size]=10');

export const getSurvey = (surveyId: string) => getAuth(`surveys/${surveyId}`);

export const submitSurvey = (surveySubmitRequest: SurveySubmitRequest) =>
postAuth('responses', surveySubmitRequest as unknown as JSONObject);
Loading