Skip to content

Commit

Permalink
Add last-modified time to Project footer (#492)
Browse files Browse the repository at this point in the history
* Add modifiedTime to project

* Add MockDate
  • Loading branch information
jeffdaley authored Dec 8, 2023
1 parent d735ef4 commit d23d51e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
19 changes: 14 additions & 5 deletions web/app/components/project/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,20 @@
</div>
{{/if}}

<div class="mt-14 -mb-6 text-body-100 text-color-foreground-disabled">
Project created
{{time-ago @project.createdTime}}
by
{{@project.creator}}
<div
class="mt-14 -mb-6 flex gap-[5px] text-body-100 text-color-foreground-disabled"
>
<span data-test-created-time>
Created
{{time-ago @project.createdTime}}
by
{{@project.creator}}
</span>
<span class="opacity-50">|</span>
<span data-test-modified-time>
Last modified
{{time-ago @project.modifiedTime}}
</span>
</div>
</div>
</div>
Expand Down
25 changes: 16 additions & 9 deletions web/tests/acceptance/authenticated/projects/project-test.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import { MirageTestContext, setupMirage } from "ember-cli-mirage/test-support";
import { authenticateSession } from "ember-simple-auth/test-support";
import { module, test, todo } from "qunit";
import {
click,
fillIn,
find,
visit,
waitFor,
waitUntil,
} from "@ember/test-helpers";
import { click, fillIn, visit, waitFor } from "@ember/test-helpers";
import { getPageTitle } from "ember-page-title/test-support";
import { setupApplicationTest } from "ember-qunit";
import { ProjectStatus } from "hermes/types/project-status";
import { TEST_USER_PHOTO } from "hermes/utils/mirage-utils";
import { TEST_USER_EMAIL, TEST_USER_PHOTO } from "hermes/utils/mirage-utils";
import MockDate from "mockdate";
import { DEFAULT_MOCK_DATE } from "hermes/utils/mockdate/dates";

const TITLE = "[data-test-project-title]";
const TITLE_BUTTON = `${TITLE} button`;
Expand All @@ -23,6 +18,9 @@ const DESCRIPTION = "[data-test-project-description]";
const DESCRIPTION_BUTTON = `${DESCRIPTION} button`;
const DESCRIPTION_INPUT = `${DESCRIPTION} textarea`;

const CREATED_TIME = "[data-test-created-time]";
const MODIFIED_TIME = "[data-test-modified-time]";

const SAVE_EDITABLE_FIELD_BUTTON = ".editable-field [data-test-save-button]";

const ADD_RESOURCE_BUTTON = "[data-test-add-project-resource-button]";
Expand Down Expand Up @@ -135,6 +133,8 @@ module("Acceptance | authenticated/projects/project", function (hooks) {
});

test("it renders the correct filled-in state", async function (this: AuthenticatedProjectsProjectRouteTestContext, assert) {
MockDate.set(DEFAULT_MOCK_DATE);

const docTitle = "Foo bar";
const docSummary = "Baz qux";
const docStatus = "Approved";
Expand Down Expand Up @@ -255,6 +255,13 @@ module("Acceptance | authenticated/projects/project", function (hooks) {
.hasAttribute("data-test-assignee", jiraAssignee);

assert.dom(JIRA_OVERFLOW_BUTTON).exists();

assert
.dom(CREATED_TIME)
.hasText(`Created 32 years ago by ${TEST_USER_EMAIL}`);
assert.dom(MODIFIED_TIME).hasText(`Last modified 32 years ago`);

MockDate.reset();
});

test("you can edit a project title", async function (this: AuthenticatedProjectsProjectRouteTestContext, assert) {
Expand Down

0 comments on commit d23d51e

Please sign in to comment.