Skip to content

Commit

Permalink
@bruno/bumps (#879)
Browse files Browse the repository at this point in the history
Co-authored-by: BrodyHughes <[email protected]>
  • Loading branch information
brunobar79 and BrodyHughes authored Aug 23, 2023
1 parent b8f02f7 commit 748e13b
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 65 deletions.
3 changes: 3 additions & 0 deletions .github/actions/testSetup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ runs:
- name: Copy dotenv
shell: 'bash'
run: cat tmp/dotenv >> .env && rm -rf tmp
- name: Clear old screenshots
shell: 'bash'
run: rm -rf screenshots/*
60 changes: 59 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
with:
name: rainbowbx-${{ github.sha }}.zip
path: build/
# FIREFOX TESTS - Disabled for now till all tests are passing
# FIREFOX TESTS
firefox-e2e-parallel:
runs-on: ubuntu-latest
timeout-minutes: 16
Expand Down Expand Up @@ -114,12 +114,23 @@ jobs:
shell: 'bash'
run: cat tmp/dotenv >> .env && rm -rf tmp
- name: Run e2e parallel (Firefox)
id: FFE2eParallel
continue-on-error: true
run: |
export BROWSER=firefox
export OS=linux
export FIREFOX_BIN=/opt/hostedtoolcache/firefox/latest-devedition/x64/firefox
yarn firefox:manifest && yarn firefox:zip
yarn vitest:parallel --retry=5
- name: Upload deps artifacts
if: steps.FFE2eParallel.outcome == 'failure'
uses: actions/upload-artifact@v3
with:
name: screenshots
path: screenshots/
- name: Fail if any tests failed
if: steps.FFE2eParallel.outcome == 'failure'
run: exit 1
# CHROME TESTS
chrome-e2e-parallel:
runs-on: ubuntu-latest
Expand All @@ -134,11 +145,22 @@ jobs:
with:
gh-access-token: ${{ secrets.DOTENV_GITHUB_ACCESS_TOKEN }}
- name: Run e2e parallel (Chrome)
id: ChromeE2EParallel
continue-on-error: true
run: |
export BROWSER=chrome
export OS=linux
export CHROMIUM_BIN=$(find chrome -type f -name 'chrome')
yarn vitest:parallel --retry=5
- name: Upload deps artifacts
if: steps.ChromeE2EParallel.outcome == 'failure'
uses: actions/upload-artifact@v3
with:
name: screenshots
path: screenshots/
- name: Fail if any tests failed
if: steps.ChromeE2EParallel.outcome == 'failure'
run: exit 1
chrome-e2e-swap:
runs-on: beefy-runner-bx
timeout-minutes: 25
Expand All @@ -152,6 +174,8 @@ jobs:
with:
gh-access-token: ${{ secrets.DOTENV_GITHUB_ACCESS_TOKEN }}
- name: Run e2e swap (Chrome)
id: ChromeE2ESwaps
continue-on-error: true
uses: nick-fields/retry@v2
with:
timeout_minutes: 25
Expand All @@ -161,6 +185,15 @@ jobs:
export OS=linux
export CHROMIUM_BIN=$(find chrome -type f -name 'chrome')
yarn vitest:swap
- name: Upload deps artifacts
if: steps.ChromeE2ESwaps.outcome == 'failure'
uses: actions/upload-artifact@v3
with:
name: screenshots
path: screenshots/
- name: Fail if any tests failed
if: steps.ChromeE2ESwaps.outcome == 'failure'
run: exit 1
chrome-e2e-send:
runs-on: beefy-runner-bx
timeout-minutes: 25
Expand All @@ -174,11 +207,22 @@ jobs:
with:
gh-access-token: ${{ secrets.DOTENV_GITHUB_ACCESS_TOKEN }}
- name: Run e2e send (Chrome)
id: ChromeE2ESend
continue-on-error: true
run: |
export BROWSER=chrome
export OS=linux
export CHROMIUM_BIN=$(find chrome -type f -name 'chrome')
yarn vitest:send --retry=5
- name: Upload deps artifacts
if: steps.ChromeE2ESend.outcome == 'failure'
uses: actions/upload-artifact@v3
with:
name: screenshots
path: screenshots/
- name: Fail if any tests failed
if: steps.ChromeE2ESend.outcome == 'failure'
run: exit 1
chrome-e2e-dappInteractions:
runs-on: beefy-runner-bx
timeout-minutes: 25
Expand All @@ -192,11 +236,22 @@ jobs:
with:
gh-access-token: ${{ secrets.DOTENV_GITHUB_ACCESS_TOKEN }}
- name: Run e2e dappInteractions (Chrome)
id: ChromeE2EDappInteractions
continue-on-error: true
run: |
export BROWSER=chrome
export OS=linux
export CHROMIUM_BIN=$(find chrome -type f -name 'chrome')
yarn vitest:dappInteractions --retry=5
- name: Upload deps artifacts
if: steps.ChromeE2EDappInteractions.outcome == 'failure'
uses: actions/upload-artifact@v3
with:
name: screenshots
path: screenshots/
- name: Fail if any tests failed
if: steps.ChromeE2EDappInteractions.outcome == 'failure'
run: exit 1
# BRAVE TESTS
# brave-e2e:
# needs: [build]
Expand Down Expand Up @@ -328,3 +383,6 @@ jobs:
- uses: geekyeggo/delete-artifact@v2
with:
name: node_modules.tar.gz
- uses: geekyeggo/delete-artifact@v2
with:
name: screenshots
38 changes: 29 additions & 9 deletions e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,17 @@ export async function getExtensionIdByName(
// search functions

export async function querySelector(driver: WebDriver, selector: string) {
await driver.wait(untilDocumentLoaded(), waitUntilTime);
const el = await driver.wait(
until.elementLocated(By.css(selector)),
waitUntilTime,
);
return await driver.wait(until.elementIsVisible(el), waitUntilTime);
try {
await driver.wait(untilDocumentLoaded(), waitUntilTime);
const el = await driver.wait(
until.elementLocated(By.css(selector)),
waitUntilTime,
);
return await driver.wait(until.elementIsVisible(el), waitUntilTime);
} catch (error) {
await takeScreenshot(driver, selector);
throw error;
}
}

export async function findElementByText(driver: WebDriver, text: string) {
Expand Down Expand Up @@ -318,9 +323,13 @@ export async function waitAndClick(element: WebElement, driver: WebDriver) {
await driver.wait(until.elementIsEnabled(element), waitUntilTime);
return element.click();
} catch (error) {
throw new Error(
`Failed to click element ${await element.getAttribute('data-testid')}`,
);
const testId = await element.getAttribute('data-testid');
if (testId) {
await takeScreenshot(driver, testId);
} else {
console.log("couldn't take screenshot because element has no test id");
}
throw new Error(`Failed to click element ${testId}`);
}
}

Expand Down Expand Up @@ -719,3 +728,14 @@ export async function delayTime(
return await delay(5000);
}
}

export async function takeScreenshot(driver: WebDriver, name: string) {
try {
const image = await driver.takeScreenshot();
const safeName = name.replace('[data-testid="', '').replace('"]', '');
const filename = `${new Date().getTime()}-${safeName}`;
require('fs').writeFileSync(`screenshots/${filename}.png`, image, 'base64');
} catch (error) {
console.error('Error occurred while taking screenshot:', error);
}
}
2 changes: 1 addition & 1 deletion e2e/serial/dappInteractions/1_appInteractionsFlow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ describe('App interactions flow', () => {
const { popupHandler } = await getAllWindowHandles({ driver, dappHandler });

await driver.switchTo().window(popupHandler);
await delayTime('long');
await delayTime('very-long');
await findElementByTestIdAndClick({ id: 'accept-request-button', driver });
await delayTime('long');
await driver.switchTo().window(dappHandler);
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
"@vanilla-extract/webpack-plugin": "2.2.0",
"audit-ci": "6.3.0",
"browserify": "17.0.0",
"chromedriver": "115.0.0",
"chromedriver": "116.0.0",
"circular-dependency-plugin": "5.2.2",
"copy-webpack-plugin": "11.0.0",
"css-loader": "6.7.1",
Expand All @@ -186,7 +186,7 @@
"eslint-plugin-prettier": "4.2.1",
"file-loader": "6.2.0",
"fs-extra": "10.1.0",
"geckodriver": "4.1.3",
"geckodriver": "4.2.0",
"globby": "11.0.4",
"happy-dom": "8.9.0",
"html-webpack-plugin": "5.5.0",
Expand All @@ -205,7 +205,7 @@
"svg-path-commander": "1.0.5",
"ts-loader": "9.4.1",
"typescript": "4.9.4",
"vitest": "0.33.0",
"vitest": "0.34.2",
"web-ext": "7.6.2",
"webpack": "5.76.0",
"webpack-bundle-analyzer": "4.8.0",
Expand Down Expand Up @@ -289,4 +289,4 @@
"yarn lint --fix --ignore-pattern '!*.d.ts'"
]
}
}
}
1 change: 1 addition & 0 deletions screenshots/.dummy
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

File renamed without changes.
Loading

0 comments on commit 748e13b

Please sign in to comment.