-
Notifications
You must be signed in to change notification settings - Fork 1
CI: Unit and integration tests #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
aa6772f
Add tests and configure CI
WezSieTato 4a858c2
Add integration tests
WezSieTato 01207fc
Add more integration tests
WezSieTato a488c7f
Disable tests for some pages
WezSieTato a53647d
Fix missing domain
WezSieTato 2e84bd2
Fix readme
WezSieTato 5d41705
Fix playwright instalation
WezSieTato 8742fe0
Fix: cache removing
WezSieTato a2d82c4
fix: readme separator
WezSieTato d006c9a
fix: guard
WezSieTato File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| name: Integration Tests | ||
|
|
||
| on: | ||
| push: | ||
| pull_request: | ||
| schedule: | ||
| - cron: '0 6 * * *' | ||
|
|
||
| jobs: | ||
| e2e: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v7 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: '20' | ||
| cache: 'npm' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Install Playwright browsers | ||
| run: npx playwright install --with-deps chromium | ||
| - name: Run integration tests | ||
| run: npm run test:integration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| name: Unit Tests | ||
|
|
||
| on: | ||
| push: | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v7 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: '20' | ||
| cache: 'npm' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Run unit tests | ||
| run: npm test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| node_modules/ | ||
| test-results |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| module.exports = { | ||
| testEnvironment: 'jsdom', | ||
| testMatch: ['**/test/**/*.test.js'], | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /** | ||
| * Validates an EAN-8 or EAN-13 barcode using the check digit algorithm. | ||
| */ | ||
| function validateEAN(elem) { | ||
| if (isNaN(elem)) { | ||
| return false; | ||
| } | ||
| let sum = 0; | ||
| if (elem.length === 8) { | ||
| sum = (parseInt(elem[0], 10) + parseInt(elem[2], 10) | ||
| + parseInt(elem[4], 10) + parseInt(elem[6], 10)) | ||
| * 3 | ||
| + parseInt(elem[1], 10) | ||
| + parseInt(elem[3], 10) | ||
| + parseInt(elem[5], 10); | ||
| } else { | ||
| sum = (parseInt(elem[1], 10) + parseInt(elem[3], 10) | ||
| + parseInt(elem[5], 10) + parseInt(elem[7], 10) | ||
| + parseInt(elem[9], 10) + parseInt(elem[11], 10)) | ||
| * 3 | ||
| + parseInt(elem[0], 10) | ||
| + parseInt(elem[2], 10) | ||
| + parseInt(elem[4], 10) | ||
| + parseInt(elem[6], 10) | ||
| + parseInt(elem[8], 10) + parseInt(elem[10], 10); | ||
| } | ||
| let num = (10 - (sum % 10)) % 10; | ||
| return num === parseInt(elem[elem.length - 1], 10); | ||
| } | ||
|
|
||
| if (typeof module !== 'undefined' && module.exports) module.exports = { validateEAN }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.