generated from redhat-developer/new-project-template
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
e2e tests added #210
Open
xbabalov
wants to merge
8
commits into
redhat-developer:main
Choose a base branch
from
xbabalov:e2e-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,130
−419
Open
e2e tests added #210
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b048ab8
e2e tests added
xbabalov d03989c
yarn format fix
xbabalov 59696e7
e2e tests added
xbabalov d63acaf
yarn format fix
xbabalov f9439db
rebase, fix dependencies, fix methods
xbabalov 2f6e107
rebase, fix dependencies, fix methods
xbabalov 3c9323f
updating playwright version
xbabalov 44a446c
address changes
xbabalov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/********************************************************************** | ||
* 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 { defineConfig, devices } from '@playwright/test'; | ||
|
||
export default defineConfig({ | ||
outputDir: 'tests/output/', | ||
workers: 1, | ||
timeout: 60000, | ||
|
||
reporter: [ | ||
['list'], | ||
['junit', { outputFile: 'tests/output/junit-results.xml' }], | ||
['json', { outputFile: 'tests/output/json-results.json' }], | ||
['html', { open: 'never', outputFolder: 'tests/playwright/output/html-results' }], | ||
], | ||
|
||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { | ||
...devices['Desktop Chrome'], | ||
}, | ||
}, | ||
], | ||
}); |
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,184 @@ | ||
/********************************************************************** | ||
* 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 { NavigationBar } from '@podman-desktop/tests-playwright'; | ||
import { | ||
ResourcesPage, | ||
expect as playExpect, | ||
ExtensionCardPage, | ||
RunnerOptions, | ||
test, | ||
} from '@podman-desktop/tests-playwright'; | ||
import { DeveloperSandboxPage } from './model/pages/developer-sandbox-page'; | ||
|
||
let extensionInstalled = false; | ||
let extensionCard: ExtensionCardPage; | ||
const imageName = 'ghcr.io/redhat-developer/podman-desktop-sandbox-ext:latest'; | ||
const extensionLabel = 'redhat.redhat-sandbox'; | ||
const extensionLabelName = 'redhat-sandbox'; | ||
const extensionResourceLabel = 'redhat.sandbox'; | ||
const extensionProvider = 'Developer Sandbox Provider'; | ||
const activeExtensionStatus = 'ACTIVE'; | ||
const disabledExtensionStatus = 'DISABLED'; | ||
const activeConnectionStatus = 'RUNNING'; | ||
const skipInstallation = process.env.SKIP_INSTALLATION === 'true'; | ||
|
||
test.use({ | ||
runnerOptions: new RunnerOptions({ customFolder: 'sandbox-tests-pd', autoUpdate: false, autoCheckUpdates: false }), | ||
}); | ||
test.beforeAll(async ({ runner, page, welcomePage }) => { | ||
runner.setVideoAndTraceName('sandbox-e2e'); | ||
await welcomePage.handleWelcomePage(true); | ||
extensionCard = new ExtensionCardPage(page, extensionLabelName, extensionLabel); | ||
}); | ||
|
||
test.afterAll(async ({ runner }) => { | ||
await runner.close(); | ||
}); | ||
|
||
test.describe.serial('Red Hat Developer Sandbox extension verification', () => { | ||
test.describe.serial('Red Hat Developer Sandbox extension installation', () => { | ||
// PR check builds extension locally and so it is available already | ||
test('Go to extensions and check if extension is already installed', async ({ navigationBar }) => { | ||
const extensions = await navigationBar.openExtensions(); | ||
if (await extensions.extensionIsInstalled(extensionLabel)) { | ||
extensionInstalled = true; | ||
} | ||
}); | ||
|
||
// we want to skip removing of the extension when we are running tests from PR check | ||
test('Uninstall previous version of sandbox extension', async ({ navigationBar }) => { | ||
test.skip(!extensionInstalled || skipInstallation); | ||
test.setTimeout(60000); | ||
await removeExtension(navigationBar); | ||
}); | ||
|
||
// we want to install extension from OCI image (usually using latest tag) after new code was added to the codebase | ||
// and extension was published already | ||
test('Extension can be installed using OCI image', async ({ navigationBar }) => { | ||
test.skip(skipInstallation); | ||
test.setTimeout(200000); | ||
const extensions = await navigationBar.openExtensions(); | ||
await extensions.installExtensionFromOCIImage(imageName); | ||
await playExpect(extensionCard.card).toBeVisible(); | ||
}); | ||
|
||
test('Extension (card) is installed, present and active', async ({ navigationBar }) => { | ||
const extensions = await navigationBar.openExtensions(); | ||
await playExpect | ||
.poll(async () => await extensions.extensionIsInstalled(extensionLabel), { timeout: 30000 }) | ||
.toBeTruthy(); | ||
const extensionCard = await extensions.getInstalledExtension(extensionLabelName, extensionLabel); | ||
await playExpect(extensionCard.status).toHaveText(activeExtensionStatus); | ||
}); | ||
|
||
test("Extension's details show correct status, no error", async ({ page, navigationBar }) => { | ||
const extensions = await navigationBar.openExtensions(); | ||
const extensionCard = await extensions.getInstalledExtension(extensionLabelName, extensionLabel); | ||
await extensionCard.openExtensionDetails('Red Hat Openshift Sandbox extension'); | ||
const details = new DeveloperSandboxPage(page); | ||
await playExpect(details.heading).toBeVisible(); | ||
await playExpect(details.status).toHaveText(activeExtensionStatus); | ||
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('Developer Sandbox is available in Resources Page', async ({ navigationBar }) => { | ||
await checkSandboxInResources(navigationBar, true); | ||
}); | ||
|
||
test('Developer Sandbox is available in Dashboard', async ({ navigationBar }) => { | ||
await checkSandboxInDashboard(navigationBar, true); | ||
}); | ||
}); | ||
|
||
test.describe.serial('Developer Sandbox extension handling', () => { | ||
test('Extension can be disabled', async ({ navigationBar }) => { | ||
const extensions = await navigationBar.openExtensions(); | ||
playExpect(await extensions.extensionIsInstalled(extensionLabel)).toBeTruthy(); | ||
const extensionCard = await extensions.getInstalledExtension(extensionLabelName, extensionLabel); | ||
await playExpect(extensionCard.status).toHaveText(activeExtensionStatus); | ||
await extensionCard.disableExtension(); | ||
await playExpect(extensionCard.status).toHaveText(disabledExtensionStatus); | ||
|
||
await checkSandboxInResources(navigationBar, false); | ||
await checkSandboxInDashboard(navigationBar, false); | ||
}); | ||
|
||
test('Extension can be re-enabled correctly', async ({ navigationBar }) => { | ||
const extensions = await navigationBar.openExtensions(); | ||
playExpect(await extensions.extensionIsInstalled(extensionLabel)).toBeTruthy(); | ||
const extensionCard = await extensions.getInstalledExtension(extensionLabelName, extensionLabel); | ||
await playExpect(extensionCard.status).toHaveText(disabledExtensionStatus); | ||
await extensionCard.enableExtension(); | ||
await playExpect(extensionCard.status).toHaveText(activeExtensionStatus); | ||
|
||
await checkSandboxInResources(navigationBar, true); | ||
await checkSandboxInDashboard(navigationBar, true); | ||
}); | ||
}); | ||
|
||
test('Extension can be removed', async ({ navigationBar }) => { | ||
await removeExtension(navigationBar); | ||
}); | ||
}); | ||
|
||
async function removeExtension(navBar: NavigationBar): Promise<void> { | ||
const extensions = await navBar.openExtensions(); | ||
const extensionCard = await extensions.getInstalledExtension(extensionLabelName, extensionLabel); | ||
await extensionCard.disableExtension(); | ||
await extensionCard.removeExtension(); | ||
await playExpect | ||
.poll(async () => await extensions.extensionIsInstalled(extensionLabel), { timeout: 15000 }) | ||
.toBeFalsy(); | ||
} | ||
|
||
async function checkSandboxInResources(navigationBar: NavigationBar, isInstalled: boolean) { | ||
const settingsBar = await navigationBar.openSettings(); | ||
const resourcesPage = await settingsBar.openTabPage(ResourcesPage); | ||
const sandboxResourceCard = resourcesPage.featuredProviderResources.getByRole('region', { | ||
name: extensionResourceLabel, | ||
}); | ||
const createButton = sandboxResourceCard.getByRole('button', { name: 'Create new Developer Sandbox' }); | ||
|
||
if (isInstalled) { | ||
await playExpect(sandboxResourceCard).toBeVisible(); | ||
await playExpect(createButton).toBeVisible(); | ||
} else { | ||
await playExpect(sandboxResourceCard).toBeHidden(); | ||
} | ||
} | ||
|
||
async function checkSandboxInDashboard(navigationBar: NavigationBar, isInstalled: boolean) { | ||
const dashboardPage = await navigationBar.openDashboard(); | ||
const sandboxProviderCard = dashboardPage.content.getByRole('region', { name: extensionProvider }); | ||
const sandboxStatus = sandboxProviderCard.getByLabel('Connection Status Label'); | ||
|
||
if (isInstalled) { | ||
await playExpect(sandboxProviderCard).toBeVisible(); | ||
await playExpect(sandboxStatus).toHaveText(activeConnectionStatus); | ||
} else { | ||
await playExpect(sandboxProviderCard).toBeHidden(); | ||
} | ||
} |
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,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 DeveloperSandboxPage extends ExtensionDetailsPage { | ||
constructor(page: Page) { | ||
super(page, 'Red Hat OpenShift Sandbox extension'); | ||
} | ||
} |
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,16 @@ | ||
{ | ||
"compilerOptions": { | ||
"strictNullChecks": true, | ||
"lib": [ "ES2017", "webworker" ], | ||
"module": "esnext", | ||
"target": "esnext", | ||
"sourceMap": true, | ||
"rootDir": "src", | ||
"outDir": "dist", | ||
"skipLibCheck": true, | ||
"types": [ "node" ], | ||
"allowSyntheticDefaultImports": true, | ||
"moduleResolution": "Node", | ||
"esModuleInterop": true | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node-fetch is to be removed as fetch is now native since fetch is now part of nodejs