Skip to content

Commit 2b8837b

Browse files
committed
fix(StatementForm): broken update
1 parent 2af3ee9 commit 2b8837b

File tree

6 files changed

+64
-10
lines changed

6 files changed

+64
-10
lines changed

app/components/Statements/Statement.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default class Statement extends React.PureComponent {
1717
const { statement, speaker, handleEdit, handleDelete, withoutActions, offset = 0 } = this.props
1818

1919
return (
20-
<div>
20+
<div data-cy="statement">
2121
<StatementHeader
2222
statementTime={statement.time + offset}
2323
isDraft={statement.is_draft}

app/components/Statements/StatementForm.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ export class StatementForm extends React.Component {
117117

118118
return (
119119
<form
120+
data-cy="statement-form"
120121
ref={this.containerRef}
121122
onSubmit={handleSubmit(this.handleSubmit)}
122123
className={cn('bg-white rounded-lg shadow-lg border border-gray-200', {

app/components/VideoDebate/ActionBubbleMenu.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ export const ActionBubble = ({
139139
...props
140140
}) => (
141141
<div
142+
role="button"
143+
tabIndex={0}
144+
onKeyDown={(e) => {
145+
if (e.key === 'Enter' || e.key === ' ') {
146+
props.onClick?.()
147+
}
148+
}}
149+
data-cy="action-bubble"
142150
className={cn(
143151
'mb-2 first:mb-0 transition-all duration-300',
144152
'cursor-pointer shadow-md hover:shadow-lg right-0',
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
describe('Can add and edit statements', () => {
2+
it('adds a new statement, edits it, then deletes it', () => {
3+
const statementText = `Cypress statement ${Date.now()}`
4+
const updatedStatementText = `${statementText} - edited`
5+
6+
cy.login().then(() => {
7+
cy.visit('/videos/Jzqg')
8+
9+
// Add a statement
10+
cy.contains('[data-cy="action-bubble"]', 'Add a Statement').click()
11+
cy.get('[data-cy="statement-form"] textarea[name="text"]').type(statementText)
12+
cy.contains('button[type=submit]', 'Save').click()
13+
14+
cy.contains('A speaker should be added. To continue without one, press "Save".').should(
15+
'exist',
16+
)
17+
cy.contains('button[type=submit]', 'Save').click()
18+
cy.contains('[data-cy="statement"]', statementText, { timeout: 15000 }).should('exist')
19+
20+
// Edit
21+
cy.contains('[data-cy="statement"]', statementText)
22+
.find('button[aria-haspopup="menu"]')
23+
.click()
24+
cy.contains('[role="menuitem"]', 'Edit').click()
25+
cy.get('[data-cy="statement-form"] textarea[name="text"]').clear().type(updatedStatementText)
26+
cy.contains('button[type=submit]', 'Save').click()
27+
28+
cy.contains('A speaker should be added. To continue without one, press "Save".').should(
29+
'exist',
30+
)
31+
cy.contains('button[type=submit]', 'Save').click()
32+
33+
// Remove
34+
cy.contains('[data-cy="statement"]', updatedStatementText, { timeout: 15000 }).should('exist')
35+
cy.contains('[data-cy="statement"]', statementText)
36+
.find('button[aria-haspopup="menu"]')
37+
.click()
38+
cy.contains('[role="menuitem"]', 'Remove').click()
39+
cy.contains('[role="alertdialog"] button', 'Remove').click()
40+
cy.contains('[data-cy="statement"]', updatedStatementText, { timeout: 15000 }).should(
41+
'not.exist',
42+
)
43+
})
44+
})
45+
})

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
"reactjs-popup": "~2.0.6",
116116
"redux": "~4.2.1",
117117
"redux-actions": "~2.6.5",
118-
"redux-form": "8.3.10",
118+
"redux-form": "8.3.9",
119119
"redux-promise": "~0.6.0",
120120
"redux-thunk": "~2.3.0",
121121
"remark-gfm": "4.0.1",

0 commit comments

Comments
 (0)