-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5611d44
commit 756ff53
Showing
50 changed files
with
1,381 additions
and
21 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 |
---|---|---|
@@ -1,6 +1,12 @@ | ||
GITHUB_TOKEN=secret_token | ||
NOTION_TOKEN=secret_token | ||
ASSETS=/User/bob/web/assets | ||
HOSTD_E2E_TEST_API_URL=https://hostd.zen.local | ||
HOSTD_E2E_TEST_API_PASSWORD=password | ||
RENTERD_E2E_TEST_API_URL=https://renterd.zen.local | ||
RENTERD_E2E_TEST_API_PASSWORD=password | ||
WALLETD_E2E_TEST_API_URL=https://walletd.zen.local | ||
WALLETD_E2E_TEST_API_PASSWORD=password | ||
|
||
# Make Go use UTC for time formatting | ||
TZ=UTC |
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
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,25 @@ | ||
{ | ||
"extends": ["plugin:playwright/recommended", "../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["src/**/*.{ts,js,tsx,jsx}"], | ||
"rules": {} | ||
} | ||
], | ||
"rules": { | ||
"playwright/expect-expect": "off" | ||
} | ||
} |
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 @@ | ||
output |
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,81 @@ | ||
import { defineConfig, devices } from '@playwright/test' | ||
import { nxE2EPreset } from '@nx/playwright/preset' | ||
|
||
import { workspaceRoot } from '@nx/devkit' | ||
|
||
// For CI, you may want to set BASE_URL to the deployed application. | ||
const baseURL = process.env['BASE_URL'] || 'http://localhost:3006' | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// require('dotenv').config(); | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
...nxE2EPreset(__filename, { testDir: './src' }), | ||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
baseURL, | ||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: 'on-first-retry', | ||
video: 'on-first-retry', | ||
}, | ||
// Timeout per test. | ||
timeout: 60_000, | ||
expect: { | ||
// Raise the timeout because it is running against next dev mode | ||
// which requires compilation the first to a page is visited | ||
timeout: 15_000, | ||
}, | ||
outputDir: 'output', | ||
/* Run your local dev server before starting the tests */ | ||
webServer: { | ||
command: 'npx nx serve hostd', | ||
url: baseURL, | ||
reuseExistingServer: !process.env.CI, | ||
cwd: workspaceRoot, | ||
}, | ||
// Run the tests serially as they may mutate the state of the same application. | ||
workers: 1, | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
}, | ||
|
||
// Disable firefox and webkit to save time since tests are running serially. | ||
// { | ||
// name: 'firefox', | ||
// use: { ...devices['Desktop Firefox'] }, | ||
// }, | ||
|
||
// { | ||
// name: 'webkit', | ||
// use: { ...devices['Desktop Safari'] }, | ||
// }, | ||
|
||
// Uncomment for mobile browsers support | ||
/* { | ||
name: 'Mobile Chrome', | ||
use: { ...devices['Pixel 5'] }, | ||
}, | ||
{ | ||
name: 'Mobile Safari', | ||
use: { ...devices['iPhone 12'] }, | ||
}, */ | ||
|
||
// Uncomment for branded browsers | ||
/* { | ||
name: 'Microsoft Edge', | ||
use: { ...devices['Desktop Edge'], channel: 'msedge' }, | ||
}, | ||
{ | ||
name: 'Google Chrome', | ||
use: { ...devices['Desktop Chrome'], channel: 'chrome' }, | ||
} */ | ||
], | ||
}) |
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,19 @@ | ||
{ | ||
"name": "hostd-e2e", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "apps/hostd-e2e/src", | ||
"projectType": "application", | ||
"implicitDependencies": ["hostd"], | ||
"targets": { | ||
"e2e": { | ||
"executor": "@nx/playwright:playwright", | ||
"outputs": ["{workspaceRoot}/dist/.playwright/apps/hostd-e2e"], | ||
"options": { | ||
"config": "apps/hostd-e2e/playwright.config.ts" | ||
} | ||
}, | ||
"lint": { | ||
"executor": "@nx/eslint:lint" | ||
} | ||
} | ||
} |
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,11 @@ | ||
import { Page } from '@playwright/test' | ||
|
||
export async function clearToasts({ page }: { page: Page }) { | ||
const clearButtons = page.getByTestId('toasts').locator('button') | ||
while ((await clearButtons.count()) > 0) { | ||
await clearButtons.first().click() | ||
// Timeout required because the toast animation is not instantaneous. | ||
// eslint-disable-next-line playwright/no-wait-for-timeout | ||
await page.waitForTimeout(1000) | ||
} | ||
} |
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,35 @@ | ||
import { Locator, expect } from '@playwright/test' | ||
|
||
export async function clickIfEnabledAndWait( | ||
locator: Locator, | ||
waitForLocator?: Locator | ||
) { | ||
const isDisabled = await locator.isDisabled() | ||
if (!isDisabled) { | ||
await locator.click() | ||
if (waitForLocator) { | ||
await expect(waitForLocator).toBeVisible() | ||
} | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
export async function clickAndWait(locator: Locator, waitForLocator?: Locator) { | ||
await locator.click() | ||
if (waitForLocator) { | ||
await expect(waitForLocator).toBeVisible() | ||
} | ||
} | ||
|
||
export async function clickIf( | ||
locator: Locator, | ||
clickIf: 'isVisible' | 'isDisabled' | ||
) { | ||
const click = await locator[clickIf]() | ||
if (click) { | ||
await locator.click() | ||
return true | ||
} | ||
return false | ||
} |
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,71 @@ | ||
import { Page } from '@playwright/test' | ||
import { setSwitchByLabel } from './switchValue' | ||
import { setViewMode } from './configViewMode' | ||
import { fillTextInputByName } from './textInput' | ||
import { fillSelectInputByName } from './selectInput' | ||
import { clearToasts } from './clearToasts' | ||
import { clickIfEnabledAndWait } from './click' | ||
|
||
export async function configResetAllSettings({ page }: { page: Page }) { | ||
await setViewMode({ page, state: 'advanced' }) | ||
|
||
// host | ||
await setSwitchByLabel(page, 'acceptingContracts', false) | ||
await fillTextInputByName(page, 'netAddress', 'foobar.com:9880') | ||
await fillTextInputByName(page, 'maxContractDuration', '6') | ||
|
||
// pricing | ||
await fillSelectInputByName(page, 'pinnedCurrency', 'USD') | ||
await fillTextInputByName(page, 'pinnedThreshold', '3') | ||
|
||
await setSwitchByLabel(page, 'shouldPinStoragePrice', false) | ||
await fillTextInputByName(page, 'storagePrice', '10') | ||
await setSwitchByLabel(page, 'shouldPinStoragePrice', true) | ||
await fillTextInputByName(page, 'storagePricePinned', '5') | ||
await setSwitchByLabel(page, 'shouldPinStoragePrice', false) | ||
|
||
await setSwitchByLabel(page, 'shouldPinEgressPrice', false) | ||
await fillTextInputByName(page, 'egressPrice', '10') | ||
await setSwitchByLabel(page, 'shouldPinEgressPrice', true) | ||
await fillTextInputByName(page, 'egressPricePinned', '5') | ||
await setSwitchByLabel(page, 'shouldPinEgressPrice', false) | ||
|
||
await setSwitchByLabel(page, 'shouldPinIngressPrice', false) | ||
await fillTextInputByName(page, 'ingressPrice', '10') | ||
await setSwitchByLabel(page, 'shouldPinIngressPrice', true) | ||
await fillTextInputByName(page, 'ingressPricePinned', '5') | ||
await setSwitchByLabel(page, 'shouldPinIngressPrice', false) | ||
|
||
await fillTextInputByName(page, 'collateralMultiplier', '2') | ||
|
||
await setSwitchByLabel(page, 'shouldPinMaxCollateral', false) | ||
await setSwitchByLabel(page, 'shouldPinMaxCollateral', false) | ||
await setSwitchByLabel(page, 'autoMaxCollateral', false) | ||
await fillTextInputByName(page, 'maxCollateral', '10') | ||
await setSwitchByLabel(page, 'shouldPinMaxCollateral', true) | ||
await fillTextInputByName(page, 'maxCollateralPinned', '5') | ||
await setSwitchByLabel(page, 'shouldPinMaxCollateral', false) | ||
|
||
await fillTextInputByName(page, 'contractPrice', '0.2') | ||
await fillTextInputByName(page, 'baseRPCPrice', '1') | ||
await fillTextInputByName(page, 'sectorAccessPrice', '1') | ||
await fillTextInputByName(page, 'priceTableValidity', '30') | ||
|
||
// accounts | ||
await fillTextInputByName(page, 'accountExpiry', '30') | ||
await fillTextInputByName(page, 'maxAccountBalance', '10') | ||
|
||
// bandwidth | ||
await fillTextInputByName(page, 'ingressLimit', '0') | ||
await fillTextInputByName(page, 'egressLimit', '0') | ||
|
||
// DNS | ||
await fillSelectInputByName(page, 'dnsProvider', '') | ||
|
||
// save | ||
await clickIfEnabledAndWait( | ||
page.getByText('Save changes'), | ||
page.getByText('Settings have been saved') | ||
) | ||
await clearToasts({ page }) | ||
} |
Oops, something went wrong.