Skip to content

Commit

Permalink
[#10] Add test id for survey list home page
Browse files Browse the repository at this point in the history
  • Loading branch information
suphanatjarukulgowit committed Mar 1, 2023
1 parent 7c6cd12 commit a2d1529
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/screens/Survey/SurveyHomePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ import SurveyList from 'components/SurveyList';
import useAuth from 'hooks/useAuth';
import { Survey } from 'types/survey';

const SurveyHomepageScreenDataTestIds = {
defaultLayout: 'defaultLayout',
thankYouPage: 'thankYouPage',
surveyList: 'surveyList',
};

const SurveyHomepageScreen = (): JSX.Element => {
const { setUserProfile } = useAuth();
const [surveyBackground, setSurveyBackground] = useState('');
Expand Down Expand Up @@ -51,23 +57,26 @@ const SurveyHomepageScreen = (): JSX.Element => {
// eslint-disable-next-line react-hooks/exhaustive-deps
[]
);

useEffect(() => {
fetchSurveyList();
}, [fetchSurveyList]);

return (
<div data-test-id="SurveyHomepageScreen">
<div>
<DefaultLayout>
{surveyLoading ? (
<div>display skeleton loading</div>
) : surveys && surveys.length !== 0 ? (
<>
<BackgroundImage imageUrl={surveyBackground} />
<SurveyList onSlideChange={onSlideChange} surveys={surveys} />
<SurveyList
data-test-id={SurveyHomepageScreenDataTestIds.surveyList}
onSlideChange={onSlideChange}
surveys={surveys}
/>
</>
) : (
<div>thank you page</div>
<div data-test-id={SurveyHomepageScreenDataTestIds.thankYouPage}>thank you page</div>
)}
</DefaultLayout>
</div>
Expand Down

0 comments on commit a2d1529

Please sign in to comment.