Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [pull_request]

jobs:
pull_request:
uses: MapColonies/shared-workflows/.github/workflows/pull_request.yaml@v5
uses: MapColonies/shared-workflows/.github/workflows/pull_request.yaml@v4
secrets: inherit
with:
openApiFilePath: './bundledApi.yaml'
3 changes: 2 additions & 1 deletion src/validator/validationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ export class ValidationManager {

if (payload.productName != undefined) {
const records = await this.catalog.findRecords({ productName: payload.productName });
if (records.length > 0) {
const differentRecordsWithSameNameExists = records.some((recordWithSameName) => recordWithSameName.id !== identifier);
if (differentRecordsWithSameNameExists) {
refReason.outFailedReason = ERROR_METADATA_PRODUCT_NAME_UNIQUE!;
return false;
}
Expand Down
19 changes: 19 additions & 0 deletions tests/integration/metadata/metadataController.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,25 @@ describe('MetadataController', function () {
expect(response).toSatisfyApiSpec();
});

it(`Should return 200 status code if record product name is my name (unique)`, async function () {
const identifier = faker.string.uuid();
const payload = createUpdatePayload();
const expected = createRecord();
const record = createRecord();
record.id = identifier;
const linkUrl = extractLink(record.links);
await s3Helper.createFile(linkUrl, true);
mockAxios.get.mockResolvedValueOnce({ status: StatusCodes.OK, data: record });
mockAxios.get.mockResolvedValueOnce({ data: [{ value: payload.classification }] as ILookupOption[] });
mockAxios.post.mockResolvedValueOnce({ status: StatusCodes.OK, data: [record] });
mockAxios.patch.mockResolvedValueOnce({ status: StatusCodes.OK, data: expected });

const response = await requestSender.updateMetadata(identifier, payload);

expect(response.status).toBe(StatusCodes.OK);
expect(response).toSatisfyApiSpec();
});

it(`Should return 200 status code and metadata if payload is valid and footprint is 3D and pass footprint 2D to catalog`, async function () {
const identifier = faker.string.uuid();
const payload = createUpdatePayload('Sphere');
Expand Down