From 786878a3e4ae2b2ff1f56a21c4f1c93de30506f7 Mon Sep 17 00:00:00 2001 From: Nicco Date: Tue, 19 Jul 2022 14:12:51 +0200 Subject: [PATCH] Testing (#41) * testing * try playwrigth * testing * add pr support * not on each commit --- .github/workflows/test.yaml | 36 ++++++++++++++++++++++++++ .gitignore | 3 +++ README.md | 4 ++- frontend/package.json | 2 +- frontend/src/lib/ui/NoteResult.svelte | 1 + frontend/src/lib/ui/ShowNote.svelte | 28 ++++++++++---------- frontend/src/routes/note/[id].svelte | 2 +- package.json | 11 +++++++- playwright.config.ts | 25 ++++++++++++++++++ pnpm-lock.yaml | 21 +++++++++++++++ test/text.ts | 37 +++++++++++++++++++++++++++ 11 files changed, 153 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/test.yaml create mode 100644 playwright.config.ts create mode 100644 test/text.ts diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..6e44ad1 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,36 @@ +on: + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + services: + redis: + image: redis:7-alpine + ports: + - 6379:6379 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: "16" + - uses: pnpm/action-setup@v2 + with: + version: 7 + - uses: actions-rs/toolchain@v1 + with: + toolchain: 1.61 + - name: Prepare + run: | + pnpm install + pnpm run ci:prepare + - name: Install Playwright + run: npx playwright install --with-deps + - name: Run your tests + run: pnpm run test + - name: Upload test results + if: always() + uses: actions/upload-artifact@v2 + with: + name: playwright-report + path: playwright-report diff --git a/.gitignore b/.gitignore index 3f28053..f3198e7 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,6 @@ node_modules /build /functions .env + +General +test-results diff --git a/README.md b/README.md index 6771579..5175cc5 100644 --- a/README.md +++ b/README.md @@ -167,4 +167,6 @@ You can see the app under [localhost:1234](http://localhost:1234). ###### Attributions -Icons made by freepik from www.flaticon.com +- Text for tests [Nietzsche Ipsum](https://nietzsche-ipsum.com/) +- Loading animation by [Nikhil Krishnan](https://codepen.io/nikhil8krishnan/pen/rVoXJa) +- Icons made by freepik from www.flaticon.com diff --git a/frontend/package.json b/frontend/package.json index 381d2bb..7ff4842 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -3,7 +3,7 @@ "scripts": { "dev": "vite dev", "build": "vite build", - "preview": "svelte-kit preview", + "preview": "vite preview --port 3000", "check": "svelte-check --tsconfig tsconfig.json", "licenses": "license-checker --summary > licenses.csv", "locale:download": "node scripts/locale.js" diff --git a/frontend/src/lib/ui/NoteResult.svelte b/frontend/src/lib/ui/NoteResult.svelte index b1d1b41..2569052 100644 --- a/frontend/src/lib/ui/NoteResult.svelte +++ b/frontend/src/lib/ui/NoteResult.svelte @@ -24,6 +24,7 @@ label={$t('common.share_link')} value="{window.location.origin}/note/{result.id}#{result.password}" copy + data-testid="share-link" />

diff --git a/frontend/src/lib/ui/ShowNote.svelte b/frontend/src/lib/ui/ShowNote.svelte index 96793b6..ad96153 100644 --- a/frontend/src/lib/ui/ShowNote.svelte +++ b/frontend/src/lib/ui/ShowNote.svelte @@ -44,20 +44,22 @@

{@html $t('show.warning_will_not_see_again')}

-{#if note.meta.type === 'text'} -
- {@html contentWithLinks(note.contents)} -
- -{:else} - {#each files as file} -
- downloadFile(file)}>↓ {file.name} - {file.type} - {prettyBytes(file.size)} +
+ {#if note.meta.type === 'text'} +
+ {@html contentWithLinks(note.contents)}
- {/each} - -{/if} + + {:else} + {#each files as file} +
+ downloadFile(file)}>↓ {file.name} + {file.type} - {prettyBytes(file.size)} +
+ {/each} + + {/if} +