-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
98 additions
and
23 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { render } from "@ember/test-helpers"; | ||
import { hbs } from "ember-cli-htmlbars"; | ||
import { setupMirage } from "ember-cli-mirage/test-support"; | ||
import { setupRenderingTest } from "ember-qunit"; | ||
import { module, test } from "qunit"; | ||
import MockDate from "mockdate"; | ||
import { HERMES_GITHUB_REPO_URL } from "hermes/utils/hermes-urls"; | ||
import ConfigService from "hermes/services/config"; | ||
import RouterService from "@ember/routing/router-service"; | ||
|
||
const SUPPORT_URL = "https://example.com/support"; | ||
|
||
module("Integration | Component | footer", function (hooks) { | ||
setupRenderingTest(hooks); | ||
setupMirage(hooks); | ||
|
||
test("it renders as expected (default setup)", async function (assert) { | ||
MockDate.set("2000-01-01T06:00:00.000-07:00"); | ||
|
||
await render(hbs`<Footer />`); | ||
|
||
assert | ||
.dom("[data-test-footer-copyright]") | ||
.containsText("2000", "The current year is shown"); | ||
|
||
assert | ||
.dom("[data-test-footer-github-link]") | ||
.hasAttribute("href", HERMES_GITHUB_REPO_URL); | ||
|
||
MockDate.reset(); | ||
}); | ||
|
||
test("it renders as expected (with optional links)", async function (assert) { | ||
let mockConfigSvc = this.owner.lookup("service:config") as ConfigService; | ||
mockConfigSvc.config.support_link_url = SUPPORT_URL; | ||
|
||
await render(hbs`<Footer />`); | ||
|
||
assert | ||
.dom("[data-test-footer-support-link]") | ||
.hasAttribute("href", SUPPORT_URL); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -6,6 +6,11 @@ import { setupWindowMock } from "ember-window-mock/test-support"; | |
import AuthenticatedUserService from "hermes/services/authenticated-user"; | ||
import { setupMirage } from "ember-cli-mirage/test-support"; | ||
import window from "ember-window-mock"; | ||
import { HERMES_GITHUB_REPO_URL } from "hermes/utils/hermes-urls"; | ||
import ConfigService from "hermes/services/config"; | ||
|
||
const SUPPORT_URL = "https://example.com/support"; | ||
const USER_MENU_TOGGLE_SELECTOR = "[data-test-user-menu-toggle]"; | ||
|
||
module("Integration | Component | header/nav", function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
@@ -28,7 +33,6 @@ module("Integration | Component | header/nav", function (hooks) { | |
|
||
test("it renders correctly", async function (assert) { | ||
await render(hbs` | ||
{{! @glint-nocheck: not typesafe yet }} | ||
<Header::Nav /> | ||
`); | ||
|
||
|
@@ -39,10 +43,14 @@ module("Integration | Component | header/nav", function (hooks) { | |
|
||
assert.dom(".global-search").exists(); | ||
|
||
await click("[data-test-user-menu-toggle]"); | ||
await click(USER_MENU_TOGGLE_SELECTOR); | ||
|
||
assert.dom("[data-test-user-menu-title]").hasText("Foo Bar"); | ||
assert.dom("[data-test-user-menu-email]").hasText("[email protected]"); | ||
assert | ||
.dom("[data-test-user-menu-github]") | ||
.hasText("GitHub") | ||
.hasAttribute("href", HERMES_GITHUB_REPO_URL); | ||
|
||
assert | ||
.dom('[data-test-user-menu-item="email-notifications"]') | ||
|
@@ -53,7 +61,6 @@ module("Integration | Component | header/nav", function (hooks) { | |
|
||
test("it shows an icon when the user menu has something to highlight", async function (assert) { | ||
await render(hbs` | ||
{{! @glint-nocheck: not typesafe yet }} | ||
<Header::Nav /> | ||
`); | ||
|
||
|
@@ -64,7 +71,7 @@ module("Integration | Component | header/nav", function (hooks) { | |
|
||
assert.dom("[data-test-user-menu-highlight]").exists("highlight is shown"); | ||
|
||
await click("[data-test-user-menu-toggle]"); | ||
await click(USER_MENU_TOGGLE_SELECTOR); | ||
|
||
assert | ||
.dom("[data-test-user-menu-highlight]") | ||
|
@@ -79,11 +86,27 @@ module("Integration | Component | header/nav", function (hooks) { | |
); | ||
|
||
// close and reopen the menu | ||
await click("[data-test-user-menu-toggle]"); | ||
await click("[data-test-user-menu-toggle]"); | ||
await click(USER_MENU_TOGGLE_SELECTOR); | ||
await click(USER_MENU_TOGGLE_SELECTOR); | ||
|
||
assert | ||
.dom(".highlighted-new") | ||
.doesNotExist("highlight is hidden after the menu is closed"); | ||
}); | ||
|
||
test("it renders a support link if it is configured", async function (assert) { | ||
let mockConfigSvc = this.owner.lookup("service:config") as ConfigService; | ||
mockConfigSvc.config.support_link_url = SUPPORT_URL; | ||
|
||
await render(hbs` | ||
<Header::Nav /> | ||
`); | ||
|
||
await click(USER_MENU_TOGGLE_SELECTOR); | ||
|
||
assert | ||
.dom("[data-test-user-menu-support]") | ||
.hasText("Support") | ||
.hasAttribute("href", SUPPORT_URL); | ||
}); | ||
}); |