Skip to content

Commit

Permalink
Merge pull request #532 from Satellite-im/luis/attachement
Browse files Browse the repository at this point in the history
  • Loading branch information
luisecm authored Nov 24, 2023
2 parents 73e29aa + e6df9ef commit 968c97a
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 55 deletions.
55 changes: 45 additions & 10 deletions tests/screenobjects/chats/ComposeAttachment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,37 @@ const SELECTORS_WINDOWS = {
COMPOSE_ATTACHMENTS_BUTTON: '[name="attachment-button"]',
COMPOSE_ATTACHMENTS_FILE_EMBED: '[name="file-embed"]',
COMPOSE_ATTACHMENTS_FILE_ICON: '[name="file-icon"]',
COMPOSE_ATTACHMENTS_FILE_ICON_VALUE: "//Group/Text",
COMPOSE_ATTACHMENTS_FILE_INFO: '[name="file-info"]',
COMPOSE_ATTACHMENTS_FILE_META: '[name="file-meta"]',
COMPOSE_ATTACHMENTS_FILE_NAME: '[name="file-name"]',
COMPOSE_ATTACHMENTS_FILE_NAME_TEXT: "<Text>",
COMPOSE_ATTACHMENTS_IMAGE_PREVIEW_MODAL: '[name="image-preview-modal"]',
COMPOSE_ATTACHMENTS_INPUT_ERROR: '[name="input-error"]',
COMPOSE_ATTACHMENTS_INPUT_ERROR_TEXT: "<Text>",
COMPOSE_ATTACHMENTS_MESSAGE_IMAGE: '[name="message-image"]',
COMPOSE_ATTACHMENTS_MESSAGE_IMAGE_CONTAINER:
'[name="message-image-container"]',
};

const SELECTORS_MACOS = {
COMPOSE_ATTACHMENTS: "~compose-attachments",
COMPOSE_ATTACHMENTS_BUTTON: "~attachment-button",
COMPOSE_ATTACHMENTS_FILE_EMBED: "~file-embed",
COMPOSE_ATTACHMENTS_FILE_ICON: "~file-icon",
COMPOSE_ATTACHMENTS_FILE_ICON_VALUE:
"-ios class chain:**/XCUIElementTypeGroup/XCUIElementTypeStaticText/XCUIElementTypeStaticText",
COMPOSE_ATTACHMENTS_FILE_INFO: "~file-info",
COMPOSE_ATTACHMENTS_FILE_META: "~file-meta",
COMPOSE_ATTACHMENTS_FILE_NAME: "~file-name",
COMPOSE_ATTACHMENTS_FILE_NAME_TEXT:
"-ios class chain:**/XCUIElementTypeStaticText",
COMPOSE_ATTACHMENTS_IMAGE_PREVIEW_MODAL: "~image-preview-modal",
COMPOSE_ATTACHMENTS_INPUT_ERROR: "~input-error",
COMPOSE_ATTACHMENTS_INPUT_ERROR_TEXT:
"-ios class chain:**/XCUIElementTypeStaticText",
COMPOSE_ATTACHMENTS_MESSAGE_IMAGE: "~message-image",
COMPOSE_ATTACHMENTS_MESSAGE_IMAGE_CONTAINER: "~message-image-container",
};

currentOS === WINDOWS_DRIVER
Expand All @@ -58,25 +68,31 @@ export default class ComposeAttachments extends UplinkMainScreen {

get composeAttachmentsFileIcon() {
return this.composeAttachmentsFileEmbed.$(
SELECTORS.COMPOSE_ATTACHMENTS_FILE_ICON
SELECTORS.COMPOSE_ATTACHMENTS_FILE_ICON,
);
}

get composeAttachmentsFileIconValue() {
return this.composeAttachmentsFileIcon.$(
SELECTORS.COMPOSE_ATTACHMENTS_FILE_ICON_VALUE,
);
}

get composeAttachmentsFileInfo() {
return this.composeAttachmentsFileEmbed.$(
SELECTORS.COMPOSE_ATTACHMENTS_FILE_INFO
SELECTORS.COMPOSE_ATTACHMENTS_FILE_INFO,
);
}

get composeAttachmentsFileMeta() {
return this.composeAttachmentsFileEmbed.$(
SELECTORS.COMPOSE_ATTACHMENTS_FILE_META
SELECTORS.COMPOSE_ATTACHMENTS_FILE_META,
);
}

get composeAttachmentsFileName() {
return this.composeAttachmentsFileEmbed.$(
SELECTORS.COMPOSE_ATTACHMENTS_FILE_NAME
SELECTORS.COMPOSE_ATTACHMENTS_FILE_NAME,
);
}

Expand All @@ -86,23 +102,42 @@ export default class ComposeAttachments extends UplinkMainScreen {
.$(SELECTORS.COMPOSE_ATTACHMENTS_FILE_NAME_TEXT);
}

get composeAttachmentsImagePreviewModal() {
return this.composeAttachmentsFileEmbed.$(
SELECTORS.COMPOSE_ATTACHMENTS_IMAGE_PREVIEW_MODAL,
);
}

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

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

get composeAttachmentsMessageImage() {
return this.composeAttachmentsMessageImageContainer.$(
SELECTORS.COMPOSE_ATTACHMENTS_MESSAGE_IMAGE,
);
}

get composeAttachmentsMessageImageContainer() {
return this.composeAttachmentsFileEmbed.$(
SELECTORS.COMPOSE_ATTACHMENTS_MESSAGE_IMAGE_CONTAINER,
);
}

async clickOnDeleteAttachment(attachment: number) {
// Get the locator of attachment to delete by passing the index
const attachmentToDelete = await this.instance.$$(
SELECTORS.COMPOSE_ATTACHMENTS_FILE_EMBED
SELECTORS.COMPOSE_ATTACHMENTS_FILE_EMBED,
)[attachment];
await this.hoverOnElement(attachmentToDelete);
const deleteAttachmentButton = await attachmentToDelete.$(
SELECTORS.COMPOSE_ATTACHMENTS_BUTTON
SELECTORS.COMPOSE_ATTACHMENTS_BUTTON,
);
await deleteAttachmentButton.click();
}
Expand All @@ -116,7 +151,7 @@ export default class ComposeAttachments extends UplinkMainScreen {
const composeAttachments = await this.composeAttachments;
await composeAttachments.waitForExist();
const filesAttached = await this.instance.$$(
SELECTORS.COMPOSE_ATTACHMENTS_FILE_EMBED
SELECTORS.COMPOSE_ATTACHMENTS_FILE_EMBED,
);
let results = [];
for (let fileAttached of filesAttached) {
Expand All @@ -139,13 +174,13 @@ export default class ComposeAttachments extends UplinkMainScreen {
{
timeout: 15000,
timeoutMsg: "Attachment file was not added after 15 seconds",
}
},
);
}

async validateAttachmentWithFileNameIsAdded(
fileName: string,
expectedAssertion: boolean
expectedAssertion: boolean,
) {
const attachmentsList = await this.getListOfAttachmentsEmbed();
const includesAttachment = await attachmentsList.includes(fileName);
Expand Down
12 changes: 6 additions & 6 deletions tests/screenobjects/chats/InputBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ export default class InputBar extends UplinkMainScreen {

async pressEnterKeyOnInputBar() {
const currentDriver = await this.getCurrentDriver();
let enterValue;
currentDriver === WINDOWS_DRIVER
? (enterValue = "\uE007")
: (enterValue = "\n");
const inputText = await this.inputText;
await inputText.addValue(enterValue);
if (currentDriver === WINDOWS_DRIVER) {
const inputText = await this.inputText;
await inputText.addValue("\uE007");
} else {
await this.clickOnSendMessage();
}
}

async selectUploadFromLocalDisk() {
Expand Down
3 changes: 2 additions & 1 deletion tests/screenobjects/chats/PinnedMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ const SELECTORS_MACOS = {
"-ios class chain:**/XCUIElementTypeStaticText/XCUIElementTypeStaticText",
PINNED_MESSAGE_ATTACHMENTS_FILE_INFO: "~file-info",
PINNED_MESSAGE_ATTACHMENTS_FILE_META: "~file-meta",
PINNED_MESSAGE_ATTACHMENTS_FILE_META_TEXT: "<Text>",
PINNED_MESSAGE_ATTACHMENTS_FILE_META_TEXT:
"-ios class chain:**/XCUIElementTypeStaticText",
PINNED_MESSAGE_ATTACHMENTS_FILE_NAME: "~file-name",
PINNED_MESSAGE_ATTACHMENTS_FILE_NAME_TEXT:
"-ios class chain:**/XCUIElementTypeStaticText",
Expand Down
32 changes: 20 additions & 12 deletions tests/screenobjects/chats/SendFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ const SELECTORS_MACOS = {
FILES_LIST: "~files-list",
GO_TO_FILES_BUTTON: "~go_to_files_btn",
HOME_DIR: "~home-dir",
HOME_DIR_TEXT: "~Home",
HOME_DIR_TEXT:
'-ios class chain:**/XCUIElementTypeStaticText[`value == "Home"`]',
INPUT_ERROR: "~input-error",
INPUT_ERROR_TEXT: "-ios class chain:**/XCUIElementTypeStaticText",
INPUT_FILE_NAME: '[name="file-name-input"]',
Expand Down Expand Up @@ -172,12 +173,18 @@ export default class SendFiles extends UplinkMainScreen {
await closeButton.click();
}

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

async clickOnFolder(locator: string) {
const folderLocator = await this.getLocatorOfFolderFile(locator);
const folderElement = await this.instance.$(folderLocator);
await folderElement.click();
}

async clickOnFolderCrumb(folderName: string) {
Expand Down Expand Up @@ -212,8 +219,6 @@ export default class SendFiles extends UplinkMainScreen {
let result;
if (currentDriver === WINDOWS_DRIVER) {
result = await sendFilesModalSendButton.getAttribute("HelpText");
} else {
result = await sendFilesModalSendButton.getAttribute("placeholderValue");
}
return result.toString();
}
Expand All @@ -234,7 +239,7 @@ export default class SendFiles extends UplinkMainScreen {
const folders = await this.filesCrumb;
const treeLength = folders.length - 1;
const currentFolderName = await folders[treeLength].$(
SELECTORS.FILES_CRUMB_TEXT
SELECTORS.FILES_CRUMB_TEXT,
);
const currentFolderNameText = await currentFolderName.getText();
return currentFolderNameText;
Expand Down Expand Up @@ -306,9 +311,12 @@ export default class SendFiles extends UplinkMainScreen {
}

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

async validateSendFilesModalIsShown() {
Expand Down
10 changes: 4 additions & 6 deletions tests/specs/reusable-accounts/05-message-attachments.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,10 @@ export default async function messageAttachmentsTests() {
await sendFilesFirstUser.validateThumbnailIsShown("banner.jpg");
});

// Skipping test because it takes too much time for execution
xit("Send files from Browse Files - User can navigate through folders and to home", async () => {
it("Send files from Browse Files - User can navigate through folders and to home", async () => {
// Navigate to testfolder01 and ensure thumbnail from testfile.txt is shown
await sendFilesFirstUser.clickOnFileOrFolder("testfolder01");
await sendFilesFirstUser.clickOnFolder("testfolder01");
await filesScreenFirstUser.validateFileOrFolderExist("testfile.txt");
await sendFilesFirstUser.validateThumbnailIsShown("testfile.txt");

// Navigate to home folder and ensure thumbnail from banner.jpg is shown
await sendFilesFirstUser.clickOnHomeFolderCrumb();
Expand Down Expand Up @@ -98,7 +96,7 @@ export default async function messageAttachmentsTests() {

it("Send files from Browse Files - Send files counter is updated", async () => {
// Select one file from root folder and ensure Send Files button displays 1/8 File(s)
await sendFilesFirstUser.clickOnFileOrFolder("banner.jpg");
await sendFilesFirstUser.clickOnFile("banner.jpg");
await sendFilesFirstUser.validateSendFilesButtonText("Send 1/8 File(s)");
});

Expand Down Expand Up @@ -161,7 +159,7 @@ export default async function messageAttachmentsTests() {

it("Send Files on Chats - Delete attachment before sending the message", async () => {
// Click on upload button and attach a file to compose attachment
await chatsAttachmentFirstUser.deleteFileOnComposeAttachment();
await chatsAttachmentFirstUser.clickOnDeleteAttachment(0);
});

it("Send File from Add Files - Select a file and send message with attachment", async () => {
Expand Down
25 changes: 6 additions & 19 deletions tests/specs/reusable-accounts/06-chat-topbar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,9 @@ let chatsTopbarFirstUser = new Topbar(USER_A_INSTANCE);
let pinnedMessagesFirstUser = new PinnedMessages(USER_A_INSTANCE);

export default async function chatTopbarTests() {
it("Chat User B - Send a message to Chat User A", async () => {
// Send a message to Chat User A
await chatsInputFirstUser.typeMessageOnInput("Temp...");
await chatsInputFirstUser.clickOnSendMessage();
await chatsMessagesFirstUser.waitForMessageSentToExist("Temp...");
});

it("Chat User A - Receive message from Chat User B", async () => {
// Assert message received from Chat User A
await activateFirstApplication();
await chatsMessagesFirstUser.waitForReceivingMessage("Temp...");
});

it("Chat User A - Validate Chat Screen tooltips are displayed", async () => {
// Validate Favorites button tooltip
await activateFirstApplication();
await chatsTopbarFirstUser.hoverOnFavoritesButton();
const favoritesAddTooltipText =
await chatsTopbarFirstUser.topbarAddToFavoritesTooltipText;
Expand Down Expand Up @@ -82,12 +70,12 @@ export default async function chatTopbarTests() {

it("Pinned Messages - Pin a message with attachments", async () => {
// Look for the latest message received by User A, open context menu and pin message
await chatsMessagesFirstUser.openContextMenuOnLastReceived();
await chatsMessagesFirstUser.openContextMenuOnLastSent();
await chatsContextMenuFirstUser.validateContextMenuIsOpen();
await chatsContextMenuFirstUser.selectContextOptionPin();

// Ensure that message shows a pin indicator
await chatsMessageGroupsFirstUser.validateLastMessageReceivedHasPinIndicator();
await chatsMessageGroupsFirstUser.validateLastMessageSentHasPinIndicator();
});

it("Pinned Messages - Pinned message shows timestamp, sender and message", async () => {
Expand All @@ -98,12 +86,11 @@ export default async function chatTopbarTests() {
// Validate pinned message shows timestamp, sender and message
await pinnedMessagesFirstUser.validateFirstPinnedMessageImageProfileIsShown();
await pinnedMessagesFirstUser.validateFirstPinnedMessageTimestampIsShown();
await pinnedMessagesFirstUser.validateFirstPinnedMessageSender("ChatUserB");
await pinnedMessagesFirstUser.validateFirstPinnedMessageText("Temp...");
await pinnedMessagesFirstUser.validateFirstPinnedMessageSender("ChatUserA");
await pinnedMessagesFirstUser.validateFirstPinnedMessageText("Attached2");
});

// Skipping due to issue with Upload files button
xit("Pinned Messages - Pinned message with attachment shows icon, extension, filename and metadata", async () => {
it("Pinned Messages - Pinned message with attachment shows icon, extension, filename and metadata", async () => {
// Validate attachment elements are shown in pinned message
await pinnedMessagesFirstUser.validateFirstPinnedMessageAttachmentFileIcon();
await pinnedMessagesFirstUser.validateFirstPinnedMessageAttachmentFileIconExtension(
Expand Down
2 changes: 1 addition & 1 deletion tests/suites/Chats/01-Chats.suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe("MacOS Chats Tests", function () {
describe("Chat Replies Tests", repliesTests.bind(this));
describe("Message Context Menu Tests", messageContextMenuTests.bind(this));
describe("Message Input Tests", messageInputTests.bind(this));
xdescribe("Message Attachments Tests", messageAttachmentsTests.bind(this));
describe("Message Attachments Tests", messageAttachmentsTests.bind(this));
describe("Chat Topbar Tests", chatTopbarTests.bind(this));
describe("Quick Profile Tests", quickProfileTests.bind(this));
describe("Sidebar Chats Tests", sidebarChatsTests.bind(this));
Expand Down

0 comments on commit 968c97a

Please sign in to comment.