Skip to content

Commit

Permalink
Add agent mode test
Browse files Browse the repository at this point in the history
  • Loading branch information
ayinloya committed Aug 9, 2024
1 parent 34cd791 commit ee0ee85
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
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', 'disable-for-tests', 'true');

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()
.should('contain.text', 'Agent Mode');

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

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

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
@@ -0,0 +1,41 @@
<!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%;
}

smart-camera-web {
margin-left: auto;
margin-right: auto;
max-width: 40ch;
padding: 1rem;
width: auto;
}
</style>
</head>

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

<script src="./js/components/smart-camera-web/src/SmartCameraWeb.js"></script>
<script>
const app = document.querySelector('smart-camera-web');
app.addEventListener('smart-camera-web.published', async (e) => {
console.log(e.detail);
});
</script>
</body>
</html>

0 comments on commit ee0ee85

Please sign in to comment.