mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACA-4265]Refactor attachFileFromLocal method
* Refactor attachFileFromLocal method
This commit is contained in:
@@ -316,7 +316,7 @@ describe('Start Task Form', () => {
|
|||||||
|
|
||||||
const localFileWidget = await widget.attachFileWidgetCloud('Attachlocalfile');
|
const localFileWidget = await widget.attachFileWidgetCloud('Attachlocalfile');
|
||||||
await localFileWidget.clickAttachContentFile('Attachlocalfile');
|
await localFileWidget.clickAttachContentFile('Attachlocalfile');
|
||||||
await contentNodeSelectorDialogPage.attachFileFromLocal(pdfFile.name, pdfFile.location);
|
await contentNodeSelectorDialogPage.attachFilesFromLocal([pdfFile]);
|
||||||
await localFileWidget.checkFileIsAttached(pdfFile.name);
|
await localFileWidget.checkFileIsAttached(pdfFile.name);
|
||||||
await localFileWidget.removeFile(pdfFile.name);
|
await localFileWidget.removeFile(pdfFile.name);
|
||||||
await localFileWidget.checkFileIsNotAttached(pdfFile.name);
|
await localFileWidget.checkFileIsNotAttached(pdfFile.name);
|
||||||
|
@@ -924,7 +924,7 @@ export class DocumentListComponent implements OnInit, OnChanges, OnDestroy, Afte
|
|||||||
}
|
}
|
||||||
|
|
||||||
onPreselectNodes() {
|
onPreselectNodes() {
|
||||||
if (this.data.hasPreselectedRows()) {
|
if (this.data?.hasPreselectedRows()) {
|
||||||
const preselectedNodes = [...this.isSingleSelectionMode() ? [this.data.getPreselectedRows()[0]] : this.data.getPreselectedRows()];
|
const preselectedNodes = [...this.isSingleSelectionMode() ? [this.data.getPreselectedRows()[0]] : this.data.getPreselectedRows()];
|
||||||
const selectedNodes = [...this.selection, ...preselectedNodes];
|
const selectedNodes = [...this.selection, ...preselectedNodes];
|
||||||
|
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { by, element, browser } from 'protractor';
|
import { by, element } from 'protractor';
|
||||||
import { DocumentListPage } from '../pages/document-list.page';
|
import { DocumentListPage } from '../pages/document-list.page';
|
||||||
import { BrowserVisibility } from '../../core/utils/browser-visibility';
|
import { BrowserVisibility } from '../../core/utils/browser-visibility';
|
||||||
import { BrowserActions } from '../../core/utils/browser-actions';
|
import { BrowserActions } from '../../core/utils/browser-actions';
|
||||||
@@ -23,6 +23,8 @@ import { DropdownPage } from '../../core/pages/material/dropdown.page';
|
|||||||
import { BreadcrumbDropdownPage } from '../pages/breadcrumb/breadcrumb-dropdown.page';
|
import { BreadcrumbDropdownPage } from '../pages/breadcrumb/breadcrumb-dropdown.page';
|
||||||
import { Logger } from '../../core/utils/logger';
|
import { Logger } from '../../core/utils/logger';
|
||||||
import { TabPage } from '../../core/pages/form/widgets/tab.page';
|
import { TabPage } from '../../core/pages/form/widgets/tab.page';
|
||||||
|
import { UploadButtonPage } from '../pages/upload-button.page';
|
||||||
|
import { FileModel } from '../../core/models/file.model';
|
||||||
|
|
||||||
export class ContentNodeSelectorDialogPage {
|
export class ContentNodeSelectorDialogPage {
|
||||||
dialog = element(by.css(`adf-content-node-selector`));
|
dialog = element(by.css(`adf-content-node-selector`));
|
||||||
@@ -36,12 +38,21 @@ export class ContentNodeSelectorDialogPage {
|
|||||||
contentList = new DocumentListPage(this.dialog);
|
contentList = new DocumentListPage(this.dialog);
|
||||||
dataTable = this.contentList.dataTablePage();
|
dataTable = this.contentList.dataTablePage();
|
||||||
siteListDropdown = new DropdownPage(this.dialog.element(by.css(`mat-select[data-automation-id='site-my-files-option']`)));
|
siteListDropdown = new DropdownPage(this.dialog.element(by.css(`mat-select[data-automation-id='site-my-files-option']`)));
|
||||||
breadcrumbDropdownPage = new BreadcrumbDropdownPage();
|
breadcrumbDropdown = new BreadcrumbDropdownPage();
|
||||||
tabPage: TabPage = new TabPage();
|
tabPage: TabPage = new TabPage();
|
||||||
|
uploadButtonComponent = new UploadButtonPage();
|
||||||
|
|
||||||
uploadFromLocalTabName = 'Upload from your device';
|
uploadFromLocalTabName = 'Upload from your device';
|
||||||
repositoryTabName = 'Repository';
|
repositoryTabName = 'Repository';
|
||||||
|
|
||||||
|
breadcrumbDropdownPage(): BreadcrumbDropdownPage {
|
||||||
|
return this.breadcrumbDropdown;
|
||||||
|
}
|
||||||
|
|
||||||
|
uploadButtonPage(): UploadButtonPage {
|
||||||
|
return this.uploadButtonComponent;
|
||||||
|
}
|
||||||
|
|
||||||
async checkDialogIsDisplayed(): Promise<void> {
|
async checkDialogIsDisplayed(): Promise<void> {
|
||||||
await BrowserVisibility.waitUntilElementIsVisible(this.dialog);
|
await BrowserVisibility.waitUntilElementIsVisible(this.dialog);
|
||||||
}
|
}
|
||||||
@@ -140,25 +151,27 @@ export class ContentNodeSelectorDialogPage {
|
|||||||
await this.clickMoveCopyButton();
|
await this.clickMoveCopyButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
async attachFileFromLocal(fileName: string, fileLocation: string): Promise<void> {
|
async checkFileServerTabIsLoaded(): Promise<void> {
|
||||||
await this.checkDialogIsDisplayed();
|
await this.checkDialogIsDisplayed();
|
||||||
await this.dataTable.waitForTableBody();
|
await this.dataTable.waitForTableBody();
|
||||||
await this.breadcrumbDropdownPage.checkCurrentFolderIsDisplayed();
|
await this.breadcrumbDropdown.checkCurrentFolderIsDisplayed();
|
||||||
|
}
|
||||||
|
|
||||||
|
async attachFilesFromLocal(files: FileModel[]): Promise<void> {
|
||||||
|
await this.checkFileServerTabIsLoaded();
|
||||||
|
|
||||||
await this.tabPage.clickTabByLabel(this.uploadFromLocalTabName);
|
await this.tabPage.clickTabByLabel(this.uploadFromLocalTabName);
|
||||||
|
|
||||||
const uploadButton = element(by.css('adf-upload-button input'));
|
await this.uploadButtonComponent.attachFiles(files);
|
||||||
await BrowserVisibility.waitUntilElementIsPresent(uploadButton);
|
|
||||||
await browser.sleep(500);
|
|
||||||
await uploadButton.sendKeys(fileLocation);
|
|
||||||
|
|
||||||
await this.tabPage.clickTabByLabel(this.repositoryTabName);
|
await this.tabPage.clickTabByLabel(this.repositoryTabName);
|
||||||
|
|
||||||
await this.dataTable.waitForTableBody();
|
await this.dataTable.waitForTableBody();
|
||||||
await this.dataTable.waitTillContentLoaded();
|
await this.dataTable.waitTillContentLoaded();
|
||||||
await this.dataTable.checkRowContentIsDisplayed(fileName);
|
for ( const file of files) {
|
||||||
|
await this.dataTable.checkRowContentIsDisplayed(file.getName());
|
||||||
|
}
|
||||||
|
|
||||||
await this.clickContentNodeSelectorResult(fileName);
|
|
||||||
await this.checkCopyMoveButtonIsEnabled();
|
await this.checkCopyMoveButtonIsEnabled();
|
||||||
await this.clickMoveCopyButton();
|
await this.clickMoveCopyButton();
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,41 @@
|
|||||||
|
/*!
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Alfresco Software, Ltd.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { element, by } from 'protractor';
|
||||||
|
import { BrowserVisibility } from '../../core/utils/browser-visibility';
|
||||||
|
import { FileModel } from '../../core/models/file.model';
|
||||||
|
|
||||||
|
export class UploadButtonPage {
|
||||||
|
|
||||||
|
uploadButton = element(by.css('adf-upload-button input'));
|
||||||
|
|
||||||
|
async attachFiles(files: FileModel[]): Promise<void> {
|
||||||
|
await BrowserVisibility.waitUntilElementIsPresent(this.uploadButton);
|
||||||
|
for ( const file of files) {
|
||||||
|
await this.uploadButton.sendKeys(file.getLocation());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async isButtonNotDisplayed(): Promise<boolean> {
|
||||||
|
try {
|
||||||
|
await BrowserVisibility.waitUntilElementIsNotVisible(this.uploadButton);
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
lib/testing/src/lib/core/models/file.model.ts
Normal file
36
lib/testing/src/lib/core/models/file.model.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
/*!
|
||||||
|
* @license
|
||||||
|
* Copyright 2019 Alfresco Software, Ltd.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { StringUtil } from '../utils/string.util';
|
||||||
|
|
||||||
|
export class FileModel {
|
||||||
|
|
||||||
|
name = StringUtil.generateRandomString();
|
||||||
|
location = StringUtil.generateRandomString();
|
||||||
|
|
||||||
|
constructor(details?: any) {
|
||||||
|
Object.assign(this, details);
|
||||||
|
}
|
||||||
|
|
||||||
|
getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
getLocation() {
|
||||||
|
return this.location;
|
||||||
|
}
|
||||||
|
}
|
@@ -17,4 +17,5 @@
|
|||||||
|
|
||||||
export * from './user.model';
|
export * from './user.model';
|
||||||
export * from './application-model';
|
export * from './application-model';
|
||||||
|
export * from './file.model';
|
||||||
export * from './tenant';
|
export * from './tenant';
|
||||||
|
@@ -15,15 +15,17 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { by, element, browser } from 'protractor';
|
import { by, element } from 'protractor';
|
||||||
import { BrowserActions, BrowserVisibility } from '../../../utils/public-api';
|
import { BrowserActions, BrowserVisibility } from '../../../utils/public-api';
|
||||||
|
|
||||||
export class TabPage {
|
export class TabPage {
|
||||||
|
|
||||||
|
changeTabAnimation = element(by.css('div[class="mat-ripple-element"]'));
|
||||||
|
|
||||||
async clickTabByLabel(tabLabel): Promise<void> {
|
async clickTabByLabel(tabLabel): Promise<void> {
|
||||||
const user = element(by.cssContainingText('.mat-tab-label-content', tabLabel));
|
const user = element(by.cssContainingText('.mat-tab-label-content', tabLabel));
|
||||||
await BrowserActions.click(user);
|
await BrowserActions.click(user);
|
||||||
await browser.sleep(300);
|
await BrowserVisibility.waitUntilElementIsNotVisible(this.changeTabAnimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
async checkTabIsDisplayedByLabel(tabLabel): Promise<void> {
|
async checkTabIsDisplayedByLabel(tabLabel): Promise<void> {
|
||||||
|
@@ -32,14 +32,6 @@ export class AttachFileWidgetCloudPage {
|
|||||||
this.widget = element(by.css(`adf-form-field div[id='field-${fieldId}-container']`));
|
this.widget = element(by.css(`adf-form-field div[id='field-${fieldId}-container']`));
|
||||||
}
|
}
|
||||||
|
|
||||||
async attachLocalFile(fileLocation: string): Promise<void> {
|
|
||||||
const uploadButton = element(by.css('adf-upload-button input'));
|
|
||||||
await BrowserVisibility.waitUntilElementIsPresent(uploadButton);
|
|
||||||
await uploadButton.sendKeys(fileLocation);
|
|
||||||
await BrowserActions.click(uploadButton);
|
|
||||||
await BrowserVisibility.waitUntilElementIsPresent(uploadButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
async clickAttachContentFile(fileId: string): Promise<void> {
|
async clickAttachContentFile(fileId: string): Promise<void> {
|
||||||
const uploadButton = this.widget.element(by.css(`button[id=${fileId}]`));
|
const uploadButton = this.widget.element(by.css(`button[id=${fileId}]`));
|
||||||
await BrowserActions.click(uploadButton);
|
await BrowserActions.click(uploadButton);
|
||||||
@@ -60,6 +52,12 @@ export class AttachFileWidgetCloudPage {
|
|||||||
await BrowserVisibility.waitUntilElementIsVisible(fileAttached);
|
await BrowserVisibility.waitUntilElementIsVisible(fileAttached);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async checkFilesAreAttached(filesName: string[]): Promise<void> {
|
||||||
|
for (const fileName of filesName) {
|
||||||
|
await this.checkFileIsAttached(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async checkFileIsNotAttached(name): Promise<void> {
|
async checkFileIsNotAttached(name): Promise<void> {
|
||||||
const fileAttached = this.widget.element(this.filesListLocator).element(by.cssContainingText('mat-list-item span ', name));
|
const fileAttached = this.widget.element(this.filesListLocator).element(by.cssContainingText('mat-list-item span ', name));
|
||||||
await BrowserVisibility.waitUntilElementIsNotVisible(fileAttached);
|
await BrowserVisibility.waitUntilElementIsNotVisible(fileAttached);
|
||||||
|
Reference in New Issue
Block a user