Skip to content

Commit 790ab87

Browse files
committed
fix: fix
Signed-off-by: Anton Misskii <[email protected]>
1 parent 5f9bc65 commit 790ab87

File tree

3 files changed

+46
-39
lines changed

3 files changed

+46
-39
lines changed

tests/playwright/src/ai-lab-extension.spec.ts

Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -437,15 +437,15 @@ test.describe.serial(`AI Lab extension installation and verification`, () => {
437437
});
438438
});
439439

440-
['Audio to Text', 'ChatBot', 'Summarizer', 'Code Generation', 'RAG Chatbot', 'Function calling'].forEach(appName => {
440+
['ChatBot', 'Function calling'].forEach(appName => {
441441
test.describe.serial(`AI Recipe installation`, () => {
442442
test.skip(
443443
!process.env.EXT_TEST_RAG_CHATBOT && appName === 'RAG Chatbot',
444444
'EXT_TEST_RAG_CHATBOT variable not set, skipping test',
445445
);
446446
let recipesCatalogPage: AILabRecipesCatalogPage;
447447

448-
test(`Navigate to Recipes Catalog for ${appName}`, async ({ runner, page, navigationBar }) => {
448+
test.beforeAll(`Open Recipes Catalog`, async ({ runner, page, navigationBar }) => {
449449
[page, webview] = await handleWebview(runner, page, navigationBar);
450450
aiLabPage = new AILabPage(page, webview);
451451
await aiLabPage.navigationBar.waitForLoad();
@@ -461,46 +461,52 @@ test.describe.serial(`AI Lab extension installation and verification`, () => {
461461
await demoApp.startNewDeployment();
462462
});
463463

464-
/* eslint-disable sonarjs/no-nested-functions */
465-
if (appName === 'Function calling') {
466-
test(`Verify that model service for the ${appName} is working`, async ({ request }) => {
467-
test.setTimeout(600_000);
468-
const modelServicePage = await aiLabPage.navigationBar.openServices();
469-
const serviceDetailsPage = await modelServicePage.openSercviceDetails(
470-
'ibm-granite/granite-3.3-8b-instruct-GGUF',
471-
);
472-
await playExpect.poll(async () => await serviceDetailsPage.getServiceState()).toBe('RUNNING');
473-
const port = await serviceDetailsPage.getInferenceServerPort();
474-
const url = `http://localhost:${port}/v1/chat/completions`;
464+
test(`Verify that model service for the ${appName} is working`, async ({ request }) => {
465+
test.skip(appName !== 'Function calling');
466+
test.setTimeout(600_000);
475467

476-
const response = await request.post(url, {
477-
data: {
478-
messages: [
479-
{
480-
content: 'You are a helpful assistant.',
481-
role: 'system',
482-
},
483-
{
484-
content: 'What is the capital of Czech Republic?',
485-
role: 'user',
486-
},
487-
],
488-
},
489-
timeout: 600_000,
490-
});
468+
const modelServicePage = await aiLabPage.navigationBar.openServices();
469+
const serviceDetailsPage = await modelServicePage.openServiceDetails(
470+
'ibm-granite/granite-3.3-8b-instruct-GGUF',
471+
);
472+
// eslint-disable-next-line sonarjs/no-nested-functions
473+
await playExpect.poll(async () => await serviceDetailsPage.getServiceState()).toBe('RUNNING');
474+
const port = await serviceDetailsPage.getInferenceServerPort();
475+
const url = `http://localhost:${port}/v1/chat/completions`;
491476

492-
playExpect(response.ok()).toBeTruthy();
493-
const body = await response.body();
494-
const text = body.toString();
495-
playExpect(text).toContain('Prague');
477+
const response = await request.post(url, {
478+
data: {
479+
messages: [
480+
{
481+
content: 'You are a helpful assistant.',
482+
role: 'system',
483+
},
484+
{
485+
content: 'What is the capital of Czech Republic?',
486+
role: 'user',
487+
},
488+
],
489+
},
490+
timeout: 600_000,
496491
});
497-
}
498-
/* eslint-enable sonarjs/no-nested-functions */
499492

500-
test(`Stop ${appName} app`, async ({ navigationBar }) => {
493+
playExpect(response.ok()).toBeTruthy();
494+
const body = await response.body();
495+
const text = body.toString();
496+
playExpect(text).toContain('Prague');
497+
});
498+
499+
test(`Stop ${appName} app`, async () => {
501500
test.setTimeout(150_000);
502501
await stopAndDeleteApp(appName);
503502
await cleanupServiceModels();
503+
});
504+
505+
test.afterAll(`Ensure cleanup of "${appName}" app, related service, and images`, async ({ navigationBar }) => {
506+
test.setTimeout(150_000);
507+
508+
await stopAndDeleteApp(appName);
509+
await cleanupServiceModels();
504510
await deleteUnusedImages(navigationBar);
505511
});
506512
});
@@ -521,6 +527,9 @@ async function cleanupServiceModels(): Promise<void> {
521527
async function stopAndDeleteApp(appName: string): Promise<void> {
522528
const aiRunningAppsPage = await aiLabPage.navigationBar.openRunningApps();
523529
await aiRunningAppsPage.waitForLoad();
530+
if (!(await aiRunningAppsPage.appExists(appName))) {
531+
console.log(`"${appName}" is not present in the running apps list. Skipping stop and delete operations.`);
532+
}
524533
await playExpect.poll(async () => await aiRunningAppsPage.appExists(appName), { timeout: 10_000 }).toBeTruthy();
525534
await playExpect
526535
.poll(async () => await aiRunningAppsPage.getCurrentStatusForApp(appName), { timeout: 60_000 })

tests/playwright/src/model/ai-lab-model-service-page.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class AiModelServicePage extends AILabBasePage {
6767
return (await this.getAllTableRows()).length;
6868
}
6969

70-
async openSercviceDetails(modelName: string): Promise<AILabServiceDetailsPage> {
70+
async openServiceDetails(modelName: string): Promise<AILabServiceDetailsPage> {
7171
const serviceRow = await this.getServiceByModel(modelName);
7272
if (serviceRow === undefined) {
7373
throw new Error(`Model [${modelName}] service doesn't exist`);
@@ -80,6 +80,7 @@ export class AiModelServicePage extends AILabBasePage {
8080
async getServiceByModel(modelName: string): Promise<Locator | undefined> {
8181
const rows = await this.getAllTableRows();
8282
for (let rowNum = 1; rowNum < rows.length; rowNum++) {
83+
//skip header
8384
const serviceModel = rows[rowNum].getByRole('cell').nth(4);
8485
if ((await serviceModel.textContent()) === modelName) {
8586
return rows[rowNum];

tests/playwright/src/model/ai-lab-service-details-page.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ export class AILabServiceDetailsPage extends AILabBasePage {
5959

6060
async getServiceState(): Promise<string> {
6161
const serviceState = await this.webview.getByRole('status').getAttribute('title');
62-
if (serviceState === 'RUNNING') {
63-
return 'RUNNING';
64-
}
6562
return serviceState ?? 'UNKNOWN';
6663
}
6764
}

0 commit comments

Comments
 (0)