Skip to content

Commit

Permalink
fix: send and cancel btn tooltips (#436)
Browse files Browse the repository at this point in the history
* fix: tooltips

* fix: use test id

---------

Co-authored-by: Gerred Dillon <gerred@defenseunicorns.com>
  • Loading branch information
andrewrisse and gerred committed Apr 25, 2024
1 parent fe3bd9b commit bbb6ea9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
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 });
};

0 comments on commit bbb6ea9

Please sign in to comment.