ESLint: cleanup await expect from protractor tests (#9630)

This commit is contained in:
Denys Vuika
2024-04-30 08:07:10 -04:00
committed by GitHub
parent 4109f272ea
commit f401b8c13e
114 changed files with 2096 additions and 1908 deletions

View File

@@ -23,7 +23,6 @@ import { UploadTogglesPage } from '../../core/pages/dialog/upload-toggles.page';
import { FileModel } from '../../models/ACS/file.model';
describe('Upload component', async () => {
const apiService = createApiService();
const contentServicesPage = new ContentServicesPage();
const uploadDialog = new UploadDialogPage();
@@ -58,14 +57,13 @@ describe('Upload component', async () => {
await contentServicesPage.goToDocumentList();
});
const deleteNodesInCurrentPage = async function() {
const deleteNodesInCurrentPage = async () => {
const nodeList = await contentServicesPage.getElementsDisplayedId();
for (const node of nodeList) {
try {
await uploadActions.deleteFileOrFolder(node);
} catch (error) {
}
} catch (error) {}
}
};
@@ -74,18 +72,20 @@ describe('Upload component', async () => {
await contentServicesPage.uploadFile(mediumFile.location);
await expect(await uploadDialog.getTitleText()).toEqual('Upload canceled');
expect(await uploadDialog.getTitleText()).toEqual('Upload canceled');
await uploadDialog.clickOnCloseButton();
await uploadDialog.dialogIsNotDisplayed();
await contentServicesPage.checkContentIsNotDisplayed(mediumFile.name);
});
it('[C287790] Should be possible to cancel upload of a big file through the cancel uploads button', async () => {
await browser.executeScript(' setInterval(() => {document.querySelector("#adf-upload-dialog-cancel-all").click();' +
'document.querySelector("#adf-upload-dialog-cancel").click(); }, 500)');
await browser.executeScript(
' setInterval(() => {document.querySelector("#adf-upload-dialog-cancel-all").click();' +
'document.querySelector("#adf-upload-dialog-cancel").click(); }, 500)'
);
await contentServicesPage.uploadFile(largeFile.location);
await expect(await uploadDialog.getTitleText()).toEqual('Upload canceled');
expect(await uploadDialog.getTitleText()).toEqual('Upload canceled');
await uploadDialog.clickOnCloseButton();
await uploadDialog.dialogIsNotDisplayed();
await contentServicesPage.checkContentIsNotDisplayed(largeFile.name);
@@ -94,12 +94,14 @@ describe('Upload component', async () => {
it('[C272793] Should be able to cancel multiple files upload', async () => {
await uploadToggles.enableMultipleFileUpload();
await browser.executeScript(' setInterval(() => {document.querySelector("#adf-upload-dialog-cancel-all").click();' +
'document.querySelector("#adf-upload-dialog-cancel").click(); }, 500)');
await browser.executeScript(
' setInterval(() => {document.querySelector("#adf-upload-dialog-cancel-all").click();' +
'document.querySelector("#adf-upload-dialog-cancel").click(); }, 500)'
);
await contentServicesPage.uploadMultipleFile([mediumFile.location, largeFile.location]);
await expect(await uploadDialog.getTitleText()).toEqual('Upload canceled');
expect(await uploadDialog.getTitleText()).toEqual('Upload canceled');
await uploadDialog.clickOnCloseButton();
await uploadDialog.dialogIsNotDisplayed();
await contentServicesPage.checkContentIsNotDisplayed(mediumFile.name);

View File

@@ -24,7 +24,6 @@ import { browser } from 'protractor';
import { VersionManagePage } from '../pages/version-manager.page';
describe('Upload component', () => {
const contentServicesPage = new ContentServicesPage();
const uploadDialog = new UploadDialogPage();
const uploadToggles = new UploadTogglesPage();
@@ -90,17 +89,17 @@ describe('Upload component', () => {
await uploadDialog.fileIsUploaded(docxFileModel.name);
await uploadDialog.checkCloseButtonIsDisplayed();
await expect(await uploadDialog.numberOfCurrentFilesUploaded()).toEqual('1');
await expect(await uploadDialog.numberOfInitialFilesUploaded()).toEqual('1');
expect(await uploadDialog.numberOfCurrentFilesUploaded()).toEqual('1');
expect(await uploadDialog.numberOfInitialFilesUploaded()).toEqual('1');
await uploadDialog.minimizeUploadDialog();
await uploadDialog.dialogIsMinimized();
await expect(await uploadDialog.numberOfCurrentFilesUploaded()).toEqual('1');
await expect(await uploadDialog.numberOfInitialFilesUploaded()).toEqual('1');
expect(await uploadDialog.numberOfCurrentFilesUploaded()).toEqual('1');
expect(await uploadDialog.numberOfInitialFilesUploaded()).toEqual('1');
await uploadDialog.maximizeUploadDialog();
await uploadDialog.dialogIsDisplayed();
await uploadDialog.fileIsUploaded(docxFileModel.name);
await expect(await uploadDialog.numberOfCurrentFilesUploaded()).toEqual('1');
await expect(await uploadDialog.numberOfInitialFilesUploaded()).toEqual('1');
expect(await uploadDialog.numberOfCurrentFilesUploaded()).toEqual('1');
expect(await uploadDialog.numberOfInitialFilesUploaded()).toEqual('1');
await uploadDialog.checkCloseButtonIsDisplayed();
await uploadDialog.clickOnCloseButton();
await uploadDialog.dialogIsNotDisplayed();
@@ -112,7 +111,7 @@ describe('Upload component', () => {
await uploadDialog.fileIsUploaded(docxFileModel.name);
await uploadDialog.checkCloseButtonIsDisplayed();
await expect(await uploadDialog.getTitleText()).toEqual('Uploaded 1 / 1');
expect(await uploadDialog.getTitleText()).toEqual('Uploaded 1 / 1');
await uploadDialog.checkCloseButtonIsDisplayed();
await uploadDialog.clickOnCloseButton();
await uploadDialog.dialogIsNotDisplayed();
@@ -144,7 +143,7 @@ describe('Upload component', () => {
await contentServicesPage.uploadMultipleFile(filesLocation);
await contentServicesPage.checkContentsAreDisplayed(filesName);
await uploadDialog.filesAreUploaded(filesName);
await expect(await uploadDialog.getTitleText()).toEqual('Uploaded 4 / 4');
expect(await uploadDialog.getTitleText()).toEqual('Uploaded 4 / 4');
await uploadDialog.clickOnCloseButton();
await uploadDialog.dialogIsNotDisplayed();
await uploadToggles.disableMultipleFileUpload();

View File

@@ -190,7 +190,7 @@ describe('Upload component', () => {
await uploadToggles.enableMaxSize();
await uploadToggles.addMaxSize('0');
await contentServicesPage.uploadFile(fileWithSpecificSize.location);
// await expect(await contentServicesPage.getErrorMessage()).toEqual('File ' + fileWithSpecificSize.name + ' is larger than the allowed file size');
// expect(await contentServicesPage.getErrorMessage()).toEqual('File ' + fileWithSpecificSize.name + ' is larger than the allowed file size');
await uploadDialog.fileIsNotDisplayedInDialog(fileWithSpecificSize.name);
await contentServicesPage.uploadFile(emptyFile.location);
@@ -250,6 +250,6 @@ describe('Upload component', () => {
await contentServicesPage.uploadFile(pdfFileModel.location);
await uploadDialog.displayTooltip();
await expect(await uploadDialog.getTooltip()).toEqual('Upload location no longer exists [404]');
expect(await uploadDialog.getTooltip()).toEqual('Upload location no longer exists [404]');
});
});

View File

@@ -25,7 +25,6 @@ import CONSTANTS = require('../../util/constants');
import { SiteEntry, SitesApi } from '@alfresco/js-api';
describe('Upload - User permission', () => {
const contentServicesPage = new ContentServicesPage();
const uploadDialog = new UploadDialogPage();
const loginPage = new LoginPage();
@@ -84,7 +83,6 @@ describe('Upload - User permission', () => {
});
describe('Consumer permissions', () => {
beforeEach(async () => {
await contentServicesPage.goToDocumentList();
});
@@ -99,7 +97,7 @@ describe('Upload - User permission', () => {
await uploadDialog.fileIsError(emptyFile.name);
await uploadDialog.displayTooltip();
await expect(await uploadDialog.getTooltip()).toEqual('Insufficient permissions to upload in this location [403]');
expect(await uploadDialog.getTooltip()).toEqual('Insufficient permissions to upload in this location [403]');
});
it('[C279915] Should not be allowed to upload a file in folder with consumer permissions', async () => {
@@ -118,7 +116,7 @@ describe('Upload - User permission', () => {
await contentServicesPage.uploadFile(emptyFile.location);
const message = await new SnackbarPage().getSnackBarMessage();
expect(message).toEqual('You don\'t have the create permission to upload the content');
expect(message).toEqual(`You don't have the create permission to upload the content`);
});
});

View File

@@ -15,7 +15,8 @@
* limitations under the License.
*/
import { createApiService,
import {
createApiService,
BrowserActions,
BrowserVisibility,
FileBrowserUtil,
@@ -33,7 +34,6 @@ import { NavigationBarPage } from '../../core/pages/navigation-bar.page';
import { VersionManagePage } from '../pages/version-manager.page';
describe('Version component actions', () => {
const loginPage = new LoginPage();
const contentServicesPage = new ContentServicesPage();
const versionManagePage = new VersionManagePage();
@@ -54,7 +54,6 @@ describe('Version component actions', () => {
name: browser.params.resources.Files.ADF_DOCUMENTS.TXT.file_name,
location: browser.params.resources.Files.ADF_DOCUMENTS.TXT.file_location
});
let uploadActions;
const bigFileToCancel = new FileModel({
name: browser.params.resources.Files.ADF_DOCUMENTS.LARGE_FILE.file_name,
@@ -62,7 +61,7 @@ describe('Version component actions', () => {
});
beforeAll(async () => {
uploadActions = new UploadActions(apiService);
const uploadActions = new UploadActions(apiService);
await apiService.loginWithProfile('admin');
acsUser = await usersActions.createUser();
await apiService.login(acsUser.username, acsUser.password);
@@ -72,7 +71,7 @@ describe('Version component actions', () => {
await loginPage.login(acsUser.username, acsUser.password);
await navigationBarPage.navigateToContentServices();
await contentServicesPage.waitForTableBody();
});
});
beforeEach(async () => {
await contentServicesPage.versionManagerContent(txtFileModel.name);
@@ -84,14 +83,14 @@ describe('Version component actions', () => {
it('[C280003] Should not be possible delete a file version if there is only one version', async () => {
await versionManagePage.clickActionButton('1.0');
await expect(await element(by.css(`[id="adf-version-list-action-delete-1.0"]`)).isEnabled()).toBe(false);
expect(await element(by.css(`[id="adf-version-list-action-delete-1.0"]`)).isEnabled()).toBe(false);
await versionManagePage.closeActionsMenu();
await BrowserVisibility.waitUntilElementIsNotVisible(element(by.css(`[id="adf-version-list-action-delete-1.0"]`)));
});
it('[C280004] Should not be possible restore the version if there is only one version', async () => {
await versionManagePage.clickActionButton('1.0');
await expect(await element(by.css(`[id="adf-version-list-action-restore-1.0"]`)).isEnabled()).toBe(false);
expect(await element(by.css(`[id="adf-version-list-action-restore-1.0"]`)).isEnabled()).toBe(false);
await versionManagePage.closeActionsMenu();
await BrowserVisibility.waitUntilElementIsNotVisible(element(by.css(`[id="adf-version-list-action-restore-1.0"]`)));
});
@@ -169,11 +168,13 @@ describe('Version component actions', () => {
await versionManagePage.showNewVersionButton.click();
await browser.executeScript(' setTimeout(() => {document.querySelector("div[data-automation-id=\'cancel-upload-progress\']").click();}, 1000)');
await browser.executeScript(
' setTimeout(() => {document.querySelector("div[data-automation-id=\'cancel-upload-progress\']").click();}, 1000)'
);
await versionManagePage.uploadNewVersionFile(bigFileToCancel.location);
await versionManagePage.closeVersionDialog();
await expect(await uploadDialog.getTitleText()).toEqual('Upload canceled');
expect(await uploadDialog.getTitleText()).toEqual('Upload canceled');
await browser.refresh();

View File

@@ -16,15 +16,7 @@
*/
import { browser, by, element } from 'protractor';
import {
createApiService,
LoginPage,
SnackbarPage,
StringUtil,
UploadActions,
UserModel,
UsersActions
} from '@alfresco/adf-testing';
import { createApiService, LoginPage, SnackbarPage, StringUtil, UploadActions, UserModel, UsersActions } from '@alfresco/adf-testing';
import { NavigationBarPage } from '../../core/pages/navigation-bar.page';
import { VersionManagePage } from '../pages/version-manager.page';
import { UploadDialogPage } from '../pages/upload-dialog.page';
@@ -34,7 +26,6 @@ import CONSTANTS = require('../../util/constants');
import { NodesApi, SitesApi } from '@alfresco/js-api';
describe('Version component permissions', () => {
const loginPage = new LoginPage();
const versionManagePage = new VersionManagePage();
const navigationBarPage = new NavigationBarPage();
@@ -115,9 +106,9 @@ describe('Version component permissions', () => {
Object.assign(lockFileModel, lockFileUploaded.entry);
await nodesApi.lockNode(lockFileModel.id, {
type: 'FULL',
lifetime: 'PERSISTENT'
});
type: 'FULL',
lifetime: 'PERSISTENT'
});
await apiService.login(fileCreatorUser.username, fileCreatorUser.password);
@@ -161,8 +152,8 @@ describe('Version component permissions', () => {
await versionManagePage.uploadNewVersionFile(newVersionFile.location);
await versionManagePage.checkFileVersionExist('1.1');
await expect(await versionManagePage.getFileVersionName('1.1')).toEqual(newVersionFile.name);
await expect(await versionManagePage.getFileVersionDate('1.1')).not.toBeUndefined();
expect(await versionManagePage.getFileVersionName('1.1')).toEqual(newVersionFile.name);
expect(await versionManagePage.getFileVersionDate('1.1')).not.toBeUndefined();
await versionManagePage.deleteFileVersion('1.1');
await versionManagePage.confirmAccept.click();
@@ -176,7 +167,7 @@ describe('Version component permissions', () => {
it('[C277204] Should be disabled the option for locked file', async () => {
await contentServices.getDocumentList().rightClickOnRow(lockFileModel.name);
await expect(await contentServices.isContextActionEnabled('Manage versions')).toBe(false, 'Manage versions is enabled');
expect(await contentServices.isContextActionEnabled('Manage versions')).toBe(false, 'Manage versions is enabled');
});
});
@@ -200,7 +191,7 @@ describe('Version component permissions', () => {
it('[C277201] Should a user with Consumer permission not be able to upload a new version for a locked file', async () => {
await contentServices.getDocumentList().rightClickOnRow(lockFileModel.name);
await expect(await contentServices.isContextActionEnabled('Manage versions')).toBe(false, 'Manage version is enabled');
expect(await contentServices.isContextActionEnabled('Manage versions')).toBe(false);
});
});
@@ -234,8 +225,8 @@ describe('Version component permissions', () => {
await versionManagePage.uploadNewVersionFile(newVersionFile.location);
await versionManagePage.checkFileVersionExist('1.1');
await expect(await versionManagePage.getFileVersionName('1.1')).toEqual(newVersionFile.name);
await expect(await versionManagePage.getFileVersionDate('1.1')).not.toBeUndefined();
expect(await versionManagePage.getFileVersionName('1.1')).toEqual(newVersionFile.name);
expect(await versionManagePage.getFileVersionDate('1.1')).not.toBeUndefined();
await versionManagePage.deleteFileVersion('1.1');
await versionManagePage.confirmAccept.click();
@@ -256,7 +247,7 @@ describe('Version component permissions', () => {
it('[C277202] Should be disabled the option for a locked file', async () => {
await contentServices.getDocumentList().rightClickOnRow(lockFileModel.name);
await expect(await contentServices.isContextActionEnabled('Manage versions')).toBe(false, 'Manage versions is enabled');
expect(await contentServices.isContextActionEnabled('Manage versions')).toBe(false);
});
});
@@ -290,8 +281,8 @@ describe('Version component permissions', () => {
await versionManagePage.uploadNewVersionFile(newVersionFile.location);
await versionManagePage.checkFileVersionExist('1.1');
await expect(await versionManagePage.getFileVersionName('1.1')).toEqual(newVersionFile.name);
await expect(await versionManagePage.getFileVersionDate('1.1')).not.toBeUndefined();
expect(await versionManagePage.getFileVersionName('1.1')).toEqual(newVersionFile.name);
expect(await versionManagePage.getFileVersionDate('1.1')).not.toBeUndefined();
await versionManagePage.deleteFileVersion('1.1');
await versionManagePage.confirmAccept.click();
@@ -310,12 +301,12 @@ describe('Version component permissions', () => {
await versionManagePage.uploadNewVersionFile(newVersionFile.location);
await versionManagePage.checkFileVersionExist('1.1');
await expect(await versionManagePage.getFileVersionName('1.1')).toEqual(newVersionFile.name);
await expect(await versionManagePage.getFileVersionDate('1.1')).not.toBeUndefined();
expect(await versionManagePage.getFileVersionName('1.1')).toEqual(newVersionFile.name);
expect(await versionManagePage.getFileVersionDate('1.1')).not.toBeUndefined();
await versionManagePage.clickActionButton('1.1');
await expect(await element(by.css(`[id="adf-version-list-action-delete-1.1"]`)).isEnabled()).toBe(false);
expect(await element(by.css(`[id="adf-version-list-action-delete-1.1"]`)).isEnabled()).toBe(false);
await versionManagePage.closeActionsMenu();
@@ -324,7 +315,7 @@ describe('Version component permissions', () => {
it('[C277203] Should a user with Collaborator permission not be able to upload a new version for a locked file', async () => {
await contentServices.getDocumentList().rightClickOnRow(lockFileModel.name);
await expect(await contentServices.isContextActionEnabled('Manage versions')).toBe(false, 'Manage versions is enabled');
expect(await contentServices.isContextActionEnabled('Manage versions')).toBe(false);
});
});
});

View File

@@ -16,20 +16,13 @@
*/
import { browser, by, element } from 'protractor';
import { createApiService,
BrowserVisibility,
LoginPage,
UploadActions,
UserModel,
UsersActions, ViewerPage
} from '@alfresco/adf-testing';
import { createApiService, BrowserVisibility, LoginPage, UploadActions, UserModel, UsersActions, ViewerPage } from '@alfresco/adf-testing';
import { ContentServicesPage } from '../../core/pages/content-services.page';
import { VersionManagePage } from '../pages/version-manager.page';
import { FileModel } from '../../models/ACS/file.model';
import { NavigationBarPage } from '../../core/pages/navigation-bar.page';
describe('Version Properties', () => {
const loginPage = new LoginPage();
const contentServicesPage = new ContentServicesPage();
const versionManagePage = new VersionManagePage();
@@ -111,9 +104,8 @@ describe('Version Properties', () => {
await versionManagePage.commentText.typeText('Example comment text');
await versionManagePage.uploadNewVersionFile(fileModelVersionTwo.location);
await versionManagePage.checkFileVersionExist('1.1');
await expect(await versionManagePage.getFileVersionComment('1.1')).toEqual('Example comment text');
expect(await versionManagePage.getFileVersionComment('1.1')).toEqual('Example comment text');
await versionManagePage.disableComments();
await BrowserVisibility.waitUntilElementIsNotVisible(element(by.css(`[id="adf-version-list-item-comment-1.1"]`)));
});
});

View File

@@ -23,7 +23,6 @@ import { FileModel } from '../../models/ACS/file.model';
import { NavigationBarPage } from '../../core/pages/navigation-bar.page';
describe('Version component', () => {
let txtUploadedFile;
const loginPage = new LoginPage();
const contentServicesPage = new ContentServicesPage();
@@ -79,14 +78,14 @@ describe('Version component', () => {
await navigationBarPage.navigateToContentServices();
await contentServicesPage.waitForTableBody();
await contentServicesPage.versionManagerContent(txtFileModel.name);
});
});
it('[C272768] Should be visible the first file version when you upload a file', async () => {
await versionManagePage.showNewVersionButton.waitVisible();
await versionManagePage.checkFileVersionExist('1.0');
await expect(await versionManagePage.getFileVersionName('1.0')).toEqual(txtFileModel.name);
await expect(await versionManagePage.getFileVersionDate('1.0')).not.toBeUndefined();
expect(await versionManagePage.getFileVersionName('1.0')).toEqual(txtFileModel.name);
expect(await versionManagePage.getFileVersionDate('1.0')).not.toBeUndefined();
});
it('[C279995] Should show/hide the new upload file options when click on add New version/cancel button', async () => {
@@ -114,12 +113,12 @@ describe('Version component', () => {
await versionManagePage.uploadNewVersionFile(fileModelVersionTwo.location);
await versionManagePage.checkFileVersionExist('1.0');
await expect(await versionManagePage.getFileVersionName('1.0')).toEqual(txtFileModel.name);
await expect(await versionManagePage.getFileVersionDate('1.0')).not.toBeUndefined();
expect(await versionManagePage.getFileVersionName('1.0')).toEqual(txtFileModel.name);
expect(await versionManagePage.getFileVersionDate('1.0')).not.toBeUndefined();
await versionManagePage.checkFileVersionExist('1.1');
await expect(await versionManagePage.getFileVersionName('1.1')).toEqual(fileModelVersionTwo.name);
await expect(await versionManagePage.getFileVersionDate('1.1')).not.toBeUndefined();
expect(await versionManagePage.getFileVersionName('1.1')).toEqual(fileModelVersionTwo.name);
expect(await versionManagePage.getFileVersionDate('1.1')).not.toBeUndefined();
});
it('[C269084] Should be possible add a comment when add a new version', async () => {
@@ -128,9 +127,9 @@ describe('Version component', () => {
await versionManagePage.uploadNewVersionFile(fileModelVersionThree.location);
await versionManagePage.checkFileVersionExist('1.2');
await expect(await versionManagePage.getFileVersionName('1.2')).toEqual(fileModelVersionThree.name);
await expect(await versionManagePage.getFileVersionDate('1.2')).not.toBeUndefined();
await expect(await versionManagePage.getFileVersionComment('1.2')).toEqual('Example comment text');
expect(await versionManagePage.getFileVersionName('1.2')).toEqual(fileModelVersionThree.name);
expect(await versionManagePage.getFileVersionDate('1.2')).not.toBeUndefined();
expect(await versionManagePage.getFileVersionComment('1.2')).toEqual('Example comment text');
});
it('[C275719] Should be possible preview the file when you add a new version', async () => {
@@ -140,7 +139,7 @@ describe('Version component', () => {
await versionManagePage.uploadNewVersionFile(fileModelVersionFor.location);
await versionManagePage.checkFileVersionExist('2.0');
await expect(await versionManagePage.getFileVersionName('2.0')).toEqual(fileModelVersionFor.name);
expect(await versionManagePage.getFileVersionName('2.0')).toEqual(fileModelVersionFor.name);
await versionManagePage.showNewVersionButton.click();
await versionManagePage.minorRadio.click();
@@ -148,6 +147,6 @@ describe('Version component', () => {
await versionManagePage.uploadNewVersionFile(fileModelVersionFive.location);
await versionManagePage.checkFileVersionExist('2.1');
await expect(await versionManagePage.getFileVersionName('2.1')).toEqual(fileModelVersionFive.name);
expect(await versionManagePage.getFileVersionName('2.1')).toEqual(fileModelVersionFive.name);
});
});