Skip to content

Commit

Permalink
Merge pull request #673 from Satellite-im/luis/share-did
Browse files Browse the repository at this point in the history
chore(appium): refactor tests for less time retriability
  • Loading branch information
luisecm authored Apr 25, 2024
2 parents de1f2bb + 6dd8ad7 commit 0fde0d6
Show file tree
Hide file tree
Showing 25 changed files with 1,026 additions and 872 deletions.
13 changes: 1 addition & 12 deletions .github/workflows/ui-automated-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -459,16 +459,6 @@ jobs:
name: appium-log-macos-chats
path: ./appium.log

- name: Upload Uplink Logs if test fails 📷
uses: actions/upload-artifact@v3
if: failure()
with:
name: uplink-logs
path: |
~/.uplink/.user/debug.log
~/.uplinkUserB/.user/debug.log
~/.uplinkUserC/.user/debug.log
- name: Add label if any of test jobs failed
if: failure()
uses: buildsville/[email protected]
Expand Down Expand Up @@ -697,7 +687,7 @@ jobs:
allure_results: testing-uplink/allure
allure_report: allure-report
allure_history: allure-history
keep_reports: 20
keep_reports: 100

- name: Deploy report to Github Pages
if: success()
Expand Down Expand Up @@ -746,7 +736,6 @@ jobs:
test-allure-mac-ci
test-allure-mac-chats
test-allure-windows-ci
uplink-logs
- name: Remove label if all test jobs succeeded
uses: buildsville/[email protected]
Expand Down
14 changes: 10 additions & 4 deletions config/wdio.mac.app.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,16 @@ export const config: WebdriverIO.Config = {
}
},

afterTest: async function (test, describe, { error }) {
if (error) {
afterTest: async function (
test,
context,
{ error, result, duration, passed, retries },
) {
if (!passed) {
let imageFile = await driver.takeScreenshot();
const imageFolder = join(
process.cwd(),
"./test-results/macos-app",
"./test-results/macos",
test.parent,
);
const imageTitle = test.title + " - Failed.png";
Expand All @@ -144,8 +148,10 @@ export const config: WebdriverIO.Config = {
// Add to Screenshot to Allure Reporter
const data = await readFileSync(`${imageFolder}/${imageTitle}`);
allureReporter.addAttachment(imageTitle, data, "image/png");
}

// Close application if still open
if (error) {
// Close applications if open
await terminateApplication(MACOS_BUNDLE_ID);
}
},
Expand Down
17 changes: 11 additions & 6 deletions config/wdio.mac.ci.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,12 @@ export const config: WebdriverIO.Config = {
/**
* Function to be executed after a test (in Mocha/Jasmine).
*/
afterTest: async function (test, describe, { error }) {
if (error) {
// If test fails, take a screenshot, make a folder with the test name and save it there
afterTest: async function (
test,
context,
{ error, result, duration, passed, retries },
) {
if (!passed) {
let imageFile = await driver.takeScreenshot();
const imageFolder = join(
process.cwd(),
Expand All @@ -146,10 +149,12 @@ export const config: WebdriverIO.Config = {
);

// Add to Screenshot to Allure Reporter
const dataImage = await readFileSync(`${imageFolder}/${imageTitle}`);
allureReporter.addAttachment(imageTitle, dataImage, "image/png");
const data = await readFileSync(`${imageFolder}/${imageTitle}`);
allureReporter.addAttachment(imageTitle, data, "image/png");
}

// Close application if still open
if (error) {
// Close applications if open
await terminateApplication(MACOS_BUNDLE_ID);
}
},
Expand Down
41 changes: 23 additions & 18 deletions config/wdio.mac.multiremote.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const config: WebdriverIO.Config = {
// then the current working directory is where your `package.json` resides, so `wdio`
// will be called from there.
//
specs: [join(process.cwd(), "./tests/suites/Chats/01-Chats.suite.ts")],
specs: [join(process.cwd(), "./tests/specs/reusable-accounts/*.spec.ts")],
// Patterns to exclude.
exclude: [
// 'path/to/excluded/files'
Expand Down Expand Up @@ -92,6 +92,10 @@ export const config: WebdriverIO.Config = {
],
],
maxInstances: 1,
// The number of times to retry the entire specfile when it fails as a whole
specFileRetries: 1,
// Delay in seconds between the spec file retry attempts
specFileRetriesDelay: 0,
//
// =====
// Hooks
Expand All @@ -100,7 +104,10 @@ export const config: WebdriverIO.Config = {
// it and to build services around it. You can either apply a single function or an array of
// methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
// resolved to continue.
onPrepare: async function () {
/**
* Function to be executed after a test (in Mocha/Jasmine).
*/
onPrepare: async function (config, capabilities) {
const cacheFolderUserA = homedir() + "/.uplink/.user";
const cacheFolderUserB = homedir() + "/.uplinkUserB/.user";
const cacheFolderUserC = homedir() + "/.uplinkUserC/.user";
Expand All @@ -126,12 +133,14 @@ export const config: WebdriverIO.Config = {
);
}
},
/**
* Function to be executed after a test (in Mocha/Jasmine).
*/
afterTest: async function (test, describe, { error }) {
if (error) {
let imageFile = await driver.takeScreenshot();

afterTest: async function (
test,
context,
{ error, result, duration, passed, retries },
) {
if (!passed) {
let imageFile = await browser.takeScreenshot();
const imageFolder = join(
process.cwd(),
"./test-results/macos-multiremote",
Expand All @@ -148,19 +157,15 @@ export const config: WebdriverIO.Config = {
// Add to Screenshot to Allure Reporter
const data = await readFileSync(`${imageFolder}/${imageTitle}`);
allureReporter.addAttachment(imageTitle, data, "image/png");

// Close applications if open
await terminateApplication(MACOS_USER_A_BUNDLE_ID);
await terminateApplication(MACOS_USER_B_BUNDLE_ID);
await terminateApplication(MACOS_USER_C_BUNDLE_ID);
}
},
},

afterSuite: async function (suite) {
// Close second and third applications if open
await terminateApplication(MACOS_USER_B_BUNDLE_ID);
await terminateApplication(MACOS_USER_C_BUNDLE_ID);
afterSuite: async function (suite) {
// Close applications if open
await terminateApplication(MACOS_USER_A_BUNDLE_ID);
await terminateApplication(MACOS_USER_B_BUNDLE_ID);
await terminateApplication(MACOS_USER_C_BUNDLE_ID);
},
},
};

Expand Down
12 changes: 8 additions & 4 deletions config/wdio.windows.app.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,16 @@ export const config: WebdriverIO.Config = {
}
},

afterTest: async function (test, describe, { error }) {
if (error) {
afterTest: async function (
test,
context,
{ error, result, duration, passed, retries },
) {
if (!passed) {
let imageFile = await driver.takeScreenshot();
let imageFolder = join(
const imageFolder = join(
process.cwd(),
"./test-results/windows-app",
"./test-results/windows",
test.parent,
);
const imageTitle = test.title + " - Failed.png";
Expand Down
31 changes: 20 additions & 11 deletions config/wdio.windows.ci.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ export const config: WebdriverIO.Config = {
]);
},

afterTest: async function (test, describe, { error }) {
afterTest: async function (
test,
context,
{ error, result, duration, passed, retries },
) {
// Stop video recording and saved it into base64 format
const base64Video = await driver.executeScript(
"windows: stopRecordingScreen",
Expand All @@ -174,21 +178,18 @@ export const config: WebdriverIO.Config = {
},
],
);
if (error) {
let imageFile = await driver.takeScreenshot();
let imageFolder = join(
if (!passed) {
await driver.takeScreenshot();
const imageFile = await driver.takeScreenshot();
const imageFolder = join(
process.cwd(),
"./test-results/windows-ci",
test.parent,
);

const imageTitle = test.title + " - Failed.png";
const videoTitle = test.title + " - Failed.mp4";
await fsp.mkdir(imageFolder, { recursive: true });
await fsp.writeFile(
imageFolder + "/" + imageTitle,
imageFile,
"base64",
);

// Write Video File if test failure and add it to failed screenshots folder
await fsp.writeFile(
Expand All @@ -197,12 +198,20 @@ export const config: WebdriverIO.Config = {
"base64",
);

await fsp.writeFile(
imageFolder + "/" + imageTitle,
imageFile,
"base64",
);

// Add to Screenshot to Allure Reporter
const data = await readFileSync(`${imageFolder}/${imageTitle}`);
const dataVideo = await readFileSync(`${imageFolder}/${videoTitle}`);
allureReporter.addAttachment(imageTitle, data, "image/png");
allureReporter.addAttachment(videoTitle, dataVideo, "video/mp4");

// Add to Screenshot to Allure Reporter
const data = await readFileSync(`${imageFolder}/${imageTitle}`);
allureReporter.addAttachment(imageTitle, data, "image/png");

// Close application if still open
await driver.executeScript("windows: closeApp", [
{
Expand Down
8 changes: 6 additions & 2 deletions config/wdio.windows.onetime.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,12 @@ export const config: WebdriverIO.Config = {
}
},

afterTest: async function (test, describe, { error }) {
if (error) {
afterTest: async function (
test,
context,
{ error, result, duration, passed, retries },
) {
if (!passed) {
let imageFile = await driver.takeScreenshot();
let imageFolder = join(
process.cwd(),
Expand Down
Loading

0 comments on commit 0fde0d6

Please sign in to comment.