itemengine-cypress-automation 1.0.352-IEI-6059-a5d8e8c.0 → 1.0.353-capture-image-c0b337c.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -111,51 +111,88 @@ describe('Create question page - Upload Response: Preview', () => {
111
111
  });
112
112
  });
113
113
 
114
- //Added to manual testing list
115
- describe.skip('Allow students to capture photos preview', () => {
114
+ describe('Allow students to capture photos preview', () => {
116
115
  abortEarlySetup();
117
116
  before(() => {
117
+ cy.mockCamera();
118
118
  uploadResponsePage.steps.navigateToCreateQuestion('upload response');
119
119
  uploadResponsePage.steps.switchToPreviewTab();
120
120
  });
121
121
 
122
122
  it('Camera icon should be displayed before link text \'capture an image\'', () => {
123
+ utilities.verifyElementVisibilityState(uploadResponsePage.cameraIcon(), 'visible');
124
+ utilities.verifyElementVisibilityState(uploadResponsePage.captureAnImageLabel(), 'visible');
125
+ utilities.verifyInnerText(uploadResponsePage.captureAnImageLabel(), 'capture an image');
123
126
  });
124
127
 
125
128
  it('When the user clicks on the link text \'capture an image\' a \'Capture image\' popup should open', () => {
126
-
127
- });
128
-
129
- it('CSS of \'Capture image\' popup', () => {
130
-
129
+ uploadResponsePage.steps.captureImage();
130
+ utilities.verifyElementVisibilityState(uploadResponsePage.dialogBox(), 'visible');
131
131
  });
132
132
 
133
133
  it('On \'Capture image\' popup following should be displayed - \'Capture image\' title text, Camera preview, Capture and Cancel buttons', () => {
134
+ uploadResponsePage.steps.verifyCaptureImagePopup();
135
+ });
134
136
 
137
+ it('CSS of \'Capture image\' popup', { tags: 'css' }, () => {
138
+ utilities.verifyCSS(uploadResponsePage.dialogBoxTitle(), {
139
+ 'color': css.color.secondaryBtn,
140
+ 'font-size': css.fontSize.heading,
141
+ 'font-weight': css.fontWeight.semibold
142
+ });
143
+ utilities.verifyCSS(uploadResponsePage.cancelButton(), {
144
+ 'color': css.color.secondaryBtn,
145
+ 'background-color': css.color.transparent,
146
+ 'font-size': css.fontSize.default,
147
+ 'font-weight': css.fontWeight.semibold
148
+ });
149
+ utilities.verifyCSS(uploadResponsePage.acceptButton(), {
150
+ 'color': css.color.primaryBtn,
151
+ 'background-color': css.color.activeButtons,
152
+ 'font-size': css.fontSize.default,
153
+ 'font-weight': css.fontWeight.semibold
154
+ });
135
155
  });
136
156
 
137
157
  it('When the user clicks on \'Cancel\' button the \'Capture image\' popup should close', () => {
138
-
158
+ uploadResponsePage.steps.clickCancelButtonInPopup();
159
+ utilities.verifyElementVisibilityState(uploadResponsePage.dialogBox(), 'notExist');
139
160
  });
140
161
 
141
162
  it('When the user clicks on \'Capture\' button, then an image should get captured and a preview of the captured image should be displayed in place of the camera preview and also two buttons \'Retake\' and \'Save\' should be displayed in the popup and \'Cancel\' and \'Capture\' buttons should not be displayed in the popup', () => {
142
-
163
+ uploadResponsePage.steps.captureImage();
164
+ uploadResponsePage.steps.clickAcceptButtonInPopup();
165
+ utilities.verifyInnerText(uploadResponsePage.cancelButton(), 'Retake');
166
+ utilities.verifyInnerText(uploadResponsePage.acceptButton(), 'Save');
143
167
  });
144
168
 
145
169
  it('When the user clicks on \'Save\' button, it should upload the captured image in the response', () => {
146
-
170
+ uploadResponsePage.steps.clickAcceptButtonInPopup();
171
+ utilities.verifyElementVisibilityState(uploadResponsePage.uploadingProgressBar(), 'notExist');
147
172
  });
148
173
 
149
174
  it('The captured image should be saved in .jpeg format and the 1st image should be saved with the name \'Photo.jpeg\'', () => {
150
-
175
+ uploadResponsePage.steps.uploadedFileContentsPreviewTab(0, 'Photo.jpeg');
151
176
  });
152
177
 
153
178
  it('If the user uploads another image the name should be \'Photo-1.jpeg\' and so on', () => {
154
- //check till Photo-2.jpeg
155
-
179
+ uploadResponsePage.steps.captureImage();
180
+ uploadResponsePage.steps.clickAcceptButtonInPopup();
181
+ uploadResponsePage.steps.clickAcceptButtonInPopup();
182
+ uploadResponsePage.steps.uploadedFileContentsPreviewTab(1, 'Photo-1.jpeg');
183
+ uploadResponsePage.steps.captureImage();
184
+ uploadResponsePage.steps.clickAcceptButtonInPopup();
185
+ uploadResponsePage.steps.clickAcceptButtonInPopup();
186
+ uploadResponsePage.steps.uploadedFileContentsPreviewTab(2, 'Photo-2.jpeg');
156
187
  });
157
188
 
158
189
  it('When the user clicks on \'Retake\' button, it should take the user back to the capture an image flow where the user should be able to capture another image', () => {
190
+ uploadResponsePage.steps.captureImage();
191
+ uploadResponsePage.steps.clickAcceptButtonInPopup();
192
+ uploadResponsePage.steps.clickCancelButtonInPopup();
193
+ uploadResponsePage.steps.verifyCaptureImagePopup();
194
+ uploadResponsePage.steps.clickAcceptButtonInPopup();
195
+ uploadResponsePage.steps.clickAcceptButtonInPopup();
159
196
  });
160
197
  });
161
198
  });
@@ -61,6 +61,7 @@ const selectors = {
61
61
  deviceLink: () => cy.get('.icon-Device'),
62
62
  googleDriveLink: () => cy.get('.icon-Google-Drive'),
63
63
  cameraIcon: () => cy.get('.icon-Capture-an-image'),
64
+ captureAnImageLabel: () => cy.get('.upload-text.icon-Capture-an-image'),
64
65
  supportedFileFormatLabel: () => cy.get('.supported-file-text'),
65
66
  supportedFileInfoIcon: () => cy.get('.supported-file-icon-wrapper'),
66
67
  uploadingProgressBar: () => cy.get('.uploading-document-progress-bar'),
@@ -86,6 +87,7 @@ const selectors = {
86
87
  warningMessage: () => cy.get('.disabled-wrapper-cls [class*="DisabledTextWrapper"]'),
87
88
  acceptButton: () => cy.get('.popup-button-wrapper button').eq(1),
88
89
  cancelButton: () => cy.get('.popup-button-wrapper button').eq(0),
90
+ cameraCanvas: () => cy.get('.camera-capturing-canvas'),
89
91
  questionWrapperPreviewTab: () => cy.get('[class*="UploadQuestionPreviewstyle__UploadQuestionPreviewWrapper"]'),
90
92
  maximumFileSize: () => cy.get('[class*="UploadQuestionPreviewstyle__MaxFileLimitDesc"]'),
91
93
  unSupportedFileInfoIcon: () => cy.get('[class*="UploadedDocumentsstyle__UnSupportedFileIcon"]'),
@@ -640,6 +642,19 @@ const steps = {
640
642
  verifyAllowStudentToAddFileDescriptionCheckboxUnchecked: () => {
641
643
  uploadResponsePage.allowStudentToAddFileDescriptionCheckbox()
642
644
  .should('not.be.checked');
645
+ },
646
+
647
+ captureImage: () => {
648
+ uploadResponsePage.cameraIcon()
649
+ .click();
650
+ },
651
+
652
+ verifyCaptureImagePopup: () => {
653
+ utilities.verifyInnerText(uploadResponsePage.dialogBoxTitle(), 'Capture image');
654
+ utilities.verifyInnerText(uploadResponsePage.cancelButton(), 'Cancel');
655
+ utilities.verifyElementVisibilityState(uploadResponsePage.cancelButton(), 'visible');
656
+ utilities.verifyInnerText(uploadResponsePage.acceptButton(), 'Capture');
657
+ utilities.verifyElementVisibilityState(uploadResponsePage.acceptButton(), 'visible');
643
658
  }
644
659
  }
645
660
 
@@ -1,7 +1,7 @@
1
1
  import crypto from 'crypto';
2
2
  import { v4 as uuidv4 } from 'uuid';
3
3
  import "cypress-real-events/support";
4
- import 'cypress-file-upload';
4
+ // import 'cypress-file-upload';
5
5
  import { iePage } from './migrationHelpers/verifyIeQuestionData';
6
6
  import { lrnPage } from './migrationHelpers/extractLrnQuestionData';
7
7
  require('cy-verify-downloads').addCustomCommand();
@@ -203,6 +203,15 @@ Cypress.Commands.add('startApplitools', () => {
203
203
  });
204
204
  });
205
205
 
206
+ Cypress.Commands.add('mockCamera', () => {
207
+ cy.visit(Cypress.config().baseUrl, {
208
+ onBeforeLoad(win) {
209
+ win.navigator.mediaDevices.getUserMedia = () =>
210
+ Promise.resolve(new MediaStream());
211
+ }
212
+ });
213
+ });
214
+
206
215
  export function getShortDate(previous, dayFormat = 'oneDigitFormat') {
207
216
 
208
217
  var date = new Date();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itemengine-cypress-automation",
3
- "version": "1.0.352-IEI-6059-a5d8e8c.0",
3
+ "version": "1.0.353-capture-image-c0b337c.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {