-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(SmartCameraWeb): add image test, show an error message when test …
…fails (#120) * fix: count colors in images, and show an error message * build: add correct version * fix: fix lint errors * redesign: use `enable-image-tests` to configure tests * workflows: deploy files and not folders for smart-camera-web * lint: remove global rule and disable-next-line for no-bitwise * redesign: test by default, do not test on `disable-image-tests` attribute * tests: disable-image-tests on default test files * docs: update version in README.md * redesign: change error message for image tests * tests: add test for image-tests functionality * refactor: make hasMoreThanNColors a top level function * fix: fix lint errors * refactor: address PR feedback, use dedicated screen for failed-image-test * redesign: add image, copy for failed image test screen * copy: update failed-image-test copy * assets: change icon for failed-image-test * version: bump embed version * tests: disable image tests for smart-camera-web
1 parent
c19f1e9
commit 974ecba
Showing
16 changed files
with
220 additions
and
25 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
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,51 @@ | ||
// smart-camera-web.spec.js created with Cypress | ||
// | ||
// Start writing your Cypress tests below! | ||
// If you're unfamiliar with how Cypress works, | ||
// check out the link below and learn how to write your first test: | ||
// https://on.cypress.io/writing-first-test | ||
context('SmartCameraWeb - Image Tests', () => { | ||
beforeEach(() => { | ||
cy.visit('/image-tests'); | ||
}); | ||
|
||
it('should show an error message when image is unusable', () => { | ||
cy | ||
.get('smart-camera-web') | ||
.shadow() | ||
.find('#request-camera-access') | ||
.click(); | ||
|
||
cy | ||
.get('smart-camera-web') | ||
.shadow() | ||
.find('#start-image-capture') | ||
.click(); | ||
|
||
cy | ||
.wait(8000); | ||
|
||
cy | ||
.get('smart-camera-web') | ||
.shadow() | ||
.find('#camera-screen') | ||
.should('not.be.visible'); | ||
|
||
cy | ||
.get('smart-camera-web') | ||
.shadow() | ||
.find('#review-screen') | ||
.should('not.be.visible'); | ||
|
||
cy | ||
.get('smart-camera-web') | ||
.shadow() | ||
.find('#failed-image-test-screen') | ||
.should('be.visible'); | ||
|
||
cy.get('smart-camera-web') | ||
.shadow() | ||
.find('#failed-image-test-screen p') | ||
.should('contain.text', 'Device not supported'); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
<smart-camera-web | ||
capture-id='back' | ||
hide-attribution | ||
disable-image-tests | ||
> | ||
</smart-camera-web> | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
<body> | ||
<smart-camera-web | ||
capture-id='back' | ||
disable-image-tests | ||
> | ||
</smart-camera-web> | ||
|
||
|
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 |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
<smart-camera-web | ||
capture-id='true' | ||
hide-back-to-host | ||
disable-image-tests | ||
> | ||
</smart-camera-web> | ||
|
||
|
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 |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
<body> | ||
<smart-camera-web | ||
capture-id='true' | ||
disable-image-tests | ||
> | ||
</smart-camera-web> | ||
|
||
|
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 |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
<body> | ||
<smart-camera-web | ||
capture-id='back' | ||
disable-image-tests | ||
> | ||
</smart-camera-web> | ||
|
||
|
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,73 @@ | ||
<!doctype html> | ||
<html lang='en'> | ||
<head> | ||
<meta name='viewport' content='width=device-width, initial-scale=1' /> | ||
<style> | ||
*, | ||
*::before, | ||
*::after { | ||
box-sizing: border-box; | ||
} | ||
|
||
body { | ||
max-width: 100%; | ||
min-height: 100%; | ||
} | ||
button[data-type='icon'] { | ||
align-items: center; | ||
background-color: transparent; | ||
border: 0; | ||
cursor: pointer; | ||
display: flex; | ||
padding: 0; | ||
} | ||
.justify-right { | ||
justify-content: end !important; | ||
} | ||
|
||
.nav { | ||
display: flex; | ||
justify-content: space-between; | ||
} | ||
|
||
.back-button { | ||
display: block !important; | ||
} | ||
|
||
.back-button-text { | ||
font-size: 11px; | ||
line-height: 11px; | ||
color: #3886F7; | ||
} | ||
|
||
smart-camera-web { | ||
margin-left: auto; | ||
margin-right: auto; | ||
max-width: 40ch; | ||
padding: 1rem; | ||
width: auto; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<smart-camera-web show-navigation> | ||
</smart-camera-web> | ||
|
||
<script src='./instrumented/smart-camera-web.js'></script> | ||
<script> | ||
const app = document.querySelector('smart-camera-web'); | ||
app.addEventListener('imagesComputed', async (e) => { | ||
console.log(e.detail); | ||
}); | ||
|
||
app.addEventListener('backExit', async (e) => { | ||
location.href = '/back_pressed' | ||
}) | ||
|
||
app.addEventListener('close', async (e) => { | ||
location.href = '/closed' | ||
}) | ||
</script> | ||
</body> | ||
</html> |
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
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