parent
bbad42da6f
commit
e7d128a482
@ -0,0 +1,24 @@ |
||||
/// <reference types="Cypress" />
|
||||
|
||||
describe("registration should", () => { |
||||
it.only("handle its form", () => { |
||||
cy.visit("/register") |
||||
|
||||
cy.get("form") |
||||
.contains("Login") |
||||
.next("input") |
||||
.type("mylogin") |
||||
|
||||
cy.get("form") |
||||
.contains("Password") |
||||
.next("input") |
||||
.type("mypassword") |
||||
|
||||
cy.get("form") |
||||
.contains("Submit") |
||||
.click() |
||||
|
||||
cy.url().should("not.contain", "?") |
||||
cy.get("#output").should("contain", "mylogin") |
||||
}) |
||||
}) |
@ -1,19 +1,30 @@ |
||||
describe('Sapper template app', () => { |
||||
describe("app should", () => { |
||||
beforeEach(() => { |
||||
cy.visit('/') |
||||
}); |
||||
cy.visit("/") |
||||
}) |
||||
|
||||
it('has the correct <h1>', () => { |
||||
cy.contains('h1', 'Great success!') |
||||
}); |
||||
it("has the correct <h1>", () => { |
||||
cy.contains("h1", "Great success!") |
||||
}) |
||||
|
||||
it('navigates to /about', () => { |
||||
cy.get('nav a').contains('about').click(); |
||||
cy.url().should('include', '/about'); |
||||
}); |
||||
it("navigates to /about", () => { |
||||
cy.get("nav a") |
||||
.contains("about") |
||||
.click() |
||||
cy.url().should("include", "/about") |
||||
}) |
||||
|
||||
it('navigates to /blog', () => { |
||||
cy.get('nav a').contains('blog').click(); |
||||
cy.url().should('include', '/blog'); |
||||
}); |
||||
}); |
||||
it("navigates to /blog", () => { |
||||
cy.get("nav a") |
||||
.contains("blog") |
||||
.click() |
||||
cy.url().should("include", "/blog") |
||||
}) |
||||
|
||||
it("navigate to /register", () => { |
||||
cy.get("nav a") |
||||
.contains("Register") |
||||
.click() |
||||
cy.url().should("include", "/register") |
||||
}) |
||||
}) |
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,57 @@ |
||||
<script> |
||||
import { request } from "graphql-request" |
||||
|
||||
const uri = "http://localhost:4000/graphql" |
||||
const createUserMutation = ` |
||||
mutation ($email: String!, $password: String!) { |
||||
createUser(email: $email, password: $password) { |
||||
email |
||||
id |
||||
} |
||||
}` |
||||
|
||||
const handleSubmit = () => { |
||||
response = getResponse() |
||||
} |
||||
|
||||
const getResponse = async () => { |
||||
if (email && password) { |
||||
const res = await request(uri, createUserMutation, { email, password }) |
||||
return res.createUser |
||||
} |
||||
} |
||||
// function handleSubmit() { |
||||
// console.log("HANDLE") |
||||
// } |
||||
|
||||
let email |
||||
let password |
||||
let response |
||||
</script> |
||||
|
||||
<svelte:head> |
||||
<title>User Registration</title> |
||||
</svelte:head> |
||||
|
||||
<h1>User Registration</h1> |
||||
|
||||
<form on:submit|preventDefault="{handleSubmit}"> |
||||
<label>Login</label> |
||||
<input bind:value="{email}" type="text" />{email} |
||||
<br /> |
||||
|
||||
<label>Password</label> |
||||
<input bind:value="{password}" type="text" />{password} |
||||
|
||||
<br /> |
||||
<button type="submit">Submit</button> |
||||
</form> |
||||
|
||||
{#await response} |
||||
<p>...waiting</p> |
||||
{:then user} |
||||
<p>The user ID is {{...user}.id}</p> |
||||
<p id="output">The user email is {{...user}.email}</p> |
||||
{:catch error} |
||||
<p style="color: red">{error.message}</p> |
||||
{/await} |
Loading…
Reference in new issue