Skip to content

Commit

Permalink
Add missing is existing check
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalKinas committed Nov 3, 2023
1 parent 4c9ab0d commit 87bd5fd
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions e2e/protractor/suites/actions/copy-move/copy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,15 +246,24 @@ describe('Copy content', () => {
undoCopyFolderWithExistingName(folderExisting, destinationPF));
});

async function baseCopy(itemName: string | string[], location: string, destination: string, undo = false, expectedMsg = 'Copied 1 item') {
async function baseCopy(
itemName: string | string[],
location: string,
destination: string,
undo = false,
isExisting = false,
expectedMsg = 'Copied 1 item'
) {
if (itemName instanceof Array) {
await dataTable.selectMultipleItems(itemName, location);
} else {
await dataTable.selectItem(itemName, location);
}
await toolbar.clickMoreActionsCopy();
await copyDialog.selectLocation('Personal Files');
await copyDialog.dataTable.doubleClickOnRowByName(source);
if (isExisting) {
await copyDialog.dataTable.doubleClickOnRowByName(source);
}
await copyDialog.selectDestination(destination);
await BrowserActions.click(copyDialog.copyButton);
const msg = await page.getSnackBarMessage();
Expand All @@ -280,7 +289,7 @@ describe('Copy content', () => {
if (doBefore) {
doBefore();
}
await baseCopy(itemName, location, destination, undo, expectedMsg);
await baseCopy(itemName, location, destination, undo, false, expectedMsg);
}

async function baseCopyDoBeforeAsync(
Expand All @@ -289,12 +298,13 @@ describe('Copy content', () => {
destination: string,
doBefore?: () => Promise<void>,
undo?: boolean,
isExisting?: boolean,
expectedMsg?: string
) {
if (doBefore) {
await doBefore();
}
await baseCopy(itemName, location, destination, undo, expectedMsg);
await baseCopy(itemName, location, destination, undo, isExisting, expectedMsg);
}

async function copyFile(fileName: string, destination: string, location = '', doBefore?: () => void) {
Expand Down Expand Up @@ -426,7 +436,7 @@ describe('Copy content', () => {
}

async function undoCopyFileWithExistingName(fileName: string, destination: string, location = '', doBefore?: () => Promise<void>) {
await baseCopyDoBeforeAsync(fileName, location, destination, doBefore, true);
await baseCopyDoBeforeAsync(fileName, location, destination, doBefore, true, true);
await dataTable.doubleClickOnRowByName(source);
await dataTable.doubleClickOnRowByName(folder2);
expect(await dataTable.isItemPresent(fileInFolder2)).toBe(true, `${fileInFolder2} not present in ${destination} folder`);
Expand Down

0 comments on commit 87bd5fd

Please sign in to comment.