mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2026-09-09 18:02:54 +00:00
[ACS-11759] MNT-25541 automated (#5186)
* [ACS-11759] MNT-25541 automated * [ACS-11759] copilot review fixes 1
This commit is contained in:
@@ -51,6 +51,7 @@ test.describe('viewer file types', () => {
|
|||||||
const randomMp4Name = `${TEST_FILES.MP4_FILE.name}-${randomString}.mp4`;
|
const randomMp4Name = `${TEST_FILES.MP4_FILE.name}-${randomString}.mp4`;
|
||||||
const randomWebmName = `${TEST_FILES.WEBM_FILE.name}-${randomString}.webm`;
|
const randomWebmName = `${TEST_FILES.WEBM_FILE.name}-${randomString}.webm`;
|
||||||
const randomAzw3Name = `${TEST_FILES.AZW3_FILE.name}-${randomString}.azw3`;
|
const randomAzw3Name = `${TEST_FILES.AZW3_FILE.name}-${randomString}.azw3`;
|
||||||
|
const randomPdfJp2Name = `${TEST_FILES.PDF_JP2_FILE.name}-${randomString}.pdf`;
|
||||||
let nodesApi: NodesApi;
|
let nodesApi: NodesApi;
|
||||||
let trashcanApi: TrashcanApi;
|
let trashcanApi: TrashcanApi;
|
||||||
let fileActionApi: FileActionsApi;
|
let fileActionApi: FileActionsApi;
|
||||||
@@ -58,16 +59,7 @@ test.describe('viewer file types', () => {
|
|||||||
test.beforeAll(async () => {
|
test.beforeAll(async () => {
|
||||||
const apiClientFactory = new ApiClientFactory();
|
const apiClientFactory = new ApiClientFactory();
|
||||||
await apiClientFactory.setUpAcaBackend('admin');
|
await apiClientFactory.setUpAcaBackend('admin');
|
||||||
|
await apiClientFactory.createUser({ username });
|
||||||
try {
|
|
||||||
await apiClientFactory.createUser({ username });
|
|
||||||
} catch (exception) {
|
|
||||||
if (JSON.parse(exception.message).error.statusCode !== 409) {
|
|
||||||
const errorMessage = `----- beforeAll failed : ${exception}`;
|
|
||||||
logger.error(errorMessage);
|
|
||||||
throw new Error(errorMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nodesApi = await NodesApi.initialize(username, username);
|
nodesApi = await NodesApi.initialize(username, username);
|
||||||
fileActionApi = await FileActionsApi.initialize(username, username);
|
fileActionApi = await FileActionsApi.initialize(username, username);
|
||||||
@@ -83,7 +75,8 @@ test.describe('viewer file types', () => {
|
|||||||
{ path: TEST_FILES.MP3_FILE.path, name: randomMp3Name },
|
{ path: TEST_FILES.MP3_FILE.path, name: randomMp3Name },
|
||||||
{ path: TEST_FILES.MP4_FILE.path, name: randomMp4Name },
|
{ path: TEST_FILES.MP4_FILE.path, name: randomMp4Name },
|
||||||
{ path: TEST_FILES.WEBM_FILE.path, name: randomWebmName },
|
{ path: TEST_FILES.WEBM_FILE.path, name: randomWebmName },
|
||||||
{ path: TEST_FILES.AZW3_FILE.path, name: randomAzw3Name }
|
{ path: TEST_FILES.AZW3_FILE.path, name: randomAzw3Name },
|
||||||
|
{ path: TEST_FILES.PDF_JP2_FILE.path, name: randomPdfJp2Name }
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const file of filesToUpload) {
|
for (const file of filesToUpload) {
|
||||||
@@ -92,6 +85,7 @@ test.describe('viewer file types', () => {
|
|||||||
|
|
||||||
await fileActionApi.waitForNodes(randomWebmName, { expect: 1 });
|
await fileActionApi.waitForNodes(randomWebmName, { expect: 1 });
|
||||||
await fileActionApi.waitForNodes(randomAzw3Name, { expect: 1 });
|
await fileActionApi.waitForNodes(randomAzw3Name, { expect: 1 });
|
||||||
|
await fileActionApi.waitForNodes(randomPdfJp2Name, { expect: 1 });
|
||||||
});
|
});
|
||||||
|
|
||||||
test.beforeEach(async ({ loginPage }) => {
|
test.beforeEach(async ({ loginPage }) => {
|
||||||
@@ -201,4 +195,8 @@ test.describe('viewer file types', () => {
|
|||||||
await personalFiles.viewer.thumbnailsCloseButton.click();
|
await personalFiles.viewer.thumbnailsCloseButton.click();
|
||||||
await expect(personalFiles.viewer.thumbnailsPages.first()).toBeHidden();
|
await expect(personalFiles.viewer.thumbnailsPages.first()).toBeHidden();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('[XAT-19373] PDFs containing JP2 images are displayed properly', async ({ personalFiles }) => {
|
||||||
|
await checkViewerDisplay(personalFiles, randomPdfJp2Name, 'viewerDocument');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -162,8 +162,12 @@ export class ApiClientFactory {
|
|||||||
try {
|
try {
|
||||||
return await peopleApi.createPerson(person);
|
return await peopleApi.createPerson(person);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (String(error).includes('409')) {
|
||||||
|
logger.warn(`[API Client Factory] createUser: user "${user.username}" already exists, skipping creation`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
logger.error(`[API Client Factory] createUser failed: ${error}`);
|
logger.error(`[API Client Factory] createUser failed: ${error}`);
|
||||||
return null;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,11 +42,18 @@ export class FileActionsApi {
|
|||||||
|
|
||||||
async uploadFile(fileLocation: string, fileName: string, parentFolderId: string): Promise<NodeEntry> {
|
async uploadFile(fileLocation: string, fileName: string, parentFolderId: string): Promise<NodeEntry> {
|
||||||
const file = fs.createReadStream(fileLocation);
|
const file = fs.createReadStream(fileLocation);
|
||||||
return this.apiService.upload.uploadFile(file, '', parentFolderId, null, {
|
try {
|
||||||
name: fileName,
|
const result = await this.apiService.upload.uploadFile(file, '', parentFolderId, undefined, {
|
||||||
nodeType: 'cm:content',
|
name: fileName,
|
||||||
renditions: 'doclib'
|
nodeType: 'cm:content',
|
||||||
});
|
renditions: 'doclib'
|
||||||
|
});
|
||||||
|
logger.info(`File uploaded successfully: ${fileName}`);
|
||||||
|
return result;
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(`Failed to upload file: ${fileName}: ${error}`);
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async uploadFileWithRename(
|
async uploadFileWithRename(
|
||||||
@@ -70,8 +77,11 @@ export class FileActionsApi {
|
|||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return this.apiService.upload.uploadFile(file, '', parentId, nodeProps, opts);
|
const result = await this.apiService.upload.uploadFile(file, '', parentId, nodeProps, opts);
|
||||||
|
logger.info(`File uploaded successfully: ${newName}`);
|
||||||
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
logger.error(`Failed to upload file: ${newName}: ${error}`);
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -95,7 +105,7 @@ export class FileActionsApi {
|
|||||||
async getNodeProperty(nodeId: string, property: string): Promise<string> {
|
async getNodeProperty(nodeId: string, property: string): Promise<string> {
|
||||||
try {
|
try {
|
||||||
const node = await this.getNodeById(nodeId);
|
const node = await this.getNodeById(nodeId);
|
||||||
return node.entry.properties?.[property] || '';
|
return node?.entry?.properties?.[property] || '';
|
||||||
} catch {
|
} catch {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@@ -133,7 +143,7 @@ export class FileActionsApi {
|
|||||||
private async queryNodesNames(searchTerm: string): Promise<ResultSetPaging> {
|
private async queryNodesNames(searchTerm: string): Promise<ResultSetPaging> {
|
||||||
const data = {
|
const data = {
|
||||||
query: {
|
query: {
|
||||||
query: `cm:name:\"${searchTerm}*\"`,
|
query: `cm:name:"${searchTerm}*"`,
|
||||||
language: 'afts'
|
language: 'afts'
|
||||||
},
|
},
|
||||||
filterQueries: [{ query: `+TYPE:'cm:folder' OR +TYPE:'cm:content'` }]
|
filterQueries: [{ query: `+TYPE:'cm:folder' OR +TYPE:'cm:content'` }]
|
||||||
@@ -147,11 +157,17 @@ export class FileActionsApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async waitForNodes(searchTerm: string, data: { expect: number }): Promise<void> {
|
async waitForNodes(searchTerm: string, data: { expect: number }): Promise<void> {
|
||||||
|
logger.info(`waitForNodes: Waiting for ${data.expect} node(s) matching "${searchTerm}"`);
|
||||||
const predicate = (totalItems: number) => totalItems === data.expect;
|
const predicate = (totalItems: number) => totalItems === data.expect;
|
||||||
|
let pollCount = 0;
|
||||||
|
|
||||||
const apiCall = async () => {
|
const apiCall = async () => {
|
||||||
try {
|
try {
|
||||||
return (await this.queryNodesNames(searchTerm)).list.pagination.totalItems;
|
const totalItems = (await this.queryNodesNames(searchTerm)).list?.pagination?.totalItems || 0;
|
||||||
|
if (pollCount++ % 4 === 0) {
|
||||||
|
logger.info(`waitForNodes: "${searchTerm}" — found ${totalItems}, expecting ${data.expect}`);
|
||||||
|
}
|
||||||
|
return totalItems;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -208,7 +224,7 @@ export class FileActionsApi {
|
|||||||
|
|
||||||
const apiCall = async (): Promise<number> => {
|
const apiCall = async (): Promise<number> => {
|
||||||
try {
|
try {
|
||||||
return (await this.queryNodesSearchHighlight(searchTerm)).list.pagination.totalItems;
|
return (await this.queryNodesSearchHighlight(searchTerm)).list?.pagination?.totalItems || 0;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.warn(`queryNodesSearchHighlight failed for "${searchTerm}": ${error}`);
|
logger.warn(`queryNodesSearchHighlight failed for "${searchTerm}": ${error}`);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -225,11 +241,13 @@ export class FileActionsApi {
|
|||||||
|
|
||||||
async updateNodeContent(nodeId: string, content: string, majorVersion: boolean = true, comment?: string, newName?: string): Promise<NodeEntry> {
|
async updateNodeContent(nodeId: string, content: string, majorVersion: boolean = true, comment?: string, newName?: string): Promise<NodeEntry> {
|
||||||
try {
|
try {
|
||||||
const opts: { [key: string]: string | boolean } = {
|
const opts: { [key: string]: string | boolean } = { majorVersion };
|
||||||
majorVersion: majorVersion,
|
if (comment !== undefined) {
|
||||||
comment: comment,
|
opts['comment'] = comment;
|
||||||
name: newName
|
}
|
||||||
};
|
if (newName !== undefined) {
|
||||||
|
opts['name'] = newName;
|
||||||
|
}
|
||||||
return await this.apiService.nodes.updateNodeContent(nodeId, content, opts);
|
return await this.apiService.nodes.updateNodeContent(nodeId, content, opts);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(`${this.constructor.name} ${this.updateNodeContent.name}: ${error}`);
|
logger.error(`${this.constructor.name} ${this.updateNodeContent.name}: ${error}`);
|
||||||
|
|||||||
Binary file not shown.
@@ -111,5 +111,10 @@ export const TEST_FILES = {
|
|||||||
AZW3_FILE: {
|
AZW3_FILE: {
|
||||||
path: resolve(__dirname, 'file-azw3.azw3'),
|
path: resolve(__dirname, 'file-azw3.azw3'),
|
||||||
name: 'file-azw3'
|
name: 'file-azw3'
|
||||||
|
},
|
||||||
|
PDF_JP2_FILE: {
|
||||||
|
path: resolve(__dirname, 'file-pdf-with-jp2.pdf'),
|
||||||
|
name: 'file-pdf-jp2',
|
||||||
|
data: 'Lorem ipsum dolor sit amet'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user