Skip to content

Commit

Permalink
refactor: extracted prompt texts in new test into variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Jurredr committed Jan 9, 2025
1 parent 0f93cb8 commit 4bcd012
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,34 @@ export const navigatePromptsFirstLastLineCheck = async (page: Page, skipScreensh
await closeTab(page, false, true);
await openNewTab(page, false, true);

const firstPrompt = 'This is the first user prompt';
const secondPrompt = 'This is the second user prompt\nIt spans two separate lines.';

const promptInput = page.locator(getSelector(testIds.prompt.input));
const sendButton = page.locator(getSelector(testIds.prompt.send));

await promptInput.fill('This is the first user prompt');
await promptInput.fill(firstPrompt);
await sendButton.click();
await waitForAnimationEnd(page);

await promptInput.fill('This is the second user prompt\nIt spans two separate lines.');
await promptInput.fill(secondPrompt);
await waitForAnimationEnd(page);

// The input should start as the input with two lines
expect(await promptInput.inputValue()).toBe('This is the second user prompt\nIt spans two separate lines.');
expect(await promptInput.inputValue()).toBe(secondPrompt);

// Input should remain the same and the cursor position should move to the first line
await promptInput.press('ArrowUp');
await waitForAnimationEnd(page);
expect(await promptInput.inputValue()).toBe('This is the second user prompt\nIt spans two separate lines.');
expect(await promptInput.inputValue()).toBe(secondPrompt);

// Now that we're in the first line, it should navigate to the first user prompt
await promptInput.press('ArrowUp');
await waitForAnimationEnd(page);
expect(await promptInput.inputValue()).toBe('This is the first user prompt');
expect(await promptInput.inputValue()).toBe(firstPrompt);

// Given that this input only has one line, we should be able to go down to prompt 2 immediately again
await promptInput.press('ArrowDown');
await waitForAnimationEnd(page);
expect(await promptInput.inputValue()).toBe('This is the second user prompt\nIt spans two separate lines.');
expect(await promptInput.inputValue()).toBe(secondPrompt);
};

0 comments on commit 4bcd012

Please sign in to comment.