From d23d51e867f4c93874b4941acc9bd245a56e4115 Mon Sep 17 00:00:00 2001 From: Jeff Daley Date: Thu, 7 Dec 2023 20:32:23 -0500 Subject: [PATCH] Add last-modified time to Project footer (#492) * Add modifiedTime to project * Add MockDate --- web/app/components/project/index.hbs | 19 ++++++++++---- .../authenticated/projects/project-test.ts | 25 ++++++++++++------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/web/app/components/project/index.hbs b/web/app/components/project/index.hbs index 424fd29a9..9ddcc2bb0 100644 --- a/web/app/components/project/index.hbs +++ b/web/app/components/project/index.hbs @@ -321,11 +321,20 @@ {{/if}} -
- Project created - {{time-ago @project.createdTime}} - by - {{@project.creator}} +
+ + Created + {{time-ago @project.createdTime}} + by + {{@project.creator}} + + | + + Last modified + {{time-ago @project.modifiedTime}} +
diff --git a/web/tests/acceptance/authenticated/projects/project-test.ts b/web/tests/acceptance/authenticated/projects/project-test.ts index a7aa09f20..43231476b 100644 --- a/web/tests/acceptance/authenticated/projects/project-test.ts +++ b/web/tests/acceptance/authenticated/projects/project-test.ts @@ -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`; @@ -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]"; @@ -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"; @@ -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) {