Skip to content

Commit dfdc3d6

Browse files
authored
chore(test): implementing GPU preferences test (#2887)
Signed-off-by: Tibor Dancs <[email protected]>
1 parent 1729873 commit dfdc3d6

File tree

5 files changed

+56
-3
lines changed

5 files changed

+56
-3
lines changed

.github/workflows/recipe-catalog-change-template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ jobs:
9696
DEFAULT_NPM_TARGET: 'test:e2e'
9797
DEFAULT_ENV_VARS: 'TEST_PODMAN_MACHINE=true,ELECTRON_ENABLE_INSPECT=true'
9898
DEFAULT_PODMAN_OPTIONS: 'INIT=1,START=1,ROOTFUL=1,NETWORKING=0'
99-
DEFAULT_EXT_TESTS_OPTIONS: 'EXT_RUN_TESTS_FROM_EXTENSION=1,EXT_RUN_TESTS_AS_ADMIN=1'
99+
DEFAULT_EXT_TESTS_OPTIONS: 'EXT_RUN_TESTS_FROM_EXTENSION=1,EXT_RUN_TESTS_AS_ADMIN=1,EXT_TEST_GPU_SUPPORT_ENABLED=0'
100100
DEFAULT_EXT_REPO_OPTIONS: 'REPO=podman-desktop-extension-ai-lab,FORK=containers,BRANCH=main'
101101
DEFAULT_PODMAN_VERSION: "${{ env.PD_PODMAN_VERSION || '5.3.2' }}"
102102
DEFAULT_URL: "https://github.com/containers/podman/releases/download/v$DEFAULT_PODMAN_VERSION/podman-$DEFAULT_PODMAN_VERSION-setup.exe"

.github/workflows/recipe-catalog-change-trigger.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,5 @@ jobs:
6565
trigger-workflow-branch: ${{ needs.extract-context.outputs.fork-branch }}
6666
trigger-workflow-commit-sha: ${{ needs.extract-context.outputs.commit-sha }}
6767
trigger-workflow-base-repo: ${{ needs.extract-context.outputs.base-repo }}
68-
ext_tests_options: 'EXT_RUN_TESTS_FROM_EXTENSION=1,EXT_RUN_TESTS_AS_ADMIN=0'
68+
ext_tests_options: 'EXT_RUN_TESTS_FROM_EXTENSION=1,EXT_RUN_TESTS_AS_ADMIN=0,EXT_TEST_GPU_SUPPORT_ENABLED=0'
6969
secrets: inherit

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {
3636
getExtensionCard,
3737
getExtensionVersion,
3838
openAILabExtensionDetails,
39+
openAILabPreferences,
3940
reopenAILabDashboard,
4041
waitForExtensionToInitialize,
4142
} from './utils/aiLabHandler';
@@ -106,6 +107,45 @@ test.describe.serial(`AI Lab extension installation and verification`, () => {
106107
});
107108
});
108109

110+
test.describe.serial(`AI Lab extension GPU preferences`, { tag: '@smoke' }, () => {
111+
test(`Verify GPU support banner is visible, preferences are disabled`, async ({ page, navigationBar }) => {
112+
test.setTimeout(15_000);
113+
await playExpect(aiLabPage.gpuSupportBanner).toBeVisible();
114+
await playExpect(aiLabPage.enableGpuButton).toBeVisible();
115+
await playExpect(aiLabPage.dontDisplayButton).toBeVisible();
116+
const preferencesPage = await openAILabPreferences(navigationBar, page);
117+
await preferencesPage.waitForLoad();
118+
playExpect(await preferencesPage.isGPUPreferenceEnabled()).toBeFalsy();
119+
});
120+
121+
test(`Enable GPU support and verify preferences`, async ({ runner, page, navigationBar }) => {
122+
test.setTimeout(30_000);
123+
aiLabPage = await reopenAILabDashboard(runner, page, navigationBar);
124+
await aiLabPage.waitForLoad();
125+
await aiLabPage.enableGpuSupport();
126+
const preferencesPage = await openAILabPreferences(navigationBar, page);
127+
await preferencesPage.waitForLoad();
128+
playExpect(await preferencesPage.isGPUPreferenceEnabled()).toBeTruthy();
129+
});
130+
131+
test.afterAll(
132+
`Disable GPU support, return to AI Lab Dashboard and hide banner`,
133+
async ({ runner, page, navigationBar }) => {
134+
test.setTimeout(30_000);
135+
const preferencesPage = await openAILabPreferences(navigationBar, page);
136+
await preferencesPage.waitForLoad();
137+
await preferencesPage.disableGPUPreference();
138+
playExpect(await preferencesPage.isGPUPreferenceEnabled()).toBeFalsy();
139+
aiLabPage = await reopenAILabDashboard(runner, page, navigationBar);
140+
await playExpect(aiLabPage.gpuSupportBanner).toBeVisible();
141+
await playExpect(aiLabPage.enableGpuButton).toBeVisible();
142+
await playExpect(aiLabPage.dontDisplayButton).toBeVisible();
143+
await aiLabPage.dontDisplayButton.click();
144+
await playExpect(aiLabPage.gpuSupportBanner).toBeHidden();
145+
},
146+
);
147+
});
148+
109149
test.describe.serial('AI Lab API endpoint e2e test', { tag: '@smoke' }, () => {
110150
let localServerPort: string;
111151
let extensionVersion: string | undefined;

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,30 @@
1717
***********************************************************************/
1818

1919
import type { Locator, Page } from '@playwright/test';
20+
import { expect as playExpect } from '@playwright/test';
2021

2122
export abstract class AILabBasePage {
2223
readonly page: Page;
2324
readonly webview: Page;
2425
readonly heading: Locator;
26+
readonly gpuSupportBanner: Locator;
27+
readonly enableGpuButton: Locator;
28+
readonly dontDisplayButton: Locator;
2529

2630
constructor(page: Page, webview: Page, heading: string | undefined) {
2731
this.page = page;
2832
this.webview = webview;
2933
this.heading = webview.getByRole('heading', { name: heading, exact: true }).first();
34+
this.gpuSupportBanner = this.webview.getByLabel('GPU promotion banner');
35+
this.enableGpuButton = this.gpuSupportBanner.getByRole('button', { name: 'Enable GPU support' });
36+
this.dontDisplayButton = this.gpuSupportBanner.getByRole('button', { name: `Don't display anymore` });
3037
}
3138

3239
abstract waitForLoad(): Promise<void>;
40+
41+
async enableGpuSupport(): Promise<void> {
42+
await playExpect(this.gpuSupportBanner).toBeVisible();
43+
await this.enableGpuButton.click();
44+
await playExpect(this.gpuSupportBanner).not.toBeVisible();
45+
}
3346
}

tests/playwright/src/model/preferences-extension-ai-lab-page.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class ExtensionAILabPreferencesPage extends PreferencesPage {
2626

2727
constructor(page: Page) {
2828
super(page);
29-
this.heading = page.getByRole('heading', { name: ExtensionAILabPreferencesPage.tabName });
29+
this.heading = this.content.getByText(ExtensionAILabPreferencesPage.tabName, { exact: true });
3030
this.experimentalGPUCheckbox = this.content.getByRole('checkbox', {
3131
name: 'Experimental GPU support for inference servers',
3232
});

0 commit comments

Comments
 (0)