Skip to content

Commit

Permalink
Update snapshot and make file path constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Muller committed May 7, 2020
1 parent e56c7b5 commit 3dae576
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 26 deletions.
10 changes: 5 additions & 5 deletions packages/server/__snapshots__/8_read_only_fs.ts.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
exports['e2e project dir access / warns when unable to write to dir'] = `
Folder /var/folders/k1/3m_8g1215_3ds89dv0g55fn40000gn/T/71d038ec is not writable.
Folder /tmp/8_read_only_fs is not writable.
Writing to this directory is required by Cypress in order to store screenshots and videos.
Expand Down Expand Up @@ -47,17 +47,17 @@ Warning: We failed to record the video.
This error will not alter the exit code.
Error: ffmpeg exited with code 1: /var/folders/k1/3m_8g1215_3ds89dv0g55fn40000gn/T/71d038ec/cypress/videos/spec.js.mp4: Permission denied
Error: ffmpeg exited with code 1: /tmp/8_read_only_fs/cypress/videos/spec.js.mp4: Permission denied
[stack trace lines]
[stack trace lines]
Warning: We failed processing this video.
This error will not alter the exit code.
Error: ffmpeg exited with code 1: /var/folders/k1/3m_8g1215_3ds89dv0g55fn40000gn/T/71d038ec/cypress/videos/spec.js.mp4: Permission denied
Error: ffmpeg exited with code 1: /tmp/8_read_only_fs/cypress/videos/spec.js.mp4: Permission denied
[stack trace lines]
[stack trace lines]
====================================================================================================
Expand Down
3 changes: 2 additions & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
"chai-as-promised": "7.1.1",
"chai-subset": "1.6.0",
"chai-uuid": "1.0.6",
"chmodr": "1.2.0",
"chokidar-cli": "1.2.2",
"chrome-har-capturer": "0.13.4",
"coffee-coverage": "3.0.1",
Expand Down Expand Up @@ -200,4 +201,4 @@
"optionalDependencies": {
"registry-js": "1.8.0"
}
}
}
25 changes: 5 additions & 20 deletions packages/server/test/e2e/8_read_only_fs.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import * as fs from 'fs-extra'
import * as os from 'os'
import * as fs from 'fs'
import * as path from 'path'
import * as crypto from 'crypto'

const e2e = require('../support/helpers/e2e')
const chmodr = require('chmodr')

describe('e2e project dir access', function () {
e2e.setup()
const projectDir: string = path.join(os.tmpdir(), crypto.randomBytes(4).toString('hex'))
const projectDir: string = path.join('/', 'tmp', '8_read_only_fs')

beforeEach(() => {
if (fs.existsSync(projectDir)) {
Expand All @@ -18,36 +17,22 @@ describe('e2e project dir access', function () {
// we cant sue one define by source code since we need to modify the file permissions on the dir and files
fs.mkdirSync(path.join(projectDir))

fs.writeFile(path.join(projectDir, 'cypress.json'), `{"projectId": "2pz86o"}`)

fs.writeFileSync(path.join(projectDir, 'cypress.json'), `{"projectId": "2pz86o"}`)
fs.mkdirSync(path.join(projectDir, 'cypress'))
fs.mkdirSync(path.join(projectDir, 'cypress', 'integration'))
fs.writeFileSync(path.join(projectDir, 'cypress', 'integration', 'spec.js'), `it('test',() => expect(true).to.be.true )`)

fs.mkdirSync(path.join(projectDir, 'cypress', 'plugins'))
fs.writeFileSync(path.join(projectDir, 'cypress', 'plugins', 'index.js'), `module.exports = () => {}`)

fs.mkdirSync(path.join(projectDir, 'cypress', 'support'))
fs.writeFileSync(path.join(projectDir, 'cypress', 'support', 'index.js'), `module.exports = () => {}`)

fs.mkdirSync(path.join(projectDir, 'cypress', 'videos'))

// setup the file/folder permissions
// 500 means individual read + execute
// the dir needs executable for debugging
// the main test here is that it isn't writable, which would be either 6 or 7
// See here for more info on these numbers http://permissions-calculator.org/
const readExe = 0o500

fs.chmodSync(path.join(projectDir), readExe)
fs.chmodSync(path.join(projectDir, 'cypress'), readExe)
fs.chmodSync(path.join(projectDir, 'cypress', 'integration'), readExe)
fs.chmodSync(path.join(projectDir, 'cypress', 'integration', 'spec.js'), readExe)
fs.chmodSync(path.join(projectDir, 'cypress', 'plugins'), readExe)
fs.chmodSync(path.join(projectDir, 'cypress', 'plugins', 'index.js'), readExe)
fs.chmodSync(path.join(projectDir, 'cypress', 'support'), readExe)
fs.chmodSync(path.join(projectDir, 'cypress', 'support', 'index.js'), readExe)
fs.chmodSync(path.join(projectDir, 'cypress', 'videos'), readExe)
chmodr.sync(projectDir, 0o500)

// test that we setup the folder structure correctly
let err: any
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7751,6 +7751,11 @@ cheerio@^1.0.0-rc.3:
lodash "^4.15.0"
parse5 "^3.0.1"

chmodr@1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/chmodr/-/chmodr-1.2.0.tgz#720e96caa09b7f1cdbb01529b7d0ab6bc5e118b9"
integrity sha512-Y5uI7Iq/Az6HgJEL6pdw7THVd7jbVOTPwsmcPOBjQL8e3N+pz872kzK5QxYGEy21iRys+iHWV0UZQXDFJo1hyA==

chokidar-cli@1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/chokidar-cli/-/chokidar-cli-1.2.2.tgz#fbfddcf1f9062c07744f0bbeb6f60a49de12c656"
Expand Down

0 comments on commit 3dae576

Please sign in to comment.