parent
000f713751
commit
e94c1eeb61
After Width: | Height: | Size: 3.8 KiB |
@ -0,0 +1,19 @@ |
|||||||
|
/// <reference types="Cypress" />
|
||||||
|
|
||||||
|
describe("upload route should", () => { |
||||||
|
it.only("handle one file upload", () => { |
||||||
|
cy.visit("/") |
||||||
|
cy.contains("Drop files") |
||||||
|
|
||||||
|
cy.fixture("logos/mcdonald.png", "base64").then(fileContent => { |
||||||
|
cy.get('[cy="dropzone"]').upload( |
||||||
|
{ |
||||||
|
fileContent, |
||||||
|
fileName: "mcdonald.png", |
||||||
|
mimeType: "image/png", |
||||||
|
}, |
||||||
|
{ subjectType: "drag-n-drop" } |
||||||
|
) |
||||||
|
}) |
||||||
|
}) |
||||||
|
}) |
@ -1,20 +1,35 @@ |
|||||||
<svelte:head> |
<script> |
||||||
<title>Sapper project template</title> |
import { onMount } from "svelte" |
||||||
</svelte:head> |
let dz |
||||||
|
|
||||||
<p> |
onMount(async () => { |
||||||
<strong> |
const dropzone = await import("dropzone") |
||||||
Try editing this file (src/routes/index.svelte) to test live reloading. |
dz = new dropzone.default("div#dropzone", { |
||||||
</strong> |
url: "http://localhost:4000/graphql", |
||||||
</p> |
autoProcessQueue: true, |
||||||
|
}) |
||||||
<style> |
|
||||||
p { |
dz.on("sending", (file, xhr, data) => { |
||||||
text-align: center; |
data.append( |
||||||
margin: 0 auto; |
"operations", |
||||||
} |
`{ "query": "mutation ($file: Upload!) { uploadFigure(file: $file)}", "variables": { "file": null } }` |
||||||
|
) |
||||||
p { |
data.append("map", `{ "file": ["variables.file"] }`) |
||||||
margin: 1em auto; |
}) |
||||||
} |
}) |
||||||
</style> |
</script> |
||||||
|
|
||||||
|
<div id="dropzone" class="dropzone" cy="dropzone" /> |
||||||
|
|
||||||
|
<style> |
||||||
|
.dropzone { |
||||||
|
height: 300px; |
||||||
|
background: #fdfdfd; |
||||||
|
border-radius: 5px; |
||||||
|
border: 2px dashed #ff3e00; |
||||||
|
display: flex; |
||||||
|
justify-content: center; |
||||||
|
align-items: center; |
||||||
|
transition: all 300ms ease-out; |
||||||
|
} |
||||||
|
</style> |
||||||
|
Loading…
Reference in new issue