Files
radicle-explorer/tests/support/globalSetup.ts
T
Rūdolfs OšiņšandSebastian Martinez 9cb9332e88 Replace Cypress with Playwright
Playwright is more flexible and has better developer experience than Cypress.
We add end to end tests covering:

  - project source browsing
    - tree view
    - commit list view
    - commit view
  - routing
    - hash based
    - history API based
  - clipboard copy paste functionality
  - seed view
  - project search
  - landing page view
  - settings

Co-authored-by: Sebastian Martinez <me@sebastinez.dev>
Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
2022-12-01 15:54:56 +01:00

34 lines
1.0 KiB
TypeScript

import type { FullConfig } from "@playwright/test";
export default async function globalSetup(_config: FullConfig): Promise<void> {
assertHttpApiRunning();
}
// Assert that the test http-api is running. If it is not running, throw an
// error that explains how to run it.
async function assertHttpApiRunning(): Promise<void> {
const palmTestFixtureSeedId =
"hyb6i8oggc3mgra9siy8yuohhtz34r98pcybja97c9o789wpsg6nn4";
const notRunningMessage =
"The http-api server with test fixtures needs to be running.\n" +
"👉 You can start it with `./scripts/run-http-api-with-fixtures`\n";
let peerId: string | undefined = undefined;
try {
const response = await fetch("http://0.0.0.0:8777");
const data = await response.json();
peerId = data.peer.id;
} catch (err) {
console.error(err);
throw new Error(notRunningMessage);
}
if (peerId !== palmTestFixtureSeedId) {
const wrongSeedMessage =
"The server on port 8777 doesn't have the right fixtures.\n";
throw new Error(wrongSeedMessage + notRunningMessage);
}
}