File size: 1,844 Bytes
df11144
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import streamlit as st
import backend  # Importing backend functions
import os

# Title
st.title("Test Case Generator - QA User Story")

# Input field for the user story
user_story = st.text_area("Enter the QA User Story", "")

# Button to generate test cases
if st.button("Generate Test Cases"):
    if user_story:
        # Show a spinner while the test cases are being generated
        with st.spinner("Generating test cases..."):
            test_cases = backend.generate_testcases(user_story)
        st.subheader("Generated Test Cases")
        st.write(test_cases)
        st.session_state.test_cases = test_cases  # Store test cases in session state for further use
    else:
        st.error("Please enter a user story to generate test cases.")

# Export test cases
st.sidebar.title("Export Test Cases")
format = st.sidebar.selectbox("Select Format", ["json", "csv"], key="export_format")
if st.sidebar.button("Export Test Cases", key="export_button"):
    if 'test_cases' in st.session_state:
        test_cases = st.session_state.test_cases
        export_content = backend.export_test_cases(test_cases, format)

        if format == 'json':
            mime_type = "application/json"
        elif format == 'csv':
            mime_type = "text/csv"
        else:
            st.sidebar.error(f"Unsupported format: {format}")
            export_content = None

        if export_content:
            st.sidebar.download_button(
                label=f"Download Test Cases as {format.upper()}",
                data=export_content,
                file_name=f"test_cases.{format}",
                mime=mime_type,
                key="download_button"
            )
    else:
        st.sidebar.error("No test cases available to export.")

# Footer with a clean divider
st.markdown("---")
st.write("Built by the QA Automation Team")