Skip to content
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

Add support for resouce/fixture files #972

Open
seanstory opened this issue Oct 22, 2024 · 4 comments
Open

Add support for resouce/fixture files #972

seanstory opened this issue Oct 22, 2024 · 4 comments

Comments

@seanstory
Copy link
Member

I'd like to write a synthetic journey that tests a file upload UI. Unfortunately, I'm hitting errors like:

error executing step: ENOENT: no such file or directory, stat '/tmp/elastic-synthetics-unzip-382249059/lib/common/helper/fixtures/sample.pdf'

Upon further investigation, it seems that the PDF file we have in our source code isn't actually included in the tree under /tmp/elastic-synthetics-unzip-*. @vigneshshanmugam indicated that this is because of previous security concerns that prevented non-source-code file types from being included in the bundle, but that perhaps some exceptions could be made.

@shahzad31
Copy link
Contributor

related request #897

@babwade
Copy link

babwade commented Nov 6, 2024

Same probleme here. Watching for further updates

@babwade
Copy link

babwade commented Nov 6, 2024

I work with ELK + playwright. I found a workaround => i have to bufferize the image that i want to upload
// 1 - encode the image
const imageEncoded = Buffer.from(fs.readFileSync('path_image.jpg')).toString('base64')
// 2 -do playwright request multipart

let response = await request.post(`${params.API_URL}/api/endpoint`, {{
  headers: {
    Accept: 'application/json',
    Authorization: 'Bearer 437a7a2b4d07c66c4b0f07d3900816a6'
  },
  multipart: {
    id: 'myId-1234',
    time: 1730823793,
    picture: {
      name: 'picture',
      mimeType: 'image/jpg',
      buffer: Buffer.from(imageEncoded, 'base64')
    },
  }
}
  const { body } = await response.json()
  expect(response.status()).toBe(200)

i hope it helps

@seanstory
Copy link
Member Author

I'm thinking your issue wasn't related @babwade - this ticket is about the fact that path_image.jpg wouldn't actually be available on the filesystem when the code is run. In your case, maybe the file was actually included in the /tmp/elastic-synthetics-unzip-*, but seems that not all files are. Buffering wouldn't help if you couldn't read the file from disk to start with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants