-
Notifications
You must be signed in to change notification settings - Fork 38
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
Added functionality for downloading spectrum image #245
Conversation
Thanks for opening this pull request! |
a4dfa53
to
3652a39
Compare
3652a39
to
4fedbce
Compare
@@ -161,6 +161,27 @@ $W = { | |||
this_.getRecentCalibrations("#calibration_id"); | |||
}, | |||
|
|||
downloadSpectrum: function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks awesome. Is this something we ought to write a test for? It seems like it could be a pretty easy test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, in which file would it make more sense tho 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the test assertion would be to confirm what a.href
equals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we try using Cypress to press the download button and then assert if a.href
is not empty? If that doesn't work, then we can try inserting an image to the
efa4f22
to
4368655
Compare
So I think the |
Yes that should be fine, we can simulate a click and then check the href attribute to see if it correctly generated? |
Another way you could insert the image is to just overwrite $W.data, I think, before clicking download, but that might test a narrower set of steps. Still useful! |
db9fd08
to
a191a81
Compare
So the anchor tag is generated and destroyed really fast according to the implementation. Even after checking for its presence, the tests prove to be really slow to detect it. let a = document.createElement('a');
a.href = base64_imgdata;
a.download = ('spectrum_img.png');
a.click();
} Same's the case for |
aaafda1
to
4368655
Compare
wait, but why would it be changed to a new one - can't we just pass in a
static image? Then if it returns anything at all, that's not blank, we
should be OK -- or maybe I'm missing something? Thanks!
…On Sat, Aug 21, 2021 at 3:45 PM Mohammad Warid ***@***.***> wrote:
So the anchor tag is generated and destroyed really fast according to the
implementation. Even after checking for its presence, the tests prove to be
really slow to detect it.
let a = document.createElement('a');
a.href = base64_imgdata;
a.download = ('spectrum_img.png');
a.click();
}
Same's the case for $W.data. If we try to get the current data after
clicking the Download button, then that wouldn't work since by that time,
the base64 of the spectrum would be changed to a new one 😕
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#245 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAF6J6GJ3IMFWOKRY32XK3T5764NANCNFSM5BVMDPAQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email>
.
|
The data keeps changing due to the default nature of cypress which provides This means we can't assert the The other thing is that the cypress tests stop since there is a prompt for downloading the cypress-download-prompt.mp4 |
However, we can set a test video with |
I think there ought to be a cypress tool for accepting the prompt... https://testersdock.com/cypress-javascript-alert-confirm-prompt/ |
Sure, this prompt however I think is not a JS generated so there are means to get passed this like - https://www.npmjs.com/package/cypress-downloadfile / Cypress v6.xx |
https://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement/download https://stackoverflow.com/a/66811222
Also possibly -- cypress-io/cypress#949 |
Hi @waridrox would you like me to give this one a try? Happy to if you'd like! |
Hi @jywarren!, I’m currently busy with my exams right now for the upcoming week or two 😅. If you would like to experiment, please by all means go ahead 🙌 |
OK, will give it a try if I have a moment - good luck in your exams!!! |
<button class="demo-button next" id="capture-page-next">Save Capture</button> | ||
<p style="margin-top: 0.5em">Once you save the capture, you cannot go back here.</p> | ||
<img style="display:none;background:#333;" id="spectrum-preview" /> | ||
|
||
<button class="demo-button next" id="download-spectrum" onClick="$W.downloadSpectrum();">Download</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here's the button
Let's start by testing that it's /some/ minimum length. Then we can also try presetting the video output using publiclab/spectral-workbench#710 for a more specific test. |
|
// and has length - and we assume that it has finished downloading then | ||
cy.readFile(filename, { timeout: 15000 }) | ||
.should('have.length.gt', 5000000000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This failed. Great!
Nice!!! Woohoo!! |
* Update README.md * Update README.md * Bump jasmine from 3.6.1 to 3.7.0 (#216) Bumps [jasmine](https://github.com/jasmine/jasmine-npm) from 3.6.1 to 3.7.0. - [Release notes](https://github.com/jasmine/jasmine-npm/releases) - [Commits](jasmine/jasmine-npm@v3.6.1...v3.7.0) Signed-off-by: dependabot-preview[bot] <[email protected]> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> * Bump tape from 5.2.0 to 5.2.2 (#211) Bumps [tape](https://github.com/substack/tape) from 5.2.0 to 5.2.2. - [Release notes](https://github.com/substack/tape/releases) - [Commits](tape-testing/tape@v5.2.0...v5.2.2) Signed-off-by: dependabot-preview[bot] <[email protected]> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> * [Security] Bump ini from 1.3.5 to 1.3.8 (#198) Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.8. **This update includes a security fix.** - [Release notes](https://github.com/isaacs/ini/releases) - [Commits](npm/ini@v1.3.5...v1.3.8) Signed-off-by: dependabot-preview[bot] <[email protected]> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> * bump to v0.2.0 (#238) * Camera switching in a dropdown list (#247) * Added camera switching in a dropdown * Added dropdown element for camera switching on old and new interface Added dropdown element on old interface * bump to v0.2.1 * Bump moment from 2.10.6 to 2.19.3 (#230) Bumps [moment](https://github.com/moment/moment) from 2.10.6 to 2.19.3. - [Release notes](https://github.com/moment/moment/releases) - [Changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md) - [Commits](moment/moment@2.10.6...2.19.3) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump jquery from 3.5.1 to 3.6.0 (#232) Bumps [jquery](https://github.com/jquery/jquery) from 3.5.1 to 3.6.0. - [Release notes](https://github.com/jquery/jquery/releases) - [Commits](jquery/jquery@3.5.1...3.6.0) Signed-off-by: dependabot-preview[bot] <[email protected]> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> * Bump grunt-cli from 1.3.2 to 1.4.3 (#234) Bumps [grunt-cli](https://github.com/gruntjs/grunt-cli) from 1.3.2 to 1.4.3. - [Release notes](https://github.com/gruntjs/grunt-cli/releases) - [Changelog](https://github.com/gruntjs/grunt-cli/blob/main/CHANGELOG.md) - [Commits](gruntjs/grunt-cli@v1.3.2...v1.4.3) Signed-off-by: dependabot-preview[bot] <[email protected]> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> * Bump cypress from 5.1.0 to 8.1.0 (#244) Bumps [cypress](https://github.com/cypress-io/cypress) from 5.1.0 to 8.1.0. - [Release notes](https://github.com/cypress-io/cypress/releases) - [Changelog](https://github.com/cypress-io/cypress/blob/develop/.releaserc.base.js) - [Commits](https://github.com/cypress-io/cypress/compare/@cypress/react-v5.1.0...v8.1.0) Signed-off-by: dependabot-preview[bot] <[email protected]> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> * Bump path-parse from 1.0.6 to 1.0.7 (#246) Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7. - [Release notes](https://github.com/jbgutierrez/path-parse/releases) - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7) --- updated-dependencies: - dependency-name: path-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Upgrade to GitHub-native Dependabot (#226) Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> * Bump cypress from 8.1.0 to 8.3.0 (#253) Bumps [cypress](https://github.com/cypress-io/cypress) from 8.1.0 to 8.3.0. - [Release notes](https://github.com/cypress-io/cypress/releases) - [Changelog](https://github.com/cypress-io/cypress/blob/develop/.releaserc.base.js) - [Commits](cypress-io/cypress@v8.1.0...v8.3.0) --- updated-dependencies: - dependency-name: cypress dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump grunt from 1.3.0 to 1.4.1 (#252) Bumps [grunt](https://github.com/gruntjs/grunt) from 1.3.0 to 1.4.1. - [Release notes](https://github.com/gruntjs/grunt/releases) - [Changelog](https://github.com/gruntjs/grunt/blob/main/CHANGELOG) - [Commits](gruntjs/grunt@v1.3.0...v1.4.1) --- updated-dependencies: - dependency-name: grunt dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump jquery.steps from 1.1.1 to 1.1.2 (#250) Bumps [jquery.steps](https://github.com/oguzhanoya/jquery-steps) from 1.1.1 to 1.1.2. - [Release notes](https://github.com/oguzhanoya/jquery-steps/releases) - [Commits](oguzhanoya/jquery-steps@v1.1.1...v1.1.2) --- updated-dependencies: - dependency-name: jquery.steps dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump tape from 5.2.2 to 5.3.1 (#249) Bumps [tape](https://github.com/substack/tape) from 5.2.2 to 5.3.1. - [Release notes](https://github.com/substack/tape/releases) - [Commits](tape-testing/tape@v5.2.2...v5.3.1) --- updated-dependencies: - dependency-name: tape dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump jasmine from 3.7.0 to 3.9.0 (#248) Bumps [jasmine](https://github.com/jasmine/jasmine-npm) from 3.7.0 to 3.9.0. - [Release notes](https://github.com/jasmine/jasmine-npm/releases) - [Commits](jasmine/jasmine-npm@v3.7.0...v3.9.0) --- updated-dependencies: - dependency-name: jasmine dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump moment from 2.19.3 to 2.29.1 (#257) Bumps [moment](https://github.com/moment/moment) from 2.19.3 to 2.29.1. - [Release notes](https://github.com/moment/moment/releases) - [Changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md) - [Commits](moment/moment@2.19.3...2.29.1) --- updated-dependencies: - dependency-name: moment dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump cypress from 8.3.0 to 8.3.1 (#259) Bumps [cypress](https://github.com/cypress-io/cypress) from 8.3.0 to 8.3.1. - [Release notes](https://github.com/cypress-io/cypress/releases) - [Changelog](https://github.com/cypress-io/cypress/blob/develop/.releaserc.base.js) - [Commits](cypress-io/cypress@v8.3.0...v8.3.1) --- updated-dependencies: - dependency-name: cypress dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump http-server from 0.12.3 to 13.0.1 (#258) Bumps [http-server](https://github.com/http-party/http-server) from 0.12.3 to 13.0.1. - [Release notes](https://github.com/http-party/http-server/releases) - [Commits](http-party/http-server@v0.12.3...v13.0.1) --- updated-dependencies: - dependency-name: http-server dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Added functionality for downloading spectrum image (#245) * Added function for downloading spectrum img * Adding dropdown for camera switching * download file and check length * Update spectral-workbench-demo.spec.js * Update spectral-workbench-demo.spec.js * Update spectral-workbench-demo.spec.js * increase file length test for downloaded image Co-authored-by: Jeffrey Warren <[email protected]> * Bump http-server from 13.0.1 to 13.0.2 (#260) Bumps [http-server](https://github.com/http-party/http-server) from 13.0.1 to 13.0.2. - [Release notes](https://github.com/http-party/http-server/releases) - [Commits](http-party/http-server@v13.0.1...v13.0.2) --- updated-dependencies: - dependency-name: http-server dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Mohammad Warid <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
The current
Download
button at http://spectralworkbench.org doesn't work. A blank page is open instead. The added function could be utilised wherever possible for example in the new interface to download the spectrum images with the timestamp. Here's a demo for the same:download-test.mov
Please be sure you've reviewed our contribution guidelines at https://publiclab.org/wiki/contributing-to-public-lab-software
Please alert developers on [email protected] when your request is ready or if you need assistance.
Thanks!