@@ -66,10 +65,13 @@ export default class Dropdown extends FormInputComponent {
[styles.block]: block,
[styles.opened]: isActive,
})}
- {...props}
+ data-e2e-select-name={restProps.name}
+ {...restProps}
onClick={this.onToggle}
>
-
{label}
+
+ {label}
+
@@ -96,7 +98,7 @@ export default class Dropdown extends FormInputComponent {
});
}
- onSelectItem(item) {
+ onSelectItem(item: OptionItem) {
return event => {
event.preventDefault();
@@ -106,9 +108,9 @@ export default class Dropdown extends FormInputComponent {
};
}
- getActiveItem() {
+ getActiveItem(): OptionItem {
const { items } = this.props;
- let { activeItem } = /** @type {any} */ (this.state);
+ let { activeItem } = this.state;
if (!activeItem) {
activeItem = {
@@ -130,20 +132,20 @@ export default class Dropdown extends FormInputComponent {
}
getValue() {
- return this.getActiveItem().value;
+ return this.getActiveItem()?.value;
}
- onToggle = event => {
+ onToggle = (event: React.MouseEvent) => {
event.preventDefault();
this.toggle();
};
- onBodyClick = event => {
+ onBodyClick = (event: MouseEvent) => {
if (this.state.isActive) {
const el = ReactDOM.findDOMNode(this);
- if (!el.contains(event.target) && el !== event.taget) {
+ if (!el.contains(event.target) && el !== event.target) {
event.preventDefault();
event.stopPropagation();
diff --git a/packages/app/services/api/feedback.ts b/packages/app/services/api/feedback.ts
index 9236484..a538c8d 100644
--- a/packages/app/services/api/feedback.ts
+++ b/packages/app/services/api/feedback.ts
@@ -2,6 +2,11 @@ import request from 'app/services/request';
export default {
send({ subject = '', email = '', message = '', category = '' }) {
- return request.post('/api/feedback', { subject, email, message, category });
+ return request.post('/api/feedback', {
+ subject,
+ email,
+ message,
+ category,
+ });
},
};
diff --git a/tests-e2e/cypress/integration/profile/feedback-popup.test.ts b/tests-e2e/cypress/integration/profile/feedback-popup.test.ts
new file mode 100644
index 0000000..1fc9f20
--- /dev/null
+++ b/tests-e2e/cypress/integration/profile/feedback-popup.test.ts
@@ -0,0 +1,51 @@
+import { account1 } from '../../fixtures/accounts.json';
+
+it('should send feedback', () => {
+ const subject = 'Hello world';
+ const message = 'This is a feedback message';
+
+ cy.server();
+ cy.route({
+ url: '/api/feedback',
+ method: 'POST',
+ response: { success: true },
+ });
+
+ cy.login({ accounts: ['default'] });
+
+ cy.visit('/');
+
+ cy.getByTestId('footer')
+ .contains('Contact Us')
+ .click();
+ cy.getByTestId('feedbackPopup').should('be.visible');
+
+ cy.get('[name=subject]').type(subject);
+ cy.get('[name=email]').should('have.value', account1.email);
+ cy.get('[name=message]').type(message);
+
+ cy.get('[data-e2e-select-name=category]')
+ .getByTestId('select-label')
+ .should('contain', 'What are you interested');
+ cy.get('[data-e2e-select-name=category]').click();
+ cy.get('[data-e2e-select-name=category]')
+ .contains('bug')
+ .click();
+ cy.get('[data-e2e-select-name=category]')
+ .getByTestId('select-label')
+ .should('contain', 'bug');
+
+ cy.getByTestId('feedbackPopup')
+ .get('[type=submit]')
+ .click();
+
+ cy.getByTestId('feedbackPopup').should(
+ 'contain',
+ 'Your message was received',
+ );
+ cy.getByTestId('feedbackPopup').should('contain', account1.email);
+
+ cy.getByTestId('feedback-popup-close-button').click();
+
+ cy.getByTestId('feedbackPopup').should('not.be.visible');
+});