-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(test): initial draft for creating service model e2e tests (#2161)
* chore(test): initial draft for creating service model e2e tests
- Loading branch information
Showing
6 changed files
with
216 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
tests/playwright/src/model/ai-lab-creating-model-service-page.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/********************************************************************** | ||
* Copyright (C) 2024 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
***********************************************************************/ | ||
|
||
import { expect as playExpect } from '@playwright/test'; | ||
import type { Locator, Page } from '@playwright/test'; | ||
import { AILabBasePage } from './ai-lab-base-page'; | ||
import { AILabServiceDetailsPage } from './ai-lab-service-details-page'; | ||
|
||
export class AILabCreatingModelServicePage extends AILabBasePage { | ||
readonly modelInput: Locator; | ||
readonly portInput: Locator; | ||
readonly createButton: Locator; | ||
readonly openServiceDetailsButton: Locator; | ||
readonly serviceStatus: Locator; | ||
|
||
constructor(page: Page, webview: Page) { | ||
super(page, webview, 'Creating Model service'); | ||
this.modelInput = this.webview.getByLabel('Select Model'); | ||
this.portInput = this.webview.getByLabel('Port input'); | ||
this.createButton = this.webview.getByRole('button', { name: 'Create service' }); | ||
this.openServiceDetailsButton = this.webview.getByRole('button', { name: 'Open service details' }); | ||
this.serviceStatus = this.webview.getByRole('status'); | ||
} | ||
|
||
async waitForLoad(): Promise<void> { | ||
await playExpect(this.heading).toBeVisible(); | ||
} | ||
|
||
async getCurrentStatus(): Promise<string> { | ||
const statusList = await this.getStatusListLocator(); | ||
|
||
if (statusList.length < 1) return ''; | ||
|
||
const content = await statusList[statusList.length - 1].textContent(); | ||
if (!content) return ''; | ||
|
||
return content; | ||
} | ||
|
||
async getLastStatusIconClass(): Promise<string> { | ||
const statusList = await this.getStatusListLocator(); | ||
|
||
if (statusList.length < 1) return ''; | ||
|
||
const icon = statusList[statusList.length - 1].getByRole('img'); | ||
return (await icon.getAttribute('class')) ?? ''; | ||
} | ||
|
||
async createService(modelName: string = '', port: number = 0): Promise<AILabServiceDetailsPage> { | ||
if (modelName) { | ||
await this.modelInput.fill(modelName); | ||
await this.webview.keyboard.press('Enter'); | ||
} | ||
|
||
if (port) { | ||
await this.portInput.clear(); | ||
await this.portInput.fill(port.toString()); | ||
} | ||
|
||
await playExpect(this.createButton).toBeEnabled(); | ||
await this.createButton.click(); | ||
|
||
await playExpect | ||
.poll(async () => await this.getCurrentStatus(), { timeout: 300_000 }) | ||
.toContain('Creating container'); | ||
await playExpect | ||
.poll(async () => await this.getLastStatusIconClass(), { timeout: 120_000 }) | ||
.toContain('text-green-500'); | ||
await playExpect(this.openServiceDetailsButton).toBeEnabled(); | ||
await this.openServiceDetailsButton.click(); | ||
return new AILabServiceDetailsPage(this.page, this.webview); | ||
} | ||
|
||
private async getStatusListLocator(): Promise<Locator[]> { | ||
return await this.serviceStatus.locator('ul > li').all(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/********************************************************************** | ||
* Copyright (C) 2024 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
***********************************************************************/ | ||
|
||
import { expect as playExpect } from '@playwright/test'; | ||
import type { Locator, Page } from '@playwright/test'; | ||
import { AILabBasePage } from './ai-lab-base-page'; | ||
import { AiModelServicePage } from './ai-lab-model-service-page'; | ||
import { handleConfirmationDialog } from '@podman-desktop/tests-playwright'; | ||
|
||
export class AILabServiceDetailsPage extends AILabBasePage { | ||
readonly endpointURL: Locator; | ||
readonly inferenceServerType: Locator; | ||
readonly modelName: Locator; | ||
readonly codeSnippet: Locator; | ||
readonly deleteServiceButton: Locator; | ||
readonly stopServiceButton: Locator; | ||
|
||
constructor(page: Page, webview: Page) { | ||
super(page, webview, 'Service details'); | ||
this.endpointURL = this.webview.getByLabel('Endpoint URL', { exact: true }); | ||
this.inferenceServerType = this.webview.getByLabel('Inference Type', { exact: true }); | ||
this.modelName = this.webview.getByLabel('Model name', { exact: true }); | ||
this.codeSnippet = this.webview.getByLabel('Code Snippet', { exact: true }); | ||
this.deleteServiceButton = this.webview.getByRole('button', { name: 'Delete service' }); | ||
this.stopServiceButton = this.webview.getByRole('button', { name: 'Stop service' }); | ||
} | ||
|
||
async waitForLoad(): Promise<void> { | ||
await playExpect(this.heading).toBeVisible(); | ||
} | ||
|
||
async deleteService(): Promise<AiModelServicePage> { | ||
await playExpect(this.deleteServiceButton).toBeEnabled(); | ||
await this.deleteServiceButton.click(); | ||
await handleConfirmationDialog(this.page, 'Podman AI Lab', true, 'Confirm'); | ||
return new AiModelServicePage(this.page, this.webview); | ||
} | ||
|
||
async getInferenceServerPort(): Promise<string> { | ||
const split = (await this.endpointURL.textContent())?.split(':'); | ||
const port = split ? split[split.length - 1].split('/')[0] : ''; | ||
return port; | ||
} | ||
} |