Skip to content

Commit

Permalink
LPD-38287 Applying to object-admin tests
Browse files Browse the repository at this point in the history
Co-authored-by: Carlos Correa <[email protected]>
Co-authored-by: Jaime Leon <[email protected]>
  • Loading branch information
3 people authored and brianchandotcom committed Oct 8, 2024
1 parent 48c83e2 commit 9ff1f1d
Show file tree
Hide file tree
Showing 32 changed files with 1,963 additions and 1,327 deletions.
14 changes: 12 additions & 2 deletions modules/test/playwright/helpers/ApiHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import {Page} from '@playwright/test';

import {ObjectAdminRestClient} from '../../../apps/object/object-admin-rest-client-js/src/main/resources/META-INF/resources/node';
import {liferayConfig} from '../liferay.config';
import {ApiBuilderHelper} from './ApiBuilderHelper';
import {DataEngineApiHelper} from './DataEngineApiHelper';
Expand Down Expand Up @@ -383,10 +384,19 @@ export class DataApiHelpers extends ApiHelpers {
);

break;
case 'objectDefinition':
await this.objectAdmin.deleteObjectDefinition(item.id);
case 'objectDefinition': {
const objectAdminRESTClient = await this.buildRestClient(
ObjectAdminRestClient
);

await objectAdminRESTClient.objectDefinition.deleteObjectDefinition(
{
objectDefinitionId: item.id,
}
);

break;
}
case 'option':
await this.headlessCommerceAdminCatalog.deleteOption(
item.id
Expand Down
132 changes: 23 additions & 109 deletions modules/test/playwright/helpers/ObjectAdminApiHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/

import {
ObjectAdminRestClient,
ObjectField,
ObjectFolder,
} from '../../../apps/object/object-admin-rest-client-js/src/main/resources/META-INF/resources/node';
import {getRandomInt} from '../utils/getRandomInt';
import {ApiHelpers} from './ApiHelpers';

Expand All @@ -15,38 +20,6 @@ export class ObjectAdminApiHelper {
this.basePath = 'object-admin/v1.0';
}

async deleteObjectAction(objectActionId: number) {
return this.apiHelpers.delete(
`${this.apiHelpers.baseUrl}${this.basePath}/object-actions/${objectActionId}`
);
}

async deleteObjectDefinition(objectDefinitionId: number) {
return this.apiHelpers.delete(
`${this.apiHelpers.baseUrl}${this.basePath}/object-definitions/${objectDefinitionId}`
);
}

async deleteObjectFolder(objectFolderId: number) {
return this.apiHelpers.delete(
`${this.apiHelpers.baseUrl}${this.basePath}/object-folders/${objectFolderId}`
);
}

async deleteObjectRelationship(objectRelationshipId: number) {
return this.apiHelpers.delete(
`${this.apiHelpers.baseUrl}${this.basePath}/object-relationships/${objectRelationshipId}`
);
}

async getObjectActionsByExternalReferenceCode(
objectDefinitionExternalReferenceCode: string
) {
return this.apiHelpers.get(
`${this.apiHelpers.baseUrl}${this.basePath}/object-definitions/by-external-reference-code/${objectDefinitionExternalReferenceCode}/object-actions`
);
}

async getObjectDefinitionByExternalReferenceCode(
externalReferenceCode: string
): Promise<ObjectDefinition> {
Expand All @@ -55,30 +28,6 @@ export class ObjectAdminApiHelper {
);
}

async postObjectActionByExternalReferenceCode(
externalReferenceCode: string,
objectAction?: Partial<ObjectAction>
): Promise<ObjectAction> {
return this.apiHelpers.post<Partial<ObjectAction>>(
`${this.apiHelpers.baseUrl}${this.basePath}/object-definitions/by-external-reference-code/${externalReferenceCode}/object-actions`,
{data: objectAction}
);
}

async postObjectDefinition(data: DataObject): Promise<ObjectDefinition> {
return this.apiHelpers.post(
`${this.apiHelpers.baseUrl}${this.basePath}/object-definitions`,
{data}
);
}

async postObjectDefinitionPublish(objectDefinitionId: number) {
return this.apiHelpers.post(
`${this.apiHelpers.baseUrl}${this.basePath}/object-definitions/${objectDefinitionId}/publish`,
{}
);
}

async postObjectDefinitionObjectFieldBatch(
objectDefinitionId: number,
objectFields: Partial<ObjectField>[]
Expand All @@ -89,35 +38,6 @@ export class ObjectAdminApiHelper {
);
}

async postObjectFieldByExternalReferenceCode(
externalReferenceCode: string,
objectField: Partial<ObjectField>
): Promise<ObjectField> {
return this.apiHelpers.post(
`${this.apiHelpers.baseUrl}${this.basePath}/object-definitions/by-external-reference-code/${externalReferenceCode}/object-fields`,
{data: objectField}
);
}

async postObjectRelationship(
objectRelationship: Partial<ObjectRelationship>
) {
return this.apiHelpers.post(
`${this.apiHelpers.baseUrl}${this.basePath}/object-definitions/by-external-reference-code/${objectRelationship.objectDefinitionExternalReferenceCode1}/object-relationships`,
{data: objectRelationship}
);
}

async postObjectValidation(
objectDefinitionExternalReferenceCode: string,
objectValidation: ObjectValidation
) {
return this.apiHelpers.post<ObjectValidation>(
`${this.apiHelpers.baseUrl}${this.basePath}/object-definitions/by-external-reference-code/${objectDefinitionExternalReferenceCode}/object-validation-rules`,
{data: objectValidation}
);
}

async postRandomObjectDefinition({
objectFields,
objectFolderExternalReferenceCode,
Expand Down Expand Up @@ -169,37 +89,31 @@ export class ObjectAdminApiHelper {
objectFolderExternalReferenceCode;
}

return this.apiHelpers.post(
`${this.apiHelpers.baseUrl}${this.basePath}/object-definitions`,
{data: requestBody}
) as Promise<ObjectDefinition>;
const objectAdminRestClient = await this.apiHelpers.buildRestClient(
ObjectAdminRestClient
);

return objectAdminRestClient.objectDefinition.postObjectDefinition({
requestBody,
});
}

async postRandomObjectFolder(): Promise<ObjectFolder> {
const objectFolderExternalReferenceCode =
'objectFolder' + getRandomInt();

return this.apiHelpers.post(
`${this.apiHelpers.baseUrl}${this.basePath}/object-folders`,
{
data: {
externalReferenceCode: objectFolderExternalReferenceCode,
label: {
en_US: objectFolderExternalReferenceCode,
},
name: objectFolderExternalReferenceCode,
},
}
const objectAdminRestClient = await this.apiHelpers.buildRestClient(
ObjectAdminRestClient
);
}

async putObjectRelationship(
objectRelationshipId: number,
objectRelationship: Partial<ObjectRelationship>
) {
return this.apiHelpers.put(
`${this.apiHelpers.baseUrl}${this.basePath}/object-relationships/${objectRelationshipId}`,
{data: objectRelationship}
);
return objectAdminRestClient.objectFolder.postObjectFolder({
requestBody: {
externalReferenceCode: objectFolderExternalReferenceCode,
label: {
en_US: objectFolderExternalReferenceCode,
},
name: objectFolderExternalReferenceCode,
},
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import {Locator, Page} from '@playwright/test';

import {ObjectFolder} from '../../../../apps/object/object-admin-rest-client-js/src/main/resources/META-INF/resources/node';
import {PORTLET_URLS} from '../../utils/portletUrls';
import {ApplicationsMenuPage} from '../product-navigation-applications-menu/ApplicationsMenuPage';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import {FrameLocator, Locator, Page, expect} from '@playwright/test';

import {ObjectField} from '../../../../../apps/object/object-admin-rest-client-js/src/main/resources/META-INF/resources/node';
import {PORTLET_URLS} from '../../../utils/portletUrls';

export class ViewObjectEntriesPage {
Expand Down Expand Up @@ -80,7 +81,7 @@ export class ViewObjectEntriesPage {
objectFieldLabel,
objectFieldValue,
}: {
objectFieldBusinessType?: ObjectFieldBusinessTypeName;
objectFieldBusinessType?: ObjectField['businessType'];
objectFieldLabel?: string;
objectFieldValue: string;
}) {
Expand Down
Loading

0 comments on commit 9ff1f1d

Please sign in to comment.