diff --git a/packages/design-system/src/lib/components/alert/Alert.tsx b/packages/design-system/src/lib/components/alert/Alert.tsx index c1a02f078..5e8e12382 100644 --- a/packages/design-system/src/lib/components/alert/Alert.tsx +++ b/packages/design-system/src/lib/components/alert/Alert.tsx @@ -30,15 +30,10 @@ function Alert({ variant, dismissible = true, customHeading, children, onClose } } const heading = getAlertHeading(variant, customHeading) - const handleClose = () => { - onClose && onClose() - setShow(false) - } - return ( <> {show && ( - + setShow(false)} dismissible={dismissible}>   {heading} - {children} diff --git a/public/locales/en/shared.json b/public/locales/en/shared.json index 94d48cc1a..35ac7aca8 100644 --- a/public/locales/en/shared.json +++ b/public/locales/en/shared.json @@ -151,5 +151,29 @@ "editSuccess": "Collection updated successfully." }, "createCollection": "Create Collection" + }, + "contact": { + "message": "Message", + "subject": "Subject", + "title": { + "collection": "Contact", + "dataset": "Contact Owner" + }, + "contactCollection": "Email Collection Contact", + "contactDataset": "Email Dataset Contact", + "helpText": "Email the contact for this collection.", + "verificationText": "Please fill this out to prove you are not a robot.", + "contactSuccess": "Message sent.", + "validation": { + "captchaInput": { + "required": "Validation is required.", + "invalid": "Incorrect answer.", + "onlyNumber": "Only numbers are allowed.", + "maxLength": "Answer cannot exceed 10." + }, + "email": { "required": "Email is required.", "maxLength": "Email cannot exceed 255." }, + "subject": { "required": "Subject is required.", "maxLength": "Subject cannot exceed 255." }, + "message": { "required": "Message is required.", "maxLength": "Message cannot exceed 255." } + } } } diff --git a/src/contact/domain/repositories/ContactRepository.ts b/src/contact/domain/repositories/ContactRepository.ts index a1160a3b2..8c6f7117a 100644 --- a/src/contact/domain/repositories/ContactRepository.ts +++ b/src/contact/domain/repositories/ContactRepository.ts @@ -1,6 +1,6 @@ -import { ContactDTO } from '../useCases/ContactDTO' +import { FeedbackDTO } from '../useCases/FeedbackDTO' import { Contact } from '../models/Contact' export interface ContactRepository { - submitContactInfo: (contactDTO: ContactDTO) => Promise + sendFeedbacktoOwners: (feedbackDTO: FeedbackDTO) => Promise } diff --git a/src/contact/domain/useCases/ContactDTO.ts b/src/contact/domain/useCases/FeedbackDTO.ts similarity index 75% rename from src/contact/domain/useCases/ContactDTO.ts rename to src/contact/domain/useCases/FeedbackDTO.ts index be94d9ed2..dcf390048 100644 --- a/src/contact/domain/useCases/ContactDTO.ts +++ b/src/contact/domain/useCases/FeedbackDTO.ts @@ -1,4 +1,4 @@ -export interface ContactDTO { +export interface FeedbackDTO { targetId?: number identifier?: string fromEmail: string diff --git a/src/contact/domain/useCases/submitContact.ts b/src/contact/domain/useCases/sendFeedbacktoOwners.ts similarity index 56% rename from src/contact/domain/useCases/submitContact.ts rename to src/contact/domain/useCases/sendFeedbacktoOwners.ts index 5850a7fb0..35dff8fbb 100644 --- a/src/contact/domain/useCases/submitContact.ts +++ b/src/contact/domain/useCases/sendFeedbacktoOwners.ts @@ -1,13 +1,13 @@ import { ContactRepository } from '../repositories/ContactRepository' import { WriteError } from '@iqss/dataverse-client-javascript' -import { ContactDTO } from './ContactDTO' +import { FeedbackDTO } from '../useCases/FeedbackDTO' import { Contact } from '../models/Contact' -export async function submitContact( +export async function sendFeedbacktoOwners( ContactRepository: ContactRepository, - contactDTO: ContactDTO + FeedbackDTO: FeedbackDTO ): Promise { - return ContactRepository.submitContactInfo(contactDTO).catch((error: WriteError) => { + return ContactRepository.sendFeedbacktoOwners(FeedbackDTO).catch((error: WriteError) => { throw new Error(error.message) }) } diff --git a/src/contact/infrastructure/ContactJSDataverseRepository.ts b/src/contact/infrastructure/ContactJSDataverseRepository.ts index 0b9324670..c469f918c 100644 --- a/src/contact/infrastructure/ContactJSDataverseRepository.ts +++ b/src/contact/infrastructure/ContactJSDataverseRepository.ts @@ -1,10 +1,10 @@ +import { submitContactInfo } from '@iqss/dataverse-client-javascript' import { Contact } from '../domain/models/Contact' import { ContactRepository } from '../domain/repositories/ContactRepository' -import { ContactDTO } from '../domain/useCases/ContactDTO' -import { submitContactInfo } from '@iqss/dataverse-client-javascript' +import { FeedbackDTO } from '../domain/useCases/FeedbackDTO' export class ContactJSDataverseRepository implements ContactRepository { - async submitContactInfo(contactDTO: ContactDTO): Promise { - return submitContactInfo.execute(contactDTO).then((response: Contact[]) => response) + async sendFeedbacktoOwners(feedbackDTO: FeedbackDTO): Promise { + return submitContactInfo.execute(feedbackDTO).then((response: Contact[]) => response) } } diff --git a/src/sections/collection/Collection.tsx b/src/sections/collection/Collection.tsx index 32d992766..1069b8384 100644 --- a/src/sections/collection/Collection.tsx +++ b/src/sections/collection/Collection.tsx @@ -14,12 +14,11 @@ import { PageNotFound } from '../page-not-found/PageNotFound' import { CreatedAlert } from './CreatedAlert' import { PublishCollectionButton } from './publish-collection/PublishCollectionButton' import { ShareCollectionButton } from './share-collection-button/ShareCollectionButton' -import { ContactButton } from '@/sections/contact/ContactButton' +import { ContactButton } from '@/sections/shared/contact/ContactButton' import { EditCollectionDropdown } from './edit-collection-dropdown/EditCollectionDropdown' import { FeaturedItems } from './featured-items/FeaturedItems' import styles from './Collection.module.scss' -import { useState } from 'react' -import { ContactRepositoryFactory } from '@/sections/contact/contactFactory' +import { ContactRepositoryFactory } from '@/sections/shared/contact/ContactFactory' interface CollectionProps { collectionRepository: CollectionRepository @@ -41,7 +40,6 @@ export function Collection({ }: CollectionProps) { useScrollTop() const { t } = useTranslation('collection') - const { t: tContact } = useTranslation('contact') const contactRepository = ContactRepositoryFactory.create() const { collection, isLoading: isLoadingCollection } = useCollection( collectionRepository, @@ -60,7 +58,6 @@ export function Collection({ const showAddDataActions = canUserAddCollection || canUserAddDataset const showPublishButton = !collection?.isReleased && canUserPublishCollection const showEditButton = canUserEditCollection - const [contactSuccess, setContactSuccess] = useState(false) if (isLoadingCollection) { return @@ -90,11 +87,6 @@ export function Collection({ {t('publishedAlert')} )} - {contactSuccess && ( - setContactSuccess(false)}> - {tContact('contact.contactSuccess')} - - )}
setContactSuccess(true)} toContactName={collection.name} isCollection={true} id={collection.id} diff --git a/src/sections/dataset/Dataset.tsx b/src/sections/dataset/Dataset.tsx index 5ac32992d..eee832876 100644 --- a/src/sections/dataset/Dataset.tsx +++ b/src/sections/dataset/Dataset.tsx @@ -1,5 +1,5 @@ import { useRef, useEffect, useState } from 'react' -import { Alert, Col, Row, Tabs } from '@iqss/dataverse-design-system' +import { Col, Row, Tabs } from '@iqss/dataverse-design-system' import styles from './Dataset.module.scss' import { useNavigate, useSearchParams } from 'react-router-dom' import { DatasetLabels } from './dataset-labels/DatasetLabels' @@ -54,14 +54,12 @@ export function Dataset({ const { setIsLoading } = useLoading() const { dataset, isLoading: isDatasetLoading } = useDataset() const { t } = useTranslation('dataset') - const { t: tcontact } = useTranslation('contact') const navigate = useNavigate() const [searchParams] = useSearchParams() const { hideModal, isModalOpen } = useNotImplementedModal() const publishCompleted = useCheckPublishCompleted(publishInProgress, dataset, datasetRepository) const [activeTab, setActiveTab] = useState(tab) const termsTabRef = useRef(null) - const [contactSuccess, setContactSuccess] = useState(false) useUpdateDatasetAlerts({ dataset, @@ -113,18 +111,13 @@ export function Dataset({ - {contactSuccess && ( - setContactSuccess(false)}> - {tcontact('contact.contactSuccess')} - - )}

{dataset.version.title}

- {' '} +
@@ -136,7 +129,6 @@ export function Dataset({ datasetRepository={datasetRepository} collectionRepository={collectionRepository} dataset={dataset} - onSuccess={() => setContactSuccess(true)} /> diff --git a/src/sections/dataset/dataset-action-buttons/DatasetActionButtons.tsx b/src/sections/dataset/dataset-action-buttons/DatasetActionButtons.tsx index 91074aec5..a415de81c 100644 --- a/src/sections/dataset/dataset-action-buttons/DatasetActionButtons.tsx +++ b/src/sections/dataset/dataset-action-buttons/DatasetActionButtons.tsx @@ -10,21 +10,19 @@ import { EditDatasetMenu } from './edit-dataset-menu/EditDatasetMenu' import { LinkDatasetButton } from './link-dataset-button/LinkDatasetButton' import { ShareDatasetButton } from './share-dataset-button/ShareDatasetButton' import styles from './DatasetActionButtons.module.scss' -import { ContactButton } from '@/sections/contact/ContactButton' -import { ContactRepositoryFactory } from '@/sections/contact/contactFactory' +import { ContactButton } from '@/sections/shared/contact/ContactButton' +import { ContactRepositoryFactory } from '@/sections/shared/contact/ContactFactory' interface DatasetActionButtonsProps { dataset: Dataset datasetRepository: DatasetRepository collectionRepository: CollectionRepository - onSuccess: () => void } export function DatasetActionButtons({ dataset, datasetRepository, - collectionRepository, - onSuccess + collectionRepository }: DatasetActionButtonsProps) { const { t } = useTranslation('dataset') const contactRepository = ContactRepositoryFactory.create() @@ -48,7 +46,6 @@ export function DatasetActionButtons({ void toContactName: string isCollection: boolean id: string | number @@ -14,15 +13,13 @@ interface ContactButtonProps { } export const ContactButton = ({ - onSuccess, toContactName, isCollection, id, contactRepository }: ContactButtonProps) => { - const { t } = useTranslation('contact') + const { t } = useTranslation('shared') const [showContactModal, setShowContactModal] = useState(false) - const openContactModal = () => setShowContactModal(true) const closeContactModal = () => setShowContactModal(false) @@ -37,7 +34,7 @@ export const ContactButton = ({ variant="link" onClick={openContactModal} icon={}> - {t('title.collection')} + {t('contact.title.collection')} @@ -45,7 +42,6 @@ export const ContactButton = ({ show={showContactModal} handleClose={closeContactModal} title={t('contact.contactCollection')} - onSuccess={onSuccess} toContactName={toContactName} id={id} contactRepository={contactRepository} @@ -54,14 +50,13 @@ export const ContactButton = ({ ) : ( <> void title: string - onSuccess: () => void toContactName: string id: string | number contactRepository: ContactRepository @@ -34,7 +34,6 @@ export const ContactModal = ({ show, title, handleClose, - onSuccess, toContactName, id, contactRepository @@ -42,7 +41,7 @@ export const ContactModal = ({ const { t } = useTranslation('shared') const { user } = useSession() - const { submitForm, submissionStatus, submitError } = useSubmitContact(contactRepository) + const { submitForm, submissionStatus, submitError } = useSendFeedbacktoOwners(contactRepository) const methods = useForm({ defaultValues: { @@ -57,7 +56,7 @@ export const ContactModal = ({ const { reset } = methods const onSubmit = async (data: ContactFormData) => { - const formData: ContactDTO = { + const formData: FeedbackDTO = { subject: data.subject, body: data.body, fromEmail: data.fromEmail, @@ -65,7 +64,7 @@ export const ContactModal = ({ } await submitForm(formData) - onSuccess() + toast.success(t('contact.contactSuccess')) reset() } diff --git a/src/sections/shared/form/ContactForm/ContactCaptcha.tsx b/src/sections/shared/form/ContactForm/ContactCaptcha.tsx index 3edf68083..32707540a 100644 --- a/src/sections/shared/form/ContactForm/ContactCaptcha.tsx +++ b/src/sections/shared/form/ContactForm/ContactCaptcha.tsx @@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next' import { Form, Col, Row } from '@iqss/dataverse-design-system' export function Captcha() { - const { t } = useTranslation('contact') + const { t } = useTranslation('shared') const { control } = useFormContext() const [num1, setNum1] = useState(Math.floor(Math.random() * 10)) diff --git a/src/sections/shared/form/ContactForm/ContactForm.tsx b/src/sections/shared/form/ContactForm/ContactForm.tsx index d319508c6..af7aea019 100644 --- a/src/sections/shared/form/ContactForm/ContactForm.tsx +++ b/src/sections/shared/form/ContactForm/ContactForm.tsx @@ -8,7 +8,7 @@ interface ContactFormProps { } export function ContactForm({ isLoggedIn, toContactName }: ContactFormProps) { - const { t } = useTranslation('contact') + const { t } = useTranslation('shared') const { control } = useFormContext() const emailRules: UseControllerProps['rules'] = { @@ -76,7 +76,7 @@ export function ContactForm({ isLoggedIn, toContactName }: ContactFormProps) { - {t('subject')} + {t('contact.subject')} - {t('message')} + {t('contact.message')} Promise + submitForm: (formData: FeedbackDTO) => Promise submitError: string | null } -export function useSubmitContact(contactRepository: ContactRepository): UseSubmitContactReturnType { +export function useSendFeedbacktoOwners( + contactRepository: ContactRepository +): UseSubmitContactReturnType { const [submissionStatus, setSubmissionStatus] = useState( SubmissionStatus.NotSubmitted ) const [submitError, setSubmitError] = useState(null) - const submitForm = async (formData: ContactDTO): Promise => { + const submitForm = async (formData: FeedbackDTO): Promise => { setSubmissionStatus(SubmissionStatus.IsSubmitting) setSubmitError(null) try { - const contacts: Contact[] = await contactRepository.submitContactInfo(formData) + const contacts: Contact[] = await contactRepository.sendFeedbacktoOwners(formData) setSubmissionStatus(SubmissionStatus.SubmitComplete) return contacts } catch (error) { diff --git a/src/stories/dataset/dataset-action-buttons/DatasetActionButtons.stories.tsx b/src/stories/dataset/dataset-action-buttons/DatasetActionButtons.stories.tsx index 85a7fc6a9..ab14eaf48 100644 --- a/src/stories/dataset/dataset-action-buttons/DatasetActionButtons.stories.tsx +++ b/src/stories/dataset/dataset-action-buttons/DatasetActionButtons.stories.tsx @@ -41,7 +41,6 @@ export const WithPublishPermissions: Story = { })} datasetRepository={new DatasetMockRepository()} collectionRepository={new CollectionMockRepository()} - onSuccess={() => {}} /> ) } @@ -61,7 +60,6 @@ export const WithNoDatasetPermissions: Story = { })} datasetRepository={new DatasetMockRepository()} collectionRepository={new CollectionMockRepository()} - onSuccess={() => {}} /> ) } @@ -85,7 +83,6 @@ export const WithUpdateAndNoPublishDatasetPermissions: Story = { })} datasetRepository={new DatasetMockRepository()} collectionRepository={new CollectionMockRepository()} - onSuccess={() => {}} /> ) } diff --git a/src/stories/shared/contact-modal/ContactModal.stories.tsx b/src/stories/shared/contact-modal/ContactModal.stories.tsx index 8bda7e9bf..f08e6f03d 100644 --- a/src/stories/shared/contact-modal/ContactModal.stories.tsx +++ b/src/stories/shared/contact-modal/ContactModal.stories.tsx @@ -1,6 +1,6 @@ import { Meta, StoryObj } from '@storybook/react' import { WithI18next } from '../../WithI18next' -import { ContactModal } from '@/sections/shared/contact-modal/contact-modal' +import { ContactModal } from '@/sections/shared/contact/contact-modal/contact-modal' import { ContactRepository } from '@/contact/domain/repositories/ContactRepository' const meta: Meta = { @@ -18,7 +18,6 @@ export const Default: Story = { show title="Email Collection Contact" handleClose={() => {}} - onSuccess={() => {}} toContactName="Root" id="123" contactRepository={{} as ContactRepository} @@ -32,7 +31,6 @@ export const ContactDataset: Story = { show title="Email Dataset Contact" handleClose={() => {}} - onSuccess={() => {}} toContactName="Dataset" id="123" contactRepository={{} as ContactRepository} diff --git a/tests/component/sections/collection/Collection.spec.tsx b/tests/component/sections/collection/Collection.spec.tsx index 731af0aef..156f804ca 100644 --- a/tests/component/sections/collection/Collection.spec.tsx +++ b/tests/component/sections/collection/Collection.spec.tsx @@ -291,7 +291,7 @@ describe('Collection page', () => { collectionQueryParams={{ pageQuery: 1 }} /> ) - cy.stub(ContactJSDataverseRepository.prototype, 'submitContactInfo').resolves([]) + cy.stub(ContactJSDataverseRepository.prototype, 'sendFeedbacktoOwners').resolves([]) cy.findByRole('button', { name: /Contact/i }) .should('exist') @@ -310,7 +310,7 @@ describe('Collection page', () => { collectionQueryParams={{ pageQuery: 1 }} /> ) - cy.stub(ContactJSDataverseRepository.prototype, 'submitContactInfo').resolves([]) + cy.stub(ContactJSDataverseRepository.prototype, 'sendFeedbacktoOwners').resolves([]) cy.findByRole('button', { name: /Contact/i }) .should('exist') diff --git a/tests/component/sections/contact/ContactButton.spec.tsx b/tests/component/sections/contact/ContactButton.spec.tsx index e6085201e..a1dc08863 100644 --- a/tests/component/sections/contact/ContactButton.spec.tsx +++ b/tests/component/sections/contact/ContactButton.spec.tsx @@ -1,5 +1,5 @@ import { ContactRepository } from '@/contact/domain/repositories/ContactRepository' -import { ContactButton } from '@/sections/contact/ContactButton' +import { ContactButton } from '@/sections/shared/contact/ContactButton' const mockContacts = { fromEmail: 'test@dataverse.com', @@ -10,10 +10,9 @@ const contactRepository: ContactRepository = {} as ContactRepository describe('ContactButton', () => { beforeEach(() => { - contactRepository.submitContactInfo = cy.stub().resolves([mockContacts]) + contactRepository.sendFeedbacktoOwners = cy.stub().resolves([mockContacts]) cy.customMount( {}} toContactName="Test Dataset" isCollection={true} id="root" @@ -28,7 +27,6 @@ describe('ContactButton', () => { it('shows correct contact title based on isCollection prop', () => { cy.customMount( {}} toContactName="Test Dataset" isCollection={true} id="root" @@ -41,7 +39,6 @@ describe('ContactButton', () => { cy.customMount( {}} toContactName="Test Dataset" isCollection={false} id="root" @@ -56,7 +53,6 @@ describe('ContactButton', () => { it('shows contact owner button if it is in dataset page ', () => { cy.customMount( {}} toContactName="Test Dataset" isCollection={false} id="1" @@ -88,14 +84,13 @@ describe('ContactButton', () => { describe('ContactButton Error', () => { beforeEach(() => { - contactRepository.submitContactInfo = cy + contactRepository.sendFeedbacktoOwners = cy .stub() .rejects(new Error('Failed to submit contact info')) }) it('should send alert if the submission is failed', () => { cy.customMount( {}} toContactName="Test Dataset" isCollection={true} id="root" diff --git a/tests/component/sections/contact/useSubmitContact.spec.tsx b/tests/component/sections/contact/useSubmitContact.spec.tsx index 640b6ca43..468d9d3e8 100644 --- a/tests/component/sections/contact/useSubmitContact.spec.tsx +++ b/tests/component/sections/contact/useSubmitContact.spec.tsx @@ -1,27 +1,31 @@ import { act, renderHook } from '@testing-library/react' import { - useSubmitContact, + useSendFeedbacktoOwners, SubmissionStatus -} from '@/sections/shared/form/ContactForm/useSubmitContact' +} from '@/sections/shared/form/ContactForm/useSendFeedbacktoOwners' import { ContactRepository } from '@/contact/domain/repositories/ContactRepository' -import { ContactDTO } from '@/contact/domain/useCases/ContactDTO' +import { feedbackDTO } from '@/contact/domain/useCases/feedbackDTO' const contactRepository: ContactRepository = {} as ContactRepository -const mockFormData: ContactDTO = { subject: 'Test', body: 'Hello', fromEmail: 'test@dataverse.com' } +const mockFormData: feedbackDTO = { + subject: 'Test', + body: 'Hello', + fromEmail: 'test@dataverse.com' +} const mockContacts = { fromEmail: 'test@dataverse.com', subject: 'Test', body: 'You have just been sent the following message via the Root.' } -describe('useSubmitContact', () => { +describe('useSendFeedbacktoOwners', () => { beforeEach(() => { - contactRepository.submitContactInfo = cy.stub().resolves([mockContacts]) + contactRepository.sendFeedbacktoOwners = cy.stub().resolves([mockContacts]) }) it('should handle successful form submission', async () => { - const { result } = renderHook(() => useSubmitContact(contactRepository)) + const { result } = renderHook(() => useSendFeedbacktoOwners(contactRepository)) expect(result.current.submissionStatus).to.equal(SubmissionStatus.NotSubmitted) expect(result.current.submitError).to.equal(null) @@ -37,9 +41,9 @@ describe('useSubmitContact', () => { it('should handle submission error with a proper error message', async () => { const errorMessage = 'Failed to submit contact info' - contactRepository.submitContactInfo = cy.stub().rejects(new Error(errorMessage)) + contactRepository.sendFeedbacktoOwners = cy.stub().rejects(new Error(errorMessage)) - const { result } = renderHook(() => useSubmitContact(contactRepository)) + const { result } = renderHook(() => useSendFeedbacktoOwners(contactRepository)) await act(async () => { const response = await result.current.submitForm(mockFormData) @@ -51,9 +55,9 @@ describe('useSubmitContact', () => { }) it('should handle submission error with a generic error message if not an Error instance', async () => { - contactRepository.submitContactInfo = cy.stub().rejects('Some error string') + contactRepository.sendFeedbacktoOwners = cy.stub().rejects('Some error string') - const { result } = renderHook(() => useSubmitContact(contactRepository)) + const { result } = renderHook(() => useSendFeedbacktoOwners(contactRepository)) await act(async () => { const response = await result.current.submitForm(mockFormData) @@ -65,9 +69,9 @@ describe('useSubmitContact', () => { }) it('should handle submission error with a generic error message if not an Error instance', async () => { - contactRepository.submitContactInfo = cy.stub().rejects('error') + contactRepository.sendFeedbacktoOwners = cy.stub().rejects('error') - const { result } = renderHook(() => useSubmitContact(contactRepository)) + const { result } = renderHook(() => useSendFeedbacktoOwners(contactRepository)) await act(async () => { const response = await result.current.submitForm(mockFormData) diff --git a/tests/component/sections/dataset/Dataset.spec.tsx b/tests/component/sections/dataset/Dataset.spec.tsx index df9f239cf..366641187 100644 --- a/tests/component/sections/dataset/Dataset.spec.tsx +++ b/tests/component/sections/dataset/Dataset.spec.tsx @@ -363,7 +363,7 @@ describe('Dataset', () => { />, testDataset ) - cy.stub(ContactJSDataverseRepository.prototype, 'submitContactInfo').resolves([]) + cy.stub(ContactJSDataverseRepository.prototype, 'sendFeedbacktoOwners').resolves([]) cy.findByRole('button', { name: /Contact Owner/i }) .should('exist') diff --git a/tests/component/sections/shared/pagination/contact-modal/ContactModal.spec.tsx b/tests/component/sections/shared/pagination/contact-modal/ContactModal.spec.tsx index 694423b7e..c68fabdbe 100644 --- a/tests/component/sections/shared/pagination/contact-modal/ContactModal.spec.tsx +++ b/tests/component/sections/shared/pagination/contact-modal/ContactModal.spec.tsx @@ -1,5 +1,5 @@ import { ContactRepository } from '@/contact/domain/repositories/ContactRepository' -import { ContactModal } from '@/sections/shared/contact-modal/contact-modal' +import { ContactModal } from '@/sections/shared/contact/contact-modal/contact-modal' const contactRepository: ContactRepository = {} as ContactRepository @@ -13,14 +13,13 @@ const toContactName = 'Root' describe('Contact Modal', () => { beforeEach(() => { - contactRepository.submitContactInfo = cy.stub().resolves([mockContacts]) + contactRepository.sendFeedbacktoOwners = cy.stub().resolves([mockContacts]) cy.customMount( {}} - onSuccess={() => {}} toContactName={toContactName} id="123" contactRepository={contactRepository} @@ -85,7 +84,7 @@ describe('Contact Modal', () => { }) it('should submit form and transform numeric id correctly ', () => { - contactRepository.submitContactInfo = cy.stub().resolves([mockContacts]) + contactRepository.sendFeedbacktoOwners = cy.stub().resolves([mockContacts]) const title = 'Email Collection Contact' const toContactName = 'Root' @@ -94,7 +93,6 @@ it('should submit form and transform numeric id correctly ', () => { show title={title} handleClose={() => {}} - onSuccess={() => {}} toContactName={toContactName} id={12} contactRepository={contactRepository} @@ -115,7 +113,7 @@ it('should submit form and transform numeric id correctly ', () => { cy.findByTestId('captchaInput').type(answer.toString()) cy.findByRole('button', { name: /Submit/i }).click() } - cy.wrap(contactRepository.submitContactInfo).should('have.been.calledWith', { + cy.wrap(contactRepository.sendFeedbacktoOwners).should('have.been.calledWith', { subject: 'Test Subject', body: 'This is a test message.', fromEmail: 'email@dataverse.com', diff --git a/tests/e2e-integration/integration/contact/ContactJSDataverseRepository.spec.ts b/tests/e2e-integration/integration/contact/ContactJSDataverseRepository.spec.ts index aadd43d85..c4d9f071e 100644 --- a/tests/e2e-integration/integration/contact/ContactJSDataverseRepository.spec.ts +++ b/tests/e2e-integration/integration/contact/ContactJSDataverseRepository.spec.ts @@ -1,7 +1,7 @@ import chai from 'chai' import chaiAsPromised from 'chai-as-promised' import { ContactJSDataverseRepository } from '@/contact/infrastructure/ContactJSDataverseRepository' -import { ContactDTO } from '@/contact/domain/useCases/ContactDTO' +import { FeedbackDTO } from '@/contact/domain/useCases/FeedbackDTO' import { Contact } from '@/contact/domain/models/Contact' import { TestsUtils } from '../../shared/TestsUtils' @@ -15,12 +15,12 @@ describe('Contact JSDataverse Repository', () => { beforeEach(() => TestsUtils.login()) it('send information to contacts', async () => { - const data: ContactDTO = { + const data: FeedbackDTO = { subject: 'test subject', body: 'test message body', fromEmail: 'test@dataverse.com' } - const contact: Contact[] = await repository.submitContactInfo(data) + const contact: Contact[] = await repository.sendFeedbacktoOwners(data) expect(contact).to.not.be.undefined })