Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
show welcome banner after dinopark sign up
- Loading branch information
Showing
7 changed files
with
139 additions
and
1 deletion.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
assets/javascripts/discourse/connectors/above-main-container/mozilla-iam.js.es6
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,29 @@ | ||
export default { | ||
setupComponent(args, component) { | ||
if ($.cookie("show_dinopark_banner")) { | ||
component.set("visible", true) | ||
} | ||
}, | ||
|
||
actions: { | ||
dismiss() { | ||
this.set("visible", false) | ||
$.removeCookie("show_dinopark_banner") | ||
}, | ||
|
||
click(e) { | ||
if ($(e.target).is('a')) { | ||
$.removeCookie("show_dinopark_banner") | ||
} | ||
} | ||
}, | ||
|
||
shouldRender(args, component) { | ||
if (component.currentUser) { | ||
return $.cookie("show_dinopark_banner") | ||
} else { | ||
$.removeCookie("show_dinopark_banner") | ||
return false | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
assets/javascripts/discourse/templates/connectors/above-main-container/mozilla-iam.hbs
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,8 @@ | ||
{{#if visible}} | ||
<div class="row"> | ||
<div class="alert alert-info dinopark-welcome-banner" role="alert"> | ||
<button type="button" class="close" aria-label="Close" {{action "dismiss"}}><span aria-hidden="true">×</span></button> | ||
<span onclick={{action "click"}}>{{{i18n 'dinopark.welcome_banner' a_tag='<a href="/my/preferences/account">'}}}</span> | ||
</div> | ||
</div> | ||
{{/if}} |
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
83 changes: 83 additions & 0 deletions
83
test/javascripts/acceptance/dinopark-welcome-banner-test.js.es6
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,83 @@ | ||
import { acceptance } from "helpers/qunit-helpers" | ||
|
||
acceptance("Mozilla IAM - Dinopark Welcome Banner", { | ||
loggedIn: true | ||
}) | ||
|
||
QUnit.test("loading page without show_dinopark_banner cookie set", async assert => { | ||
$.removeCookie("show_dinopark_banner") | ||
await visit("/") | ||
|
||
assert.notOk( | ||
exists(".dinopark-welcome-banner"), | ||
"dinopark welcome banner is not shown" | ||
) | ||
}) | ||
|
||
QUnit.test("loading page with show_dinopark_banner cookie set and clicking close", async assert => { | ||
$.cookie("show_dinopark_banner", 1) | ||
await visit("/") | ||
|
||
assert.ok( | ||
exists(".dinopark-welcome-banner"), | ||
"dinopark welcome banner is shown" | ||
) | ||
|
||
await click(".dinopark-welcome-banner .close") | ||
|
||
assert.notOk( | ||
exists(".dinopark-welcome-banner"), | ||
"clicking close buttons closes banner" | ||
) | ||
assert.equal( | ||
$.cookie("show_dinopark_banner"), | ||
null, | ||
"clicking close buttons removes cookie" | ||
) | ||
|
||
$.removeCookie("show_dinopark_banner") | ||
}) | ||
|
||
QUnit.skip("loading page with show_dinopark_banner cookie set and clicking link", async assert => { | ||
$.cookie("show_dinopark_banner", 1) | ||
await visit("/") | ||
|
||
assert.ok( | ||
exists(".dinopark-welcome-banner"), | ||
"dinopark welcome banner is shown" | ||
) | ||
|
||
await click(".dinopark-welcome-banner a") // navigates qunit away | ||
|
||
assert.equal( | ||
$.cookie("show_dinopark_banner"), | ||
null, | ||
"clicking link removes cookie" | ||
) | ||
assert.equal( | ||
currentRouteName(), | ||
"preferences.account", | ||
"clicking link navigates to user preferences" | ||
) | ||
|
||
$.removeCookie("show_dinopark_banner") | ||
}) | ||
|
||
acceptance("Mozilla IAM - Dinopark Welcome Banner - Logged Out") | ||
|
||
QUnit.test("logged out user with cookie", async assert => { | ||
$.cookie("show_dinopark_banner", 1) | ||
await visit("/") | ||
|
||
assert.notOk( | ||
exists(".dinopark-welcome-banner"), | ||
"dinopark welcome banner isn't shown" | ||
) | ||
assert.equal( | ||
$.cookie("show_dinopark_banner"), | ||
null, | ||
"cookie is removed" | ||
) | ||
|
||
$.removeCookie("show_dinopark_banner") | ||
}) |