mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACS-6269] update create file from template tests (#3567)
* [ACS-6269] update create file from template tests * update error messages * update beforeAll of personal files * move nodesApi initialize and delete * removing unnecessary try catch blocks
This commit is contained in:
@@ -25,19 +25,20 @@
|
|||||||
import { expect } from '@playwright/test';
|
import { expect } from '@playwright/test';
|
||||||
import {
|
import {
|
||||||
AcaHeader,
|
AcaHeader,
|
||||||
|
ApiClientFactory,
|
||||||
ContentNodeSelectorDialog,
|
ContentNodeSelectorDialog,
|
||||||
CreateFromTemplateDialogComponent,
|
CreateFromTemplateDialogComponent,
|
||||||
DataTableComponent,
|
DataTableComponent,
|
||||||
NodeContentTree,
|
NodeContentTree,
|
||||||
NodesApi,
|
NodesApi,
|
||||||
|
SitesApi,
|
||||||
Utils,
|
Utils,
|
||||||
errorStrings,
|
errorStrings,
|
||||||
getUserState,
|
|
||||||
test
|
test
|
||||||
} from '@alfresco/playwright-shared';
|
} from '@alfresco/playwright-shared';
|
||||||
|
|
||||||
test.use({ storageState: getUserState('hruser') });
|
|
||||||
test.describe('Create file from template', () => {
|
test.describe('Create file from template', () => {
|
||||||
|
let nodesApi: NodesApi;
|
||||||
let selectFileTemplateDialog: ContentNodeSelectorDialog;
|
let selectFileTemplateDialog: ContentNodeSelectorDialog;
|
||||||
let createFileFromTemplateDialog: CreateFromTemplateDialogComponent;
|
let createFileFromTemplateDialog: CreateFromTemplateDialogComponent;
|
||||||
let dataTable: DataTableComponent;
|
let dataTable: DataTableComponent;
|
||||||
@@ -46,7 +47,6 @@ test.describe('Create file from template', () => {
|
|||||||
let randomFileTitle: string;
|
let randomFileTitle: string;
|
||||||
let randomFileDescription: string;
|
let randomFileDescription: string;
|
||||||
let fileLink: string;
|
let fileLink: string;
|
||||||
let fileId: string;
|
|
||||||
const selectDialogTitle = 'Select a document template';
|
const selectDialogTitle = 'Select a document template';
|
||||||
const dialogBreadcrumb = 'Node Templates';
|
const dialogBreadcrumb = 'Node Templates';
|
||||||
const nameLabel = 'Name *';
|
const nameLabel = 'Name *';
|
||||||
@@ -58,6 +58,7 @@ test.describe('Create file from template', () => {
|
|||||||
const spaceString = ' ';
|
const spaceString = ' ';
|
||||||
const commandKey = 'Meta';
|
const commandKey = 'Meta';
|
||||||
const random = Utils.random();
|
const random = Utils.random();
|
||||||
|
const username = `user-${Utils.random()}`;
|
||||||
|
|
||||||
const restrictedTemplateFolder = `restricted-templates-${random}`;
|
const restrictedTemplateFolder = `restricted-templates-${random}`;
|
||||||
const templateInRestrictedFolder = `template-restricted-${random}.txt`;
|
const templateInRestrictedFolder = `template-restricted-${random}.txt`;
|
||||||
@@ -100,25 +101,47 @@ test.describe('Create file from template', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
test.beforeAll(async ({ nodesApiAction }) => {
|
test.beforeAll(async ({ nodesApiAction }) => {
|
||||||
|
const apiService = new ApiClientFactory();
|
||||||
|
|
||||||
|
await apiService.setUpAcaBackend('admin');
|
||||||
|
await apiService.createUser({ username: username });
|
||||||
await nodesApiAction.createContent(templates, `Data Dictionary/Node Templates`);
|
await nodesApiAction.createContent(templates, `Data Dictionary/Node Templates`);
|
||||||
await nodesApiAction.removeUserAccessOnNodeTemplate(restrictedTemplateFolder);
|
await nodesApiAction.removeUserAccessOnNodeTemplate(restrictedTemplateFolder);
|
||||||
fileLink = (await nodesApiAction.createLinkToFileName(template2InRoot, await nodesApiAction.getNodeTemplatesFolderId())).entry.name;
|
fileLink = (await nodesApiAction.createLinkToFileName(template2InRoot, await nodesApiAction.getNodeTemplatesFolderId())).entry.name;
|
||||||
|
nodesApi = await NodesApi.initialize(username, username);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.beforeEach(async ({ personalFiles }) => {
|
test.beforeEach(async ({ loginPage, personalFiles }) => {
|
||||||
await personalFiles.navigate();
|
try {
|
||||||
|
await loginPage.loginUser(
|
||||||
|
{ username: username, password: username },
|
||||||
|
{
|
||||||
|
withNavigation: true,
|
||||||
|
waitForLoading: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
await personalFiles.navigate();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Main beforeEach failed: ${error}`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test.afterAll(async ({ nodesApiAction }) => {
|
test.afterAll(async ({ nodesApiAction }) => {
|
||||||
await nodesApiAction.cleanupNodeTemplatesItems([templatesFolder1, templatesFolder2, restrictedTemplateFolder, template1InRoot, template2InRoot]);
|
await nodesApiAction.cleanupNodeTemplatesItems([templatesFolder1, templatesFolder2, restrictedTemplateFolder, template1InRoot, template2InRoot]);
|
||||||
|
await nodesApi.deleteCurrentUserNodes();
|
||||||
});
|
});
|
||||||
|
|
||||||
test.describe('Personal Files page', () => {
|
test.describe('Personal Files page', () => {
|
||||||
test.beforeEach(async ({ personalFiles }) => {
|
test.beforeEach(async ({ personalFiles }) => {
|
||||||
selectFileTemplateDialog = personalFiles.contentNodeSelector;
|
try {
|
||||||
dataTable = personalFiles.dataTable;
|
selectFileTemplateDialog = personalFiles.contentNodeSelector;
|
||||||
toolbar = personalFiles.acaHeader;
|
dataTable = personalFiles.dataTable;
|
||||||
await toolbar.clickCreateFileFromTemplate();
|
toolbar = personalFiles.acaHeader;
|
||||||
|
await toolbar.clickCreateFileFromTemplate();
|
||||||
|
await selectFileTemplateDialog.loadMoreNodes();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Personal Files page, beforeEach failed: ${error}`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test.describe('Select Template dialog', () => {
|
test.describe('Select Template dialog', () => {
|
||||||
@@ -196,18 +219,17 @@ test.describe('Create file from template', () => {
|
|||||||
|
|
||||||
test.describe('Create document from template dialog', () => {
|
test.describe('Create document from template dialog', () => {
|
||||||
test.beforeAll(async () => {
|
test.beforeAll(async () => {
|
||||||
const nodesApi = await NodesApi.initialize('hruser');
|
await nodesApi.createFile(commonFileName);
|
||||||
fileId = (await nodesApi.createFolder(commonFileName)).entry.id;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test.beforeEach(async ({ personalFiles }) => {
|
test.beforeEach(async ({ personalFiles }) => {
|
||||||
createFileFromTemplateDialog = personalFiles.createFromTemplateDialogComponent;
|
try {
|
||||||
await dataTable.getRowByName(template1InRoot).click();
|
createFileFromTemplateDialog = personalFiles.createFromTemplateDialogComponent;
|
||||||
await selectFileTemplateDialog.actionButton.click();
|
await dataTable.getRowByName(template1InRoot).click();
|
||||||
});
|
await selectFileTemplateDialog.actionButton.click();
|
||||||
|
} catch (error) {
|
||||||
test.afterAll(async ({ nodesApiAction }) => {
|
console.error(`Create document from template dialog, beforeEach failed: ${error}`);
|
||||||
await nodesApiAction.deleteNodeById(fileId);
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('[C325020] Create file from template - dialog UI', async () => {
|
test('[C325020] Create file from template - dialog UI', async () => {
|
||||||
@@ -315,18 +337,16 @@ test.describe('Create file from template', () => {
|
|||||||
|
|
||||||
test.describe('File created from template on Personal Files', () => {
|
test.describe('File created from template on Personal Files', () => {
|
||||||
test.beforeEach(async ({ personalFiles }) => {
|
test.beforeEach(async ({ personalFiles }) => {
|
||||||
randomFileName = `playwright-file-${Utils.random()}`;
|
try {
|
||||||
randomFileTitle = `file-title-${Utils.random()}`;
|
randomFileName = `playwright-file-${Utils.random()}`;
|
||||||
randomFileDescription = `file-description-${Utils.random()}`;
|
randomFileTitle = `file-title-${Utils.random()}`;
|
||||||
createFileFromTemplateDialog = personalFiles.createFromTemplateDialogComponent;
|
randomFileDescription = `file-description-${Utils.random()}`;
|
||||||
await dataTable.getRowByName(template1InRoot).click();
|
createFileFromTemplateDialog = personalFiles.createFromTemplateDialogComponent;
|
||||||
await selectFileTemplateDialog.actionButton.click();
|
await dataTable.getRowByName(template1InRoot).click();
|
||||||
});
|
await selectFileTemplateDialog.actionButton.click();
|
||||||
|
} catch (error) {
|
||||||
test.afterEach(async () => {
|
console.error(`File created from template on Personal Files, beforeEach failed: ${error}`);
|
||||||
const nodesApi = await NodesApi.initialize('hruser');
|
}
|
||||||
fileId = await nodesApi.getNodeIdFromParent(randomFileName, '-my-');
|
|
||||||
await nodesApi.deleteNodeById(fileId);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('[C325030] Create a file from a template - with a new Name', async () => {
|
test('[C325030] Create a file from a template - with a new Name', async () => {
|
||||||
@@ -351,32 +371,38 @@ test.describe('Create file from template', () => {
|
|||||||
|
|
||||||
test.describe('File created from template on Personal Files Libraries', () => {
|
test.describe('File created from template on Personal Files Libraries', () => {
|
||||||
const randomLibraryName = `playwright-library-${Utils.random()}`;
|
const randomLibraryName = `playwright-library-${Utils.random()}`;
|
||||||
|
let sitesApi: SitesApi;
|
||||||
|
|
||||||
test.beforeAll(async ({ sitesApiAction, nodesApiAction }) => {
|
test.beforeAll(async () => {
|
||||||
await sitesApiAction.createSite(randomLibraryName);
|
sitesApi = await SitesApi.initialize(username, username);
|
||||||
const libraryGuId = await sitesApiAction.getDocLibId(randomLibraryName);
|
await sitesApi.createSite(randomLibraryName);
|
||||||
await nodesApiAction.createFolder(commonFileName, libraryGuId);
|
const libraryGuId = await sitesApi.getDocLibId(randomLibraryName);
|
||||||
|
await nodesApi.createFile(commonFileName, libraryGuId);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.beforeEach(async ({ myLibrariesPage }) => {
|
test.beforeEach(async ({ myLibrariesPage }) => {
|
||||||
randomFileName = `playwright-file-${Utils.random()}`;
|
try {
|
||||||
randomFileTitle = `file-title-${Utils.random()}`;
|
randomFileName = `playwright-file-${Utils.random()}`;
|
||||||
randomFileDescription = `file-description-${Utils.random()}`;
|
randomFileTitle = `file-title-${Utils.random()}`;
|
||||||
await myLibrariesPage.navigate();
|
randomFileDescription = `file-description-${Utils.random()}`;
|
||||||
selectFileTemplateDialog = myLibrariesPage.contentNodeSelector;
|
await myLibrariesPage.navigate();
|
||||||
createFileFromTemplateDialog = myLibrariesPage.createFromTemplateDialogComponent;
|
selectFileTemplateDialog = myLibrariesPage.contentNodeSelector;
|
||||||
dataTable = myLibrariesPage.dataTable;
|
createFileFromTemplateDialog = myLibrariesPage.createFromTemplateDialogComponent;
|
||||||
toolbar = myLibrariesPage.acaHeader;
|
dataTable = myLibrariesPage.dataTable;
|
||||||
await dataTable.goThroughPagesLookingForRowWithName(randomLibraryName);
|
toolbar = myLibrariesPage.acaHeader;
|
||||||
await dataTable.getRowByName(randomLibraryName).dblclick();
|
await dataTable.getRowByName(randomLibraryName).dblclick();
|
||||||
await dataTable.spinnerWaitForReload();
|
await dataTable.spinnerWaitForReload();
|
||||||
await toolbar.clickCreateFileFromTemplate();
|
await toolbar.clickCreateFileFromTemplate();
|
||||||
await dataTable.getRowByName(template1InRoot).click();
|
await selectFileTemplateDialog.loadMoreNodes();
|
||||||
await selectFileTemplateDialog.actionButton.click();
|
await dataTable.getRowByName(template1InRoot).click();
|
||||||
|
await selectFileTemplateDialog.actionButton.click();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`File created from template on Personal Files Libraries, beforeEach failed: ${error}`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test.afterAll(async ({ sitesApiAction }) => {
|
test.afterAll(async () => {
|
||||||
await sitesApiAction.deleteSites([randomLibraryName]);
|
await sitesApi.deleteSites([randomLibraryName]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('[C325023] Create a file from a template from library - with Name, Title and Description', async () => {
|
test('[C325023] Create a file from a template from library - with Name, Title and Description', async () => {
|
||||||
|
Reference in New Issue
Block a user