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

[Issue #3156] Revert agencies from api #3933

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 2 additions & 0 deletions .github/workflows/ci-frontend-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ jobs:
run: |
sed -En '/API_JWT_PUBLIC_KEY/,/-----END PUBLIC KEY-----/p' ../api/override.env >> .env.local
cat .env.development >> .env.local
# Use the localhost url for tests
sed -i 's|^SENDY_API_URL=.*|SENDY_API_URL=http://localhost:3000|' .env.local
npm run build -- --no-lint
- name: Run e2e tests (Shard ${{ matrix.shard }}/${{ matrix.total_shards }})
Expand Down
26 changes: 18 additions & 8 deletions analytics/src/analytics/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import logging
import logging.config
import time
from datetime import datetime
from pathlib import Path
from typing import Annotated
Expand Down Expand Up @@ -82,8 +83,13 @@ def export_github_data(
config = load_config(config_path, GitHubProjectConfig)
config.temp_dir = temp_dir
config.output_file = output_file

# Run ETL pipeline
logger.info("running extract workflow")
start_time = time.perf_counter()
GitHubProjectETL(config).run()
end_time = time.perf_counter()
logger.info("extract workflow executed in %.5f seconds", end_time - start_time)


# ===========================================================
Expand Down Expand Up @@ -143,13 +149,12 @@ def transform_and_load(
logger.info("running transform and load with effective date %s", datestamp)

# hydrate a dataset instance from the input data
start_time = time.perf_counter()
dataset = EtlDataset.load_from_json_file(file_path=issue_file)

# sync data to db
etldb.sync_data(dataset, datestamp)

# finish
logger.info("transform and load is done")
end_time = time.perf_counter()
logger.info("transform and load is done after %.5f seconds", end_time - start_time)


@etl_app.command(name="extract_transform_and_load")
Expand All @@ -175,16 +180,21 @@ def extract_transform_and_load(

# extract data from GitHub
logger.info("extracting data from GitHub")
start_time = time.perf_counter()
extracted_json = GitHubProjectETL(config).extract_and_transform_in_memory()
end_time = time.perf_counter()
logger.info("extract executed in %.5f seconds", end_time - start_time)

# hydrate a dataset instance from the input data
logger.info("transforming data")
logger.info("transforming and loading data")
start_time = time.perf_counter()
dataset = EtlDataset.load_from_json_object(json_data=extracted_json)

# sync dataset to db
logger.info("writing to database")
etldb.sync_data(dataset, datestamp)
end_time = time.perf_counter()
logger.info("transform and load executed in %.5f seconds", end_time - start_time)

logger.info("workflow is done!")
logger.info("ETL workflow is done")


def validate_effective_date(effective_date: str) -> str | None:
Expand Down
3 changes: 3 additions & 0 deletions frontend/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ const nextConfig = {
"types",
],
},
experimental: {
testProxy: true,
},
};

module.exports = withNextIntl(nextConfig);
69 changes: 69 additions & 0 deletions frontend/tests/e2e/subscribe.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/* eslint-disable testing-library/prefer-screen-queries */

import {
expect,
NextFixture,
test,
} from "next/experimental/testmode/playwright";

function mockAPIEndpoints(next: NextFixture, responseText = "1") {
next.onFetch((request: Request) => {
if (request.url.endsWith("/subscribe") && request.method === "POST") {
return new Response(responseText, {
status: 200,
headers: {
"Content-Type": "text/plain",
},
});
}

return "abort";
});
}
test.beforeEach(async ({ page }) => {
await page.goto("/subscribe");
});

test.afterEach(async ({ context }) => {
await context.close();
});

test("has title", async ({ page }) => {
await expect(page).toHaveTitle(/Subscribe | Simpler.Grants.gov/);
});

test("client side errors", async ({ page }) => {
await page.getByRole("button", { name: /subscribe/i }).click();

// Verify client-side errors for required fields
await expect(page.getByTestId("errorMessage")).toHaveCount(2);
await expect(page.getByText("Please enter a name.")).toBeVisible();
await expect(page.getByText("Please enter an email address.")).toBeVisible();
});

test("successful signup", async ({ next, page }) => {
mockAPIEndpoints(next);

await page.getByLabel("First Name (required)").fill("Apple");
await page.getByLabel("Email (required)").fill("[email protected]");

await page.getByRole("button", { name: /subscribe/i }).click();

await expect(
page.getByRole("heading", { name: /you[']re subscribed/i }),
).toBeVisible();
});

test("error during signup", async ({ next, page }) => {
mockAPIEndpoints(next, "Error with subscribing");

await page.getByLabel("First Name (required)").fill("Apple");
await page.getByLabel("Email (required)").fill("[email protected]");

await page.getByRole("button", { name: /subscribe/i }).click();

await expect(page.getByTestId("errorMessage")).toHaveCount(1);
await expect(
page.getByText(/an error occurred when trying to save your subscription./i),
).toBeVisible();
});