Skip to content

feat: e2e workflow & timeouts parametrization #102

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

Merged
merged 2 commits into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: E2E Tests

on:
workflow_call:

jobs:
e2e:
name: E2E Tests
runs-on: ubuntu-latest
steps:
- name: Check out github repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Setup environment
uses: ./.github/actions/setup

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run tests
run: pnpm test:e2e
6 changes: 3 additions & 3 deletions .github/workflows/main-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ jobs:
uses: ./.github/workflows/test.yml
needs: lint

test-integration:
uses: ./.github/workflows/test-integration.yml
needs: lint
e2e-tests:
uses: ./.github/workflows/e2e-tests.yml
needs: test
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Tests
name: Unit and Integration Tests

on:
workflow_call:

jobs:
unit:
name: Unit tests
name: Unit and Integration Tests
runs-on: ubuntu-latest
steps:
- name: Check out github repository
Expand Down
5 changes: 5 additions & 0 deletions tests/e2e/test/globalSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import type { TestProject } from "vitest/node";

import { TestEnvironment } from "../src/utils/test-environment.js";

/**
* Delay in milliseconds to wait for the processing service to finish processing events
*/
export const PROCESSING_SERVICE_RUNNING_DELAY_MS = 10000;

let env: TestEnvironment | undefined;

/**
Expand Down
5 changes: 4 additions & 1 deletion tests/e2e/test/scenarios/allocation.spec-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { beforeAll, describe, expect, inject, it } from "vitest";
import { Bytes32String, IndexerFetchedEvent, TimestampMs } from "@grants-stack-indexer/shared";

import { TestHelper } from "../../src/utils/test-helper.js";
import { PROCESSING_SERVICE_RUNNING_DELAY_MS } from "../globalSetup.js";

/**
* This test suite covers allocation event types:
Expand Down Expand Up @@ -272,7 +273,9 @@ describe("Allocation Events", () => {
]);

await testHelper.startProcessingService();
await new Promise((resolve) => setTimeout(resolve, 4000));
await new Promise((resolve) =>
setTimeout(resolve, PROCESSING_SERVICE_RUNNING_DELAY_MS),
);
await testHelper.stopProcessingService();
});

Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/test/scenarios/attestation.spec-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { beforeAll, describe, expect, inject, it } from "vitest";
import { Bytes32String, IndexerFetchedEvent, TimestampMs } from "@grants-stack-indexer/shared";

import { TestHelper } from "../../src/utils/test-helper.js";
import { PROCESSING_SERVICE_RUNNING_DELAY_MS } from "../globalSetup.js";

/**
* This test suite covers attestation scenarios:
Expand Down Expand Up @@ -206,7 +207,7 @@ describe("Attestation Events", () => {
fetchDelayMs: 5000,
},
]);
await new Promise((resolve) => setTimeout(resolve, 3500));
await new Promise((resolve) => setTimeout(resolve, PROCESSING_SERVICE_RUNNING_DELAY_MS));
await testHelper.stopProcessingService();
await testHelperOtherChain.stopProcessingService();
});
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/test/scenarios/profileCreated.spec-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { beforeAll, describe, expect, inject, it } from "vitest";
import { Bytes32String, IndexerFetchedEvent, TimestampMs } from "@grants-stack-indexer/shared";

import { TestHelper } from "../../src/utils/test-helper.js";
import { PROCESSING_SERVICE_RUNNING_DELAY_MS } from "../globalSetup.js";

describe("Profile Created", () => {
let testHelper: TestHelper;
Expand Down Expand Up @@ -54,7 +55,7 @@ describe("Profile Created", () => {

await testHelper.startProcessingService();
// give some time to fetch the events
await new Promise((resolve) => setTimeout(resolve, 1000));
await new Promise((resolve) => setTimeout(resolve, PROCESSING_SERVICE_RUNNING_DELAY_MS));
await testHelper.stopProcessingService();
});

Expand Down
5 changes: 3 additions & 2 deletions tests/e2e/test/scenarios/roundApplication.spec-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { beforeAll, describe, expect, expectTypeOf, inject, it } from "vitest";
import { Bytes32String, IndexerFetchedEvent, TimestampMs } from "@grants-stack-indexer/shared";

import { TestHelper } from "../../src/utils/test-helper.js";
import { PROCESSING_SERVICE_RUNNING_DELAY_MS } from "../globalSetup.js";

/**
* Happy path events sequence:
Expand Down Expand Up @@ -133,7 +134,7 @@ describe("DVMD Round creation with Pending Role and Application", () => {
]);

await testHelper.startProcessingService();
await new Promise((resolve) => setTimeout(resolve, 2500));
await new Promise((resolve) => setTimeout(resolve, PROCESSING_SERVICE_RUNNING_DELAY_MS));
await testHelper.stopProcessingService();
});

Expand Down Expand Up @@ -528,7 +529,7 @@ describe("Unsupported Strategy and Events", () => {
]);

await testHelper.startProcessingService();
await new Promise((resolve) => setTimeout(resolve, 1500));
await new Promise((resolve) => setTimeout(resolve, 10000));
await testHelper.stopProcessingService();
});

Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/test/scenarios/searchProjects.spec-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { beforeAll, describe, expect, inject, it } from "vitest";
import { Bytes32String, Hex, IndexerFetchedEvent, TimestampMs } from "@grants-stack-indexer/shared";

import { TestHelper } from "../../src/utils/test-helper.js";
import { PROCESSING_SERVICE_RUNNING_DELAY_MS } from "../globalSetup.js";

describe("Search Projects", () => {
let testHelper: TestHelper;
Expand Down Expand Up @@ -84,7 +85,7 @@ describe("Search Projects", () => {
await testHelper.addEvents(events);

await testHelper.startProcessingService();
await new Promise((resolve) => setTimeout(resolve, 2000));
await new Promise((resolve) => setTimeout(resolve, PROCESSING_SERVICE_RUNNING_DELAY_MS));
await testHelper.stopProcessingService();
});

Expand Down
Loading