Skip to content

Link preview test #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions tests/automation/linked_device_user.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable no-await-in-loop */
import { Page, expect } from '@playwright/test';
import { englishStrippedStr } from '../locale/localizedString';
import { sleepFor } from '../promise_utils';
import { forceCloseAllWindows } from './setup/closeWindows';
import { newUser } from './setup/new_user';
Expand All @@ -18,7 +19,6 @@ import {
clickOnTestIdWithText,
clickOnTextMessage,
doWhileWithMax,
doesElementExist,
hasElementBeenDeleted,
hasTextMessageBeenDeleted,
typeIntoInput,
Expand All @@ -28,7 +28,6 @@ import {
waitForTestIdWithText,
waitForTextMessage,
} from './utilities/utils';
import { englishStrippedStr } from '../locale/localizedString';

sessionTestOneWindow('Link a device', async ([aliceWindow1]) => {
let aliceWindow2: Page | undefined;
Expand Down
66 changes: 60 additions & 6 deletions tests/automation/message_checks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,24 +323,78 @@ sessionTestTwoWindows(
},
);

// *************** NEED TO WAIT FOR LINK PREVIEW FIX *************************************************

test_Alice_1W_Bob_1W(
'Send link 1:1',
async ({ alice, aliceWindow1, bob, bobWindow1 }) => {
const testMessage = 'https://example.net';
const testMessage = 'https://getsession.org/';
const testReply = `${bob.userName} replying to link from ${alice.userName}`;

await createContact(aliceWindow1, bobWindow1, alice, bob);

await typeIntoInput(aliceWindow1, 'message-input-text-area', testMessage);
await sleepFor(5000);
await clickOnElement({
window: aliceWindow1,
strategy: 'data-testid',
selector: 'send-message-button',
});
await sleepFor(1000);
await clickOnTestIdWithText(
aliceWindow1,
'message-content',
testMessage,
true,
);
// Need to copy link to clipboard, as the enable link preview modal
// doesn't pop up if manually typing link (needs to be pasted)
// Need to have a nth(0) here to account for Copy Account ID, Appium was getting confused
const firstCopyBtn = await aliceWindow1
.locator(
`[data-testid=context-menu-item]:has-text(${englishStrippedStr(
'copy',
).toString()})`,
)
.nth(0);
await firstCopyBtn.click();
await waitForTestIdWithText(
aliceWindow1,
'session-toast',
englishStrippedStr('copied').toString(),
);
await clickOnTestIdWithText(aliceWindow1, 'message-input-text-area');
const isMac = process.platform === 'darwin';
await aliceWindow1.keyboard.press(`${isMac ? 'Meta' : 'Control'}+V`);
// No test tag on modal-description
// await checkModalStrings(
// aliceWindow1,
// englishStrippedStr('linkPreviewsEnable').toString(),
// englishStrippedStr('linkPreviewsFirstDescription')
// .withArgs({ app_name: 'Session' })
// .toString(),
// );
await clickOnTestIdWithText(
aliceWindow1,
'session-confirm-ok-button',
englishStrippedStr('enable').toString(),
);
// Needs to be changed to link-preview-loading
await waitForLoadingAnimationToFinish(aliceWindow1, 'loading-spinner');
// Also needs to be implemented
// await waitForTestIdWithText(aliceWindow1, 'link-preview-image')
// await waitForTestIdWithText(
// aliceWindow1,
// 'link-preview-title',
// 'Session | Send Messages, Not Metadata. | Private Messenger',
// );
await clickOnElement({
window: aliceWindow1,
strategy: 'data-testid',
selector: 'send-message-button',
});
await waitForElement(
bobWindow1,
'class',
'module-message__link-preview__title',
undefined,
'Session | Send Messages, Not Metadata. | Private Messenger',
);
await replyTo({
senderWindow: bobWindow1,
textMessage: testMessage,
Expand Down
111 changes: 109 additions & 2 deletions tests/automation/message_checks_groups.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ import { test_group_Alice_1W_Bob_1W_Charlie_1W } from './setup/sessionTest';
import { sendMessage } from './utilities/message';
import { replyTo } from './utilities/reply_message';
import {
checkModalStrings,
clickOnElement,
clickOnMatchingText,
clickOnTestIdWithText,
clickOnTextMessage,
hasTextMessageBeenDeleted,
lookForPartialTestId,
typeIntoInput,
waitForElement,
waitForLoadingAnimationToFinish,
waitForMatchingText,
waitForTestIdWithText,
waitForTextMessage,
Expand Down Expand Up @@ -221,13 +225,110 @@ test_group_Alice_1W_Bob_1W_Charlie_1W(
},
);

test_group_Alice_1W_Bob_1W_Charlie_1W(
'Send link to group',
async ({
alice,
bob,
aliceWindow1,
bobWindow1,
charlieWindow1,
groupCreated,
}) => {
const testMessage = `${alice.userName} sending link to ${groupCreated.userName}`;
const testReply = `${bob.userName} replying to link from ${alice.userName} in ${groupCreated.userName}`;
const testLink = 'https://getsession.org/';
await typeIntoInput(aliceWindow1, 'message-input-text-area', testLink);
await clickOnElement({
window: aliceWindow1,
strategy: 'data-testid',
selector: 'send-message-button',
});
await clickOnTestIdWithText(
aliceWindow1,
'message-content',
testMessage,
true,
);
// Need to copy link to clipboard, as the enable link preview modal
// doesn't pop up if manually typing link (needs to be pasted)
// Need to have a nth(0) here to account for Copy Account ID, Appium was getting confused
const firstCopyBtn = await aliceWindow1
.locator(
`[data-testid=context-menu-item]:has-text(${englishStrippedStr(
'copy',
).toString()})`,
)
.nth(0);
await firstCopyBtn.click();
await waitForTestIdWithText(
aliceWindow1,
'session-toast',
englishStrippedStr('copied').toString(),
);
await clickOnTestIdWithText(aliceWindow1, 'message-input-text-area');
const isMac = process.platform === 'darwin';
await aliceWindow1.keyboard.press(`${isMac ? 'Meta' : 'Control'}+V`);
await checkModalStrings(
aliceWindow1,
englishStrippedStr('linkPreviewsEnable').toString(),
englishStrippedStr('linkPreviewsFirstDescription')
.withArgs({ app_name: 'Session' })
.toString(),
);
await clickOnTestIdWithText(
aliceWindow1,
'session-confirm-ok-button',
englishStrippedStr('enable').toString(),
);
// Needs to be changed to link-preview-loading
await waitForLoadingAnimationToFinish(aliceWindow1, 'loading-spinner');
// Also needs to be implemented
// await waitForTestIdWithText(aliceWindow1, 'link-preview-image')
// await waitForTestIdWithText(
// aliceWindow1,
// 'link-preview-title',
// 'Session | Send Messages, Not Metadata. | Private Messenger',
// );
await clickOnElement({
window: aliceWindow1,
strategy: 'data-testid',
selector: 'send-message-button',
});
await Promise.all([
waitForElement(
bobWindow1,
'class',
'module-message__link-preview__title',
undefined,
'Session | Send Messages, Not Metadata. | Private Messenger',
),
waitForElement(
charlieWindow1,
'class',
'module-message__link-preview__title',
undefined,
'Session | Send Messages, Not Metadata. | Private Messenger',
),
]);
await replyTo({
senderWindow: bobWindow1,
textMessage: testMessage,
replyText: testReply,
receiverWindow: aliceWindow1,
});
},
);

test_group_Alice_1W_Bob_1W_Charlie_1W(
'Unsend message to group',
async ({ aliceWindow1, bobWindow1, charlieWindow1, groupCreated }) => {
const unsendMessage = `Testing unsend functionality in ${groupCreated.userName}`;
await sendMessage(aliceWindow1, unsendMessage);
await waitForTextMessage(bobWindow1, unsendMessage);
await waitForTextMessage(charlieWindow1, unsendMessage);
await Promise.all([
waitForTextMessage(bobWindow1, unsendMessage),
waitForTextMessage(charlieWindow1, unsendMessage),
]);
await clickOnTextMessage(aliceWindow1, unsendMessage, true);
await clickOnMatchingText(
aliceWindow1,
Expand All @@ -237,6 +338,12 @@ test_group_Alice_1W_Bob_1W_Charlie_1W(
aliceWindow1,
englishStrippedStr('clearMessagesForEveryone').toString(),
);
// To be implemented in Standardise Message Deletion feature
// await checkModalStrings(
// aliceWindow1,
// englishStrippedStr('deleteMessage').withArgs({ count: 1 }).toString(),
// englishStrippedStr('deleteMessageConfirm').toString(),
// );
await clickOnElement({
window: aliceWindow1,
strategy: 'data-testid',
Expand Down
9 changes: 7 additions & 2 deletions tests/automation/types/testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ export type WithPage = { window: Page };
export type WithMaxWait = { maxWait?: number };
export type WithRightButton = { rightButton?: boolean };

export type loaderType = 'loading-animation' | 'loading-spinner';
export type loaderType =
| 'loading-animation'
| 'loading-spinner'
| 'link-preview-loading';

export type Strategy = 'data-testid' | 'class' | ':has-text';

Expand Down Expand Up @@ -176,4 +179,6 @@ export type DataTestId =
| 'modal-heading'
| 'chooser-invite-friend'
| 'your-account-id'
| 'copy-button-account-id';
| 'copy-button-account-id'
| 'link-preview-title'
| 'link-preview-image';
3 changes: 1 addition & 2 deletions tests/automation/user_actions.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect } from '@playwright/test';
import { englishStrippedStr } from '../locale/localizedString';
import { sleepFor } from '../promise_utils';
import { newUser } from './setup/new_user';
import {
Expand All @@ -10,7 +11,6 @@ import {
import { createContact } from './utilities/create_contact';
import { sendMessage } from './utilities/message';
import {
checkModalStrings,
clickOnElement,
clickOnMatchingText,
clickOnTestIdWithText,
Expand All @@ -20,7 +20,6 @@ import {
waitForMatchingText,
waitForTestIdWithText,
} from './utilities/utils';
import { englishStrippedStr } from '../locale/localizedString';

// Send message in one to one conversation with new contact
sessionTestTwoWindows('Create contact', async ([windowA, windowB]) => {
Expand Down