Skip to content

Commit

Permalink
Merge pull request #2520 from fgchaio/doi-1552-avoid-form-rendering-w…
Browse files Browse the repository at this point in the history
…hen-invite-already-accepted

[DOI-1552] Avoid form rendering when user already accepted collaborator invite
  • Loading branch information
fgchaio authored Aug 14, 2024
2 parents 060b403 + 50b19bc commit b6a152b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/components/CollaborationInvite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ export const CollaboratorsInvite = InjectAppServices(
setEmail(jwtDecode(token).email);
} catch {}

sendInvitationData(null);

await sendInvitationData(null);
setLoading(false);
};

fetchData();

// eslint-disable-next-line
}, []);

Expand Down Expand Up @@ -156,7 +156,7 @@ export const CollaboratorsInvite = InjectAppServices(
validate={validate}
>
<ScrollToFieldError fieldsOrder={Object.values(fieldNames)} />
<fieldset>
<fieldset data-testid="collaboration-invite-form">
<FieldGroup>
<InputFieldItemAccessible
fieldName={fieldNames.email}
Expand Down
14 changes: 8 additions & 6 deletions src/components/CollaborationInvite/index.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import '@testing-library/jest-dom/extend-expect';
import { cleanup, render, screen, act } from '@testing-library/react';
import { cleanup, render, screen, act, waitForElementToBeRemoved } from '@testing-library/react';
import { AppServicesProvider } from '../../services/pure-di';
import DopplerIntlProvider from '../../i18n/DopplerIntlProvider';
import { MemoryRouter as Router } from 'react-router-dom';
Expand Down Expand Up @@ -34,6 +34,9 @@ describe('CollaborationInvite', () => {
);

// Assert
const loader = screen.getByTestId('wrapper-loading');
await waitForElementToBeRemoved(loader);

act(() => expect(screen.getByTestId('unexpected-error')).toBeInTheDocument());
act(() =>
expect(
Expand Down Expand Up @@ -68,10 +71,9 @@ describe('CollaborationInvite', () => {
);

// Assert
act(() =>
expect(screen.getByTestId('unexpected-error')).not.toContainHTML(
'<p>validation_messages.error_expired_invitation_link</p>',
),
);
const loader = screen.getByTestId('wrapper-loading');
await waitForElementToBeRemoved(loader);

act(() => expect(screen.getByTestId('collaboration-invite-form')).toBeInTheDocument());
});
});

0 comments on commit b6a152b

Please sign in to comment.