From 45d8dc33b2c122c5e943c3d1f0a8af91cc0b7317 Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Fri, 9 Feb 2024 13:43:54 -0500 Subject: [PATCH] create Game component --- Taskfile.yaml | 10 ++ e2e/hide-game.test.js | 16 +++- src/routes/Game.svelte | 114 ++++++++++++++++++++++ src/routes/GameList.svelte | 79 ++-------------- src/routes/GameList.svelte.orig | 162 ++++++++++++++++++++++++++++++++ 5 files changed, 303 insertions(+), 78 deletions(-) create mode 100644 src/routes/Game.svelte create mode 100644 src/routes/GameList.svelte.orig diff --git a/Taskfile.yaml b/Taskfile.yaml index c1d7c5b..2ba33ea 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -6,6 +6,16 @@ vars: GREETING: Hello, World! tasks: + is-clean: git is-clean + integrate: + deps: [is-clean, test] + cmds: + - echo "do something" + test:unit: + cmds: + - vitest run + test: + deps: [test:unit, test:e2e] preview: deps: [build] cmds: diff --git a/e2e/hide-game.test.js b/e2e/hide-game.test.js index 6facf69..fb6d581 100644 --- a/e2e/hide-game.test.js +++ b/e2e/hide-game.test.js @@ -2,16 +2,22 @@ import { test, expect } from '@playwright/test'; test('hide game', async ({ page }) => { await page.goto('/'); - const nbr_games = await page - .locator('.games > div') - .all() - .then((games) => games.length); + + let nbr_games = 0; + + await expect(async () => { + nbr_games = await page + .locator('.game') + .all() + .then((games) => games.length); + expect(nbr_games).toBeGreaterThan(0); + }).toPass(); await page.getByRole('button', { name: 'visibility' }).first().click(); await expect(async () => { const one_hidden = await page - .locator('.games > div') + .locator('.game') .all() .then((games) => games.length); diff --git a/src/routes/Game.svelte b/src/routes/Game.svelte new file mode 100644 index 0000000..67eb235 --- /dev/null +++ b/src/routes/Game.svelte @@ -0,0 +1,114 @@ +
+
+ + +
+
+ + + {name} + +
+
+
+ {username} +   + + email +
+
+ {seller?.neighbourhood ?? ''} +
+
+
+ {price ? '$' + price : ''} +
+
+ {notes} +
+
+ {#if updated_at} + {pretty_date(updated_at)} + {/if} +
+
+
+ +
+
+
+
+
+ + + + diff --git a/src/routes/GameList.svelte b/src/routes/GameList.svelte index a697bb8..372d45e 100644 --- a/src/routes/GameList.svelte +++ b/src/routes/GameList.svelte @@ -19,79 +19,18 @@ .includes(target); }) as game} {#if show_hidden || !game.is_hidden} -
-
- - -
- -
- -
- {sellers[game.username]?.neighbourhood ?? ''} -
-
-
- {game.price ? '$' + game.price : ''} -
-
- {game.notes} -
-
- {#if game.updated_at} - {pretty_date(game.updated_at)} - {/if} -
-
-
- -
-
-
-
-
-
+ toggle_visibility(game.id)} + {...game} + seller={sellers[game.username]} /> +
{/if} {/each}