-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [BUG] https check sign blob (#1074) (#1075) * uses full url to check for https on sign blob interaction * Added translations * remves file accidentally added by transalations hook Co-authored-by: aristides <aristides.staffieri@stellar.org> * adds remaining onboarding tests, cleans up fixtures * cleans up test fixtures, removes excperimental react playwright package, removes action workflow, not ready * ignore playwright tests in CI for now * adds snapshot tests, cleans up debug logs * update ignore pattern for e2e in jest target --------- Co-authored-by: Piyal Basu <pbasu235@gmail.com>
- Loading branch information
1 parent
57309b3
commit 826cbf2
Showing
18 changed files
with
330 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
node_modules/ | ||
/test-results/ | ||
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ | ||
/test-results/ | ||
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ | ||
/test-results/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
import { shuffle } from "lodash"; | ||
import { test, expect } from "./test-fixtures"; | ||
|
||
test.beforeEach(async ({ page, extensionId }) => { | ||
await page.goto(`chrome-extension://${extensionId}/index.html`); | ||
}); | ||
|
||
test("Welcome page loads", async ({ page }) => { | ||
await expect( | ||
page.getByText("Welcome! Is this your first time using Freighter?"), | ||
).toBeVisible(); | ||
await expect(page.getByText("I’m going to need a seed phrase")).toBeVisible(); | ||
await expect(page.getByText("I’ve done this before")).toBeVisible(); | ||
await expect(page).toHaveScreenshot("welcome-page.png"); | ||
}); | ||
|
||
test("Create new wallet", async ({ page }) => { | ||
await expect(page).toHaveScreenshot("welcome-page.png"); | ||
await page.getByText("Create Wallet").click(); | ||
await expect(page.getByText("Create a password")).toBeVisible(); | ||
|
||
await page.locator("#new-password-input").fill("My-password123"); | ||
await page.locator("#confirm-password-input").fill("My-password123"); | ||
await page.locator("#termsOfUse-input").check({ force: true }); | ||
await page.getByText("Confirm").click(); | ||
|
||
await expect(page.getByText("Secret Recovery phrase")).toBeVisible(); | ||
await expect(page).toHaveScreenshot("recovery-page.png", { | ||
mask: [page.locator(".MnemonicDisplay__list-item")], | ||
}); | ||
|
||
const domWords = page.getByTestId("word"); | ||
const wordCount = await domWords.count(); | ||
const words = [] as string[]; | ||
for (let i = 0; i < wordCount; i++) { | ||
const word = await domWords.nth(i).innerText(); | ||
words.push(word); | ||
} | ||
|
||
await page.getByTestId("display-mnemonic-phrase-next-btn").click(); | ||
await expect(page.getByText("Confirm your recovery phrase")).toBeVisible(); | ||
|
||
await expect(page).toHaveScreenshot("confirm-recovery-page.png", { | ||
mask: [page.locator(".ConfirmMnemonicPhrase__word-bubble-wrapper")], | ||
}); | ||
|
||
for (let i = 0; i < words.length; i++) { | ||
await page.getByTestId(words[i]).check(); | ||
} | ||
await page.getByTestId("display-mnemonic-phrase-confirm-btn").click(); | ||
await expect( | ||
page.getByText("Your Freighter install is complete"), | ||
).toBeVisible(); | ||
await expect(page).toHaveScreenshot("wallet-create-complete-page.png"); | ||
}); | ||
|
||
test("Import wallet", async ({ page }) => { | ||
await expect(page).toHaveScreenshot("welcome-page.png"); | ||
await page.getByText("Import Wallet").click(); | ||
await expect( | ||
page.getByText("Import wallet from recovery phrase"), | ||
).toBeVisible(); | ||
|
||
const TEST_WORDS = [ | ||
"have", | ||
"style", | ||
"milk", | ||
"flush", | ||
"you", | ||
"possible", | ||
"thrive", | ||
"dice", | ||
"delay", | ||
"police", | ||
"seminar", | ||
"face", | ||
]; | ||
|
||
for (let i = 1; i <= TEST_WORDS.length; i++) { | ||
await page.locator(`#MnemonicPhrase-${i}`).fill(TEST_WORDS[i - 1]); | ||
} | ||
|
||
await page.locator("#password-input").fill("My-password123"); | ||
await page.locator("#confirm-password-input").fill("My-password123"); | ||
await page.locator("#termsOfUse-input").check({ force: true }); | ||
await page.getByRole("button", { name: "Import" }).click(); | ||
|
||
await expect(page.getByText("Wallet created successfully!")).toBeVisible(); | ||
await expect(page).toHaveScreenshot("wallet-import-complete-page.png"); | ||
}); | ||
|
||
test("Import wallet with wrong password", async ({ page }) => { | ||
await expect(page).toHaveScreenshot("welcome-page.png"); | ||
await page.getByText("Import Wallet").click(); | ||
await expect( | ||
page.getByText("Import wallet from recovery phrase"), | ||
).toBeVisible(); | ||
|
||
const TEST_WORDS = [ | ||
"have", | ||
"style", | ||
"milk", | ||
"flush", | ||
"you", | ||
"possible", | ||
"thrive", | ||
"dice", | ||
"delay", | ||
"police", | ||
"seminar", | ||
"face", | ||
]; | ||
|
||
for (let i = 1; i <= TEST_WORDS.length; i++) { | ||
await page.locator(`#MnemonicPhrase-${i}`).fill(TEST_WORDS[i - 1]); | ||
} | ||
|
||
await page.locator("#password-input").fill("My-password123"); | ||
await page.locator("#confirm-password-input").fill("Not-my-password123"); | ||
await page.locator("#termsOfUse-input").focus(); | ||
|
||
await expect(page.getByText("Passwords must match")).toBeVisible(); | ||
await expect(page).toHaveScreenshot("recovery-bad-password.png", { | ||
mask: [ | ||
page.locator(".RecoverAccount__mnemonic-input"), | ||
page.locator("#password-input"), | ||
page.locator("#confirm-password-input"), | ||
], | ||
}); | ||
}); | ||
|
||
test("Incorrect mnemonic phrase", async ({ page }) => { | ||
await expect(page).toHaveScreenshot("welcome-page.png"); | ||
await page.getByText("Create Wallet").click(); | ||
await expect(page.getByText("Create a password")).toBeVisible(); | ||
|
||
await page.locator("#new-password-input").fill("My-password123"); | ||
await page.locator("#confirm-password-input").fill("My-password123"); | ||
await page.locator("#termsOfUse-input").check({ force: true }); | ||
await page.getByText("Confirm").click(); | ||
|
||
await expect(page.getByText("Secret Recovery phrase")).toBeVisible(); | ||
await expect(page).toHaveScreenshot("recovery-page.png", { | ||
mask: [page.locator(".MnemonicDisplay__list-item")], | ||
}); | ||
|
||
const domWords = page.getByTestId("word"); | ||
const wordCount = await domWords.count(); | ||
const words = [] as string[]; | ||
for (let i = 0; i < wordCount; i++) { | ||
const word = await domWords.nth(i).innerText(); | ||
words.push(word); | ||
} | ||
|
||
await page.getByTestId("display-mnemonic-phrase-next-btn").click(); | ||
await expect(page.getByText("Confirm your recovery phrase")).toBeVisible(); | ||
|
||
const shuffledWords = shuffle(words); | ||
|
||
for (let i = 0; i < shuffledWords.length; i++) { | ||
await page.getByTestId(shuffledWords[i]).check(); | ||
} | ||
|
||
await page.getByTestId("display-mnemonic-phrase-confirm-btn").click(); | ||
await expect( | ||
page.getByText("The secret phrase you entered is incorrect."), | ||
).toBeVisible(); | ||
await expect(page).toHaveScreenshot("incorrect-recovery-phrase-page.png", { | ||
mask: [page.locator(".ConfirmMnemonicPhrase__word-bubble-wrapper")], | ||
}); | ||
}); |
Binary file added
BIN
+30.4 KB
...2e-tests/onboarding.test.ts-snapshots/confirm-recovery-page-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+34.1 KB
...onboarding.test.ts-snapshots/incorrect-recovery-phrase-page-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+41.6 KB
...2e-tests/onboarding.test.ts-snapshots/recovery-bad-password-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+51.9 KB
extension/e2e-tests/onboarding.test.ts-snapshots/recovery-page-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+45.8 KB
...ts/onboarding.test.ts-snapshots/wallet-create-complete-page-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+70.6 KB
...ts/onboarding.test.ts-snapshots/wallet-import-complete-page-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+39.6 KB
extension/e2e-tests/onboarding.test.ts-snapshots/welcome-page-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { test as base, chromium, BrowserContext } from "@playwright/test"; | ||
import path from "path"; | ||
|
||
export const test = base.extend<{ | ||
context: BrowserContext; | ||
extensionId: string; | ||
}>({ | ||
context: async ({}, use) => { | ||
const pathToExtension = path.join(__dirname, "../build"); | ||
const context = await chromium.launchPersistentContext("", { | ||
headless: false, | ||
args: [ | ||
`--disable-extensions-except=${pathToExtension}`, | ||
`--load-extension=${pathToExtension}`, | ||
], | ||
}); | ||
await use(context); | ||
await context.close(); | ||
}, | ||
extensionId: async ({ context }, use) => { | ||
// for manifest v2: | ||
let [background] = context.backgroundPages(); | ||
if (!background) background = await context.waitForEvent("backgroundpage"); | ||
|
||
// for manifest v3: | ||
// let [background] = context.serviceWorkers(); | ||
// if (!background) | ||
// background = await context.waitForEvent('serviceworker'); | ||
|
||
const extensionId = background.url().split("/")[2]; | ||
await use(extensionId); | ||
}, | ||
}); | ||
export const expect = test.expect; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { defineConfig, devices } from "@playwright/test"; | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// require('dotenv').config(); | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
testDir: "./e2e-tests", | ||
/* Run tests in files in parallel */ | ||
fullyParallel: true, | ||
/* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
forbidOnly: !!process.env.CI, | ||
/* Retry on CI only */ | ||
retries: process.env.CI ? 2 : 0, | ||
/* Opt out of parallel tests on CI. */ | ||
workers: process.env.CI ? 1 : undefined, | ||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: "list", | ||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
/* Base URL to use in actions like `await page.goto('/')`. */ | ||
// baseURL: 'http://127.0.0.1:3000', | ||
|
||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: "on-first-retry", | ||
}, | ||
|
||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ | ||
name: "chromium", | ||
use: { ...devices["Desktop Chrome"] }, | ||
}, | ||
|
||
// { | ||
// name: 'firefox', | ||
// use: { ...devices['Desktop Firefox'] }, | ||
// }, | ||
|
||
/* Test against mobile viewports. */ | ||
// { | ||
// name: 'Mobile Chrome', | ||
// use: { ...devices['Pixel 5'] }, | ||
// }, | ||
// { | ||
// name: 'Mobile Safari', | ||
// use: { ...devices['iPhone 12'] }, | ||
// }, | ||
|
||
/* Test against branded browsers. */ | ||
// { | ||
// name: 'Microsoft Edge', | ||
// use: { ...devices['Desktop Edge'], channel: 'msedge' }, | ||
// }, | ||
// { | ||
// name: 'Google Chrome', | ||
// use: { ...devices['Desktop Chrome'], channel: 'chrome' }, | ||
// }, | ||
], | ||
|
||
/* Run your local dev server before starting the tests */ | ||
// webServer: { | ||
// command: 'npm run start', | ||
// url: 'http://127.0.0.1:3000', | ||
// reuseExistingServer: !process.env.CI, | ||
// }, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Testing Page</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="./index.tsx"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Import styles, initialize component theme here. | ||
// import '../src/common.css'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.