diff --git a/cypress/integration/spectral-workbench-demo.spec.js b/cypress/integration/spectral-workbench-demo.spec.js
index 363a1c49..934653b8 100644
--- a/cypress/integration/spectral-workbench-demo.spec.js
+++ b/cypress/integration/spectral-workbench-demo.spec.js
@@ -1,4 +1,5 @@
///
+const path = require('path')
context('Actions', () => {
@@ -6,7 +7,6 @@ context('Actions', () => {
cy.visit('http://127.0.0.1:8080/examples/new-capture/')
})
-
it('It reach the default landing page', () => {
cy.get('#landing-page-content').contains('Spectral WorkBench');
cy.get('#landing-page-content').contains('What is Spectral Workbench?');
@@ -28,5 +28,23 @@ context('Actions', () => {
cy.get('.bs-stepper-header>div').eq(6).not('have.class', 'active')
});
-
-})
\ No newline at end of file
+ const downloadsFolder = Cypress.config('downloadsFolder')
+
+ it('can be clicked through to begin capturing', () => {
+ cy.get('#landing-page-next').click()
+ cy.get('#setting-page-next').click()
+ cy.get('#download-spectrum').click()
+
+ cy.log('**read downloaded file**')
+
+ // file path is relative to the working folder
+ const filename = path.join(downloadsFolder, 'spectrum_img.png')
+
+ // browser might take a while to download the file,
+ // so use "cy.readFile" to retry until the file exists
+ // and has length - and we assume that it has finished downloading then
+ cy.readFile(filename, { timeout: 15000 })
+ .should('have.length.gt', 50)
+ });
+
+})
diff --git a/examples/capture/capture.js b/examples/capture/capture.js
index 07134dd4..8b7778a7 100644
--- a/examples/capture/capture.js
+++ b/examples/capture/capture.js
@@ -161,6 +161,16 @@ $W = {
this_.getRecentCalibrations("#calibration_id");
},
+ downloadSpectrum: function() {
+ let base64_imgdata = $('#dataurl').val($W.canvas.toDataURL())[0].defaultValue;
+ console.log(base64_imgdata);
+
+ let a = document.createElement('a');
+ a.href = base64_imgdata;
+ a.download = ('spectrum_img.png');
+ a.click();
+ },
+
getRecentCalibrations: function(selector) {
$.ajax({
url: "/capture/recent_calibrations.json?calibration_id=" + $W.calibration_id,
diff --git a/examples/new-capture/index.html b/examples/new-capture/index.html
index 9227ef73..f9fa310b 100644
--- a/examples/new-capture/index.html
+++ b/examples/new-capture/index.html
@@ -246,9 +246,14 @@
+
+
Once you save the capture, you cannot go back here.
+
+
+