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

[#IOCOM-704] Add has_remote_content flag #347

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 48 additions & 3 deletions openapi/__tests__/definitions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ import { Change_typeEnum as ReadingChangeType } from "../../generated/definition
import { Change_typeEnum as ArchinvingChangeType } from "../../generated/definitions/MessageStatusArchivingChange";
import { FeatureLevelTypeEnum } from "../../generated/definitions/FeatureLevelType";
import { ThirdPartyMessage } from "../../generated/definitions/ThirdPartyMessage";
import { Semver } from "@pagopa/ts-commons/lib/strings";
import { NonEmptyString, Semver } from "@pagopa/ts-commons/lib/strings";

import { AppVersion } from "../../generated/definitions/AppVersion";
import { ThirdPartyData } from "../../generated/definitions/ThirdPartyData";

describe("ServicePayload definition", () => {
const commonServicePayload = {
Expand Down Expand Up @@ -229,6 +230,8 @@ const aContentWithThirdPartyData = {

const aPayee: Payee = { fiscal_code: anOrganizationFiscalCode };

const aThirdPartyId = "aThirdPartyId" as NonEmptyString;

describe("NewMessage definition", () => {
it("should decode STANDARD NewMessage with content but without payment data", () => {
const aMessageWithContentWithoutPaymentData = {
Expand Down Expand Up @@ -573,7 +576,8 @@ describe("Type definition", () => {
...aContentWithThirdPartyData,
third_party_data: {
...aContentWithThirdPartyData.third_party_data,
has_attachments: false
has_attachments: false,
has_remote_content: false
}
})
)
Expand Down Expand Up @@ -949,7 +953,12 @@ describe("ThirdPartyMessage", () => {
const aThirdPartyMessage = {
attachments: [
{ id: "anId", url: "an/Url", category: "DOCUMENT" },
{ id: "anotherId", url: "another/Url", name: "anotherName", category: "DOCUMENT" }
{
id: "anotherId",
url: "another/Url",
name: "anotherName",
category: "DOCUMENT"
}
]
};

Expand All @@ -963,6 +972,42 @@ describe("ThirdPartyMessage", () => {
});
});

describe("ThirdPartyData", () => {
it("should decode a ThirdPartyData adding has_attachments and has_remote_content to false if not provided", () => {
const aThirdPartyData = { id: aThirdPartyId };

const decoded = ThirdPartyData.decode(aThirdPartyData);

expect(decoded).toMatchObject(
expect.objectContaining({
_tag: "Right",
right: {
id: aThirdPartyId,
has_attachments: false,
has_remote_content: false
}
})
);
});

it("should decode a ThirdPartyData with has_remote_content true if provided with true", () => {
const aThirdPartyData = { id: aThirdPartyId, has_remote_content: true };

const decoded = ThirdPartyData.decode(aThirdPartyData);

expect(decoded).toMatchObject(
expect.objectContaining({
_tag: "Right",
right: {
id: aThirdPartyId,
has_attachments: false,
has_remote_content: true
}
})
);
});
});

/**
* Semver type and AppVersion definition compatibility tests
*/
Expand Down
3 changes: 3 additions & 0 deletions openapi/definitions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ ThirdPartyData:
has_attachments:
type: boolean
default: false
has_remote_content:
type: boolean
default: false
has_precondition:
type: string
x-extensible-enum:
Expand Down