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

[ACS-6269] update create file from template tests #3567

Merged
merged 5 commits into from
Dec 20, 2023
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,21 @@
import { expect } from '@playwright/test';
import {
AcaHeader,
ApiClientFactory,
ContentNodeSelectorDialog,
CreateFromTemplateDialogComponent,
DataTableComponent,
NodeContentTree,
NodesApi,
SitesApi,
Utils,
errorStrings,
getUserState,
test
} from '@alfresco/playwright-shared';

test.use({ storageState: getUserState('hruser') });
test.describe('Create file from template', () => {
const apiClientFactory = new ApiClientFactory();
let nodesApi: NodesApi;
let selectFileTemplateDialog: ContentNodeSelectorDialog;
let createFileFromTemplateDialog: CreateFromTemplateDialogComponent;
let dataTable: DataTableComponent;
Expand All @@ -46,7 +48,6 @@ test.describe('Create file from template', () => {
let randomFileTitle: string;
let randomFileDescription: string;
let fileLink: string;
let fileId: string;
const selectDialogTitle = 'Select a document template';
const dialogBreadcrumb = 'Node Templates';
const nameLabel = 'Name *';
Expand All @@ -58,6 +59,7 @@ test.describe('Create file from template', () => {
const spaceString = ' ';
const commandKey = 'Meta';
const random = Utils.random();
const username = `user-${Utils.random()}`;

const restrictedTemplateFolder = `restricted-templates-${random}`;
const templateInRestrictedFolder = `template-restricted-${random}.txt`;
Expand Down Expand Up @@ -100,25 +102,73 @@ test.describe('Create file from template', () => {
};

test.beforeAll(async ({ nodesApiAction }) => {
await nodesApiAction.createContent(templates, `Data Dictionary/Node Templates`);
await nodesApiAction.removeUserAccessOnNodeTemplate(restrictedTemplateFolder);
fileLink = (await nodesApiAction.createLinkToFileName(template2InRoot, await nodesApiAction.getNodeTemplatesFolderId())).entry.name;
try {
await apiClientFactory.setUpAcaBackend('admin');
await apiClientFactory.createUser({ username: username });
await nodesApiAction.createContent(templates, `Data Dictionary/Node Templates`);
await nodesApiAction.removeUserAccessOnNodeTemplate(restrictedTemplateFolder);
fileLink = (await nodesApiAction.createLinkToFileName(template2InRoot, await nodesApiAction.getNodeTemplatesFolderId())).entry.name;
} catch (error) {
console.error(`Main beforeAll failed : ${error}`);
}
});

test.beforeEach(async ({ personalFiles }) => {
await personalFiles.navigate();
test.beforeEach(async ({ loginPage, personalFiles }) => {
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 }) => {
await nodesApiAction.cleanupNodeTemplatesItems([templatesFolder1, templatesFolder2, restrictedTemplateFolder, template1InRoot, template2InRoot]);
try {
await nodesApiAction.cleanupNodeTemplatesItems([
templatesFolder1,
templatesFolder2,
restrictedTemplateFolder,
template1InRoot,
template2InRoot
]);
} catch (error) {
console.error(`Main afterAll failed : ${error}`);
}
});

test.describe('Personal Files page', () => {
test.beforeAll(async () => {
try {
nodesApi = await NodesApi.initialize(username, username);
} catch (error) {
console.error(`Personal Files page, beforeAll failed : ${error}`);
}
});

test.beforeEach(async ({ personalFiles }) => {
selectFileTemplateDialog = personalFiles.contentNodeSelector;
dataTable = personalFiles.dataTable;
toolbar = personalFiles.acaHeader;
await toolbar.clickCreateFileFromTemplate();
try {
selectFileTemplateDialog = personalFiles.contentNodeSelector;
dataTable = personalFiles.dataTable;
toolbar = personalFiles.acaHeader;
await toolbar.clickCreateFileFromTemplate();
await selectFileTemplateDialog.loadMoreNodes();
} catch (error) {
console.error(`Personal Files page, beforeEach failed : ${error}`);
}
});

test.afterAll(async () => {
try {
await nodesApi.deleteCurrentUserNodes();
} catch (error) {
console.error(`Personal Files page, afterAll failed : ${error}`);
}
});

test.describe('Select Template dialog', () => {
Expand Down Expand Up @@ -196,18 +246,21 @@ test.describe('Create file from template', () => {

test.describe('Create document from template dialog', () => {
test.beforeAll(async () => {
const nodesApi = await NodesApi.initialize('hruser');
fileId = (await nodesApi.createFolder(commonFileName)).entry.id;
try {
await nodesApi.createFile(commonFileName);
} catch (error) {
console.error(`Create document from template dialog, beforeAll failed : ${error}`);
}
});

test.beforeEach(async ({ personalFiles }) => {
createFileFromTemplateDialog = personalFiles.createFromTemplateDialogComponent;
await dataTable.getRowByName(template1InRoot).click();
await selectFileTemplateDialog.actionButton.click();
});

test.afterAll(async ({ nodesApiAction }) => {
await nodesApiAction.deleteNodeById(fileId);
try {
createFileFromTemplateDialog = personalFiles.createFromTemplateDialogComponent;
await dataTable.getRowByName(template1InRoot).click();
await selectFileTemplateDialog.actionButton.click();
} catch (error) {
console.error(`Create document from template dialog, beforeEach failed : ${error}`);
}
});

test('[C325020] Create file from template - dialog UI', async () => {
Expand Down Expand Up @@ -315,18 +368,16 @@ test.describe('Create file from template', () => {

test.describe('File created from template on Personal Files', () => {
test.beforeEach(async ({ personalFiles }) => {
randomFileName = `playwright-file-${Utils.random()}`;
randomFileTitle = `file-title-${Utils.random()}`;
randomFileDescription = `file-description-${Utils.random()}`;
createFileFromTemplateDialog = personalFiles.createFromTemplateDialogComponent;
await dataTable.getRowByName(template1InRoot).click();
await selectFileTemplateDialog.actionButton.click();
});

test.afterEach(async () => {
const nodesApi = await NodesApi.initialize('hruser');
fileId = await nodesApi.getNodeIdFromParent(randomFileName, '-my-');
await nodesApi.deleteNodeById(fileId);
try {
randomFileName = `playwright-file-${Utils.random()}`;
randomFileTitle = `file-title-${Utils.random()}`;
randomFileDescription = `file-description-${Utils.random()}`;
createFileFromTemplateDialog = personalFiles.createFromTemplateDialogComponent;
await dataTable.getRowByName(template1InRoot).click();
await selectFileTemplateDialog.actionButton.click();
} catch (error) {
console.error(`File created from template on Personal Files, beforeEach failed : ${error}`);
}
});

test('[C325030] Create a file from a template - with a new Name', async () => {
Expand All @@ -351,32 +402,47 @@ test.describe('Create file from template', () => {

test.describe('File created from template on Personal Files Libraries', () => {
const randomLibraryName = `playwright-library-${Utils.random()}`;

test.beforeAll(async ({ sitesApiAction, nodesApiAction }) => {
await sitesApiAction.createSite(randomLibraryName);
const libraryGuId = await sitesApiAction.getDocLibId(randomLibraryName);
await nodesApiAction.createFolder(commonFileName, libraryGuId);
let sitesApi: SitesApi;

test.beforeAll(async () => {
try {
sitesApi = await SitesApi.initialize(username, username);
await sitesApi.createSite(randomLibraryName);
const libraryGuId = await sitesApi.getDocLibId(randomLibraryName);
await nodesApi.createFolder(commonFileName, libraryGuId);
} catch (error) {
console.error(`File created from template on Personal Files Libraries, beforeAll failed : ${error}`);
}
});

test.beforeEach(async ({ myLibrariesPage }) => {
randomFileName = `playwright-file-${Utils.random()}`;
randomFileTitle = `file-title-${Utils.random()}`;
randomFileDescription = `file-description-${Utils.random()}`;
await myLibrariesPage.navigate();
selectFileTemplateDialog = myLibrariesPage.contentNodeSelector;
createFileFromTemplateDialog = myLibrariesPage.createFromTemplateDialogComponent;
dataTable = myLibrariesPage.dataTable;
toolbar = myLibrariesPage.acaHeader;
await dataTable.goThroughPagesLookingForRowWithName(randomLibraryName);
await dataTable.getRowByName(randomLibraryName).dblclick();
await dataTable.spinnerWaitForReload();
await toolbar.clickCreateFileFromTemplate();
await dataTable.getRowByName(template1InRoot).click();
await selectFileTemplateDialog.actionButton.click();
try {
randomFileName = `playwright-file-${Utils.random()}`;
randomFileTitle = `file-title-${Utils.random()}`;
randomFileDescription = `file-description-${Utils.random()}`;
await myLibrariesPage.navigate();
selectFileTemplateDialog = myLibrariesPage.contentNodeSelector;
createFileFromTemplateDialog = myLibrariesPage.createFromTemplateDialogComponent;
dataTable = myLibrariesPage.dataTable;
toolbar = myLibrariesPage.acaHeader;
await dataTable.goThroughPagesLookingForRowWithName(randomLibraryName);
await dataTable.getRowByName(randomLibraryName).dblclick();
await dataTable.spinnerWaitForReload();
await toolbar.clickCreateFileFromTemplate();
await selectFileTemplateDialog.loadMoreNodes();
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 }) => {
await sitesApiAction.deleteSites([randomLibraryName]);
test.afterAll(async () => {
try {
await sitesApi.deleteSites([randomLibraryName]);
} catch (error) {
console.error(`File created from template on Personal Files Libraries, afterAll failed : ${error}`);
}
});

test('[C325023] Create a file from a template from library - with Name, Title and Description', async () => {
Expand Down
Loading