Skip to content

Commit

Permalink
test: update "generates a random session id"
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaclen committed Apr 11, 2024
1 parent b4b8ef5 commit 8673024
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions tests/session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,19 @@ test('creates new session and chats', async ({ page }) => {

test('generates a random session id', async ({ page }) => {
await page.goto('/');
const newSessionButton = page.getByText('New session');
const sessionId1 = await newSessionButton.getAttribute('href');
expect(sessionId1).toMatch(/[a-z0-9]{2,8}/);

await newSessionButton.click();
const sessionId2 = await newSessionButton.getAttribute('href');
expect(sessionId2).toMatch(/[a-z0-9]{2,8}/);

expect(sessionId1).not.toEqual(sessionId2);
const sessionIds = [];
const newSessionButton = page.getByText('New session');

await newSessionButton.click();
const sessionId3 = await newSessionButton.getAttribute('href');
expect(sessionId3).toMatch(/[a-z0-9]{2,8}/);
// Check it generates a new session id 3 times in a row
for (let i = 0; i < 3; i++) {
const sessionId = await newSessionButton.getAttribute('href');
expect(sessionId).toMatch(/[a-z0-9]{2,8}/);
sessionIds.push(sessionId);
await newSessionButton.click();
}

expect(sessionId1).not.toEqual(sessionId3);
expect(sessionId2).not.toEqual(sessionId3);
expect(new Set(sessionIds).size).toBe(3);
});

test.skip('handles API error when generating AI response', async ({ page }) => {
Expand Down

0 comments on commit 8673024

Please sign in to comment.