Skip to content

Commit

Permalink
attempt test fix in pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrisse committed Aug 2, 2024
1 parent cf727d9 commit 0c52960
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
7 changes: 4 additions & 3 deletions src/leapfrogai_ui/src/lib/helpers/chatHelpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@ describe('chat helpers', () => {
expect(timestamp).toBe(timestampValue * 1000);
});

it('should default to a timestamp in miliseconds of right now for invalid or missing date value', () => {
it('should default to a timestamp in milliseconds of right now for invalid or missing date value', () => {
const message: LFMessage = {
...getFakeOpenAIMessage({ thread_id: '123', content: 'test', role: 'user' }),
createdAt: null,
created_at: null
};
const timestamp = normalizeTimestamp(message);
expect(timestamp).toBe(new Date().getTime());
// Occasionally the timestamps can be off by 1 millisecond and fail the tests, so we just check seconds here
const timestamp = Math.floor(normalizeTimestamp(message) / 1000);
expect(timestamp).toBe(Math.floor(new Date().getTime() / 1000));
});
});
});
3 changes: 1 addition & 2 deletions src/leapfrogai_ui/tests/api-keys.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ test('it can create and delete an API key', async ({ page }) => {
await expect(page.getByText('Save secret key')).not.toBeVisible();

const row = await getTableRow(page, keyName);
expect(row).not.toBeNull();
await row!.getByRole('checkbox').check({ force: true });
await row.getByRole('checkbox').check();
const deleteBtn = page.getByRole('button', { name: 'delete' });
await deleteBtn.click();
const deleteModal = page.getByTestId('delete-api-key-modal');
Expand Down
9 changes: 4 additions & 5 deletions src/leapfrogai_ui/tests/assistants.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ test('it DOES NOT confirm you want to navigate away if you click the cancel butt
});

test('it allows you to edit an assistant', async ({ page, openAIClient }) => {
// const pictogramName = 'Analytics';
const pictogramName = 'Analytics';
const assistant1 = await createAssistantWithApi({ openAIClient });
const newAssistantAttributes = getFakeAssistantInput();

Expand All @@ -237,10 +237,9 @@ test('it allows you to edit an assistant', async ({ page, openAIClient }) => {
await page.getByLabel('tagline').fill(newAssistantAttributes.description);
await page.getByPlaceholder("You'll act as...").fill(newAssistantAttributes.instructions);

// TODO - re-enable after avatar flowbite refactor
// await page.locator('.mini-avatar-container').click();
// await page.getByTestId(`pictogram-${pictogramName}`).click();
// await page.getByRole('dialog').getByRole('button', { name: 'Save' }).click();
await page.getByTestId('mini-avatar-container').click();
await page.getByTestId(`pictogram-${pictogramName}`).click();
await page.getByRole('dialog').getByRole('button', { name: 'Save' }).click();

// Wait for modal save button to disappear if avatar modal was open
const saveButtons = page.getByRole('button', { name: 'Save' });
Expand Down
6 changes: 2 additions & 4 deletions src/leapfrogai_ui/tests/file-management.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ test('it cancels the delete confirmation modal', async ({ page, openAIClient })
await expect(page.getByText(`${filename} imported successfully`)).not.toBeVisible(); // wait for upload to finish

const row = await getTableRow(page, filename);
expect(row).not.toBeNull();
await row!.getByRole('checkbox').check({ force: true });
await row.getByRole('checkbox').check();

await initiateDeletion(page, filename);

Expand Down Expand Up @@ -171,8 +170,7 @@ test('shows an error toast when there is an error deleting a file', async ({
await expect(page.getByText(`${filename} imported successfully`)).not.toBeVisible(); // wait for upload to finish

const row = await getTableRow(page, filename);
expect(row).not.toBeNull();
await row!.getByRole('checkbox').check({ force: true });
await row.getByRole('checkbox').check();

await initiateDeletion(page, filename);
await confirmDeletion(page);
Expand Down
2 changes: 2 additions & 0 deletions src/leapfrogai_ui/tests/global.setup.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { test as setup } from './fixtures';
import * as OTPAuth from 'otpauth';
import { delay } from 'msw';

const authFile = 'playwright/.auth/user.json';

setup('authenticate', async ({ page }) => {
await page.goto('/'); // go to the home page
await delay(2000); // allow page to fully hydrate
if (process.env.PUBLIC_DISABLE_KEYCLOAK === 'true') {
// when running in Github CI, create a new account because we don't have seed migrations
const emailField = page.getByTestId('email-input');
Expand Down
3 changes: 3 additions & 0 deletions src/leapfrogai_ui/tests/helpers/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,8 @@ export const getTableRow = async (page: Page, textToSearchWith: string) => {
break;
}
}
if (!targetRow) {
throw new Error('error getting row');
}
return targetRow;
};

0 comments on commit 0c52960

Please sign in to comment.