Skip to content

Commit

Permalink
Merge branch 'initial_e2e_test' of github.com:Zipstack/unstract into …
Browse files Browse the repository at this point in the history
…initial_e2e_test
  • Loading branch information
ritwik-g committed Jan 31, 2025
2 parents f0bbc43 + 1f2b526 commit f51b3b3
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 18 deletions.
47 changes: 39 additions & 8 deletions frontend/src/components/input-output/add-source/AddSource.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Typography } from "antd";
import PropTypes from "prop-types";
import { useEffect, useState } from "react";
import { useEffect, useMemo, useState } from "react";

import { sourceTypes } from "../../../helpers/GetStaticData";
import { useAxiosPrivate } from "../../../hooks/useAxiosPrivate";
Expand All @@ -14,6 +14,7 @@ let transformLlmWhispererJsonSchema;
let LLMW_V2_ID;
let PLAN_TYPES;
let unstractSubscriptionPlanStore;
let llmWhipererAdapterSchema;
try {
transformLlmWhispererJsonSchema =
require("../../../plugins/unstract-subscription/helper/transformLlmWhispererJsonSchema").transformLlmWhispererJsonSchema;
Expand All @@ -22,6 +23,7 @@ try {
PLAN_TYPES =
require("../../../plugins/unstract-subscription/helper/constants").PLAN_TYPES;
unstractSubscriptionPlanStore = require("../../../plugins/store/unstract-subscription-plan-store");
llmWhipererAdapterSchema = require("../../../plugins/unstract-subscription/hooks/useLlmWhispererAdapterSchema.js");
} catch (err) {
// Ignore if not available
}
Expand All @@ -48,13 +50,48 @@ function AddSource({
const axiosPrivate = useAxiosPrivate();
const handleException = useExceptionHandler();

let transformLlmWhispererFormData;
try {
transformLlmWhispererFormData =
llmWhipererAdapterSchema?.useLlmWhipererAdapterSchema()
?.transformLlmWhispererFormData;
} catch {
// Ignore if not available
}

let planType;
if (unstractSubscriptionPlanStore?.useUnstractSubscriptionPlanStore) {
planType = unstractSubscriptionPlanStore?.useUnstractSubscriptionPlanStore(
(state) => state?.unstractSubscriptionPlan?.planType
);
}

const isLLMWPaidSchema = useMemo(() => {
return (
LLMW_V2_ID &&
transformLlmWhispererJsonSchema &&
PLAN_TYPES &&
selectedSourceId === LLMW_V2_ID &&
planType === PLAN_TYPES?.PAID
);
}, [
LLMW_V2_ID,
transformLlmWhispererJsonSchema,
PLAN_TYPES,
selectedSourceId,
planType,
]);

useEffect(() => {
if (!isLLMWPaidSchema || !transformLlmWhispererFormData) return;

const modifiedFormData = transformLlmWhispererFormData(formData);

if (JSON.stringify(modifiedFormData) !== JSON.stringify(formData)) {
setFormData(modifiedFormData);
}
}, [isLLMWPaidSchema, formData]);

useEffect(() => {
if (!selectedSourceId) {
setSpec({});
Expand All @@ -80,13 +117,7 @@ function AddSource({
const data = res?.data;
setFormData(metadata || {});

if (
LLMW_V2_ID &&
transformLlmWhispererJsonSchema &&
PLAN_TYPES &&
selectedSourceId === LLMW_V2_ID &&
planType === PLAN_TYPES?.PAID
) {
if (isLLMWPaidSchema) {
setSpec(transformLlmWhispererJsonSchema(data?.json_schema || {}));
} else {
setSpec(data?.json_schema || {});
Expand Down
10 changes: 10 additions & 0 deletions frontend/src/components/navigations/top-nav-bar/TopNavBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,13 @@ try {
let unstractSubscriptionPlan;
let unstractSubscriptionPlanStore;
let UNSTRACT_SUBSCRIPTION_PLANS;
let UnstractPricingMenuLink;
try {
unstractSubscriptionPlanStore = require("../../../plugins/store/unstract-subscription-plan-store");
UNSTRACT_SUBSCRIPTION_PLANS =
require("../../../plugins/unstract-subscription/helper/constants").UNSTRACT_SUBSCRIPTION_PLANS;
UnstractPricingMenuLink =
require("../../../plugins/unstract-subscription/components/UnstractPricingMenuLink.jsx").UnstractPricingMenuLink;
} catch (err) {
// Plugin unavailable.
}
Expand Down Expand Up @@ -294,6 +297,13 @@ function TopNavBar({ isSimpleLayout, topNavBarOptions }) {
});
}

if (isUnstract && UnstractPricingMenuLink) {
menuItems.push({
key: "7",
label: <UnstractPricingMenuLink orgName={orgName} />,
});
}

// Logout
menuItems.push({
key: "2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Typography } from "antd";
import PropTypes from "prop-types";

const CustomFieldTemplate = (props) => {
const { classNames, errors, children, help } = props;
return (
<div className={classNames}>
{children}
{errors}
<Typography.Text type="danger">{errors}</Typography.Text>
{help}
</div>
);
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/layouts/rjsf-form-layout/RjsfFormLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ function RjsfFormLayout({
const uiSchema = useMemo(
() => ({
"ui:classNames": "my-rjsf-form",
mark_horizontal_lines: {
"ui:widget": !formData?.mark_vertical_lines ? "hidden" : undefined,
},
}),
[formData]
);
Expand Down
5 changes: 1 addition & 4 deletions frontend/src/routes/useMainAppRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ function useMainAppRoutes() {
<Route path="dashboard" element={<UnstractUsagePage />} />
)}
{UnstractSubscriptionPage && (
<Route
path="subscription-plans"
element={<UnstractSubscriptionPage />}
/>
<Route path="pricing" element={<UnstractSubscriptionPage />} />
)}
<Route path="profile" element={<ProfilePage />} />
<Route
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/test_login.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait


class TestLogin:
Expand Down Expand Up @@ -29,6 +29,6 @@ def test_login(self):
self.driver.find_element(By.CSS_SELECTOR, "input:nth-child(11)").click()
WebDriverWait(self.driver, timeout=5).until(
lambda _: self.driver.current_url.endswith("/mock_org/onboard"),
"Login failed."
"Login failed.",
)
self.driver.close()

0 comments on commit f51b3b3

Please sign in to comment.