Skip to content
Draft
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
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"fs-extra": "^11.1.1",
"lodash": "^4.17.21",
"prettier": "^3.0.1",
"typescript": "^5.1.6",
"semver": "^7.5.4",
"typescript": "^5.5.4",
"uuid": "^9.0.1"
},
"scripts": {
Expand All @@ -38,5 +39,8 @@
"allure-create": "allure generate ./allure-results",
"allure-open": "allure open ./allure-report"
},
"dependencies": {}
"dependencies": {
"@session-foundation/qa-seeder": "^0.0.11",
"buffer-crc32": "^1.0.0"
}
}
7 changes: 5 additions & 2 deletions sessionReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
TestResult,
} from '@playwright/test/reporter';
import chalk from 'chalk';
import { Dictionary, groupBy, isString, mean, sortBy } from 'lodash';
import { Dictionary, groupBy, isString, mean, omit, sortBy } from 'lodash';

type TestAndResult = { test: TestCase; result: TestResult };

Expand Down Expand Up @@ -248,7 +248,10 @@ class SessionReporter implements Reporter {
}

onError?(error: TestError) {
console.info('global error:', error);
console.info('global error:', omit(error, ['stack', 'snippet']));
error.stack?.split('\n').forEach((line) => {
process.stderr.write(`${line}\n`);
});
}
}

Expand Down
16 changes: 12 additions & 4 deletions tests/automation/constants/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,38 @@ export const mediaArray = [
];

type DisappearingOption = {
durationSeconds: number;
timeOption: DMTimeOption;
disappearingMessagesType: DisappearType | DisappearGroupType;
disappearAction: DisappearActions;
};

const duration10Seconds = 10;
const duration30Seconds = 30;

export const defaultDisappearingOptions = {
DAS: {
timeOption: 'time-option-30-seconds',
durationSeconds: duration30Seconds,
timeOption: `time-option-${duration30Seconds}-seconds`,
disappearingMessagesType: 'disappear-after-send-option',
disappearAction: 'sent',
},
DAR: {
timeOption: 'time-option-10-seconds',
durationSeconds: duration10Seconds,
timeOption: `time-option-${duration10Seconds}-seconds`,
disappearingMessagesType: 'disappear-after-read-option',
disappearAction: 'read',
},
group: {
timeOption: 'time-option-10-seconds',
durationSeconds: duration10Seconds,
timeOption: `time-option-${duration10Seconds}-seconds`,
disappearingMessagesType:
'disappear-after-send-option' satisfies DisappearGroupType,
disappearAction: 'sent',
},
NTS: {
timeOption: 'time-option-10-seconds',
durationSeconds: duration10Seconds,
timeOption: `time-option-${duration10Seconds}-seconds`,
disappearingMessagesType: 'disappear-after-send-option',
disappearAction: 'sent',
},
Expand Down
86 changes: 77 additions & 9 deletions tests/automation/group_disappearing_messages.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { buildStateForTest } from '@session-foundation/qa-seeder';
import { sleepFor } from '../promise_utils';
import {
defaultDisappearingOptions,
longText,
mediaArray,
testLink,
} from './constants/variables';
import { test_group_Alice_1W_Bob_1W_Charlie_1W } from './setup/sessionTest';
import { recoverFromSeed } from './setup/recovery_using_seed';
import {
sessionTestThreeWindows,
test_group_Alice_1W_Bob_1W_Charlie_1W,
} from './setup/sessionTest';
import { sendMessage } from './utilities/message';
import {
sendLinkPreview,
Expand All @@ -23,12 +28,16 @@ import {
} from './utilities/utils';

// Disappearing time settings for all tests
const { timeOption, disappearingMessagesType, disappearAction } =
defaultDisappearingOptions.group;
const {
durationSeconds,
timeOption,
disappearingMessagesType,
disappearAction,
} = defaultDisappearingOptions.group;

mediaArray.forEach(({ mediaType, path }) => {
test_group_Alice_1W_Bob_1W_Charlie_1W(
`Send disappearing ${mediaType} groups`,
`PLIP Send disappearing ${mediaType} groups`,
async ({
alice,
aliceWindow1,
Expand Down Expand Up @@ -58,7 +67,7 @@ mediaArray.forEach(({ mediaType, path }) => {
waitForTestIdWithText(bobWindow1, 'audio-player'),
waitForTestIdWithText(charlieWindow1, 'audio-player'),
]);
await sleepFor(30000);
await sleepFor(durationSeconds * 1000, true);
await Promise.all([
hasElementBeenDeleted(bobWindow1, 'data-testid', 'audio-player'),
hasElementBeenDeleted(charlieWindow1, 'data-testid', 'audio-player'),
Expand All @@ -68,11 +77,11 @@ mediaArray.forEach(({ mediaType, path }) => {
waitForTextMessage(bobWindow1, testMessage),
waitForTextMessage(charlieWindow1, testMessage),
]);
// Wait 30 seconds for image to disappear
await sleepFor(30000);
// Wait durationSeconds seconds for image to disappear
await sleepFor(durationSeconds * 1000, true);
await Promise.all([
hasTextMessageBeenDeleted(bobWindow1, testMessage),
hasTextMessageBeenDeleted(charlieWindow1, testMessage),
hasTextMessageBeenDeleted(bobWindow1, testMessage, 1000),
hasTextMessageBeenDeleted(charlieWindow1, testMessage, 1000),
]);
}
},
Expand Down Expand Up @@ -146,3 +155,62 @@ test_group_Alice_1W_Bob_1W_Charlie_1W(
]);
},
);

mediaArray.forEach(({ mediaType, path }) => {
sessionTestThreeWindows(
`PLOP Send disappearing ${mediaType} groups`,
async (windows, testInfo) => {
const { group, users } = await buildStateForTest(
'3friendsInGroup',
testInfo.title,
);
await Promise.all(
windows.map((w, index) => recoverFromSeed(w, users[index].seedPhrase)),
);
const [aliceWindow1, bobWindow1, charlieWindow1] = windows;

const [alice] = users;
await sleepFor(15000);

const testMessage = `${alice.userName} sending ${mediaType} to ${group.groupName}`;
await setDisappearingMessages(aliceWindow1, [
'group',
disappearingMessagesType,
timeOption,
disappearAction,
]);
// Send media
if (mediaType === 'voice') {
await sendVoiceMessage(aliceWindow1);
} else {
await sendMedia(aliceWindow1, path, testMessage);
}
await Promise.all([
waitForLoadingAnimationToFinish(bobWindow1, 'loading-animation'),
waitForLoadingAnimationToFinish(charlieWindow1, 'loading-animation'),
]);
if (mediaType === 'voice') {
await Promise.all([
waitForTestIdWithText(bobWindow1, 'audio-player'),
waitForTestIdWithText(charlieWindow1, 'audio-player'),
]);
await sleepFor(durationSeconds * 1000, true);
await Promise.all([
hasElementBeenDeleted(bobWindow1, 'data-testid', 'audio-player'),
hasElementBeenDeleted(charlieWindow1, 'data-testid', 'audio-player'),
]);
} else {
await Promise.all([
waitForTextMessage(bobWindow1, testMessage),
waitForTextMessage(charlieWindow1, testMessage),
]);
// Wait durationSeconds seconds for image to disappear
await sleepFor(durationSeconds * 1000, true);
await Promise.all([
hasTextMessageBeenDeleted(bobWindow1, testMessage),
hasTextMessageBeenDeleted(charlieWindow1, testMessage),
]);
}
},
);
});
1 change: 0 additions & 1 deletion tests/automation/linked_device_group.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
} from './setup/sessionTest';
import { leaveGroup } from './utilities/leave_group';
import {
checkModalStrings,
clickOnMatchingText,
clickOnTestIdWithText,
waitForLoadingAnimationToFinish,
Expand Down
Loading