-
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.
Merge branch 'jeffdaley/read-only-editable-fields' into jeffdaley/exp…
…lore-projects
- Loading branch information
Showing
9 changed files
with
671 additions
and
21 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
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,75 @@ | ||
import { module, test } from "qunit"; | ||
import { setupRenderingTest } from "ember-qunit"; | ||
import { render } from "@ember/test-helpers"; | ||
import { hbs } from "ember-cli-htmlbars"; | ||
import { MirageTestContext, setupMirage } from "ember-cli-mirage/test-support"; | ||
import { authenticateSession } from "ember-simple-auth/test-support"; | ||
import AuthenticatedUserService, { | ||
AuthenticatedUser, | ||
} from "hermes/services/authenticated-user"; | ||
import { HermesDocument } from "hermes/types/document"; | ||
import { HermesDocumentType } from "hermes/types/document-type"; | ||
|
||
const SUMMARY_CONTAINER = "[data-test-document-summary]"; | ||
const SUMMARY_EMPTY_STATE = `${SUMMARY_CONTAINER} .empty-state-text`; | ||
|
||
interface DocumentSidebarComponentTestContext extends MirageTestContext { | ||
profile: AuthenticatedUser; | ||
document: HermesDocument; | ||
docType: Promise<HermesDocumentType>; | ||
deleteDraft: (docID: string) => void; | ||
isCollapsed: boolean; | ||
toggleCollapsed: () => void; | ||
} | ||
|
||
module("Integration | Component | document/sidebar", function (hooks) { | ||
setupRenderingTest(hooks); | ||
setupMirage(hooks); | ||
|
||
hooks.beforeEach(async function (this: DocumentSidebarComponentTestContext) { | ||
await authenticateSession({}); | ||
|
||
const authenticatedUser = this.owner.lookup( | ||
"service:authenticated-user", | ||
) as AuthenticatedUserService; | ||
|
||
await authenticatedUser.loadInfo.perform(); | ||
|
||
this.set("profile", authenticatedUser.info); | ||
this.server.create("document", { | ||
owners: ["[email protected]"], | ||
isDraft: false, | ||
}); | ||
|
||
this.set("document", this.server.schema.document.first().attrs); | ||
this.set("docType", new Promise(() => {})); | ||
this.set("toggleCollapsed", () => {}); | ||
this.set("deleteDraft", (docID: string) => {}); | ||
}); | ||
|
||
test("it shows the correct summary empty state based on if the viewer is the doc owner", async function (this: DocumentSidebarComponentTestContext, assert) { | ||
await render<DocumentSidebarComponentTestContext>(hbs` | ||
<Document::Sidebar | ||
@profile={{this.profile}} | ||
@document={{this.document}} | ||
@docType={{this.docType}} | ||
@isCollapsed={{false}} | ||
@toggleCollapsed={{this.toggleCollapsed}} | ||
@deleteDraft={{this.deleteDraft}} | ||
/> | ||
`); | ||
|
||
// By default the viewer is the doc owner | ||
assert.dom(SUMMARY_EMPTY_STATE).containsText("Enter a summary"); | ||
|
||
// Set the doc owner to someone else | ||
this.set( | ||
"document", | ||
this.server.schema.document.first().update({ | ||
owners: ["[email protected]"], | ||
}), | ||
); | ||
|
||
assert.dom(SUMMARY_EMPTY_STATE).containsText("None"); | ||
}); | ||
}); |
Oops, something went wrong.