feat: change download flows to download as .zip file (#2870)
* 📝 (flows.py): Add endpoint to download multiple flows as a zip file 📝 (constants.ts): Add FLOWS constant for API endpoint 📝 (index.ts): Add use-post-download-multiple-flows query function 📝 (use-post-download-multiple-flows.ts): Implement function to download multiple flows as a zip file 📝 (index.tsx): Import usePostDownloadMultipleFlows in componentsComponent 📝 (index.tsx): Implement handleExport function to download multiple flows as a zip file 📝 (index.tsx): Update handleExport function to handle downloading and saving the zip file 📝 (headerComponent.tsx): Add shouldSelectAll state and setShouldSelectAll function to manage select all functionality * formatting file * 📝 (flows.py): Remove download_file endpoint and refactor download_multiple_file to support downloading multiple flows as a zip file 📝 (index.tsx): Refactor export functionality to handle exporting multiple flows as a zip file or a single flow as a JSON file 🔧 (use-post-download-multiple-flows.ts): Update API endpoint for downloading flows 🔧 (index.tsx): Remove unused imports and functions related to exporting flows 🔧 (reactflowUtils.ts): Remove unused downloadFlows function and related imports * [autofix.ci] apply automated fixes * 📝 (flows.py): remove unnecessary whitespace and improve code readability by aligning function parameters in download_multiple_file function --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
2db87e89bf
commit
61265cc327
10 changed files with 170 additions and 129 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import json
|
||||
from uuid import UUID, uuid4
|
||||
|
||||
import orjson
|
||||
|
|
@ -197,26 +198,27 @@ def test_download_file(
|
|||
)
|
||||
db_manager = get_db_service()
|
||||
with session_getter(db_manager) as session:
|
||||
saved_flows = []
|
||||
for flow in flow_list.flows:
|
||||
flow.user_id = active_user.id
|
||||
db_flow = Flow.model_validate(flow, from_attributes=True)
|
||||
session.add(db_flow)
|
||||
saved_flows.append(db_flow)
|
||||
session.commit()
|
||||
# Make request to endpoint
|
||||
response = client.get("api/v1/flows/download/", headers=logged_in_headers)
|
||||
# Make request to endpoint inside the session context
|
||||
flow_ids = [str(db_flow.id) for db_flow in saved_flows] # Convert UUIDs to strings
|
||||
flow_ids_json = json.dumps(flow_ids)
|
||||
response = client.post(
|
||||
"api/v1/flows/download/",
|
||||
data=flow_ids_json,
|
||||
headers={**logged_in_headers, "Content-Type": "application/json"},
|
||||
)
|
||||
# Check response status code
|
||||
assert response.status_code == 200, response.json()
|
||||
# Check response data
|
||||
response_data = response.json()["flows"]
|
||||
starter_projects = load_starter_projects()
|
||||
number_of_projects = len(starter_projects) + len(flow_list.flows)
|
||||
assert len(response_data) == number_of_projects, response_data
|
||||
assert response_data[0]["name"] == "Flow 1"
|
||||
assert response_data[0]["description"] == "description"
|
||||
assert response_data[0]["data"] == data
|
||||
assert response_data[1]["name"] == "Flow 2"
|
||||
assert response_data[1]["description"] == "description"
|
||||
assert response_data[1]["data"] == data
|
||||
# Since the endpoint now returns a zip file, we need to check the content type and the filename in the headers
|
||||
assert response.headers["Content-Type"] == "application/x-zip-compressed"
|
||||
assert "attachment; filename=" in response.headers["Content-Disposition"]
|
||||
|
||||
|
||||
def test_create_flow_with_invalid_data(client: TestClient, active_user, logged_in_headers):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue