Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/2181 download attachments #2206

Merged
merged 11 commits into from
May 1, 2023
Merged

Conversation

tmastrom
Copy link
Contributor

Card: #2181

@tmastrom tmastrom force-pushed the feat/2181-download-attachments branch from 0200c81 to 2623114 Compare April 27, 2023 23:57
@tmastrom tmastrom marked this pull request as ready for review April 27, 2023 23:59
Copy link
Contributor

@BCerki BCerki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, review comments are all nits. I think we could additionally use a test for VerificationStatement to check that clicking the filename calls the router or has the right href, whatever makes more sense. There's the beginnings of an example of simulating a click in old jest here: https://github.com/bcgov/cas-ciip-portal/pull/2205/files#diff-bbd02c55400eb98b04e21e90329fba88eb8c6c035b0753fcb48e0dc503534c6cR107-R124

Comment on lines 51 to 53
const attachments = applicationRevision.attachmentsByApplicationIdAndVersionNumber
? applicationRevision.attachmentsByApplicationIdAndVersionNumber.edges
: undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use optional chaining to shorten this, something like const attachments = applicationRevision?.attachmentsByApplicationIdAndVersionNumber?.edges

And then instead of checking if attachments is false for conditional rendering, check if its length is 0

<Collapse in={!isOpen}>
<Card.Body className="card-body">
{attachments ? (
attachments.map((opt) => (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could use {node} as the map argument and then you don't have to repeat opt. everywhere

handleDownload,
} from "server/middleware/attachmentDownloadRouter";

const performQuery = require("../../../../server/postgraphile/graphql");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ~* think you might be able to shorten the require path to just server/postgraphile/graphql?

const performQuery = require("../../../../server/postgraphile/graphql");
const Storage = require("@google-cloud/storage");

jest.mock("../../../../server/postgraphile/graphql");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here if it works

);
});

it("pipes the storage client's file", async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! Thanks so much for figuring out the old jest test setup

@@ -156,7 +170,72 @@ export const ApplicationDetailsComponent: React.FunctionComponent<Props> = ({
/>
))}
</div>
<Card
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks super nice in the app

@@ -21,32 +25,53 @@ describe("The Attachment Upload Component", () => {
createdAt: "date",
},
},
{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should only be 1 attachment

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense for this PR, but FYI ultimately people do need to be able to upload more than one attachment. I'm fixing and testing that part in my PR, so this is good to go

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for letting me know, I've updated the testing to reflect this

BCerki
BCerki previously approved these changes Apr 28, 2023
@@ -21,32 +25,53 @@ describe("The Attachment Upload Component", () => {
createdAt: "date",
},
},
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense for this PR, but FYI ultimately people do need to be able to upload more than one attachment. I'm fixing and testing that part in my PR, so this is good to go

@BCerki BCerki merged commit d2f7cbb into develop May 1, 2023
@bc-cas-shipit bc-cas-shipit bot temporarily deployed to dev May 5, 2023 20:25 Inactive
@bc-cas-shipit bc-cas-shipit bot temporarily deployed to test May 11, 2023 23:18 Inactive
@bc-cas-shipit bc-cas-shipit bot temporarily deployed to prod May 16, 2023 23:11 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants