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: send and cancel btn tooltips #436

Merged
merged 4 commits into from
Apr 25, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,22 @@
/>
{#if !$isLoading}
<Button
data-testid="send message"
kind="secondary"
icon={ArrowRight}
size="field"
type="submit"
aria-label="send"
iconDescription="send"
disabled={$isLoading || !$input}
/>
{:else}
<Button
data-testid="cancel message"
kind="secondary"
size="field"
type="submit"
icon={StopFilledAlt}
aria-label="cancel message"
iconDescription="cancel"
/>
{/if}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('The Chat Page', () => {

test('the send button is disabled when there is no text in the input', () => {
render(ChatPage);
const submitBtn = screen.getByLabelText('send');
const submitBtn = screen.getByTestId('send message');
expect(submitBtn).toHaveProperty('disabled', true);
});

Expand Down Expand Up @@ -99,12 +99,12 @@ describe('The Chat Page', () => {
await user.type(input, question);
await user.click(submitBtn);

expect(screen.getByLabelText('cancel message')).toBeInTheDocument();
expect(screen.getByTestId('cancel message')).toBeInTheDocument();

await delay(delayTime);

await user.type(input, 'new question');
expect(screen.queryByLabelText('cancel message')).not.toBeInTheDocument();
expect(screen.queryByTestId('cancel message')).not.toBeInTheDocument();
});

it('displays a toast error notification when there is an error with the AI response', async () => {
Expand Down Expand Up @@ -245,7 +245,7 @@ describe('The Chat Page', () => {
await user.type(input, question);
await user.click(submitBtn);
await delay(delayTime / 2);
const cancelBtn = screen.getByLabelText('cancel message');
const cancelBtn = screen.getByTestId('cancel message');
await user.click(cancelBtn);

await screen.findAllByText('Response Canceled');
Expand Down
2 changes: 1 addition & 1 deletion src/leapfrogai_ui/tests/chat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ test('it cancels responses', async ({ page }) => {
await sendMessage(page, newMessage);
await expect(messages).toHaveCount(2); // ensure new response is being received
await page.waitForTimeout(300); // let it partially complete
await page.getByLabel('cancel message').click();
await page.getByTestId('cancel message').click();
await page.waitForTimeout(200); // wait to ensure new question was not sent
await expect(messages).toHaveCount(2);
const allMessages = await messages.all();
Expand Down
6 changes: 3 additions & 3 deletions src/leapfrogai_ui/tests/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const deleteConversationsByLabel = async (labels: string[]) => {
};

export const waitForResponseToComplete = async (page: Page) => {
await expect(page.getByLabel('cancel message')).toHaveCount(1, { timeout: 25000 });
await expect(page.getByLabel('cancel message')).toHaveCount(0, { timeout: 25000 });
await expect(page.getByLabel('send')).toHaveCount(1, { timeout: 25000 });
await expect(page.getByTestId('cancel message')).toHaveCount(1, { timeout: 25000 });
await expect(page.getByTestId('cancel message')).toHaveCount(0, { timeout: 25000 });
await expect(page.getByTestId('send message')).toHaveCount(1, { timeout: 25000 });
};