Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegMoshkovich committed Jun 6, 2024
1 parent ef58f80 commit 7866294
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 9 additions & 3 deletions cypress/e2e/notes-100/comment-edit.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,30 @@ describe('Notes 100: Comment edit', () => {
beforeEach(homepageSetup)
context('Returning user visits homepage', () => {
beforeEach(returningUserVisitsHomepageWaitForModel)
context('Open Notes > first note', () => {
context('Open Notes > First note --', () => {
beforeEach(() => {
cy.get('[data-testid="control-button-notes"]').click()
cy.get('[data-testid="list-notes"] :nth-child(1) > [data-testid="note-body"]').first().click()
auth0Login()
})
it('Edit button should be visible', () => {
cy.get(`[data-testid="list-notes"] > :nth-child(3)
> [data-testid="note-card"] > .MuiCardActions-root > .MuiBox-root > [data-testid="editComment"]`)
cy.percySnapshot()
})
it('Comment switches to edit mode', () => {
auth0Login()
cy.get(`[data-testid="list-notes"] > :nth-child(3)
> [data-testid="note-card"] > .MuiCardActions-root > .MuiBox-root > [data-testid="editComment"]`).click()
cy.get('[data-testid="Save"]')
cy.percySnapshot()
})
it('Comment displays updated body', () => {
auth0Login()
cy.get(`[data-testid="list-notes"] > :nth-child(3)
> [data-testid="note-card"] > .MuiCardActions-root > .MuiBox-root > [data-testid="editComment"]`).click()
cy.get('[placeholder="Note body"]').click().type(' updated body')
cy.get('[data-testid="Save"]').click()
// eslint-disable-next-line cypress/no-unnecessary-waiting, no-magic-numbers
cy.wait(1000)
cy.percySnapshot()
})
})
Expand Down
4 changes: 1 addition & 3 deletions src/Components/Notes/NoteCard.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
import React, {ReactElement, useState, useEffect} from 'react'
import Avatar from '@mui/material/Avatar'
import Card from '@mui/material/Card'
Expand Down Expand Up @@ -180,8 +179,7 @@ export default function NoteCard({
* @param {number} commentId
*/
async function updateCommentGithub(commentId) {
const updatedComment = await updateComment(repository, commentId, editBody, accessToken)
console.log('updated comment', updatedComment.data)
await updateComment(repository, commentId, editBody, accessToken)
setEditMode(false)
}

Expand Down

0 comments on commit 7866294

Please sign in to comment.