-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Motivation Read QR code within a dapp. # Changes - new dependency `jsQR` - new QR code reader components, services and workes - docs route `qr-code` renamed to `qr-code-generator` - docs for QR reader - added `inner-end` slot to input in order to display a QR code button within - few lint rules corrected
- Loading branch information
1 parent
350349e
commit 3feb763
Showing
30 changed files
with
795 additions
and
39 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -14,4 +14,6 @@ node_modules | |
|
||
.dfx | ||
|
||
test-results | ||
test-results | ||
|
||
samples |
This file contains 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 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
File renamed without changes
File renamed without changes
This file contains 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,70 @@ | ||
import { chromium, expect, test, type Page } from "@playwright/test"; | ||
|
||
const testUrl = "/components/qr-code-reader"; | ||
|
||
test("QR code page has expected h1", async ({ page }) => { | ||
await page.goto(testUrl); | ||
await expect(page.locator("h1")).toHaveText("QR Code Reader"); | ||
}); | ||
|
||
const testQRCode = async (page: Page) => { | ||
await page.goto(testUrl); | ||
|
||
const showcase = page.getByTestId("showcase"); | ||
await showcase.scrollIntoViewIfNeeded(); | ||
|
||
const modal = page.getByTestId("qr-code-modal"); | ||
await modal.click(); | ||
|
||
// Wait for video | ||
await page.waitForTimeout(2000); | ||
|
||
await expect(page).toHaveScreenshot(); | ||
}; | ||
|
||
test("Read QR throws error because user block camera", async () => { | ||
const browser = await chromium.launch(); | ||
|
||
const context = await browser.newContext({ | ||
permissions: [], | ||
}); | ||
|
||
const page = await context.newPage(); | ||
|
||
await testQRCode(page); | ||
}); | ||
|
||
test("Read QR throws error because camera stream fails", async () => { | ||
const browser = await chromium.launch({ | ||
args: [ | ||
"--use-fake-ui-for-media-stream", | ||
"--use-fake-device-for-media-stream", | ||
"--use-file-for-fake-video-capture=./empty/stream/error", // leads to error: Requested device not found | ||
], | ||
}); | ||
|
||
const context = await browser.newContext({ | ||
permissions: ["camera"], | ||
}); | ||
|
||
const page = await context.newPage(); | ||
|
||
await testQRCode(page); | ||
}); | ||
|
||
test("Read QR code value with camera", async () => { | ||
const browser = await chromium.launch({ | ||
args: [ | ||
"--use-fake-ui-for-media-stream", | ||
"--use-fake-device-for-media-stream", | ||
"--use-file-for-fake-video-capture=./samples/qrcode.y4m", | ||
], | ||
}); | ||
|
||
const context = await browser.newContext({ | ||
permissions: ["camera"], | ||
}); | ||
|
||
const page = await context.newPage(); | ||
await testQRCode(page); | ||
}); |
Binary file added
BIN
+281 KB
e2e/qr-code-reader.e2e.ts-snapshots/Read-QR-code-value-with-camera-1-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+64.4 KB
....e2e.ts-snapshots/Read-QR-throws-error-because-camera-stream-fails-1-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+64.4 KB
...er.e2e.ts-snapshots/Read-QR-throws-error-because-user-block-camera-1-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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,15 @@ | ||
#!/usr/bin/env bash | ||
|
||
DIR="./samples" | ||
|
||
if [ ! -d $DIR ]; then | ||
mkdir $DIR | ||
fi | ||
|
||
FILE="$DIR/qrcode.y4m" | ||
|
||
if test -f "$FILE"; then | ||
echo "$FILE exists" | ||
else | ||
wget --load-cookies /tmp/cookies.txt "https://drive.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://drive.google.com/uc?export=download&id=1wpsNoXTX3_y6Wrh7NE0SVwIZufK0-xeu' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=1wpsNoXTX3_y6Wrh7NE0SVwIZufK0-xeu" -O $FILE && rm -rf /tmp/cookies.txt | ||
fi |
This file contains 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 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 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
Oops, something went wrong.