Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
fe87f5f
ADASP-33: adding google api script tag
RubySpeeders Jun 4, 2021
f1059e9
ADASP-33: creating new component
RubySpeeders Jun 4, 2021
16df00e
ADASP-33: in the middle of an error, Googleauth gomponent not quite r…
RubySpeeders Jun 4, 2021
ddc3d5b
ADASP-33: adding ts deps for gapi. writing useeffect to get the gapi …
RubySpeeders Jun 7, 2021
611cb57
ADASP-33: adding a listen function for if user signs in or not
RubySpeeders Jun 7, 2021
869f59e
ADASP-33: configuring a rtk slice for whether or not a user is signed in
RubySpeeders Jun 7, 2021
a44a5e7
ADASP-33: adding a signout reducer
RubySpeeders Jun 7, 2021
0ede644
ADASP-33: merging develop into this branch
RubySpeeders Jun 8, 2021
8b94e08
ADASP-33: hooked up rtk to hold isSignedIn, clicking the button signs…
RubySpeeders Jun 8, 2021
12e3b11
ADASP-33: added userId to be recorded on state
RubySpeeders Jun 8, 2021
dca18b7
ADASP-33: adding drawer component to show/hide sign in/out button. ad…
RubySpeeders Jun 8, 2021
91c6721
ADASP-33: adding in a dummy test in GoogleAuth
RubySpeeders Jun 8, 2021
891d85c
ADASP-33: adding dummy test to Drawer
RubySpeeders Jun 8, 2021
13ecd4f
ADASP-33: adding Provider tag to all tests
RubySpeeders Jun 8, 2021
9e1e1eb
ADASP-33: adding closing the drawer when signin/out button is clicked
RubySpeeders Jun 8, 2021
c25c7a2
ADASP-33: adding testing for oauth rtk
RubySpeeders Jun 8, 2021
f70d412
ADASP-33: adding a test in appheader to check if clicking on hamburge…
RubySpeeders Jun 8, 2021
de0295b
ADASP-33: deleted some keystrokes
RubySpeeders Jun 8, 2021
a81406b
ADASP-33: adding a test to drawerSlice to check that the drawer state…
RubySpeeders Jun 8, 2021
55261a0
ADASP-33: hiding GoogleAuth from tests for now
RubySpeeders Jun 9, 2021
21096c8
ADASP-33: creating a type for initialstate to account for null
RubySpeeders Jun 9, 2021
270f290
ADASP-33: adding a render option for is isSignedIn is null
RubySpeeders Jun 9, 2021
038a053
ADASP-33: changing the render of null state of google oauth to be the…
RubySpeeders Jun 9, 2021
e3398b4
ADASP-33: adjusting custom type for sliceState for oauth
RubySpeeders Jun 9, 2021
0219e34
ADASP-33: miscellaneous resolving requested changes from PR
RubySpeeders Jun 10, 2021
2cba37e
ADASP-33: changes from github PR comments
RubySpeeders Jun 11, 2021
2e1d2be
ADASP-33: adding a custom hook for google auth, and downloading googl…
RubySpeeders Jun 11, 2021
c97bc6f
ADASP-33: adding function in googleauth to call to api, probably need…
RubySpeeders Jun 11, 2021
7c957c0
ADASP-33: some changes from last week (oh no) changing naming convent…
RubySpeeders Jun 14, 2021
e5f980c
ADASP-33: adding dotenv package and a new component to test google lo…
RubySpeeders Jun 15, 2021
8212e49
ADASP-33: changing the name of google logins to login only, adding th…
RubySpeeders Jun 15, 2021
45120ce
ADASP-33: keystrokes?
RubySpeeders Jun 15, 2021
ce68283
ADASP-33: adding some styling to drawer
RubySpeeders Jun 16, 2021
86b247c
ADASP-33: adding correct prefix for env variable
RubySpeeders Jun 16, 2021
500c6d4
ADASP-33: adding Logout button and component
RubySpeeders Jun 17, 2021
fc45c71
ADASP-33: adding dispatch to toggle drawer closed after logging in. a…
RubySpeeders Jun 17, 2021
6f1fff1
ADASP-33: adding logout todo
RubySpeeders Jun 17, 2021
c963c0a
ADASP-33: adding toggle drawer to close drawer after logging out
RubySpeeders Jun 17, 2021
5fe9d56
ADASP-33: updating tests
RubySpeeders Jun 17, 2021
459aff6
ADASP-33: updating tests
RubySpeeders Jun 17, 2021
a3e1d20
ADASP-33: updating tests
RubySpeeders Jun 17, 2021
732970e
ADASP-33: adding custom command for testing google oauth
RubySpeeders Jun 24, 2021
6a2f27b
merge conflicts
RubySpeeders Jun 24, 2021
d7aef22
ADASP-33: actually saving
RubySpeeders Jun 24, 2021
d1102f3
ADASP-33: ran npm i
RubySpeeders Jun 28, 2021
935a3f8
ADASP-33: changing file structure for custom commands.
RubySpeeders Jun 28, 2021
f2060cb
ADASP-33: adding variables to plugin file for cypress
RubySpeeders Jun 28, 2021
21ec88c
ADASP-33: changing the variables back to use .env variables
RubySpeeders Jun 29, 2021
b86707e
ADASP-33: adding a cypress custom command
RubySpeeders Jul 8, 2021
65b8dd1
ADASP-33: adding intercept Google cypress command
RubySpeeders Jul 9, 2021
7f4403d
ADASP-33: custom createTask Cypress task. adding in a check in App.js…
RubySpeeders Jul 13, 2021
9051a5f
ADASP-33: adding another value to state for username so I can render …
RubySpeeders Jul 13, 2021
19fb255
ADASP-33: updating test to match getting username now, as well
RubySpeeders Jul 13, 2021
8f04c4f
ADASP-33: adding a few more tests
RubySpeeders Jul 13, 2021
a4b3a65
ADASP-33: tests - i'm not sure. it's been a few days
RubySpeeders Jul 22, 2021
496e1c9
ADASP-33: deleting file with secret key
RubySpeeders Jul 22, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ yarn-error.log*

# depcruiser visualizations
dependency-graph.svg
dependency-report.html
dependency-report.html

todo-app-315819-5c42dd0d1c80.json
25 changes: 12 additions & 13 deletions cypress/integration/tasks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe("App", function () {
describe("app with no oauth", () => {
it("Contains a button that starts the app in motion", function () {
cy.visit("/")
cy.findByText("Get Started").contains("Get Started")
Expand All @@ -10,6 +10,12 @@ describe("App", function () {
cy.visit("/todo")
cy.get(".AppHeader").contains("My Tasks")
})
})

describe("App with oauth before each test", function () {
beforeEach(() => {
cy.loginByGoogleApi()
})
it("shows a modal after clicking Create New Task button and hides it after clicking cancel", function () {
cy.visit("/todo")
cy.findByText("Create New Task").click()
Expand All @@ -18,26 +24,21 @@ describe("App", function () {
cy.findByText("Cancel").click()
cy.get(".taskForm").should("not.exist")
})

it("creates a new task with a checkbox", function () {
cy.visit("/todo")
cy.findByText("Create New Task").click()
cy.get("#taskInput").type("make dinner")
cy.findByText("Save").click()
cy.createTask()
cy.get(".checkbox > .MuiSvgIcon-root").should("exist")
})
it("changes an active task to completed when checkbox is clicked", function () {
cy.visit("/todo")
cy.findByText("Create New Task").click()
cy.get("#taskInput").type("make dinner")
cy.findByText("Save").click()
cy.createTask()
cy.get("[data-testid=unchecked]").click()
cy.get("[data-testid=checked] > path").should("exist")
})
it("shows an edit modal after clicking a task, edits the description, then hides the modal after clicking save", function () {
cy.visit("/todo")
cy.findByText("Create New Task").click()
cy.get("#taskInput").type("make dinner")
cy.findByText("Save").click()
cy.createTask()
cy.get(".taskCard").click()
cy.get("#taskInput").type("wash the dishes")
cy.findByText("Save").click()
Expand All @@ -48,9 +49,7 @@ describe("App", function () {
})
it("shows and hides complete tasks", function () {
cy.visit("/todo")
cy.findByText("Create New Task").click()
cy.get("#taskInput").type("another task")
cy.findByText("Save").click()
cy.createTask()
cy.get("[data-testid=unchecked]").click({ multiple: true })
cy.get(".taskCard").should("exist")
cy.get(".expand").click()
Expand Down
10 changes: 9 additions & 1 deletion cypress/plugins/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { config } from "dotenv"
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
Expand All @@ -11,7 +12,14 @@
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

module.exports = (_on, _config) => {
config()
export default (_on: Cypress.PluginEvents, config: Cypress.ConfigOptions) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
if (config.env) {
config.env.googleRefreshToken = process.env.GOOGLE_REFRESH_TOKEN
config.env.googleClientId = process.env.REACT_APP_GOOGLE_CLIENTID
config.env.googleClientSecret = process.env.REACT_APP_GOOGLE_CLIENT_SECRET
}
return config
}
1 change: 0 additions & 1 deletion cypress/support/commands.ts

This file was deleted.

7 changes: 7 additions & 0 deletions cypress/support/commands/createTask.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import "@testing-library/cypress/add-commands"

Cypress.Commands.add("createTask", () => {
cy.findByText("Create New Task").click()
cy.get("#taskInput").type("make dinner")
cy.findByText("Save").click()
})
38 changes: 38 additions & 0 deletions cypress/support/commands/googleLogin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import "@testing-library/cypress/add-commands"

Cypress.Commands.add("loginByGoogleApi", () => {
cy.log("Logging in to Google")
cy.request({
method: "POST",
url: "https://www.googleapis.com/oauth2/v4/token",
body: {
grant_type: "refresh_token",
client_id: Cypress.env("googleClientId"),
client_secret: Cypress.env("googleClientSecret"),
refresh_token: Cypress.env("googleRefreshToken"),
Comment on lines +10 to +12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RubySpeeders I think that we need to add these variables to the GitHub repo settings in order to successfully authenticate. This would be the information you have in your .env file I believe.

},
}).then(({ body }) => {
const { access_token, id_token } = body

cy.request({
method: "GET",
url: "https://www.googleapis.com/oauth2/v3/userinfo",
headers: { Authorization: `Bearer ${access_token}` },
}).then(({ body }) => {
cy.log(body)
const userItem = {
token: id_token,
user: {
googleId: body.sub,
email: body.email,
givenName: body.given_name,
familyName: body.family_name,
imageUrl: body.picture,
},
}

window.localStorage.setItem("googleCypress", JSON.stringify(userItem))
cy.visit("/todo")
})
})
})
34 changes: 34 additions & 0 deletions cypress/support/commands/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/no-namespace */
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import "./googleLogin"
import "./createTask"
import "@testing-library/cypress/add-commands"

declare global {
namespace Cypress {
interface Chainable {
/**
* Custom command to select DOM element by data-cy attribute.
* @example cy.loginByGoogleApi()
*/
loginByGoogleApi(): Chainable<Window>
createTask(): Chainable<Window>
}
}
}
2 changes: 1 addition & 1 deletion cypress/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
},
"include": [
"**/*.ts"
]
],
}
Loading