Skip to content

Commit

Permalink
fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
gravityblast committed Feb 13, 2024
2 parents d7e1703 + 371db1c commit f37115c
Show file tree
Hide file tree
Showing 43 changed files with 4,173 additions and 417 deletions.
14 changes: 14 additions & 0 deletions docs/DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,20 @@ component route

Find more information about routing [here](https://reactrouter.com/docs/en/v6).

## Running E2E tests using Synpress

Synpress is an E2E testing framework for testing dApps. It works by setting up metamask before every run.

### Running Synpress

1. Put `TEST_PRIVATE_KEY` in `.env.local` in the respective directory (e.g. `packages/round-manager`)
2. Start the dev server `pnpm start`
3. Download playwright with `pnpm exec playwright install`
4. Run tests with `pnpm synpress:test`

NOTE: some tests require you to be part of a testing program and have some gas in your wallet. Please use a private key that has some gas on Fantom Testnet and Optimism Mainnet, and is part of the "GS Optimism Program 10 Round" Program on Optimism Mainnet.


## Submitting a PR

Please always submit draft PRs at first, and make sure they pass the following conditions before you mark them as Ready for review.
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"devDependencies": {
"@commitlint/cli": "^17.7.1",
"@commitlint/config-conventional": "^17.7.0",
"turbo": "^1.11.0"
"turbo": "^1.12.2"
},
"dependencies": {
"prettier": "^3.0.3"
Expand All @@ -44,5 +44,6 @@
"overrides": {
"webpack": "^5"
}
}
},
"workspaces": ["packages/*"]
}
3 changes: 2 additions & 1 deletion packages/builder/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = {
env: {
browser: true,
es2021: true,
jest: true,
},
parser: "@typescript-eslint/parser",
extends: ["airbnb", "airbnb-typescript", "prettier"],
Expand Down Expand Up @@ -35,5 +36,5 @@ module.exports = {
"eol-last": ["error", "always"],
"react/require-default-props": "off",
},
ignorePatterns: ["node_modules/"],
ignorePatterns: ["node_modules/", "./fixtures.ts"],
};
1 change: 1 addition & 0 deletions packages/builder/craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = {
require.resolve("jest-transform-stub"),
},
setupFilesAfterEnv: ["./src/setupTests.ts"],
testPathIgnorePatterns: ["/e2e/"],
}),
},
webpack: {
Expand Down
14 changes: 14 additions & 0 deletions packages/builder/e2e/homepage.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import * as metamask from "@synthetixio/synpress/commands/metamask";
import { test } from "../fixtures";

test.beforeEach(async ({ page }) => {
// baseUrl is set in playwright.config.ts
await page.goto("/");
});

test("main page loads and wallet connects", async ({ page }) => {
await page.getByRole("navigation").getByTestId("rk-connect-button").click();
await page.getByText("Metamask").click();
await metamask.acceptAccess();
await page.getByText("My Projects").waitFor();
});
69 changes: 69 additions & 0 deletions packages/builder/fixtures.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { type BrowserContext, chromium, test as base } from "@playwright/test";
import { initialSetup } from "@synthetixio/synpress/commands/metamask";
import { setExpectInstance } from "@synthetixio/synpress/commands/playwright";
import { resetState } from "@synthetixio/synpress/commands/synpress";
import { prepareMetamask } from "@synthetixio/synpress/helpers";
import { config } from "dotenv";

export const test = base.extend<{
context: BrowserContext;
}>({
// eslint-disable-next-line no-empty-pattern
context: async ({}, use) => {
config({
path: ["./.env.local", "./.env", "./.env.test"],
});

// required for synpress as it shares same expect instance as playwright
// eslint-disable-next-line @typescript-eslint/no-use-before-define
await setExpectInstance(expect);

// download metamask
const metamaskPath = await prepareMetamask(
process.env.METAMASK_VERSION || "10.25.0"
);

// prepare browser args
const browserArgs = [
`--disable-extensions-except=${metamaskPath}`,
`--load-extension=${metamaskPath}`,
"--remote-debugging-port=9222",
];

if (process.env.CI) {
browserArgs.push("--disable-gpu");
}

if (process.env.HEADLESS_MODE) {
browserArgs.push("--headless=new");
}

// launch browser
const context = await chromium.launchPersistentContext("", {
headless: false,
args: browserArgs,
});

// wait for metamask
await context.pages()[0].waitForTimeout(3000);

// setup metamask
await initialSetup(chromium, {
secretWordsOrPrivateKey:
process.env.TEST_PRIVATE_KEY ??
"test test test test test test test test test test test junk",
network: "optimism",
password: "Tester@1234",
enableAdvancedSettings: true,
});

await use(context);

await context.close();

await resetState();
},
});

// eslint-disable-next-line prefer-destructuring
export const expect = test.expect;
12 changes: 11 additions & 1 deletion packages/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@
"@heroicons/react": "^2.0.11",
"@lagunovsky/redux-react-router": "^2.2.0",
"@pinata/sdk": "^1.1.26",
"@playwright/test": "^1.41.1",
"@rainbow-me/rainbowkit": "^0.12.18",
"@redux-devtools/extension": "^3.2.3",
"@rsbuild/core": "^0.4.1",
"@rsbuild/plugin-react": "^0.3.11",
"@rsbuild/plugin-svgr": "^0.3.11",
"@rsdoctor/rspack-plugin": "^0.1.1",
"@synthetixio/synpress": "3.7.2-beta.10",
"@tailwindcss/line-clamp": "^0.4.2",
"@tailwindcss/typography": "^0.5.9",
"@tanstack/query-core": "4.22.0",
Expand Down Expand Up @@ -54,6 +60,8 @@
"history": "^5.3.0",
"https-browserify": "^1.0.0",
"jest": "^27.0",
"jszip": "^3.10.1",
"localforage": "^1.10.0",
"os-browserify": "^0.3.0",
"pnpm": "7",
"postcss": "^8.4.14",
Expand Down Expand Up @@ -93,7 +101,8 @@
"lint": "eslint --ext .js,.jsx,.ts,.tsx ./src --cache",
"lint:ci": "CI=false pnpm lint",
"lint:fix": "eslint ./src --fix --cache",
"typecheck": "tsc --noEmit"
"typecheck": "tsc --noEmit",
"synpress:test": "playwright test --project=chromium"
},
"eslintConfig": {
"extends": [
Expand Down Expand Up @@ -125,6 +134,7 @@
"@types/react-gtm-module": "^2.0.1",
"@typescript-eslint/eslint-plugin": "^5.23.0",
"@typescript-eslint/parser": "^5.23.0",
"dotenv": "^16.4.1",
"eslint": "^8.2.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^17.0.0",
Expand Down
36 changes: 36 additions & 0 deletions packages/builder/playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { defineConfig, devices } from "@playwright/test";

export default defineConfig({
testDir: "./e2e",
timeout: 60 * 1000,
expect: {
timeout: 5000,
},
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 1 : 0,
workers: 1,
reporter: "html",
use: {
actionTimeout: 0,
baseURL: "http://localhost:3000",
trace: "on-first-retry",
headless: false,
},
// start local web server before tests
webServer: [
{
command: "pnpm start",
url: "http://localhost:3000",
timeout: 5000,
reuseExistingServer: true,
},
],
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},
],
outputDir: "test-results",
});
41 changes: 41 additions & 0 deletions packages/builder/rsbuild.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { defineConfig, loadEnv } from "@rsbuild/core";
import { pluginReact } from "@rsbuild/plugin-react";
import { pluginSvgr } from "@rsbuild/plugin-svgr";
import { RsdoctorRspackPlugin } from "@rsdoctor/rspack-plugin";
const path = require("path");

const { publicVars } = loadEnv({ prefixes: ["REACT_APP_"] });

export default defineConfig({
plugins: [pluginReact(), pluginSvgr()],
html: {
template: "./public/index.html",
},
server: {
port: Number(process.env.PORT) || 3000,
},
source: {
define: publicVars,
alias: {
localforage: path.resolve(
__dirname,
"./node_modules/localforage/src/localforage.js"
),
jszip: path.resolve(__dirname, "./node_modules/jszip/lib/index.js"),
"readable-stream": require.resolve("readable-stream"),
"csv-stringify": "csv-stringify/browser/esm",
},
},
tools: {
rspack(config, { appendPlugins }) {
// Only register the plugin when RSDOCTOR is true, as the plugin will increase the build time.
if (process.env.RSDOCTOR) {
appendPlugins(
new RsdoctorRspackPlugin({
// plugin options
})
);
}
},
},
});
Loading

0 comments on commit f37115c

Please sign in to comment.