Skip to content

Commit

Permalink
Fix agent mode showing when flag is present (#326)
Browse files Browse the repository at this point in the history
* Fix agent mode showing when flag is present

* fix agent mode check

* add test

* revert unrelated changes

* revert unrelated changes

* fix lint

* fix test

* chore: format code

---------

Co-authored-by: Khalifa Lame <[email protected]>
  • Loading branch information
ayinloya and khalibloo authored Sep 5, 2024
1 parent 8348ba4 commit acabd69
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 23 deletions.
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "example",
"private": true,
"version": "1.4.1",
"version": "1.4.2",
"type": "module",
"main": "server.js",
"scripts": {
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@smileid/web",
"version": "1.4.1",
"version": "1.4.2",
"description": "A collection of SmileID browser clients and components",
"main": "index.js",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/embed/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@smileid/embed",
"version": "1.4.1",
"version": "1.4.2",
"description": "Self Hosted Integration for Smile Identity on the Web",
"private": true,
"main": "inline.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/smart-camera-web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@smile_identity/smart-camera-web",
"version": "1.4.1",
"version": "1.4.2",
"description": "WebComponent for smartly capturing images on the web, for use with SmileIdentity",
"main": "smart-camera-web.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@ class SelfieCaptureScreens extends HTMLElement {
}

get allowAgentMode() {
return this.hasAttribute('allow-agent-mode')
? "allow-agent-mode='true'"
: '';
return this.inAgentMode ? "allow-agent-mode='true'" : '';
}

get allowAgentModeTests() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@smileid/signature-pad",
"version": "1.4.1",
"version": "1.4.2",
"private": "true",
"exports": {
".": "./index.js"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,21 @@ class SmartCameraWeb extends HTMLElement {

static get observedAttributes() {
return [
'allow-agent-mode',
'disable-image-tests',
'document-capture-modes',
'document-type',
'hide-attribution',
'hide-back-of-id',
'hide-back-to-host',
'show-navigation',
'theme-color',
'hide-attribution',
];
}

attributeChangedCallback(name) {
switch (name) {
case 'allow-agent-mode':
case 'disable-image-tests':
case 'document-capture-modes':
case 'document-type':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@ context('SmartCameraWeb', () => {
beforeEach(() => {
cy.visit('/smart-camera-web-agent-mode');
});

it('should switch from the selfie mode to agent mode"', () => {
cy.log('Enable agent mode for tests');
cy.get('smart-camera-web')
.shadow()
.find('selfie-capture')
.invoke('attr', 'show-agent-mode-for-tests', 'true');
.invoke('attr', 'allow-agent-mode', 'true')
.should('have.attr', 'allow-agent-mode', 'true');

cy.get('smart-camera-web').invoke(
'attr',
'show-agent-mode-for-tests',
'true',
);
cy.get('smart-camera-web').invoke('attr', 'disable-image-tests', '');

cy.clock();
cy.get('smart-camera-web')
Expand Down Expand Up @@ -80,4 +87,58 @@ context('SmartCameraWeb', () => {
.find('selfie-capture-review')
.should('be.visible');
});

it('should not show the agent mode switch button"', () => {
cy.get('smart-camera-web')
.shadow()
.find('selfie-capture')
.invoke('attr', 'show-agent-mode-for-tests', 'false');
cy.get('smart-camera-web').invoke('attr', 'disable-image-tests', '');

cy.clock();
cy.get('smart-camera-web')
.shadow()
.find('selfie-capture-instructions')
.shadow()
.find('#allow')
.click();

cy.get('smart-camera-web')
.shadow()
.find('selfie-capture')
.should('be.visible');

cy.get('smart-camera-web')
.shadow()
.find('selfie-capture')
.shadow()
.find('#switch-camera')
.should('not.exist');

cy.get('smart-camera-web')
.shadow()
.find('selfie-capture')
.shadow()
.should('contain.text', 'Take a Selfie');

cy.get('smart-camera-web')
.shadow()
.find('selfie-capture')
.shadow()
.find('#start-image-capture')
.click();

cy.tick(8000);

cy.get('smart-camera-web')
.shadow()
.find('selfie-capture')
.shadow()
.should('not.be.visible');

cy.get('smart-camera-web')
.shadow()
.find('selfie-capture-review')
.should('be.visible');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@
</head>

<body>
<smart-camera-web
disable-image-tests
allow-agent-mode="true"
></smart-camera-web>
<smart-camera-web></smart-camera-web>

<script src="./js/components/smart-camera-web/src/SmartCameraWeb.js"></script>
<script>
Expand Down
2 changes: 1 addition & 1 deletion packages/web-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@smileid/web-components",
"version": "1.4.1",
"version": "1.4.2",
"private": "true",
"exports": {
".": "./index.js",
Expand Down

0 comments on commit acabd69

Please sign in to comment.