Skip to content

Commit

Permalink
chore(appium): craete new config files for accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
luisecm committed Nov 1, 2023
1 parent 71c875e commit 0a70db8
Show file tree
Hide file tree
Showing 16 changed files with 460 additions and 66 deletions.
52 changes: 45 additions & 7 deletions .github/workflows/ui-automated-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,44 @@ jobs:
with:
name: appium-log-macos
path: ./appium.log

- name: Run Tests on to Create First Account 🧪
run: npm run mac.createAccountA

- name: Upload test accounts for Chat
- name: Delete data from Friends Tests for artifact of Chat User A
working-directory: ./tests/fixtures/users/mac2/
run: rm -rf ./FriendsTestUser/

- name: List all of the files extracted on Repo After First Account Created
run: |
pwd
ls -R
- name: Upload test accounts for Chat User A
uses: actions/upload-artifact@v3
if: always()
with:
name: account-first-user
path: ./tests/fixtures/users/mac2/

- name: Run Tests on to Create Second Account 🧪
run: npm run mac.createAccountB

- name: Delete data from Friends Tests for artifact of Chat User B
working-directory: ./tests/fixtures/users/mac2/
run: rm -rf ./FriendsTestUser/

- name: List all of the files extracted on Repo After Second Account Created
run: |
pwd
ls -R
- name: Upload test accounts for Chat User B
uses: actions/upload-artifact@v3
if: always()
with:
name: test-accounts
path: ./tests/fixtures/users/
name: account-second-user
path: ./tests/fixtures/users/mac2/

- name: Add label if any of test jobs failed
if: failure()
Expand Down Expand Up @@ -203,11 +234,17 @@ jobs:
name: Uplink-macos-latest
path: ./apps

- name: Download Test User Accounts 🗳️
- name: Download Test User Account User A 🗳️
uses: actions/download-artifact@v3
with:
name: account-first-user
path: ./tests/fixtures/users/mac2/

- name: Download Test User Account User A 🗳️
uses: actions/download-artifact@v3
with:
name: test-accounts
path: ./tests/fixtures/users/
name: account-second-user
path: ./tests/fixtures/users/mac2/

- name: List all of the files extracted
run: |
Expand Down Expand Up @@ -341,4 +378,5 @@ jobs:
test-allure-mac-ci
test-allure-mac-chatA
test-allure-mac-chatB
test-accounts
account-first-user
account-second-user
File renamed without changes.
File renamed without changes.
149 changes: 149 additions & 0 deletions config/macos-chats/wdio.mac.createAccountA.conf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
import "module-alias/register";
import allureReporter from '@wdio/allure-reporter'
import { config as sharedConfig } from '@config/wdio.shared.conf';
import { homedir } from "os";
import { join } from "path";
import { MACOS_BUNDLE_ID, MACOS_DRIVER } from "@helpers/constants";
const fsp = require("fs").promises;
const { readFileSync, rmSync } = require("fs");

// @ts-expect-error
export const config: WebdriverIO.Config = {
...sharedConfig,
...{
//
// ==================
// Specify Test Files
// ==================
// Define which test specs should run. The pattern is relative to the directory
// from which `wdio` was called.
//
// The specs are defined as an array of spec files (optionally using wildcards
// that will be expanded). The test for each spec file will be run in a separate
// worker process. In order to have a group of spec files run in the same worker
// process simply enclose them in an array within the specs array.
//
// If you are calling `wdio` from an NPM script (see https://docs.npmjs.com/cli/run-script),
// then the current working directory is where your `package.json` resides, so `wdio`
// will be called from there.
//
maxInstances: 1,
specs: [
join(process.cwd(), "./tests/suites/MainTests/03-CreateAccountA.suite.ts")
],
// Patterns to exclude.
exclude: [
// 'path/to/excluded/files'
],
//
// ============
// Capabilities
// ============
// Define your capabilities here. WebdriverIO can run multiple capabilities at the same
// time. Depending on the number of capabilities, WebdriverIO launches several test
// sessions. Within your capabilities you can overwrite the spec and exclude options in
// order to group specific specs to a specific capability.
//
//
// If you have trouble getting all important capabilities together, check out the
// Sauce Labs platform configurator - a great tool to configure your capabilities:
// https://docs.saucelabs.com/reference/platforms-configurator
//
port: 4723,
path: '/',
capabilities: {
userA: {
capabilities: {
platformName: "mac",
"appium:automationName": MACOS_DRIVER,
"appium:bundleId": MACOS_BUNDLE_ID,
"appium:arguments": ["--path", homedir() + "/.uplink"],
"appium:systemPort": 4724,
"appium:prerun": {
command: 'do shell script "rm -rf ~/.uplink"',
},
}
},
}
,
//
// ===================
// Test Configurations
// ===================
// Define all options that are relevant for the WebdriverIO instance here
//
reporters: [
["spec",
{
showPreface: false,
},
],
['allure',
{
outputDir: './allure-results',
disableWebdriverStepsReporting: true,
disableWebdriverScreenshotsReporting: false,
}
],
['junit',
{
outputDir: './test-report/',
outputFileFormat: function (options) {
return `test-results-macos-app-${options.cid}.xml`;
}
}
],
],
//
// =====
// Hooks
// =====
// WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
// 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() {
const cacheFolder = homedir() + "/.uplink/.user";
const allureResultsFolder = join(process.cwd(), "./allure-results");
const testReportFolder = join(process.cwd(), "./test-report");
const testResultsFolder = join(process.cwd(), "./test-results");
try {
await rmSync(allureResultsFolder, { recursive: true, force: true });
await rmSync(testReportFolder, { recursive: true, force: true });
await rmSync(testResultsFolder, { recursive: true, force: true });
console.log("Deleted Artifacts Folders Successfully!");
} catch (error) {
console.error(
`Got an error trying to delete artifacts folders: ${error.message}`
);
}
try {
await rmSync(cacheFolder, { recursive: true, force: true });
console.log("Deleted Cache Folder Successfully!");
} catch (error) {
console.error(
`Got an error trying to delete Cache Folder: ${error.message}`
);
}
},

afterTest: async function (test, describe, { error }) {
if (error) {
let imageFile = await driver.takeScreenshot();
const imageFolder = join(process.cwd(), "./test-results/macos-app", test.parent);
const imageTitle = test.title + " - Failed.png"
await fsp.mkdir(imageFolder, {recursive: true});
await fsp.writeFile(
imageFolder + "/" + imageTitle,
imageFile,
"base64"
);

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

}
149 changes: 149 additions & 0 deletions config/macos-chats/wdio.mac.createAccountB.conf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
import "module-alias/register";
import allureReporter from '@wdio/allure-reporter'
import { config as sharedConfig } from '@config/wdio.shared.conf';
import { homedir } from "os";
import { join } from "path";
import { MACOS_BUNDLE_ID, MACOS_DRIVER } from "@helpers/constants";
const fsp = require("fs").promises;
const { readFileSync, rmSync } = require("fs");

// @ts-expect-error
export const config: WebdriverIO.Config = {
...sharedConfig,
...{
//
// ==================
// Specify Test Files
// ==================
// Define which test specs should run. The pattern is relative to the directory
// from which `wdio` was called.
//
// The specs are defined as an array of spec files (optionally using wildcards
// that will be expanded). The test for each spec file will be run in a separate
// worker process. In order to have a group of spec files run in the same worker
// process simply enclose them in an array within the specs array.
//
// If you are calling `wdio` from an NPM script (see https://docs.npmjs.com/cli/run-script),
// then the current working directory is where your `package.json` resides, so `wdio`
// will be called from there.
//
maxInstances: 1,
specs: [
join(process.cwd(), "./tests/suites/MainTests/04-CreateAccountB.suite.ts")
],
// Patterns to exclude.
exclude: [
// 'path/to/excluded/files'
],
//
// ============
// Capabilities
// ============
// Define your capabilities here. WebdriverIO can run multiple capabilities at the same
// time. Depending on the number of capabilities, WebdriverIO launches several test
// sessions. Within your capabilities you can overwrite the spec and exclude options in
// order to group specific specs to a specific capability.
//
//
// If you have trouble getting all important capabilities together, check out the
// Sauce Labs platform configurator - a great tool to configure your capabilities:
// https://docs.saucelabs.com/reference/platforms-configurator
//
port: 4723,
path: '/',
capabilities: {
userA: {
capabilities: {
platformName: "mac",
"appium:automationName": MACOS_DRIVER,
"appium:bundleId": MACOS_BUNDLE_ID,
"appium:arguments": ["--path", homedir() + "/.uplink"],
"appium:systemPort": 4724,
"appium:prerun": {
command: 'do shell script "rm -rf ~/.uplink"',
},
}
},
}
,
//
// ===================
// Test Configurations
// ===================
// Define all options that are relevant for the WebdriverIO instance here
//
reporters: [
["spec",
{
showPreface: false,
},
],
['allure',
{
outputDir: './allure-results',
disableWebdriverStepsReporting: true,
disableWebdriverScreenshotsReporting: false,
}
],
['junit',
{
outputDir: './test-report/',
outputFileFormat: function (options) {
return `test-results-macos-app-${options.cid}.xml`;
}
}
],
],
//
// =====
// Hooks
// =====
// WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
// 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() {
const cacheFolder = homedir() + "/.uplink/.user";
const allureResultsFolder = join(process.cwd(), "./allure-results");
const testReportFolder = join(process.cwd(), "./test-report");
const testResultsFolder = join(process.cwd(), "./test-results");
try {
await rmSync(allureResultsFolder, { recursive: true, force: true });
await rmSync(testReportFolder, { recursive: true, force: true });
await rmSync(testResultsFolder, { recursive: true, force: true });
console.log("Deleted Artifacts Folders Successfully!");
} catch (error) {
console.error(
`Got an error trying to delete artifacts folders: ${error.message}`
);
}
try {
await rmSync(cacheFolder, { recursive: true, force: true });
console.log("Deleted Cache Folder Successfully!");
} catch (error) {
console.error(
`Got an error trying to delete Cache Folder: ${error.message}`
);
}
},

afterTest: async function (test, describe, { error }) {
if (error) {
let imageFile = await driver.takeScreenshot();
const imageFolder = join(process.cwd(), "./test-results/macos-app", test.parent);
const imageTitle = test.title + " - Failed.png"
await fsp.mkdir(imageFolder, {recursive: true});
await fsp.writeFile(
imageFolder + "/" + imageTitle,
imageFile,
"base64"
);

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

}
3 changes: 1 addition & 2 deletions config/wdio.mac.app.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ export const config: WebdriverIO.Config = {
//
maxInstances: 1,
specs: [
[join(process.cwd(), "./tests/suites/MainTests/03-CreateAccountTests.suite.ts")],
[join(process.cwd(), "./tests/suites/MainTests/01-UplinkTests.suite.ts")]
join(process.cwd(), "./tests/suites/MainTests/01-UplinkTests.suite.ts")
],
// Patterns to exclude.
exclude: [
Expand Down
3 changes: 1 addition & 2 deletions config/wdio.mac.ci.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ export const config: WebdriverIO.Config = {
// will be called from there.
maxInstances: 1,
specs: [
[join(process.cwd(), "./tests/suites/MainTests/03-CreateAccountTests.suite.ts")],
[join(process.cwd(), "./tests/suites/MainTests/01-UplinkTests.suite.ts")]
join(process.cwd(), "./tests/suites/MainTests/01-UplinkTests.suite.ts")
],
// Patterns to exclude.
exclude: [
Expand Down
Loading

0 comments on commit 0a70db8

Please sign in to comment.