Skip to content

Instantly share code, notes, and snippets.

@samselikoff
Created February 22, 2022 17:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samselikoff/208ef71cc8395b9edb2b6566309ec4f8 to your computer and use it in GitHub Desktop.
Save samselikoff/208ef71cc8395b9edb2b6566309ec4f8 to your computer and use it in GitHub Desktop.
Mocking Firebase + Hasura to test signing up
diff --git a/cypress/integration/signup.spec.js b/cypress/integration/signup.spec.js
index 3654bdd..4d7aefe 100644
--- a/cypress/integration/signup.spec.js
+++ b/cypress/integration/signup.spec.js
@@ -1,5 +1,14 @@
describe("signup", () => {
- it.skip("lets a user signup");
+ it("lets a user signup", () => {
+ cy.visit("/");
+ cy.contains("Sign up").click();
+ cy.get("[data-test=firstName]").type("Peter");
+ cy.get("[data-test=email]").type("peter@acme.com");
+ cy.get("[data-test=password]").type("abcd1234");
+ cy.get("[data-test=sign-up]").click();
+
+ cy.contains("Add goals to track your progress this week!").should("exist");
+ });
it.skip("redirectes authed users from /signup to /");
it.skip("auth errors on signup");
it.skip("user creation errors on signup");
diff --git a/mirage/resolvers.js b/mirage/resolvers.js
index 70031e2..7aa95a3 100644
--- a/mirage/resolvers.js
+++ b/mirage/resolvers.js
@@ -16,6 +16,10 @@ export const resolvers = {
});
},
+ insert_users_one(args, { schema }, info) {
+ return schema.users.create(args.object);
+ },
+
weeklyGoals(args, { schema }, info) {
let weekBeginning = args.where.weekBeginning._eq;
diff --git a/src/lib/auth-providers/test.js b/src/lib/auth-providers/test.js
index eb1ebbe..8de1ee2 100644
--- a/src/lib/auth-providers/test.js
+++ b/src/lib/auth-providers/test.js
@@ -1,3 +1,5 @@
+import { v4 as uuid } from "uuid";
+
let testProvider = {
initialize() {
return {
@@ -31,6 +33,7 @@ let testProvider = {
}, 5);
});
},
+
logout: (email, password) => {
return new Promise((resolve) => {
setTimeout(() => {
@@ -38,6 +41,10 @@ let testProvider = {
}, 5);
});
},
+
+ signup: async ({ name, email, password }) => {
+ return { token: "abc", userId: uuid() };
+ },
};
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment