Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/pr-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,23 @@ jobs:
working-directory: ./podman-desktop-extension-ai-lab
run: pnpm install --no-frozen-lockfile

- name: Build Image
working-directory: ./podman-desktop-extension-ai-lab
id: build-image
run: |
pnpm build
podman build -t local_ai_lab_image ./
CONTAINER_ID=$(podman create localhost/local_ai_lab_image --entrypoint "")
mkdir -p tests/playwright/tests/playwright/output/ai-lab-tests-pd/plugins
podman export $CONTAINER_ID | tar -x -C tests/playwright/tests/playwright/output/ai-lab-tests-pd/plugins/
podman rm -f $CONTAINER_ID
podman rmi -f localhost/local_ai_lab_image:latest

- name: Run E2E Smoke tests
working-directory: ./podman-desktop-extension-ai-lab
env:
PODMAN_DESKTOP_ARGS: ${{ github.workspace }}/podman-desktop
EXTENSION_PREINSTALLED: true
run: pnpm test:e2e:smoke

- uses: actions/upload-artifact@v4
Expand Down
43 changes: 38 additions & 5 deletions tests/playwright/src/ai-lab-extension.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,22 @@ import {
} from '@podman-desktop/tests-playwright';
import { AILabPage } from './model/ai-lab-page';
import type { AILabRecipesCatalogPage } from './model/ai-lab-recipes-catalog-page';
import { AILabExtensionDetailsPage } from './model/podman-extension-ai-lab-details-page';

const AI_LAB_EXTENSION_OCI_IMAGE = 'ghcr.io/containers/podman-desktop-extension-ai-lab:nightly';
const AI_LAB_EXTENSION_OCI_IMAGE =
process.env.EXTENSION_OCI_IMAGE ?? 'ghcr.io/containers/podman-desktop-extension-ai-lab:nightly';
const AI_LAB_EXTENSION_PREINSTALLED: boolean = process.env.EXTENSION_PREINSTALLED === 'true';
const AI_LAB_CATALOG_EXTENSION_LABEL: string = 'redhat.ai-lab';
const AI_LAB_CATALOG_EXTENSION_NAME: string = 'Podman AI Lab extension';
const AI_LAB_CATALOG_STATUS_ACTIVE: string = 'ACTIVE';
const AI_LAB_NAVBAR_EXTENSION_LABEL: string = 'AI Lab';
const AI_LAB_PAGE_BODY_LABEL: string = 'Webview AI Lab';

let webview: Page;
let aiLabPage: AILabPage;

test.use({
runnerOptions: new RunnerOptions({ customFolder: 'ai-lab-tests-pd', customOutputFolder: 'output' }),
runnerOptions: new RunnerOptions({ customFolder: 'ai-lab-tests-pd', autoUpdate: false, autoCheckUpdates: false }),
});
test.beforeAll(async ({ runner, welcomePage, page }) => {
runner.setVideoAndTraceName('ai-lab-e2e');
Expand All @@ -62,12 +67,40 @@ test.describe.serial(`AI Lab extension installation and verification`, { tag: '@
await playExpect(extensionsPage.header).toBeVisible();
});
test(`Install AI Lab extension`, async () => {
test.skip(AI_LAB_EXTENSION_PREINSTALLED, 'AI Lab extension is preinstalled');
await extensionsPage.installExtensionFromOCIImage(AI_LAB_EXTENSION_OCI_IMAGE);
});
test('Extension (card) is installed, present and active', async ({ navigationBar }) => {
const extensions = await navigationBar.openExtensions();
await playExpect
.poll(async () => await extensionsPage.extensionIsInstalled(AI_LAB_CATALOG_EXTENSION_LABEL), {
timeout: 30_000,
})
.poll(async () => await extensions.extensionIsInstalled(AI_LAB_CATALOG_EXTENSION_LABEL), { timeout: 30000 })
.toBeTruthy();
const extensionCard = await extensions.getInstalledExtension(
AI_LAB_CATALOG_EXTENSION_NAME,
AI_LAB_CATALOG_EXTENSION_LABEL,
);
await playExpect(extensionCard.status).toHaveText(AI_LAB_CATALOG_STATUS_ACTIVE);
});
test(`Extension's details show correct status, no error`, async ({ page, navigationBar }) => {
const extensions = await navigationBar.openExtensions();
const extensionCard = await extensions.getInstalledExtension('ai-lab', AI_LAB_CATALOG_EXTENSION_LABEL);
await extensionCard.openExtensionDetails(AI_LAB_CATALOG_EXTENSION_NAME);
const details = new AILabExtensionDetailsPage(page);
await playExpect(details.heading).toBeVisible();
await playExpect(details.status).toHaveText(AI_LAB_CATALOG_STATUS_ACTIVE);
const errorTab = details.tabs.getByRole('button', { name: 'Error' });
// we would like to propagate the error's stack trace into test failure message
let stackTrace = '';
if ((await errorTab.count()) > 0) {
await details.activateTab('Error');
stackTrace = await details.errorStackTrace.innerText();
}
await playExpect(errorTab, `Error Tab was present with stackTrace: ${stackTrace}`).not.toBeVisible();
});
test(`Verify AI Lab extension is installed`, async ({ runner, page, navigationBar }) => {
[page, webview] = await handleWebview(runner, page, navigationBar);
aiLabPage = new AILabPage(page, webview);
await aiLabPage.navigationBar.waitForLoad();
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**********************************************************************
* 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 type { Page } from '@playwright/test';
import { ExtensionDetailsPage } from '@podman-desktop/tests-playwright';

export class AILabExtensionDetailsPage extends ExtensionDetailsPage {
constructor(page: Page) {
super(page, 'Podman AI Lab extension');
}
}
Loading