Skip to content

Commit

Permalink
chore(test): E2E tests extension - check assets work (not included se…
Browse files Browse the repository at this point in the history
…ttings/preferences) (#364)

Fixed linter complaints



Fixed several issues



Checking extension details page



Deleted extra timeout



removed redundant check



fixing some assertions



removed one check



finding locator test



fixed locator test



using notInstalledText



fixed errata



using 'markdown-content' label



refactor test cases to before/after installation



adding a exact:true



refactor test case into previous existing case



fixing refactor



added checks during disabled extension



swapping toBeUndefined by toHaveCount



fixing linting issues part 1



fixing linting issues part 2



chore(test): refactor to use resource-connection-card-page model



chore(test): added resourceElementVisibleName param to model constructor



chore(test): fixed assertions



chore(test): fixed toHaveCount assertion



chore(test): more tests on the assertions



chore(test): more fixes



chore(test): fixing linting issues



chore(tests): refactor test case to remove redundant code



chore(tests): fix linting issue + problem 1st test case



Revert 2 previous commits

This reverts commit 5376399.

Revert "chore(tests): refactor test case to remove redundant code"

This reverts commit 7b7c499.

chore(tests): added missing awaits



chore(tests): removed checking settings/preferences



chore(tests): removed checking settings/preferences in both test cases



Revert "chore(tests): removed checking settings/preferences in both test cases"

This reverts commit 468c18a.

chore(tests): fixed linting issues + refactoring



chore(tests): more linting issues fixed



chore(tests): remove searching for markdown element

Signed-off-by: Daniel Villanueva <[email protected]>
  • Loading branch information
danivilla9 authored Nov 7, 2024
1 parent cb67762 commit a532ce1
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
48 changes: 48 additions & 0 deletions tests/src/model/pages/openshift-local-resource-details-page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**********************************************************************
* 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 { Locator, Page } from '@playwright/test';

import { ResourceElementState, DetailsPage } from '@podman-desktop/tests-playwright';

export class OpenShiftLocalResourceDetailsPage extends DetailsPage {
readonly startButton: Locator;
readonly restartButton: Locator;
readonly stopButton: Locator;
readonly deleteButton: Locator;

static readonly SUMMARY_TAB = 'Summary';
static readonly LOGS_TAB = 'Logs';

constructor(page: Page, title: string) {
super(page, title);
this.startButton = this.controlActions.getByRole('button', { name: 'Start', exact: false });
this.restartButton = this.controlActions.getByRole('button', { name: 'Restart', exact: false });
this.stopButton = this.controlActions.getByRole('button', { name: 'Stop', exact: false });
this.deleteButton = this.controlActions.getByRole('button', { name: 'Delete', exact: false });
}

async getState(): Promise<string> {
const currentState = await this.header.getByLabel('Connection Status Label').innerText();
for (const state of Object.values(ResourceElementState)) {
if (currentState === state) return state;
}

return 'UNKNOWN'; //append to ResourceElementState?
}
}
18 changes: 17 additions & 1 deletion tests/src/openshift-local-extension.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,21 @@
***********************************************************************/

import type { NavigationBar } from '@podman-desktop/tests-playwright';
import { expect as playExpect, ExtensionCardPage, RunnerOptions, test } from '@podman-desktop/tests-playwright';
import { expect as playExpect, ExtensionCardPage, RunnerOptions, test, ResourceConnectionCardPage } from '@podman-desktop/tests-playwright';

import { OpenShiftLocalExtensionPage } from './model/pages/openshift-local-extension-page';

let extensionInstalled = false;
let extensionCard: ExtensionCardPage;
let resourcesPage: ResourceConnectionCardPage;
const imageName = 'ghcr.io/crc-org/crc-extension:latest';
const extensionLabelCrc = 'redhat.openshift-local';
const extensionLabelNameCrc = 'openshift-local';
const extensionLabelAuthentication = 'redhat.redhat-authentication';
const extensionLabelNameAuthentication = 'redhat-authentication';
const activeExtensionStatus = 'ACTIVE';
const disabledExtensionStatus = 'DISABLED';
const notInstalledExtensionStatus = 'NOT-INSTALLED';
const skipInstallation = process.env.SKIP_INSTALLATION ? process.env.SKIP_INSTALLATION : false;

test.use({
Expand All @@ -39,6 +41,7 @@ test.beforeAll(async ({ runner, page, welcomePage }) => {
runner.setVideoAndTraceName('crc-e2e');
await welcomePage.handleWelcomePage(true);
extensionCard = new ExtensionCardPage(page, extensionLabelNameCrc, extensionLabelCrc);
resourcesPage = new ResourceConnectionCardPage(page, 'crc');
});

test.afterAll(async ({ runner }) => {
Expand Down Expand Up @@ -116,6 +119,12 @@ test.describe.serial('Red Hat OpenShift Local extension verification', () => {
await playExpect(extensionCard.status).toHaveText(activeExtensionStatus);
await extensionCard.disableExtension();
await playExpect(extensionCard.status).toHaveText(disabledExtensionStatus);
//checking dashboard assets
const dashboard = await navigationBar.openDashboard();
await playExpect(dashboard.openshiftLocalProvider).toHaveCount(0);
//checking settings/resources assets
await navigationBar.openSettings();
await playExpect(resourcesPage.card).toHaveCount(0);
});

test('Extension can be re-enabled correctly', async ({ navigationBar }) => {
Expand All @@ -125,6 +134,13 @@ test.describe.serial('Red Hat OpenShift Local extension verification', () => {
await playExpect(extensionCard.status).toHaveText(disabledExtensionStatus);
await extensionCard.enableExtension();
await playExpect(extensionCard.status).toHaveText(activeExtensionStatus);
//checking dashboard assets
const dashboard = await navigationBar.openDashboard();
await playExpect(dashboard.openshiftLocalProvider).toBeVisible();
await playExpect(dashboard.openshiftLocalStatusLabel).toHaveText(notInstalledExtensionStatus); // if locally, delete binary
//checking settings/resources assets
await navigationBar.openSettings();
await playExpect(resourcesPage.card).toBeVisible();
});
});

Expand Down

0 comments on commit a532ce1

Please sign in to comment.