mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
reduce duplication and code improvements (#1707)
* reduce code duplication * reduce duplication, fix license headers * simplify code * typings fixes * update tests * minor fixes * markdown fixes * revert changes
This commit is contained in:
@@ -61,6 +61,12 @@ describe('Create folder', () => {
|
||||
const { dataTable } = page;
|
||||
const adminApiActions = new AdminActions();
|
||||
|
||||
async function openCreateFolderDialog(name: string) {
|
||||
await page.dataTable.doubleClickOnRowByName(name);
|
||||
await page.sidenav.openCreateFolderDialog();
|
||||
await createDialog.waitForDialogToOpen();
|
||||
}
|
||||
|
||||
beforeAll(async (done) => {
|
||||
await adminApiActions.createUser({ username });
|
||||
|
||||
@@ -93,9 +99,7 @@ describe('Create folder', () => {
|
||||
});
|
||||
|
||||
it('[C216341] creates new folder with name', async () => {
|
||||
await page.dataTable.doubleClickOnRowByName(parent);
|
||||
await page.sidenav.openCreateFolderDialog();
|
||||
await createDialog.waitForDialogToOpen();
|
||||
await openCreateFolderDialog(parent);
|
||||
await createDialog.enterName(folderName1);
|
||||
await BrowserActions.click(createDialog.createButton);
|
||||
await createDialog.waitForDialogToClose();
|
||||
@@ -105,9 +109,7 @@ describe('Create folder', () => {
|
||||
});
|
||||
|
||||
it('[C216340] creates new folder with name and description', async (done) => {
|
||||
await page.dataTable.doubleClickOnRowByName(parent);
|
||||
await page.sidenav.openCreateFolderDialog();
|
||||
await createDialog.waitForDialogToOpen();
|
||||
await openCreateFolderDialog(parent);
|
||||
await createDialog.enterName(folderName2);
|
||||
await createDialog.enterDescription(folderDescription);
|
||||
await BrowserActions.click(createDialog.createButton);
|
||||
@@ -121,9 +123,7 @@ describe('Create folder', () => {
|
||||
});
|
||||
|
||||
it('[C216345] dialog UI elements', async () => {
|
||||
await page.dataTable.doubleClickOnRowByName(parent);
|
||||
await page.sidenav.openCreateFolderDialog();
|
||||
await createDialog.waitForDialogToOpen();
|
||||
await openCreateFolderDialog(parent);
|
||||
|
||||
expect(await createDialog.getTitle()).toMatch('Create new folder');
|
||||
expect(await createDialog.nameInput.isDisplayed()).toBe(true, 'Name input is not displayed');
|
||||
@@ -133,9 +133,7 @@ describe('Create folder', () => {
|
||||
});
|
||||
|
||||
it('[C216346] with empty folder name', async () => {
|
||||
await page.dataTable.doubleClickOnRowByName(parent);
|
||||
await page.sidenav.openCreateFolderDialog();
|
||||
await createDialog.waitForDialogToOpen();
|
||||
await openCreateFolderDialog(parent);
|
||||
await clearTextWithBackspace(createDialog.nameInput);
|
||||
|
||||
expect(await createDialog.isCreateButtonEnabled()).toBe(false, 'Create button is enabled');
|
||||
@@ -143,9 +141,7 @@ describe('Create folder', () => {
|
||||
});
|
||||
|
||||
it('[C216348] with folder name ending with a dot "."', async () => {
|
||||
await page.dataTable.doubleClickOnRowByName(parent);
|
||||
await page.sidenav.openCreateFolderDialog();
|
||||
await createDialog.waitForDialogToOpen();
|
||||
await openCreateFolderDialog(parent);
|
||||
await createDialog.enterName('folder-name.');
|
||||
|
||||
expect(await createDialog.isCreateButtonEnabled()).toBe(false, 'Create button is not disabled');
|
||||
@@ -155,9 +151,7 @@ describe('Create folder', () => {
|
||||
it('[C216347] with folder name containing special characters', async () => {
|
||||
const namesWithSpecialChars = ['a*a', 'a"a', 'a<a', 'a>a', `a\\a`, 'a/a', 'a?a', 'a:a', 'a|a'];
|
||||
|
||||
await page.dataTable.doubleClickOnRowByName(parent);
|
||||
await page.sidenav.openCreateFolderDialog();
|
||||
await createDialog.waitForDialogToOpen();
|
||||
await openCreateFolderDialog(parent);
|
||||
|
||||
for (const name of namesWithSpecialChars) {
|
||||
await createDialog.enterName(name);
|
||||
@@ -167,9 +161,7 @@ describe('Create folder', () => {
|
||||
});
|
||||
|
||||
it('[C280406] with folder name containing only spaces', async () => {
|
||||
await page.dataTable.doubleClickOnRowByName(parent);
|
||||
await page.sidenav.openCreateFolderDialog();
|
||||
await createDialog.waitForDialogToOpen();
|
||||
await openCreateFolderDialog(parent);
|
||||
await createDialog.enterName(' ');
|
||||
|
||||
expect(await createDialog.isCreateButtonEnabled()).toBe(false, 'Create button is not disabled');
|
||||
@@ -177,9 +169,7 @@ describe('Create folder', () => {
|
||||
});
|
||||
|
||||
it('[C216349] cancel folder creation', async () => {
|
||||
await page.dataTable.doubleClickOnRowByName(parent);
|
||||
await page.sidenav.openCreateFolderDialog();
|
||||
await createDialog.waitForDialogToOpen();
|
||||
await openCreateFolderDialog(parent);
|
||||
await createDialog.enterName('test');
|
||||
await createDialog.enterDescription('test description');
|
||||
await createDialog.clickCancel();
|
||||
@@ -188,9 +178,7 @@ describe('Create folder', () => {
|
||||
});
|
||||
|
||||
it('[C216350] duplicate folder name', async () => {
|
||||
await page.dataTable.doubleClickOnRowByName(parent);
|
||||
await page.sidenav.openCreateFolderDialog();
|
||||
await createDialog.waitForDialogToOpen();
|
||||
await openCreateFolderDialog(parent);
|
||||
await createDialog.enterName(duplicateFolderName);
|
||||
await BrowserActions.click(createDialog.createButton);
|
||||
|
||||
@@ -199,9 +187,7 @@ describe('Create folder', () => {
|
||||
});
|
||||
|
||||
it('[C216351] trim ending spaces from folder name', async () => {
|
||||
await page.dataTable.doubleClickOnRowByName(parent);
|
||||
await page.sidenav.openCreateFolderDialog();
|
||||
await createDialog.waitForDialogToOpen();
|
||||
await openCreateFolderDialog(parent);
|
||||
await createDialog.enterName(nameWithSpaces);
|
||||
await BrowserActions.click(createDialog.createButton);
|
||||
await createDialog.waitForDialogToClose();
|
||||
@@ -225,9 +211,7 @@ describe('Create folder', () => {
|
||||
});
|
||||
|
||||
it('[C280394] creates new folder with name and description', async () => {
|
||||
await page.dataTable.doubleClickOnRowByName(siteName);
|
||||
await page.sidenav.openCreateFolderDialog();
|
||||
await createDialog.waitForDialogToOpen();
|
||||
await openCreateFolderDialog(siteName);
|
||||
await createDialog.enterName(folderSite);
|
||||
await createDialog.enterDescription(folderDescription);
|
||||
await BrowserActions.click(createDialog.createButton);
|
||||
@@ -240,9 +224,7 @@ describe('Create folder', () => {
|
||||
});
|
||||
|
||||
it('[C280403] cancel folder creation', async () => {
|
||||
await page.dataTable.doubleClickOnRowByName(siteName);
|
||||
await page.sidenav.openCreateFolderDialog();
|
||||
await createDialog.waitForDialogToOpen();
|
||||
await openCreateFolderDialog(siteName);
|
||||
await createDialog.enterName('test');
|
||||
await createDialog.enterDescription('test description');
|
||||
await createDialog.clickCancel();
|
||||
@@ -251,9 +233,7 @@ describe('Create folder', () => {
|
||||
});
|
||||
|
||||
it('[C280404] duplicate folder name', async () => {
|
||||
await page.dataTable.doubleClickOnRowByName(siteName);
|
||||
await page.sidenav.openCreateFolderDialog();
|
||||
await createDialog.waitForDialogToOpen();
|
||||
await openCreateFolderDialog(siteName);
|
||||
await createDialog.enterName(duplicateFolderSite);
|
||||
await BrowserActions.click(createDialog.createButton);
|
||||
|
||||
|
@@ -88,46 +88,44 @@ describe('Breadcrumb', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
async function verifyBreadcrumb(expectedCount: number, expectedText: string) {
|
||||
expect(await breadcrumb.items.count()).toEqual(expectedCount, 'Breadcrumb has incorrect number of items');
|
||||
expect(await breadcrumb.currentItem.getText()).toBe(expectedText);
|
||||
}
|
||||
|
||||
it('[C260964] Personal Files breadcrumb main node', async () => {
|
||||
await page.clickPersonalFiles();
|
||||
expect(await breadcrumb.items.count()).toEqual(1, 'Breadcrumb has incorrect number of items');
|
||||
expect(await breadcrumb.currentItem.getText()).toBe('Personal Files');
|
||||
await verifyBreadcrumb(1, 'Personal Files');
|
||||
});
|
||||
|
||||
it('[C260966] My Libraries breadcrumb main node', async () => {
|
||||
await page.goToMyLibrariesAndWait();
|
||||
expect(await breadcrumb.items.count()).toEqual(1, 'Breadcrumb has incorrect number of items');
|
||||
expect(await breadcrumb.currentItem.getText()).toBe('My Libraries');
|
||||
await verifyBreadcrumb(1, 'My Libraries');
|
||||
});
|
||||
|
||||
it('[C289891] Favorite Libraries breadcrumb main node', async () => {
|
||||
await page.goToFavoriteLibrariesAndWait();
|
||||
expect(await breadcrumb.items.count()).toEqual(1, 'Breadcrumb has incorrect number of items');
|
||||
expect(await breadcrumb.currentItem.getText()).toBe('Favorite Libraries');
|
||||
await verifyBreadcrumb(1, 'Favorite Libraries');
|
||||
});
|
||||
|
||||
it('[C260971] Recent Files breadcrumb main node', async () => {
|
||||
await page.clickRecentFiles();
|
||||
expect(await breadcrumb.items.count()).toEqual(1, 'Breadcrumb has incorrect number of items');
|
||||
expect(await breadcrumb.currentItem.getText()).toBe('Recent Files');
|
||||
await verifyBreadcrumb(1, 'Recent Files');
|
||||
});
|
||||
|
||||
it('[C260972] Shared Files breadcrumb main node', async () => {
|
||||
await page.clickSharedFiles();
|
||||
expect(await breadcrumb.items.count()).toEqual(1, 'Breadcrumb has incorrect number of items');
|
||||
expect(await breadcrumb.currentItem.getText()).toBe('Shared Files');
|
||||
await verifyBreadcrumb(1, 'Shared Files');
|
||||
});
|
||||
|
||||
it('[C260973] Favorites breadcrumb main node', async () => {
|
||||
await page.clickFavorites();
|
||||
expect(await breadcrumb.items.count()).toEqual(1, 'Breadcrumb has incorrect number of items');
|
||||
expect(await breadcrumb.currentItem.getText()).toBe('Favorites');
|
||||
await verifyBreadcrumb(1, 'Favorites');
|
||||
});
|
||||
|
||||
it('[C260974] Trash breadcrumb main node', async () => {
|
||||
await page.clickTrash();
|
||||
expect(await breadcrumb.items.count()).toEqual(1, 'Breadcrumb has incorrect number of items');
|
||||
expect(await breadcrumb.currentItem.getText()).toBe('Trash');
|
||||
await verifyBreadcrumb(1, 'Trash');
|
||||
});
|
||||
|
||||
it('[C260965] Personal Files breadcrumb for a folder hierarchy', async () => {
|
||||
|
Reference in New Issue
Block a user