-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
899 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"baseUrl": "http://localhost:3000" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
hello world |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
describe('Create Secret', function () { | ||
let polyfill; | ||
|
||
before(() => { | ||
const polyfillUrl = 'https://unpkg.com/unfetch/dist/unfetch.umd.js'; | ||
|
||
cy.request(polyfillUrl).then((response) => { | ||
polyfill = response.body; | ||
}); | ||
}); | ||
|
||
beforeEach(() => { | ||
cy.server(); | ||
cy.route({ | ||
method: 'POST', | ||
url: '/secret', | ||
response: { message: '75c3383d-a0d9-4296-8ca8-026cc2272271' }, | ||
}).as('post'); | ||
|
||
cy.visit('/', { | ||
onBeforeLoad(win) { | ||
delete win.fetch; | ||
win.eval(polyfill); | ||
win.fetch = win.unfetch; | ||
}, | ||
}); | ||
}); | ||
|
||
it('create secret', () => { | ||
cy.get('textarea').type('hello world'); | ||
cy.contains('Encrypt Message').click(); | ||
cy.get('#full-i').should( | ||
'contain.value', | ||
'http://localhost:3000/#/s/75c3383d-a0d9-4296-8ca8-026cc2272271', | ||
); | ||
cy.get('@post').should((req) => { | ||
console.log(req.request.body.message); | ||
cy.route({ | ||
method: 'GET', | ||
url: '/secret/75c3383d-a0d9-4296-8ca8-026cc2272271', | ||
response: { | ||
message: req.request.body.message, | ||
}, | ||
}); | ||
expect(req.method).to.equal('POST'); | ||
expect(req.request.body.expiration).to.equal(3600); | ||
expect(req.request.body.one_time).to.equal(true); | ||
}); | ||
cy.get('#full-i') | ||
.invoke('val') | ||
.then((text) => { | ||
cy.visit(text); | ||
cy.contains('hello world'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
describe('Upload/Download File', function () { | ||
let polyfill; | ||
|
||
before(() => { | ||
const polyfillUrl = 'https://unpkg.com/unfetch/dist/unfetch.umd.js'; | ||
|
||
cy.request(polyfillUrl).then((response) => { | ||
polyfill = response.body; | ||
}); | ||
}); | ||
|
||
beforeEach(() => { | ||
cy.server(); | ||
cy.route({ | ||
method: 'POST', | ||
url: '/file', | ||
response: { message: '75c3383d-a0d9-4296-8ca8-026cc2272271' }, | ||
}).as('post'); | ||
|
||
cy.visit('#/upload', { | ||
onBeforeLoad(win) { | ||
delete win.fetch; | ||
win.eval(polyfill); | ||
win.fetch = win.unfetch; | ||
}, | ||
}); | ||
}); | ||
|
||
it('create secret', () => { | ||
const yourFixturePath = 'data.txt'; | ||
cy.get('input').attachFile(yourFixturePath); | ||
cy.get('#full-i').should( | ||
'contain.value', | ||
'http://localhost:3000/#/f/75c3383d-a0d9-4296-8ca8-026cc2272271', | ||
); | ||
cy.get('@post').should((req) => { | ||
console.log(req.request.body.message); | ||
cy.route({ | ||
method: 'GET', | ||
url: '/file/75c3383d-a0d9-4296-8ca8-026cc2272271', | ||
response: { | ||
message: req.request.body.message, | ||
}, | ||
}); | ||
expect(req.method).to.equal('POST'); | ||
expect(req.request.body.expiration).to.equal(3600); | ||
expect(req.request.body.one_time).to.equal(true); | ||
}); | ||
cy.get('#full-i') | ||
.invoke('val') | ||
.then((text) => { | ||
cy.visit(text); | ||
cy.contains( | ||
'Downloading file and decrypting in browser, please hold...', | ||
); | ||
// File downloads not supported in headless mode. | ||
// https://github.com/cypress-io/cypress/issues/949 | ||
//cy.readFile('cypress/downloads/data.txt').then((f) => { | ||
// expect(f).to.equal('hello world'); | ||
//}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/// <reference types="cypress" /> | ||
// *********************************************************** | ||
// This example plugins/index.js can be used to load plugins | ||
// | ||
// You can change the location of this file or turn off loading | ||
// the plugins file with the 'pluginsFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/plugins-guide | ||
// *********************************************************** | ||
|
||
// This function is called when a project is opened or re-opened (e.g. due to | ||
// the project's config changing) | ||
|
||
/** | ||
* @type {Cypress.PluginConfig} | ||
*/ | ||
const path = require('path'); | ||
|
||
module.exports = (on, config) => { | ||
// `on` is used to hook into various events Cypress emits | ||
// `config` is the resolved Cypress config | ||
// on('before:browser:launch', (browser = {}, launchOptions) => { | ||
// const downloadDirectory = path.join(__dirname, '..', 'downloads'); | ||
// if (browser.family === 'chromium') { | ||
// launchOptions.preferences.default['download'] = { | ||
// default_directory: downloadDirectory, | ||
// }; | ||
// } | ||
// return launchOptions; | ||
// }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// *********************************************** | ||
// This example commands.js shows you how to | ||
// create various custom commands and overwrite | ||
// existing commands. | ||
// | ||
// For more comprehensive examples of custom | ||
// commands please read more here: | ||
// https://on.cypress.io/custom-commands | ||
// *********************************************** | ||
// | ||
// | ||
// -- This is a parent command -- | ||
// Cypress.Commands.add("login", (email, password) => { ... }) | ||
// | ||
// | ||
// -- This is a child command -- | ||
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is a dual command -- | ||
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This will overwrite an existing command -- | ||
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) | ||
import 'cypress-file-upload'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// *********************************************************** | ||
// This example support/index.js is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import './commands' | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.