Skip to content

Commit

Permalink
test: extract e2e fixtures into library
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Oct 11, 2024
1 parent 1d1452d commit 024db64
Show file tree
Hide file tree
Showing 68 changed files with 323 additions and 421 deletions.
5 changes: 5 additions & 0 deletions .changeset/chatty-maps-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@siafoundation/e2e': minor
---

Added new library for shared e2e testing fixtures and methods.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@ The Sia web libraries provide developers with convenient TypeScript SDKs for usi

### Testing

- [walletd-e2e](walletd-e2e) - App for testing walletd.
- [renterd-e2e](renterd-e2e) - App for testing renterd.
- [hostd-e2e](hostd-e2e) - App for testing hostd.
- [walletd-e2e](apps/walletd-e2e) - App for testing walletd.
- [renterd-e2e](apps/renterd-e2e) - App for testing renterd.
- [hostd-e2e](apps/hostd-e2e) - App for testing hostd.
- [e2e](libs/e2e) - Shared e2e testing code.
- [@siafoundation/clusterd](libs/clusterd) - Methods for controlling `clusterd` in e2e testing.
- [@siafoundation/walletd-mock](walletd-mock) - `walletd` data and API mock library for testing.
- [@siafoundation/sia-central-mock](sia-central-mock) - Sia Central data and API mock library for testing.
- [@siafoundation/walletd-mock](libs/walletd-mock) - `walletd` data and API mock library for testing.
- [@siafoundation/sia-central-mock](libs/sia-central-mock) - Sia Central data and API mock library for testing.

## Development

Expand Down
8 changes: 5 additions & 3 deletions apps/hostd-e2e/src/fixtures/beforeTest.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { mockApiSiaCentralHostsNetworkAverages } from '@siafoundation/sia-central-mock'
import { login } from './login'
import { Page } from 'playwright'
import { mockApiSiaScanExchangeRates } from './siascan'
import { setCurrencyDisplay } from './preferences'
import {
clusterd,
setupCluster,
teardownCluster,
} from '@siafoundation/clusterd'
import { clickIf } from './click'
import {
clickIf,
setCurrencyDisplay,
mockApiSiaScanExchangeRates,
} from '@siafoundation/e2e'

export async function beforeTest(page: Page) {
await mockApiSiaScanExchangeRates({ page })
Expand Down
14 changes: 0 additions & 14 deletions apps/hostd-e2e/src/fixtures/clearToasts.ts

This file was deleted.

35 changes: 0 additions & 35 deletions apps/hostd-e2e/src/fixtures/click.ts

This file was deleted.

14 changes: 8 additions & 6 deletions apps/hostd-e2e/src/fixtures/configResetAllSettings.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
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'
import {
setSwitchByLabel,
setViewMode,
clickIfEnabledAndWait,
clearToasts,
fillTextInputByName,
fillSelectInputByName,
} from '@siafoundation/e2e'
import { navigateToConfig } from './navigate'

export async function configResetAllSettings({ page }: { page: Page }) {
Expand Down
2 changes: 1 addition & 1 deletion apps/hostd-e2e/src/fixtures/login.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Page, expect } from '@playwright/test'
import { fillTextInputByName } from './textInput'
import { fillTextInputByName } from '@siafoundation/e2e'

export async function login({
page,
Expand Down
11 changes: 0 additions & 11 deletions apps/hostd-e2e/src/fixtures/preferences.ts

This file was deleted.

10 changes: 0 additions & 10 deletions apps/hostd-e2e/src/fixtures/siascan.ts

This file was deleted.

34 changes: 0 additions & 34 deletions apps/hostd-e2e/src/fixtures/textInput.ts

This file was deleted.

2 changes: 1 addition & 1 deletion apps/hostd-e2e/src/fixtures/volumes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Page, expect } from '@playwright/test'
import { navigateToVolumes } from './navigate'
import { fillTextInputByName } from './textInput'
import { fillTextInputByName } from '@siafoundation/e2e'

export async function createVolume(page: Page, name: string, path: string) {
const fullPath = `${path}/${name}`
Expand Down
14 changes: 6 additions & 8 deletions apps/hostd-e2e/src/specs/config.spec.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { test, expect } from '@playwright/test'
import {
setViewMode,
expectTextInputByName,
expectTextInputNotVisible,
fillTextInputByName,
fillSelectInputByName,
expectSwitchByLabel,
expectSwitchVisible,
setSwitchByLabel,
} from '../fixtures/switchValue'
import { setViewMode } from '../fixtures/configViewMode'
} from '@siafoundation/e2e'
import { navigateToConfig } from '../fixtures/navigate'
import {
expectTextInputByName,
expectTextInputNotVisible,
fillTextInputByName,
} from '../fixtures/textInput'
import { fillSelectInputByName } from '../fixtures/selectInput'
import { afterTest, beforeTest } from '../fixtures/beforeTest'
import { configResetAllSettings } from '../fixtures/configResetAllSettings'

Expand Down
2 changes: 1 addition & 1 deletion apps/hostd-e2e/src/specs/volumes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { afterTest, beforeTest } from '../fixtures/beforeTest'
import fs from 'fs'
import os from 'os'
import { fillTextInputByName } from '../fixtures/textInput'
import { fillTextInputByName } from '@siafoundation/e2e'

let dirPath = '/'

Expand Down
3 changes: 1 addition & 2 deletions apps/hostd-e2e/src/specs/wallet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { test, expect } from '@playwright/test'
import { navigateToWallet } from '../fixtures/navigate'
import { random } from '@technically/lodash'
import { afterTest, beforeTest } from '../fixtures/beforeTest'
import { fillTextInputByName } from '../fixtures/textInput'
import { setSwitchByLabel } from '../fixtures/switchValue'
import { fillTextInputByName, setSwitchByLabel } from '@siafoundation/e2e'
import BigNumber from 'bignumber.js'

test.beforeEach(async ({ page }) => {
Expand Down
8 changes: 5 additions & 3 deletions apps/renterd-e2e/src/fixtures/beforeTest.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { login } from './login'
import { Page } from 'playwright'
import { setCurrencyDisplay } from './preferences'
import { mockApiSiaScanExchangeRates } from './siascan'
import { mockApiSiaCentralHostsNetworkAverages } from '@siafoundation/sia-central-mock'
import { clickIf } from './click'
import {
clusterd,
setupCluster,
teardownCluster,
waitForContracts,
} from '@siafoundation/clusterd'
import {
setCurrencyDisplay,
mockApiSiaScanExchangeRates,
clickIf,
} from '@siafoundation/e2e'

export async function beforeTest(page: Page, { hostdCount = 0 } = {}) {
await mockApiSiaScanExchangeRates({ page })
Expand Down
3 changes: 1 addition & 2 deletions apps/renterd-e2e/src/fixtures/buckets.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Page, expect } from '@playwright/test'
import { navigateToBuckets } from './navigate'
import { fillTextInputByName } from './textInput'
import { clearToasts } from './clearToasts'
import { fillTextInputByName, clearToasts } from '@siafoundation/e2e'
import { deleteDirectory, deleteFile } from './files'

export async function createBucket(page: Page, name: string) {
Expand Down
14 changes: 8 additions & 6 deletions apps/renterd-e2e/src/fixtures/configResetSettings.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { Page } from '@playwright/test'
import { setSwitchByLabel } from './switchValue'
import { setViewMode } from './configViewMode'
import { fillTextInputByName } from './textInput'
import { clearToasts } from './clearToasts'
import { clickIfEnabledAndWait } from './click'
import { fillSelectInputByName } from './selectInput'
import {
setSwitchByLabel,
setViewMode,
fillTextInputByName,
clearToasts,
clickIfEnabledAndWait,
fillSelectInputByName,
} from '@siafoundation/e2e'
import { navigateToConfig } from './navigate'

export async function configResetAllSettings({ page }: { page: Page }) {
Expand Down
24 changes: 0 additions & 24 deletions apps/renterd-e2e/src/fixtures/configViewMode.ts

This file was deleted.

2 changes: 1 addition & 1 deletion apps/renterd-e2e/src/fixtures/files.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Page, expect } from '@playwright/test'
import { readFileSync } from 'fs'
import { fillTextInputByName } from './textInput'
import { fillTextInputByName } from '@siafoundation/e2e'

export async function deleteFile(page: Page, path: string) {
await openFileContextMenu(page, path)
Expand Down
2 changes: 1 addition & 1 deletion apps/renterd-e2e/src/fixtures/login.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Page, expect } from '@playwright/test'
import { fillTextInputByName } from './textInput'
import { fillTextInputByName } from '@siafoundation/e2e'

export async function login({
page,
Expand Down
26 changes: 0 additions & 26 deletions apps/renterd-e2e/src/fixtures/selectInput.ts

This file was deleted.

34 changes: 0 additions & 34 deletions apps/renterd-e2e/src/fixtures/switchValue.ts

This file was deleted.

Loading

0 comments on commit 024db64

Please sign in to comment.