Skip to content

Commit acb0d3a

Browse files
committed
Add basic playwright tests for tasks and rewards
1 parent 2fa208c commit acb0d3a

File tree

11 files changed

+520
-10
lines changed

11 files changed

+520
-10
lines changed

.github/workflows/playwright.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Install Playwright Browsers
1919
run: npx playwright install --with-deps
2020
- name: Run Playwright tests
21-
run: npx dotenv -e .env.test playwright test --workers 1
21+
run: npx dotenv -e .env.test playwright test
2222
- uses: actions/upload-artifact@v4
2323
if: ${{ !cancelled() }}
2424
with:

app/components/ActionEntityModal.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
type="text"
1515
placeholder="Description"
1616
class="w-full"
17+
data-testid="description-input"
1718
/>
1819
</UFormField>
1920
<UFormField name="points">
@@ -22,6 +23,7 @@
2223
type="number"
2324
placeholder="Points"
2425
class="w-full"
26+
data-testid="points-input"
2527
/>
2628
</UFormField>
2729
<UFormField name="recurrenceType">
@@ -42,6 +44,7 @@
4244
color="primary"
4345
variant="solid"
4446
class="w-full"
47+
data-testid="submit-item-button"
4548
>
4649
{{ submitButtonText }}
4750
</UButton>

app/components/AppAction.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
block
2222
class="w-10 h-10 rounded-full flex"
2323
:ui="{ leadingIcon: 'text-lg' }"
24+
data-testid="create-task-button"
2425
/>
2526
</div>
2627
</Transition>
@@ -45,6 +46,7 @@
4546
block
4647
class="w-10 h-10 rounded-full flex mt-2"
4748
:ui="{ leadingIcon: 'text-lg' }"
49+
data-testid="create-reward-button"
4850
/>
4951
</div>
5052
</Transition>
@@ -67,6 +69,7 @@
6769
block
6870
class="w-10 h-10 rounded-full flex"
6971
:ui="{ leadingIcon: 'text-lg' }"
72+
data-testid="app-action-button"
7073
/>
7174
</div>
7275
</Transition>

app/components/RewardList.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
}"
1515
>
1616
<div class="flex justify-start items-start space-x-2">
17-
<p class="truncate text-indigo-700 dark:text-indigo-200 grow min-w-0">
17+
<p
18+
class="truncate text-indigo-700 dark:text-indigo-200 grow min-w-0"
19+
data-testid="reward-description"
20+
>
1821
{{ reward.description }}
1922
</p>
2023
<UButton
@@ -24,6 +27,7 @@
2427
color="error"
2528
variant="soft"
2629
@click="confirmDelete(reward)"
30+
data-testid="delete-reward-button"
2731
/>
2832
</div>
2933
<div class="flex justify-start items-start mt-2 space-x-2">
@@ -57,6 +61,7 @@
5761
color="error"
5862
variant="soft"
5963
@click="emit('reject', reward)"
64+
data-testid="reject-reward-button"
6065
/>
6166
<UButton
6267
v-if="props.mode === 'parent' || !reward.is_redemption_requested"
@@ -65,6 +70,7 @@
6570
color="success"
6671
variant="soft"
6772
@click="emit('complete', reward)"
73+
data-testid="complete-reward-button"
6874
/>
6975
<UButton
7076
v-if="props.mode === 'parent'"
@@ -73,6 +79,7 @@
7379
color="neutral"
7480
variant="soft"
7581
@click="emit('edit', reward)"
82+
data-testid="edit-reward-button"
7683
/>
7784
</div>
7885
</div>
@@ -88,7 +95,12 @@
8895
<p>Are you sure you want to delete this reward?</p>
8996
</template>
9097
<template #footer>
91-
<UButton @click="deleteConfirmed" color="error" icon="i-lucide-trash">
98+
<UButton
99+
@click="deleteConfirmed"
100+
color="error"
101+
icon="i-lucide-trash"
102+
data-testid="confirm-delete-button"
103+
>
92104
Delete
93105
</UButton>
94106
</template>

app/components/TaskList.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
}"
1515
>
1616
<div class="flex justify-start items-start space-x-2">
17-
<p class="truncate text-cyan-700 dark:text-cyan-200 grow min-w-0">
17+
<p
18+
class="truncate text-cyan-700 dark:text-cyan-200 grow min-w-0"
19+
data-testid="task-description"
20+
>
1821
{{ task.description }}
1922
</p>
2023
<UButton
@@ -23,6 +26,7 @@
2326
icon="i-lucide-x"
2427
color="error"
2528
variant="soft"
29+
data-testid="delete-task-button"
2630
@click="confirmDelete(task)"
2731
/>
2832
</div>
@@ -56,6 +60,7 @@
5660
icon="i-lucide-thumbs-down"
5761
color="error"
5862
variant="soft"
63+
data-testid="reject-task-button"
5964
@click="emit('reject', task)"
6065
/>
6166
<UButton
@@ -64,6 +69,7 @@
6469
icon="i-lucide-thumbs-up"
6570
color="success"
6671
variant="soft"
72+
data-testid="complete-task-button"
6773
@click="emit('complete', task)"
6874
/>
6975
<UButton
@@ -72,6 +78,7 @@
7278
icon="i-lucide-pencil"
7379
color="neutral"
7480
variant="soft"
81+
data-testid="edit-task-button"
7582
@click="emit('edit', task)"
7683
/>
7784
</div>
@@ -88,7 +95,12 @@
8895
<p>Are you sure you want to delete this task?</p>
8996
</template>
9097
<template #footer>
91-
<UButton @click="deleteConfirmed" color="error" icon="i-lucide-trash">
98+
<UButton
99+
:data-testid="'confirm-delete-button'"
100+
@click="deleteConfirmed"
101+
color="error"
102+
icon="i-lucide-trash"
103+
>
92104
Delete
93105
</UButton>
94106
</template>

app/pages/child/[id].vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
<span class="text-secondary">{{ child?.user?.username }}</span>
77
<span class="text-neutral-500"> earned</span>
88
</h1>
9-
<div class="text-6xl font-extrabold text-primary text-center mb-4">
9+
<div
10+
class="text-6xl font-extrabold text-primary text-center mb-4"
11+
data-testid="child-points-display"
12+
>
1013
{{ child?.user?.points || 0 }}
1114
<span class="text-neutral-500 text-base absolute ml-2 mt-8">pts</span>
1215
</div>

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"preview": "nuxt preview",
1212
"postinstall": "nuxt prepare",
1313
"e2e": "vitest run --no-file-parallelism",
14-
"playwright": "dotenv -e .env.test playwright test --workers 1",
15-
"test": "vitest run --no-file-parallelism && dotenv -e .env.test playwright test --workers 1",
14+
"playwright": "dotenv -e .env.test playwright test",
15+
"test": "vitest run --no-file-parallelism && dotenv -e .env.test playwright test",
1616
"format": "prettier --write \"{app/components,app/composables,app/layouts,app/middleware,app/pages,app/utils,server,stores,shared,test}/**/*.{ts,vue}\"",
1717
"tsc": "tsc --noEmit",
1818
"admin": "tsx ./server/database/admin.ts"

playwright.config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ export default defineConfig<ConfigOptions>({
2525
forbidOnly: !!isCI,
2626
/* Retry on CI only */
2727
retries: isCI ? 2 : 0,
28-
/* Opt out of parallel tests on CI. */
29-
workers: isCI ? 1 : undefined,
28+
workers: 1,
3029
timeout: isWindows ? 60000 : undefined,
3130
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
3231
reporter: 'html',

0 commit comments

Comments
 (0)