Skip to content
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

Fix agent mode showing when flag is present #326

Merged
merged 8 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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