Skip to content

Commit

Permalink
chore(tests,ui): Added resources check to extension installation e2e …
Browse files Browse the repository at this point in the history
…tests (podman-desktop#4806)

* chore(tests): openshift installation verification, integration with sandbox installation added

Signed-off-by: Tamara Babalova <[email protected]>

* chore(tests): address changes

Signed-off-by: Tamara Babalova <[email protected]>

* chore(tests,ui): added resources check for extension installation
Signed-off-by: Tamara Babalova <[email protected]>

---------

Signed-off-by: Tamara Babalova <[email protected]>
  • Loading branch information
xbabalov authored Nov 21, 2023
1 parent 7407c6f commit 362f303
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ function hasAnyConfiguration(provider: ProviderInfo) {
href="/preferences/extensions"
class="text-gray-700 underline underline-offset-2">Extensions</a>
</span>
<div class="h-full">
<div class="h-full" role="region" aria-label="Featured Provider Resources">
<EmptyScreen
aria-label="no-resource-panel"
icon="{EngineIcon}"
Expand Down
29 changes: 25 additions & 4 deletions tests/src/extension-installation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { DashboardPage } from './model/pages/dashboard-page';
import { OpenshiftLocalExtensionPage } from './model/pages/openshift-local-extension-page';
import { SandboxExtensionPage } from './model/pages/sandbox-extension-page';
import type { RunnerTestContext } from './testContext/runner-test-context';
import { ResourcesPage } from './model/pages/resources-page';

let pdRunner: PodmanDesktopRunner;
let page: Page;
Expand All @@ -37,6 +38,7 @@ let extensionDashboardProvider: Locator;
let extensionSettingsBox: Locator;
let installButtonLabel: string;
let settingsLink: string;
let resourceLabel: string;

const _startup = async function () {
console.log('running before all');
Expand Down Expand Up @@ -111,7 +113,7 @@ describe.each([
});

describe('Toggle and verify extension status', async () => {
test('Disable extension and verify Dashboard components', async () => {
test('Disable extension and verify Dashboard and Resources components', async () => {
const extensionPage = new extensionPageType(page);

await extensionPage.disableButton.click();
Expand All @@ -120,10 +122,17 @@ describe.each([
await goToDashboard();
await playExpect(extensionDashboardProvider).toBeHidden();
await playExpect(extensionDashboardStatus).toBeHidden();
});

test('Enable extension and verify Dashboard components', async () => {
await goToSettings();
const settingsBar = new SettingsBar(page);
const resourcesPage = await settingsBar.openTabPage(ResourcesPage);
const extensionResourceBox = resourcesPage.featuredProviderResources.getByRole('region', {
name: resourceLabel,
});
await playExpect(extensionResourceBox).toBeHidden();
});

test('Enable extension and verify Dashboard and Resources components', async () => {
const settingsBar = new SettingsBar(page);
await settingsBar.openTabPage(SettingsExtensionsPage);
const extensionPage = await settingsBar.openTabPage(extensionPageType);
Expand All @@ -134,13 +143,19 @@ describe.each([
await goToDashboard();
await playExpect(extensionDashboardProvider).toBeVisible();
await playExpect(extensionDashboardStatus).toBeVisible();

await goToSettings();
const resourcesPage = await settingsBar.openTabPage(ResourcesPage);
const extensionResourceBox = resourcesPage.featuredProviderResources.getByRole('region', {
name: resourceLabel,
});
await playExpect(extensionResourceBox).toBeVisible();
});
});
});

describe('Remove extension and verify UI', async () => {
test('Remove extension and verify Settings components', async () => {
await goToSettings();
const settingsBar = new SettingsBar(page);
await settingsBar.openTabPage(SettingsExtensionsPage);
const extensionPage = await settingsBar.openTabPage(extensionPageType);
Expand All @@ -152,6 +167,10 @@ describe.each([
await playExpect(installButton).toBeVisible();

await playExpect(settingsBar.settingsNavBar.getByRole('link', { name: settingsLink })).toBeHidden();

const resourcesPage = await settingsBar.openTabPage(ResourcesPage);
const extensionResourceBox = resourcesPage.featuredProviderResources.getByRole('region', { name: resourceLabel });
await playExpect(extensionResourceBox).toBeHidden();
});

test('Verify Dashboard components', async () => {
Expand All @@ -173,6 +192,7 @@ function initializeLocators(extensionType: string) {
extensionSettingsBox = settingsExtensionsPage.devSandboxBox;
installButtonLabel = 'Install redhat.redhat-sandbox Extension';
settingsLink = 'Red Hat OpenShift Sandbox';
resourceLabel = 'redhat.sandbox';
break;
}
case 'Openshift Local': {
Expand All @@ -182,6 +202,7 @@ function initializeLocators(extensionType: string) {
extensionSettingsBox = settingsExtensionsPage.openshiftLocalBox;
installButtonLabel = 'Install redhat.openshift-local Extension';
settingsLink = 'Red Hat OpenShift Local';
resourceLabel = 'crc';
break;
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/src/model/pages/extension-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export class ExtensionPage extends SettingsPage {
constructor(page: Page, extensionTitle: string, heading: string) {
super(page, extensionTitle);
this.heading = page.getByText(heading);
this.enableButton = page.getByRole('button', { name: ' Enable' });
this.disableButton = page.getByRole('button', { name: ' Disable' });
this.removeExtensionButton = page.getByRole('button', { name: ' Remove' });
this.enableButton = page.getByRole('button', { name: 'Enable' });
this.disableButton = page.getByRole('button', { name: 'Disable' });
this.removeExtensionButton = page.getByRole('button', { name: 'Remove' });
this.status = page.getByLabel('connection-status-label');
}
}
31 changes: 31 additions & 0 deletions tests/src/model/pages/resources-page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**********************************************************************
* Copyright (C) 2023 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 { Locator, Page } from 'playwright';
import { SettingsPage } from './settings-page';

export class ResourcesPage extends SettingsPage {
readonly heading: Locator;
readonly featuredProviderResources: Locator;

constructor(page: Page) {
super(page, 'Resources');
this.heading = page.getByRole('heading', { name: 'Resources' });
this.featuredProviderResources = page.getByRole('region', { name: 'Featured Provider Resources' });
}
}

0 comments on commit 362f303

Please sign in to comment.