Skip to content

Commit

Permalink
RelatedResources: Fix documentType bug (#370)
Browse files Browse the repository at this point in the history
* Fix and expand RelatedHermesDocument type

* Update list-item-test.ts

* Revert out-of-scope changes
  • Loading branch information
jeffdaley authored Oct 18, 2023
1 parent 2376bca commit 391476d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class DocumentSidebarRelatedResourcesListItemResourceComponent ex
*/
protected get docType() {
this.assertResourceIsDocument(this.args.resource);
return this.args.resource.type;
return this.args.resource.documentType;
}

/**
Expand Down Expand Up @@ -73,7 +73,7 @@ export default class DocumentSidebarRelatedResourcesListItemResourceComponent ex
* with the correct data model.
*/
private assertResourceIsDocument(
document: RelatedResource
document: RelatedResource,
): asserts document is RelatedHermesDocument {
if (!("googleFileID" in document)) {
throw new Error("resource must be a document");
Expand Down
2 changes: 1 addition & 1 deletion web/app/components/related-resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface RelatedHermesDocument {
id: number;
googleFileID: string;
title: string;
type: string;
documentType: string;
documentNumber: string;
sortOrder: number;
}
Expand Down
10 changes: 5 additions & 5 deletions web/app/components/related-resources/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface RelatedResourcesAddComponentSignature {
dd: XDropdownListAnchorAPI | null,
query: string,
shouldIgnoreDelay?: boolean,
options?: SearchOptions
options?: SearchOptions,
) => Promise<void>;
getObject: (dd: XDropdownListAnchorAPI | null, id: string) => Promise<void>;
headerTitle: string;
Expand Down Expand Up @@ -329,7 +329,7 @@ export default class RelatedResourcesAddComponent extends Component<RelatedResou
const relatedHermesDocument = {
googleFileID: attrs.objectID,
title: attrs.title,
type: attrs.docType,
documentType: attrs.docType,
documentNumber: attrs.docNumber,
sortOrder: 1,
} as RelatedHermesDocument;
Expand All @@ -352,7 +352,7 @@ export default class RelatedResourcesAddComponent extends Component<RelatedResou
*/
@action private checkForDuplicate(
urlOrID: string,
resourceIsHermesDocument = false
resourceIsHermesDocument = false,
) {
let isDuplicate = false;
if (resourceIsHermesDocument) {
Expand Down Expand Up @@ -400,7 +400,7 @@ export default class RelatedResourcesAddComponent extends Component<RelatedResou
*/
@action protected didInsertInput(
dd: XDropdownListAnchorAPI,
e: HTMLInputElement
e: HTMLInputElement,
) {
this.searchInput = e;
this._dd = dd;
Expand Down Expand Up @@ -626,7 +626,7 @@ export default class RelatedResourcesAddComponent extends Component<RelatedResou
private getAlgoliaObject = restartableTask(async (id: string) => {
assert(
"full url format expected",
this.firstPartyURLFormat === FirstPartyURLFormat.FullURL
this.firstPartyURLFormat === FirstPartyURLFormat.FullURL,
);

this.checkForDuplicate(id, true);
Expand Down
2 changes: 1 addition & 1 deletion web/mirage/factories/related-hermes-document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default Factory.extend({
title() {
return `Related Document ${this.id}`;
},
type: "RFC",
documentType: "RFC",
documentNumber() {
return `LAB-00${this.id}`;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ module(
setupMirage(hooks);

hooks.beforeEach(async function (
this: DocumentSidebarRelatedResourcesListItemTestContext
this: DocumentSidebarRelatedResourcesListItemTestContext,
) {
this.server.create("document");

const documentAttrs = this.server.schema.document.first().attrs;
this.set("document", {
googleFileID: documentAttrs.objectID,
title: documentAttrs.title,
type: documentAttrs.docType,
documentType: documentAttrs.docType,
documentNumber: documentAttrs.docNumber,
sortOrder: 1,
});
Expand Down Expand Up @@ -166,7 +166,7 @@ module(
.exists({ count: 2 }, "two buttons are present for external resources");

const editButton = htmlElement(
`${DROPDOWN_LIST_ITEM_SELECTOR}:nth-child(1) button`
`${DROPDOWN_LIST_ITEM_SELECTOR}:nth-child(1) button`,
);

assert.dom(editButton).hasText("Edit", "edit button is present");
Expand All @@ -187,13 +187,13 @@ module(
await click(OVERFLOW_BUTTON_SELECTOR);

const removeButton = htmlElement(
`${DROPDOWN_LIST_ITEM_SELECTOR}:nth-child(2) button`
`${DROPDOWN_LIST_ITEM_SELECTOR}:nth-child(2) button`,
);
assert.dom(removeButton).hasText("Remove", "remove button is present");

await click(removeButton);

assert.equal(count, 2, "remove button was clicked");
});
}
},
);

0 comments on commit 391476d

Please sign in to comment.