Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: e2e test and fixture overhaul #159

Merged
merged 6 commits into from
Mar 26, 2024
Merged

test: e2e test and fixture overhaul #159

merged 6 commits into from
Mar 26, 2024

Conversation

SgtPooki
Copy link
Member

@SgtPooki SgtPooki commented Mar 26, 2024

Title

test: e2e test and fixture overhaul

Description

A pretty significant improvement to the way tests can be written, and use of local kubo gateway across tests. Need to debug in CI since pulling fixtures depends on docker being available.

Summary of changes

  • Added new fixtures for testing subdomain and path routing in ./test-e2e/fixtures/routing-test-fixtures.ts which automatically sets SW config
  • Added gateway conformance fixture importing in ./test-e2e/fixtures/load-kubo-fixtures.ts
  • Updated global-setup.js to global-setup.ts & instantiates a local kubo gateway for tests to use (loading some gateway conformance fixtures timed out without this)
  • updated e2e tests to use new test fixtures where applicable
  • added do-range-request test to test range requests more easily
  • added global-teardown.ts that deletes kubo IPFS_PATH after tests are done
  • added some more locators to ./test-e2e/locators.ts that help with configuration setting via UI, and functions to use them: setConfigViaUiSubdomain and setConfigViaUi, though they are currently unused.

Notes & open questions

I will probably merge this once I get the CI passing.

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

chore: single kubo gateway for parallel tests

chore: attempting to remove beforeEach for byte-ranges

chore: working on dx for e2e

chore: move gateway conformance to global setup/teardown

test: e2e fixtures for subdomain and path routing

chore: remove unnecessary service worker wait
Copy link
Member Author

@SgtPooki SgtPooki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self review

test-e2e/fixtures/set-sw-config.ts Outdated Show resolved Hide resolved
if (partialText == null) throw new Error('missing response')
test('can get trailing byte range from car with missing data', async ({ page }) => {
const { bytes, byteSize, statusCode } = await doRangeRequest({ page, range: 'bytes=2200-', path: '/ipfs/QmYhmPjhFjYFyaoiuNzYv8WGavpSRDwdHWe5B4M5du5Rtk' })
// TODO: do we need to check the full 872 bytes...?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idk if theres some block-crossing logic we want to check here, or if checking the size is sufficient, @lidel

@@ -0,0 +1,124 @@
/**
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was ported over from helia-http-gateway and improved slightly

const controller = await createKuboNode()
await Promise.all([controller.start(), loadKuboFixtures()])

process.env.KUBO_PID = `${await controller.pid()}`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i thought we would need this to kill the kubo instance, but it seems like playwright handles it?

import { kuboRepoDir } from './fixtures/load-kubo-fixtures.js'

export default async function globalTeardown (config: Config): Promise<void> {
await $`rm -rf ${kuboRepoDir}`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about pushing up the kubo repo just to simplify things, but that feels bad.

test-e2e/layout.test.ts Outdated Show resolved Hide resolved
@SgtPooki SgtPooki self-assigned this Mar 26, 2024
@SgtPooki SgtPooki requested review from lidel and 2color March 26, 2024 21:13
@SgtPooki SgtPooki marked this pull request as ready for review March 26, 2024 21:13
@SgtPooki SgtPooki merged commit b0f26ac into main Mar 26, 2024
20 checks passed
@SgtPooki SgtPooki deleted the test/e2e-range-requests branch March 26, 2024 21:18
@SgtPooki SgtPooki mentioned this pull request Mar 26, 2024
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant