Skip to content

Commit

Permalink
Merge pull request #481 from Satellite-im/luis/send-files
Browse files Browse the repository at this point in the history
  • Loading branch information
luisecm authored Oct 5, 2023
2 parents d5d2e4a + adafed4 commit c237259
Show file tree
Hide file tree
Showing 7 changed files with 301 additions and 40 deletions.
87 changes: 62 additions & 25 deletions tests/screenobjects/chats/ComposeAttachment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const SELECTORS_WINDOWS = {
COMPOSE_ATTACHMENTS_FILE_META: '[name="file-meta"]',
COMPOSE_ATTACHMENTS_FILE_NAME: '[name="file-name"]',
COMPOSE_ATTACHMENTS_FILE_NAME_TEXT: "<Text>",
COMPOSE_ATTACHMENTS_INPUT_ERROR: '[name="input-error"]',
COMPOSE_ATTACHMENTS_INPUT_ERROR_TEXT: "<Text>",
};

const SELECTORS_MACOS = {
Expand All @@ -28,6 +30,9 @@ const SELECTORS_MACOS = {
COMPOSE_ATTACHMENTS_FILE_NAME: "~file-name",
COMPOSE_ATTACHMENTS_FILE_NAME_TEXT:
"-ios class chain:**/XCUIElementTypeStaticText",
COMPOSE_ATTACHMENTS_INPUT_ERROR: "~input-error",
COMPOSE_ATTACHMENTS_INPUT_ERROR_TEXT:
"-ios class chain:**/XCUIElementTypeStaticText",
};

currentOS === WINDOWS_DRIVER
Expand All @@ -44,58 +49,76 @@ export default class ComposeAttachments extends UplinkMainScreen {
}

get composeAttachmentsButton() {
return this.instance
.$(SELECTORS.COMPOSE_ATTACHMENTS)
.$(SELECTORS.COMPOSE_ATTACHMENTS_BUTTON);
return this.composeAttachments.$(SELECTORS.COMPOSE_ATTACHMENTS_BUTTON);
}

get composeAttachmentsFileEmbed() {
return this.instance
.$(SELECTORS.COMPOSE_ATTACHMENTS)
.$(SELECTORS.COMPOSE_ATTACHMENTS_FILE_EMBED);
return this.composeAttachments.$(SELECTORS.COMPOSE_ATTACHMENTS_FILE_EMBED);
}

get composeAttachmentsFileIcon() {
return this.instance
.$(SELECTORS.COMPOSE_ATTACHMENTS)
.$(SELECTORS.COMPOSE_ATTACHMENTS_FILE_EMBED)
.$(SELECTORS.COMPOSE_ATTACHMENTS_FILE_ICON);
return this.composeAttachmentsFileEmbed.$(
SELECTORS.COMPOSE_ATTACHMENTS_FILE_ICON
);
}

get composeAttachmentsFileInfo() {
return this.instance
.$(SELECTORS.COMPOSE_ATTACHMENTS)
.$(SELECTORS.COMPOSE_ATTACHMENTS_FILE_EMBED)
.$(SELECTORS.COMPOSE_ATTACHMENTS_FILE_INFO);
return this.composeAttachmentsFileEmbed.$(
SELECTORS.COMPOSE_ATTACHMENTS_FILE_INFO
);
}

get composeAttachmentsFileMeta() {
return this.instance
.$(SELECTORS.COMPOSE_ATTACHMENTS)
.$(SELECTORS.COMPOSE_ATTACHMENTS_FILE_EMBED)
.$(SELECTORS.COMPOSE_ATTACHMENTS_FILE_META);
return this.composeAttachmentsFileEmbed.$(
SELECTORS.COMPOSE_ATTACHMENTS_FILE_META
);
}

get composeAttachmentsFileName() {
return this.instance
.$(SELECTORS.COMPOSE_ATTACHMENTS)
.$(SELECTORS.COMPOSE_ATTACHMENTS_FILE_EMBED)
.$(SELECTORS.COMPOSE_ATTACHMENTS_FILE_NAME);
return this.composeAttachmentsFileEmbed.$(
SELECTORS.COMPOSE_ATTACHMENTS_FILE_NAME
);
}

get composeAttachmentsFileNameText() {
return this.instance
.$(SELECTORS.COMPOSE_ATTACHMENTS)
.$(SELECTORS.COMPOSE_ATTACHMENTS_FILE_EMBED)
return this.composeAttachmentsFileEmbed
.$(SELECTORS.COMPOSE_ATTACHMENTS_FILE_NAME)
.$(SELECTORS.COMPOSE_ATTACHMENTS_FILE_NAME_TEXT);
}

get composeAttachmentsInputError() {
return this.composeAttachments.$(SELECTORS.COMPOSE_ATTACHMENTS_INPUT_ERROR);
}

get composeAttachmentsInputErrorText() {
return this.composeAttachmentsInputError.$(
SELECTORS.COMPOSE_ATTACHMENTS_INPUT_ERROR_TEXT
);
}

async deleteFileOnComposeAttachment() {
const composeAttachmentsButton = await this.composeAttachmentsButton;
await composeAttachmentsButton.click();
}

async getListOfAttachmentsEmbed() {
const composeAttachments = await this.composeAttachments;
await composeAttachments.waitForExist();
const filesAttached = await this.instance.$$(
SELECTORS.COMPOSE_ATTACHMENTS_FILE_EMBED
);
let results = [];
for (let fileAttached of filesAttached) {
const fileName = await fileAttached
.$(SELECTORS.COMPOSE_ATTACHMENTS_FILE_INFO)
.$(SELECTORS.COMPOSE_ATTACHMENTS_FILE_NAME)
.$(SELECTORS.COMPOSE_ATTACHMENTS_FILE_NAME_TEXT);
const fileNameText = await fileName.getText();
results.push(fileNameText);
}
return results;
}

async validateAttachmentIsAdded() {
const composeAttachmentsFileEmbed = await this.composeAttachmentsFileEmbed;
await driver[this.executor].waitUntil(
Expand All @@ -108,4 +131,18 @@ export default class ComposeAttachments extends UplinkMainScreen {
}
);
}

async validateAttachmentWithFileNameIsAdded(
fileName: string,
expectedAssertion: boolean
) {
const attachmentsList = await this.getListOfAttachmentsEmbed();
const includesAttachment = await attachmentsList.includes(fileName);
await expect(includesAttachment).toEqual(expectedAssertion);
}

async validateComposeAttachmentsIsShown() {
const composeAttachments = await this.composeAttachments;
await composeAttachments.waitForExist();
}
}
10 changes: 10 additions & 0 deletions tests/screenobjects/chats/InputBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ export default class InputBar extends UplinkMainScreen {
await uploadButtonLocalDisk.click();
}

async selectUploadFromStorage() {
const uploadButtonStorage = await this.uploadButtonStorage;
await uploadButtonStorage.click();
}

async typeCodeOnInputBar(language: string, codeToType: string) {
const inputText = await this.inputText;
await inputText.clearValue();
Expand Down Expand Up @@ -246,4 +251,9 @@ export default class InputBar extends UplinkMainScreen {
await selectFileOnWindows(relativePath, uplinkContext, executor);
}
}

async openUploadFilesFromStorage() {
await this.clickOnUploadFile();
await this.selectUploadFromStorage();
}
}
19 changes: 10 additions & 9 deletions tests/screenobjects/chats/Messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,10 @@ export default class Messages extends UplinkMainScreen {

async getLastMessageReceivedCodeLanguage() {
const message = await this.getLastMessageReceivedLocator();
const messageCodeLanguage = await message
.$(SELECTORS.CHAT_MESSAGE_TEXT_GROUP)
.$(SELECTORS.CHAT_MESSAGE_CODE_LANGUAGE);
await messageCodeLanguage.waitForExist();
const messageText = await message.$(SELECTORS.CHAT_MESSAGE_TEXT_GROUP);
const messageCodeLanguage = await messageText.$(
SELECTORS.CHAT_MESSAGE_CODE_LANGUAGE
);
return messageCodeLanguage;
}

Expand Down Expand Up @@ -592,9 +592,10 @@ export default class Messages extends UplinkMainScreen {

async getLastMessageSentCodeLanguage() {
const message = await this.getLastMessageSentLocator();
const messageCodeLanguage = await message
.$(SELECTORS.CHAT_MESSAGE_TEXT_GROUP)
.$(SELECTORS.CHAT_MESSAGE_CODE_LANGUAGE);
const messageText = await message.$(SELECTORS.CHAT_MESSAGE_TEXT_GROUP);
const messageCodeLanguage = await messageText.$(
SELECTORS.CHAT_MESSAGE_CODE_LANGUAGE
);
await messageCodeLanguage.waitForExist();
return messageCodeLanguage;
}
Expand Down Expand Up @@ -799,7 +800,7 @@ export default class Messages extends UplinkMainScreen {
const lastMessageLinkEmbed = await lastMessage.$(
SELECTORS.CHAT_MESSAGE_LINK_EMBED
);
await lastMessageLinkEmbed.waitForExist();
await lastMessageLinkEmbed.waitForExist({ timeout: 30000 });
return lastMessageLinkEmbed;
}

Expand Down Expand Up @@ -836,7 +837,7 @@ export default class Messages extends UplinkMainScreen {
const lastMessageLinkEmbed = await lastMessage.$(
SELECTORS.CHAT_MESSAGE_LINK_EMBED
);
await lastMessageLinkEmbed.waitForExist();
await lastMessageLinkEmbed.waitForExist({ timeout: 30000 });
return lastMessageLinkEmbed;
}

Expand Down
65 changes: 64 additions & 1 deletion tests/screenobjects/chats/SendFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ let SELECTORS = {};
const SELECTORS_COMMON = {};

const SELECTORS_WINDOWS = {
CLOSE_BUTTON: "<Button>",
CLOSE_BUTTON_MODAL: '[name="modal"]',
CONTEXT_MENU: '[name="Context Menu"]',
CONTEXT_MENU_FILES_RENAME: '[name="files-rename"]',
CONTEXT_MENU_FOLDER_DELETE: '[name="folder-delete"]',
CONTEXT_MENU_FOLDER_RENAME: '[name="folder-rename"]',
FILE_FOLDER_NAME_TEXT: "//Text/Text",
FILE_THUMBNAIL: "<Image>",
FILES_BREADCRUMBS: '[name="files-breadcrumbs"]',
FILES_CRUMB: '[name="crumb"]',
FILES_CRUMB_TEXT: "<Text>",
Expand All @@ -28,18 +31,22 @@ const SELECTORS_WINDOWS = {
GO_TO_FILES_BUTTON: '[name="go_to_files_btn"]',
HOME_DIR: '[name="home-dir"]',
HOME_DIR_TEXT: '[name="Home"]',
NO_FILES_AVAILABLE: "//Text/Text",
SEND_FILES_BODY: '[name="send-files-body"]',
SEND_FILES_LAYOUT: '[name="send-files-layout"]',
SEND_FILES_MODAL_SEND_BUTTON: '[name="send_files_modal_send_button"]',
};

const SELECTORS_MACOS = {
CLOSE_BUTTON: "-ios class chain:**/XCUIElementTypeButton",
CLOSE_BUTTON_MODAL: "~modal",
CONTEXT_MENU: "~Context Menu",
CONTEXT_MENU_FILES_RENAME: "~files-rename",
CONTEXT_MENU_FOLDER_DELETE: "~folder-delete",
CONTEXT_MENU_FOLDER_RENAME: "~folder-rename",
FILE_FOLDER_NAME_TEXT:
"-ios class chain:**/XCUIElementTypeStaticText/XCUIElementTypeStaticText",
FILE_THUMBNAIL: "-ios class chain:**/XCUIElementTypeImage",
FILES_BREADCRUMBS: "~files-breadcrumbs",
FILES_CRUMB: "~crumb",
FILES_CRUMB_TEXT: "-ios class chain:**/XCUIElementTypeStaticText",
Expand All @@ -50,6 +57,8 @@ const SELECTORS_MACOS = {
INPUT_ERROR: "~input-error",
INPUT_ERROR_TEXT: "-ios class chain:**/XCUIElementTypeStaticText",
INPUT_FOLDER_FILE_NAME: "-ios class chain:**/XCUIElementTypeTextField",
NO_FILES_AVAILABLE:
"-ios class chain:**/XCUIElementTypeStaticText/XCUIElementTypeStaticText",
SEND_FILES_BODY: "~send-files-body",
SEND_FILES_LAYOUT: "~send-files-layout",
SEND_FILES_MODAL_SEND_BUTTON: "~send_files_modal_send_button",
Expand All @@ -64,6 +73,14 @@ export default class SendFiles extends UplinkMainScreen {
super(executor, SELECTORS.SEND_FILES_LAYOUT);
}

get closeButton() {
return this.closeButtonModal.$(SELECTORS.CLOSE_BUTTON);
}

get closeButtonModal() {
return this.instance.$(SELECTORS.CLOSE_BUTTON_MODAL);
}

get contextMenu() {
return this.instance.$(SELECTORS.CONTEXT_MENU);
}
Expand All @@ -84,6 +101,10 @@ export default class SendFiles extends UplinkMainScreen {
return this.sendFilesBody.$(SELECTORS.FILE_FOLDER_NAME_TEXT);
}

get fileThumbnail() {
return this.sendFilesBody.$(SELECTORS.FILE_THUMBNAIL);
}

get filesBreadcrumbs() {
return this.sendFilesBody.$(SELECTORS.FILES_BREADCRUMBS);
}
Expand Down Expand Up @@ -124,6 +145,10 @@ export default class SendFiles extends UplinkMainScreen {
return this.sendFilesBody.$(SELECTORS.INPUT_FOLDER_FILE_NAME);
}

get noFilesAvailable() {
return this.sendFilesBody.$(SELECTORS.NO_FILES_AVAILABLE);
}

get sendFilesBody() {
return this.sendFilesLayout.$(SELECTORS.SEND_FILES_BODY);
}
Expand All @@ -136,9 +161,16 @@ export default class SendFiles extends UplinkMainScreen {
return this.sendFilesBody.$(SELECTORS.SEND_FILES_MODAL_SEND_BUTTON);
}

async clickOnCloseModal() {
const closeButton = await this.closeButton;
await closeButton.click();
}

async clickOnFileOrFolder(locator: string) {
const fileOrFolderLocator = await this.getLocatorOfFolderFile(locator);
const fileOrFolderElement = await this.instance.$(fileOrFolderLocator);
const fileOrFolderElement = await this.instance
.$(fileOrFolderLocator)
.$(SELECTORS.FILE_THUMBNAIL);
await fileOrFolderElement.click();
}

Expand Down Expand Up @@ -168,6 +200,18 @@ export default class SendFiles extends UplinkMainScreen {
await sendFilesButton.click();
}

async getValueFromSendFilesButton() {
const currentDriver = await this.getCurrentDriver();
const sendFilesModalSendButton = await this.sendFilesModalSendButton;
let result;
if (currentDriver === WINDOWS_DRIVER) {
result = await sendFilesModalSendButton.getAttribute("HelpText");
} else {
result = await sendFilesModalSendButton.getAttribute("placeholderValue");
}
return result.toString();
}

async typeOnFileFolderNameInput(name: string) {
const inputFolderFileName = await this.inputFolderFileName;
await inputFolderFileName.waitForExist();
Expand Down Expand Up @@ -236,11 +280,30 @@ export default class SendFiles extends UplinkMainScreen {
await this.instance.$(fileFolderLocator).waitForExist({ reverse: true });
}

async validateNoFilesAvailableIsShown() {
const noFilesAvailable = await this.noFilesAvailable;
await noFilesAvailable.waitForExist();
await expect(noFilesAvailable).toHaveTextContaining("NO FILES AVAILABLE.");
}

async validateSendFilesButtonText(expectedText: string) {
await this.getValueFromSendFilesButton().then((value) => {
expect(value).toEqual(expectedText);
});
}

async validateSendFilesModalIsShown() {
const filesBody = await this.sendFilesLayout;
await filesBody.waitForExist();
}

async validateThumbnailIsShown(name: string) {
const fileElementLocator = await this.getLocatorOfFolderFile(name);
const fileElement = await this.instance.$(fileElementLocator);
const fileThumbnail = await fileElement.$(SELECTORS.FILE_THUMBNAIL);
await fileThumbnail.waitForExist();
}

// Context Menu methods

async openFilesContextMenu(name: string) {
Expand Down
6 changes: 6 additions & 0 deletions tests/screenobjects/files/FilesScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,12 @@ export default class FilesScreen extends UplinkMainScreen {
const filesInfoCurrentSizeLabel = await this.filesInfoCurrentSizeLabel;
await inputFolderFileName.waitForExist();
await inputFolderFileName.setValue(name);
// Retry typing if appium fails on type
const inputValue = await inputFolderFileName.getText();
if (inputValue !== name) {
await this.createFolder(name);
}
// If name was typed correctly, continue with method execution
await filesInfoCurrentSizeLabel.click();
const newFolder = await this.getLocatorOfFolderFile(name);
const newFolderElement = await this.instance.$(newFolder);
Expand Down
Loading

0 comments on commit c237259

Please sign in to comment.