diff --git a/package.json b/package.json index 39518566dd..df3bf8cd23 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,6 @@ "husky": "0.14.3", "identity-obj-proxy": "3.0.0", "npm-run-all": "4.1.5", - "openssl-self-signed-certificate": "^1.1.6", "react": "15.6.2", "react-addons-test-utils": "15.6.2", "react-dom": "15.6.2", diff --git a/testcafe/runner-drive.js b/testcafe/runner-drive.js index 7f461acea3..9c0e3cd513 100644 --- a/testcafe/runner-drive.js +++ b/testcafe/runner-drive.js @@ -1,19 +1,11 @@ const createTestCafe = require('testcafe') -const selfSignedSertificate = require('openssl-self-signed-certificate') - -const sslOptions = { - key: selfSignedSertificate.key, - cert: selfSignedSertificate.cert -} async function runRunner() { - const tc = await createTestCafe('localhost', 1337, 1338, sslOptions) + const tc = await createTestCafe() const runner = await tc.createRunner() const response = await runner .src(['testcafe/tests/drive_nav.js', 'testcafe/tests/drive_sharing.js']) - .browsers([ - 'chrome --allow-insecure-localhost --allow-running-insecure-content --start-maximized' - ]) + .browsers(['chrome --start-maximized']) .screenshots( 'reports/screenshots/', diff --git a/testcafe/tests/drive_sharing.js b/testcafe/tests/drive_sharing.js index e558bf71d2..5d06631602 100644 --- a/testcafe/tests/drive_sharing.js +++ b/testcafe/tests/drive_sharing.js @@ -2,10 +2,12 @@ import { Selector, Role } from 'testcafe' import { driveUser } from './helpers/roles' import { TESTCAFE_DRIVE_URL, - FOLDER_DATE_TIME, isExistingAndVisibile, - getCurrentDateTime + getCurrentDateTime, + FOLDER_DATE_TIME } from './helpers/utils' +import Data from './helpers/data' +const data = new Data() import DrivePage from './pages/drive-model' const drivePage = new DrivePage() @@ -36,7 +38,12 @@ test('Drive : from Drive, go in a folder, upload a file, and share it', async t await t.pressKey('esc') //close action Menu await drivePage.uploadFiles([`../data/${file}`]) - await drivePage.shareFolderPublicLink() //-> Not finish + await drivePage.shareFolderPublicLink() + + data.sharingLink = await drivePage.copyBtnShareByLink.getAttribute( + 'data-test-data' + ) + console.log(`SHARING_LINK : ` + data.sharingLink) }) //************************ @@ -47,9 +54,7 @@ fixture`Drive : Access a folder public link` await t.useRole(Role.anonymous()) }) test('Drive : Access a folder public link', async t => { - await t.navigateTo( - 'http://drive.cozy.tools:8080/public?sharecode=t2dqusHt2GFf' - ) //!// FIXME: :use URL from copy-paste + await t.navigateTo(data.sharingLink) await publicDrivePage.waitForLoading() await publicDrivePage.checkActionMenuPublicDesktop() @@ -101,9 +106,8 @@ fixture`Drive : No Access to an old folder public link` await t.useRole(Role.anonymous()) }) test('`Drive : No Access to an old folder public link', async t => { - await t.navigateTo( - 'http://drive.cozy.tools:8080/public?sharecode=Ueoxcqmt9Ve7' - ) //!// FIXME: :use URL from copy-paste + await t.navigateTo(data.sharingLink) + await publicDrivePage.waitForLoading() await publicDrivePage.checkNotAvailable() }) diff --git a/testcafe/tests/helpers/data.js b/testcafe/tests/helpers/data.js new file mode 100644 index 0000000000..66527c1997 --- /dev/null +++ b/testcafe/tests/helpers/data.js @@ -0,0 +1,5 @@ +export default class Data { + constructor() { + this.sharingLink = '' + } +} diff --git a/testcafe/tests/helpers/utils.js b/testcafe/tests/helpers/utils.js index fec3742bb5..cce6261b6a 100644 --- a/testcafe/tests/helpers/utils.js +++ b/testcafe/tests/helpers/utils.js @@ -36,6 +36,10 @@ export function getCurrentDateTime() { export const FOLDER_DATE_TIME = `Folder_${getCurrentDateTime()}` -export const getClipboardData = ClientFunction(() => { - navigator.clipboard.readText() //chrome only +export const overwriteCopyCommand = ClientFunction(() => { + document.execCommand = command => (window.lastExecutedCommand = command) }) + +export const getLastExecutedCommand = ClientFunction( + () => window.lastExecutedCommand +) diff --git a/testcafe/tests/pages/drive-model.js b/testcafe/tests/pages/drive-model.js index aec1070a43..501fc7e212 100644 --- a/testcafe/tests/pages/drive-model.js +++ b/testcafe/tests/pages/drive-model.js @@ -1,9 +1,11 @@ -import { Selector, t } from 'testcafe' +import { Selector, t, ClientFunction } from 'testcafe' import { getElementWithTestId, getPageUrl, isExistingAndVisibile, - getClipboardData + getClipboardData, + overwriteCopyCommand, + getLastExecutedCommand } from '../helpers/utils' export default class DrivePage { @@ -39,6 +41,7 @@ export default class DrivePage { this.content_placeholder = Selector( '[class*="fil-content-file-placeholder"]' ) + this.alertWrapper = Selector('[class*="c-alert-wrapper"]') //Toolbar - Action Menu this.toolbar_files = getElementWithTestId('fil-toolbar-files') @@ -66,7 +69,6 @@ export default class DrivePage { this.btnUpload = getElementWithTestId('uploadButton') this.divUpload = getElementWithTestId('uploadQueue') this.divUploadSuccess = getElementWithTestId('uploadQueue-success') - this.alertWrapper = Selector('[class*="c-alert-wrapper"]') // Sharing this.btnShare = this.toolbar_files @@ -75,9 +77,8 @@ export default class DrivePage { this.modalShare = Selector('[class*="share-modal-content"]') this.divShareByLink = getElementWithTestId('share-by-link') this.toggleShareLink = this.divShareByLink.child('[class*="toggle"]') - this.copyBtnShareByLink = getElementWithTestId( - 'share-bylink-header-copybtn' - ) + this.spanLinkCreating = Selector('[class*="share-bylink-header-creating"]') + this.copyBtnShareByLink = Selector('button').withAttribute('data-test-data') this.btnShareByMe = this.toolbar_files .child('button') .withAttribute('data-test-id', 'share-by-me-button') @@ -248,10 +249,18 @@ export default class DrivePage { .click(this.toggleShareLink) .expect(this.toggleShareLink.find('input').checked) .ok('toggle Link is unchecked') + .expect(this.spanLinkCreating.exist) + .notOk('Still creating Link') + isExistingAndVisibile(this.copyBtnShareByLink, 'Copy Link') + + await overwriteCopyCommand() + + await t .click(this.copyBtnShareByLink) + .expect(getLastExecutedCommand()) + .eql('copy') //check link copy actually happens - // const tests = await getClipboardData() - // console.log(tests) + isExistingAndVisibile(this.alertWrapper, '"successfull" modal alert') } async unshareFolderPublicLink() {