-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(procedures): rgpd add legal notice component (#13611)
ref: MANAGER-15376 Signed-off-by: Omar ALKABOUSS MOUSSANA <[email protected]>
- Loading branch information
1 parent
6916a19
commit 9d112ef
Showing
7 changed files
with
131 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
packages/manager/apps/procedures/src/components/legalInformations/LegalInformations.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { render } from '@testing-library/react'; | ||
import { describe, it, vi } from 'vitest'; | ||
import React from 'react'; | ||
import { LegalInformations } from './LegalInformations.component'; | ||
import { LegalPolicyLinkByLanguage } from '@/constants'; | ||
|
||
const faketTranslationNamespace = 'tkey'; | ||
const faketpolicyTanslationKey = 'policyKey'; | ||
const faketinformationTranslationKey = 'informationKey'; | ||
|
||
const user = { | ||
legalForm: 'other', | ||
subsidiary: 'FR', | ||
language: 'en_CA', | ||
}; | ||
|
||
vi.mock('react-i18next', () => ({ | ||
useTranslation: () => ({ | ||
t: (translationKey: string, args: any) => | ||
args ? `${translationKey} ${JSON.stringify(args)}` : translationKey, | ||
i18n: { | ||
language: user.language, | ||
}, | ||
}), | ||
})); | ||
|
||
vi.mock('@/context/User/useUser', () => ({ | ||
default: () => ({ | ||
user, | ||
}), | ||
})); | ||
|
||
describe('LegalInformations.component', () => { | ||
it('should renders the legal information', () => { | ||
const { getByText } = render( | ||
<LegalInformations | ||
translationNamespace={faketTranslationNamespace} | ||
policyTanslationKey={faketpolicyTanslationKey} | ||
informationTranslationKey={faketinformationTranslationKey} | ||
/>, | ||
); | ||
|
||
const legalInfoElement = getByText(faketinformationTranslationKey); | ||
expect(legalInfoElement).toBeInTheDocument(); | ||
}); | ||
|
||
it.each([ | ||
['FR', 'anything', LegalPolicyLinkByLanguage.FR], | ||
['CA', 'en_CA', LegalPolicyLinkByLanguage.CA.en], | ||
['CA', 'fr_CA', LegalPolicyLinkByLanguage.CA.fr], | ||
['CA', 'fr_FR', LegalPolicyLinkByLanguage.CA.fr], | ||
['CA', 'en_IN', LegalPolicyLinkByLanguage.CA.en], | ||
['unknown', 'anything', LegalPolicyLinkByLanguage.DEFAULT], | ||
])( | ||
'should have the correct link for %s user speaking %s', | ||
async (sub, locale, result) => { | ||
user.subsidiary = sub; | ||
user.language = locale; | ||
|
||
const { getByTestId } = render( | ||
<LegalInformations | ||
translationNamespace={faketTranslationNamespace} | ||
policyTanslationKey={faketpolicyTanslationKey} | ||
informationTranslationKey={faketinformationTranslationKey} | ||
/>, | ||
); | ||
|
||
const legalInformationPolicyContent = getByTestId( | ||
'legal_information_policy_content', | ||
); | ||
expect(legalInformationPolicyContent.innerHTML.includes(result)).toBe( | ||
true, | ||
); | ||
}, | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters