Skip to content

Commit d928843

Browse files
committed
refactor: implement the change requests
1 parent 8e63b56 commit d928843

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

frontend/app/components/topnav.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
<Topnav::LinkTo
9393
@onClick={{fn (mut this.expand) false}}
9494
title="Open Timed documentation for current page"
95-
href={{this.docs.docsEndpoint}}
95+
href={{this.docs.endpoint}}
9696
target="_blank"
9797
data-test-docs-link
9898
>

frontend/app/services/docs.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Service, { service } from "@ember/service";
22

33
import config from "timed/config/environment";
44

5-
const ROUTE_DOCS_MAPPING = {
5+
export const ROUTE_DOCS_MAPPING = {
66
"index.attendances": "/tracking/attendances",
77
"index.reports": "/tracking/timesheet",
88
"analysis.index": "/analysis",
@@ -16,11 +16,11 @@ const ROUTE_DOCS_MAPPING = {
1616
export default class DocsService extends Service {
1717
@service router;
1818

19-
get docsEndpoint() {
19+
get endpoint() {
2020
return config.docsBaseUrl + this.docsURL;
2121
}
2222

2323
get docsURL() {
24-
return ROUTE_DOCS_MAPPING[this.router.currentRouteName] || "";
24+
return ROUTE_DOCS_MAPPING[this.router.currentRouteName] ?? "";
2525
}
2626
}

frontend/tests/acceptance/docs-test.js

+6-12
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { authenticateSession } from "ember-simple-auth/test-support";
55
import { module, test } from "qunit";
66

77
import config from "timed/config/environment";
8+
import { ROUTE_DOCS_MAPPING } from "timed/services/docs";
89

910
module("Acceptance | docs", function (hooks) {
1011
setupApplicationTest(hooks);
@@ -17,25 +18,18 @@ module("Acceptance | docs", function (hooks) {
1718
});
1819

1920
test("Each route renders a link to the corresponding documentation page", async function (assert) {
20-
const routes = {
21-
"/attendances": "tracking/attendances",
22-
"/reports": "tracking/timesheet",
23-
"/analysis": "analysis",
24-
"/statistics": "statistics",
25-
"/projects": "projects",
26-
"/users": "users",
27-
"/": "tracking/activities",
28-
};
29-
const routesKey = Object.keys(routes);
21+
const routesKey = Object.keys(ROUTE_DOCS_MAPPING);
22+
const router = this.owner.lookup("service:router");
3023

3124
for (const routeKey of routesKey) {
25+
if (routeKey === "users.edit.index") continue;
3226
// eslint-disable-next-line no-await-in-loop
33-
await visit(routeKey);
27+
await visit(router.urlFor(routeKey));
3428
assert.dom("[data-test-docs-link]").exists();
3529

3630
assert.strictEqual(
3731
document.querySelector("[data-test-docs-link]").href,
38-
`${config.docsBaseUrl}/${routes[routeKey]}`,
32+
`${config.docsBaseUrl}${ROUTE_DOCS_MAPPING[routeKey]}`,
3933
);
4034
}
4135
});

0 commit comments

Comments
 (0)