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

Fix tutorial card logic #3793

Merged
merged 3 commits into from
Jan 23, 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
25 changes: 25 additions & 0 deletions extensions/vscode/e2e/selectors/GUI.selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,31 @@ export class GUISelectors {
);
}

public static getOnboardingTabButton(view: WebView, title: string) {
return SelectorUtils.getElementByDataTestId(
view,
`onboarding-tab-${title}`,
);
}

public static getBestChatApiKeyInput(view: WebView) {
return SelectorUtils.getElementByDataTestId(
view,
"best-chat-api-key-input",
);
}

public static getBestAutocompleteApiKeyInput(view: WebView) {
return SelectorUtils.getElementByDataTestId(
view,
"best-autocomplete-api-key-input",
);
}

public static getTutorialCard(view: WebView) {
return SelectorUtils.getElementByDataTestId(view, "tutorial-card");
}

public static getThreadMessageByText(view: WebView, text: string) {
return view.findWebElement(
By.xpath(`//*[@class="thread-message"]//*[contains(text(), "${text}")]`),
Expand Down
40 changes: 40 additions & 0 deletions extensions/vscode/e2e/tests/GUI.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect } from "chai";
import {
By,
EditorView,
Key,
VSBrowser,
Expand Down Expand Up @@ -53,6 +54,45 @@ describe("GUI Test", () => {
"Quickly get up and running using our API keys.",
);
}).timeout(DEFAULT_TIMEOUT.XL);

it("should display tutorial card after accepting onboarding quick start", async () => {
// Get paragraph with text Best
const bestTab = await GUISelectors.getOnboardingTabButton(view, "Best");
await bestTab.click();

const anthropicInput = await TestUtils.waitForSuccess(
async () => await GUISelectors.getBestChatApiKeyInput(view),
);
anthropicInput.sendKeys("invalid_api_key");

const mistralInput =
await GUISelectors.getBestAutocompleteApiKeyInput(view);
mistralInput.sendKeys("invalid_api_key");

// Get button with text "Connect" and click it
const connectButton = await view.findWebElement(
By.xpath("//button[text()='Connect']"),
);
await connectButton.click();

await TestUtils.waitForSuccess(
async () => await GUISelectors.getTutorialCard(view),
);

// TODO validate that claude has been added to list

// Skip testing Quick Start because github auth opens external app and breaks test
// const quickStartButton = await view.findWebElement(
// By.xpath("//*[contains(text(), 'Get started using our API keys')]")
// );
// await quickStartButton.click();
// await view.switchBack();
// const allowButton = await TestUtils.waitForSuccess(
// async () => await driver.findElement(By.xpath(`//a[contains(text(), "Allow")]`))
// );
// await allowButton.click();
// ({ view, driver } = await GUIActions.switchToReactIframe());
}).timeout(DEFAULT_TIMEOUT.XL);
});

describe("Chat", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ function BestExperienceConfigForm({
placeholder="Enter your Anthropic API Key"
value={chatApiKey}
onChange={(e) => setChatApiKey(e.target.value)}
data-testid="best-chat-api-key-input"
/>
<InputSubtext>
<a
Expand Down Expand Up @@ -133,6 +134,7 @@ function BestExperienceConfigForm({
placeholder="Enter your Mistral API Key"
value={autocompleteApiKey}
onChange={(e) => setAutocompleteApiKey(e.target.value)}
data-testid="best-autocomplete-api-key-input"
/>
<InputSubtext>
<a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export function OnboardingCardTabs({
key={tabType}
isActive={activeTab === tabType}
onClick={() => onTabClick(tabType as TabTitle)}
data-testid={`onboarding-tab-${tabType}`}
>
<p className="m-0 hidden font-medium md:block">
{titles.default}
Expand Down
7 changes: 2 additions & 5 deletions gui/src/components/mainInput/TutorialCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function TutorialCard({ onClose }: TutorialCardProps) {
const ideMessenger = useContext(IdeMessengerContext);

return (
<TutorialCardDiv>
<TutorialCardDiv data-testid={`tutorial-card`}>
<CloseButton onClick={onClose}>
<XMarkIcon className="h-5 w-5" />
</CloseButton>
Expand All @@ -57,10 +57,7 @@ export function TutorialCard({ onClose }: TutorialCardProps) {
<span
className="cursor-pointer underline"
onClick={() =>
ideMessenger.post(
"vscode/openMoveRightMarkdown",
undefined,
)
ideMessenger.post("vscode/openMoveRightMarkdown", undefined)
}
>
Move Chat panel to the right
Expand Down
2 changes: 1 addition & 1 deletion gui/src/pages/gui/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ export function Chat() {
</div>
)}

{showTutorialCard !== false && !onboardingCard.open && (
{showTutorialCard !== false && !onboardingCard.show && (
<div className="flex w-full justify-center">
<TutorialCard onClose={closeTutorialCard} />
</div>
Expand Down
Loading