Skip to content

Commit ba3b91a

Browse files
authored
chore(cypress): extend e2e testing to cover participation in gamified live quiz without participant account (#4735)
1 parent 53fce36 commit ba3b91a

9 files changed

Lines changed: 326 additions & 9 deletions

File tree

apps/frontend-manage/src/components/common/Header.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,14 @@ function Header({ user }: { user?: User | null }): React.ReactElement {
218218
quizzes?.length !== 0 ? 'text-green-600' : 'text-slate-400'
219219
),
220220
},
221+
data: { cy: 'running-live-quiz-dropdown' },
221222
elements:
222223
quizzes?.map((quiz) => ({
223224
key: quiz.id,
224225
type: 'link',
225226
label: quiz.name,
226227
onClick: () => router.push(`/quizzes/${quiz.id}/cockpit`),
228+
data: { cy: `running-live-quiz-${quiz.name}` },
227229
})) ?? [],
228230
},
229231
{

apps/frontend-manage/src/components/liveQuiz/cockpit/LiveQuizQRModal.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ function LiveQuizQRModal({
4646
className={{ title: 'text-base', canvas: 'flex justify-center' }}
4747
path={accountRelativeLink}
4848
width={100}
49+
data={{ cy: 'qr-link-shortname' }}
4950
/>
5051
<Link passHref href={`/qr${accountRelativeLink}`} target="_blank">
5152
<Button
@@ -72,14 +73,10 @@ function LiveQuizQRModal({
7273
className={{ title: 'text-base', canvas: 'flex justify-center' }}
7374
path={quizRelativeLink}
7475
width={100}
76+
data={{ cy: 'qr-link-direct' }}
7577
/>
7678
<Link passHref href={`/qr${quizRelativeLink}`} target="_blank">
77-
<Button
78-
fluid
79-
primary
80-
className={{ root: 'mt-2' }}
81-
data={{ cy: `qr-direct-link-${quizId}` }}
82-
>
79+
<Button fluid primary className={{ root: 'mt-2' }}>
8380
<Button.Label>{t('manage.general.presentQrCode')}</Button.Label>
8481
</Button>
8582
</Link>

apps/frontend-manage/src/components/liveQuiz/cockpit/LiveQuizTimeline.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ function LiveQuizTimeline({
147147
<Button
148148
className={{ root: 'h-8 sm:w-max' }}
149149
onClick={() => setQRModal(true)}
150-
data={{ cy: `qr-modal-${quizId}` }}
150+
data={{ cy: 'open-qr-modal' }}
151151
>
152152
<Button.Icon icon={faQrcode} />
153153
<Button.Label> {t('manage.general.qrCode')}</Button.Label>

apps/frontend-manage/src/pages/qr/[...args].tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ interface Props {
1818
showLink?: boolean
1919
showButton?: boolean
2020
showLogo?: boolean
21+
data?: { cy?: string; test?: string }
2122
}
2223

2324
export function QR({
@@ -27,6 +28,7 @@ export function QR({
2728
showLink = true,
2829
showButton = true,
2930
showLogo = true,
31+
data,
3032
}: Props): React.ReactElement {
3133
const t = useTranslations()
3234

@@ -55,6 +57,8 @@ export function QR({
5557
)}
5658
target="_blank"
5759
rel="noopener noreferrer"
60+
data-cy={data?.cy}
61+
data-test={data?.test}
5862
>
5963
{process.env.NEXT_PUBLIC_PWA_URL}
6064
{path}

apps/frontend-pwa/src/components/common/Header.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ function Header({
162162
</div>
163163
),
164164
className: { item: '!h-max py-0.5' },
165+
data: { cy: 'header-logged-in-as' },
165166
},
166167
{
167168
id: 'separator',

apps/frontend-pwa/src/components/liveQuiz/AccountSelector.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ function AccountSelector({
256256
label={t('shared.generic.pseudonym')}
257257
placeholder="klicker123"
258258
className={{ label: 'text-sm' }}
259+
data={{ cy: 'pseudonym-input' }}
259260
/>
260261
<Button
261262
type="button"
@@ -266,6 +267,7 @@ function AccountSelector({
266267
}
267268
onClick={() => setStep('avatar')}
268269
className={{ root: 'mt-2 self-end' }}
270+
data={{ cy: 'pseudonym-next-step' }}
269271
>
270272
<Button.Icon icon={faArrowRight} />
271273
<Button.Label>{t('shared.generic.next')}</Button.Label>
@@ -343,14 +345,23 @@ function AccountSelector({
343345
</div>
344346
))}
345347
</CarouselContent>
346-
<CarouselPrevious type="button" className="left-0" />
347-
<CarouselNext type="button" className="right-0" />
348+
<CarouselPrevious
349+
type="button"
350+
className="left-0"
351+
data-cy="avatar-carousel-prev"
352+
/>
353+
<CarouselNext
354+
type="button"
355+
className="right-0"
356+
data-cy="avatar-carousel-next"
357+
/>
348358
</Carousel>
349359
<Button
350360
primary
351361
type="submit"
352362
loading={loggingIn}
353363
className={{ root: 'mt-2 self-end' }}
364+
data={{ cy: 'submit-pseudonym-and-avatar' }}
354365
>
355366
{t('shared.generic.submit')}
356367
</Button>

0 commit comments

Comments
 (0)