diff --git a/tests/interop/ui/playwright.config.ts b/tests/interop/ui/playwright.config.ts new file mode 100644 index 00000000..3e862795 --- /dev/null +++ b/tests/interop/ui/playwright.config.ts @@ -0,0 +1,82 @@ +import { defineConfig, devices } from '@playwright/test'; + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +// import dotenv from 'dotenv'; +// import path from 'path'; +// dotenv.config({ path: path.resolve(__dirname, '.env') }); + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + testDir: './tests', + /* Run tests in files in parallel */ + fullyParallel: true, + /* Fail the build on CI if you accidentally left test.only in the source code. */ + forbidOnly: !!process.env.CI, + /* Retry on CI only */ + retries: process.env.CI ? 2 : 0, + /* Opt out of parallel tests on CI. */ + workers: process.env.CI ? 1 : undefined, + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: [ ['html', { open: 'never' }] ], + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + /* Base URL to use in actions like `await page.goto('/')`. */ + // baseURL: 'http://127.0.0.1:3000', + + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: 'on-first-retry', + ignoreHTTPSErrors: true, + }, + timeout: 600 * 1000, + globalTimeout: 600 * 1000, + + /* Configure projects for major browsers */ + projects: [ + { + name: 'chromium', + use: { ...devices['Desktop Chrome'] }, + }, + +// { +// name: 'firefox', +// use: { ...devices['Desktop Firefox'] }, +// }, +// +// { +// name: 'webkit', +// use: { ...devices['Desktop Safari'] }, +// }, + + /* Test against mobile viewports. */ + // { + // name: 'Mobile Chrome', + // use: { ...devices['Pixel 5'] }, + // }, + // { + // name: 'Mobile Safari', + // use: { ...devices['iPhone 12'] }, + // }, + + /* Test against branded browsers. */ + // { + // name: 'Microsoft Edge', + // use: { ...devices['Desktop Edge'], channel: 'msedge' }, + // }, + // { + // name: 'Google Chrome', + // use: { ...devices['Desktop Chrome'], channel: 'chrome' }, + // }, + ], + + /* Run your local dev server before starting the tests */ + // webServer: { + // command: 'npm run start', + // url: 'http://127.0.0.1:3000', + // reuseExistingServer: !process.env.CI, + // }, +}); diff --git a/tests/interop/ui/ragllm.spec.ts-snapshots/ragllm-add-provider-1-chromium-linux.png b/tests/interop/ui/ragllm.spec.ts-snapshots/ragllm-add-provider-1-chromium-linux.png new file mode 100644 index 00000000..a19b79ff Binary files /dev/null and b/tests/interop/ui/ragllm.spec.ts-snapshots/ragllm-add-provider-1-chromium-linux.png differ diff --git a/tests/interop/ui/ragllm.spec.ts-snapshots/ragllm-grafana-dashboard-1-chromium-linux.png b/tests/interop/ui/ragllm.spec.ts-snapshots/ragllm-grafana-dashboard-1-chromium-linux.png new file mode 100644 index 00000000..a87ef552 Binary files /dev/null and b/tests/interop/ui/ragllm.spec.ts-snapshots/ragllm-grafana-dashboard-1-chromium-linux.png differ diff --git a/tests/interop/ui/ragllm.spec.ts.j2 b/tests/interop/ui/ragllm.spec.ts.j2 new file mode 100644 index 00000000..c80b168f --- /dev/null +++ b/tests/interop/ui/ragllm.spec.ts.j2 @@ -0,0 +1,60 @@ +import { test, expect } from '@playwright/test'; + +test.use({ + ignoreHTTPSErrors: true +}); + +test('ragllm: test proposal generation and grafana dashboard', async ({ page }) => { + test.setTimeout(240000); + // Log in to Openshift console + await page.goto("{{ hub_console.stdout }}"); + await page.getByLabel('Username *').fill('kubeadmin'); + await page.getByLabel('Password *').fill("{{ kubeadmin }}"); + await page.getByRole('button', { name: 'Log in' }).click(); + + // Launch RAG-LLM demo UI + await page.locator('[data-test-id="application-launcher"]').click(); + const page1Promise = page.waitForEvent('popup'); + await page.getByRole('menuitem', { name: 'Retrieval-Augmented' }).click(); + const page1 = await page1Promise; + + // Supply customer and product names + await page1.getByRole('textbox', { name: 'Customer Enter the customer' }).click(); + await page1.getByRole('textbox', { name: 'Customer Enter the customer' }).fill('validated-patterns-qe'); + await page1.getByRole('textbox', { name: 'Product Enter the Red Hat' }).click(); + await page1.getByRole('textbox', { name: 'Product Enter the Red Hat' }).fill('RedHat OpenShift AI'); + + // Generate proposal and add rating + await page1.getByRole('button', { name: 'Generate' }).click(); + await page1.waitForTimeout(60000); + await page1.getByRole('radio', { name: '3' }).check(); + await page1.waitForTimeout(60000); + + // Add a provider + await page1.getByRole('tab', { name: 'Configuration' }).click(); + await page1.getByRole('button', { name: 'Add Provider' }).click(); + await page1.getByRole('listbox', { name: 'Providers' }).click(); + await page1.getByRole('option', { name: 'OpenAI' }).click(); + await page1.getByRole('textbox', { name: 'Model Enter the model name' }).click(); + await page1.getByRole('textbox', { name: 'Model Enter the model name' }).fill('gtp-4o-mini'); + await page1.getByRole('textbox', { name: 'URL Enter the URL' }).click(); + await page1.getByRole('textbox', { name: 'URL Enter the URL' }).fill('https://api.openai.com/vi/chat/completions'); + await page1.getByTestId('password').click(); + await page1.getByTestId('password').fill('12121212'); + await page1.getByRole('button', { name: 'Add', exact: true }).click(); + await page1.getByTestId('toast-close').click(); + await page1.screenshot({ path: 'ragllm-add-provider-1-chromium-linux.png' }); + // await page1.screenshot({ path: 'add-provider.png', fullPage: true }); + + // Check grafana dashboard + await page.locator('[data-test-id="application-launcher"]').click(); + const page2Promise = page.waitForEvent('popup'); + await page.getByRole('menuitem', { name: 'Grafana UI for LLM Ratings' }).click(); + const page2 = await page2Promise; + await page2.getByTestId('data-testid navigation mega-menu').getByRole('link', { name: 'Dashboards' }).click(); + await page2.getByRole('link', { name: 'llm-monitoring' }).click(); + await page2.getByRole('link', { name: 'MODEL FEEDBACK/RATING' }).click(); + await page2.waitForTimeout(10000); + await page2.screenshot({ path: 'ragllm-grafana-dashboard-1-chromium-linux.png' }); + // await page2.screenshot({ path: 'grafana-dashboard.png', fullPage: true }); +});