Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/persistent_user_callout_spec.js')
-rw-r--r--spec/frontend/persistent_user_callout_spec.js52
1 files changed, 50 insertions, 2 deletions
diff --git a/spec/frontend/persistent_user_callout_spec.js b/spec/frontend/persistent_user_callout_spec.js
index 376575a8acb..a9bfc0003bf 100644
--- a/spec/frontend/persistent_user_callout_spec.js
+++ b/spec/frontend/persistent_user_callout_spec.js
@@ -24,6 +24,7 @@ describe('PersistentUserCallout', () => {
>
<button type="button" class="js-close js-close-primary"></button>
<button type="button" class="js-close js-close-secondary"></button>
+ <a class="js-close-and-follow-link" href="/somewhere-pleasant">A Link</a>
</div>
`;
@@ -65,6 +66,8 @@ describe('PersistentUserCallout', () => {
return fixture;
}
+ useMockLocationHelper();
+
describe('dismiss', () => {
const buttons = {};
let mockAxios;
@@ -178,8 +181,6 @@ describe('PersistentUserCallout', () => {
let mockAxios;
let persistentUserCallout;
- useMockLocationHelper();
-
beforeEach(() => {
const fixture = createFollowLinkFixture();
const container = fixture.querySelector('.container');
@@ -222,6 +223,53 @@ describe('PersistentUserCallout', () => {
});
});
+ describe('dismiss and follow links', () => {
+ let link;
+ let mockAxios;
+ let persistentUserCallout;
+
+ beforeEach(() => {
+ const fixture = createFixture();
+ const container = fixture.querySelector('.container');
+ link = fixture.querySelector('.js-close-and-follow-link');
+ mockAxios = new MockAdapter(axios);
+
+ persistentUserCallout = new PersistentUserCallout(container);
+ jest.spyOn(persistentUserCallout.container, 'remove').mockImplementation(() => {});
+ });
+
+ afterEach(() => {
+ mockAxios.restore();
+ });
+
+ it('uses a link to trigger callout and defers following until callout is finished', async () => {
+ const { href } = link;
+ mockAxios.onPost(dismissEndpoint).replyOnce(HTTP_STATUS_OK);
+
+ link.click();
+
+ await waitForPromises();
+
+ expect(window.location.assign).toHaveBeenCalledWith(href);
+ expect(persistentUserCallout.container.remove).not.toHaveBeenCalled();
+ expect(mockAxios.history.post[0].data).toBe(JSON.stringify({ feature_name: featureName }));
+ });
+
+ it('invokes Flash when the dismiss request fails', async () => {
+ mockAxios.onPost(dismissEndpoint).replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR);
+
+ link.click();
+
+ await waitForPromises();
+
+ expect(window.location.assign).not.toHaveBeenCalled();
+ expect(createAlert).toHaveBeenCalledWith({
+ message:
+ 'An error occurred while acknowledging the notification. Refresh the page and try again.',
+ });
+ });
+ });
+
describe('factory', () => {
it('returns an instance of PersistentUserCallout with the provided container property', () => {
const fixture = createFixture();