Skip to content

chore(test,ci): enable authentication via browser in e2e tests #706

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

Merged
merged 2 commits into from
Apr 16, 2025
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
35 changes: 33 additions & 2 deletions .github/workflows/e2e-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22

- name: Update podman v. 5.x
run: |
Expand All @@ -111,16 +111,19 @@ jobs:
sudo apt-get update && \
sudo apt-get -y install podman; }
podman version

- name: Revert unprivileged user namespace restrictions in Ubuntu 24.04
run: |
# allow unprivileged user namespace
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0

- name: Build Podman Desktop for E2E tests Development Mode
working-directory: ./podman-desktop
if: ${{ env.MODE == 'development' }}
run: |
pnpm install
pnpm test:e2e:build

- name: Build Podman Desktop for E2E tests Production Mode
working-directory: ./podman-desktop
if: ${{ env.MODE == 'production' }}
Expand All @@ -132,6 +135,7 @@ jobs:
path=$(realpath ./dist/linux-unpacked/podman-desktop)
echo "Podman Desktop built binary: $path"
echo "PODMAN_DESKTOP_BINARY_PATH=$path" >> $GITHUB_ENV

- name: Execute pnpm in Red Hat Account Extension
working-directory: ${{ env.REPOSITORY }}
run: |
Expand All @@ -140,21 +144,48 @@ jobs:
echo "Version of @podman-desktop/tests-playwright to be used: $version"
jq --arg version "$version" '.devDependencies."@podman-desktop/tests-playwright" = $version' package.json > package.json_tmp && mv package.json_tmp package.json
pnpm install --no-frozen-lockfile

- name: Set default browser to Chromium
run: |
# TODO: Follow up issue: https://github.com/redhat-developer/podman-desktop-redhat-account-ext/issues/727
chromiumBrowser=$(which chromium-browser)
echo "Path to chromium: ${chromiumBrowser}"
sudo update-alternatives --install /usr/bin/x-www-browser x-www-browser $chromiumBrowser 500
sudo update-alternatives --set x-www-browser $chromiumBrowser

- name: Run All E2E tests in Red Hat Account Extension in Development Mode
working-directory: ${{ env.REPOSITORY }}
if: ${{ env.MODE == 'development' }}
env:
PODMAN_DESKTOP_ARGS: ${{ github.workspace }}/podman-desktop
DVLPR_USERNAME: ${{ secrets.DVLPR_USERNAME }}
DVLPR_PASSWORD: ${{ secrets.DVLPR_PASSWORD }}
AUTH_E2E_TESTS: true
run: pnpm test:e2e

- name: Run All E2E tests in Red Hat Account Extension in Production mode
working-directory: ${{ env.REPOSITORY }}
if: ${{ env.MODE == 'production' }}
env:
PODMAN_DESKTOP_BINARY: ${{ env.PODMAN_DESKTOP_BINARY_PATH }}
DVLPR_USERNAME: ${{ secrets.DVLPR_USERNAME }}
DVLPR_PASSWORD: ${{ secrets.DVLPR_PASSWORD }}
AUTH_E2E_TESTS: true
run: pnpm test:e2e

- uses: actions/upload-artifact@v4
- name: Publish Test Report
uses: mikepenz/action-junit-report@v5
if: always() # always run even if the previous step fails
with:
fail_on_failure: true
include_passed: true
annotate_only: true
detailed_summary: true
require_tests: true
report_paths: '**/*results.xml'

- name: Upload test artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: e2e-tests
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"test": "vitest run --coverage",
"test:all": "pnpm test && pnpm test:e2e",
"test:e2e:setup": "xvfb-maybe --auto-servernum --server-args='-screen 0 1280x960x24' --",
"test:e2e": "cross-env E2E_TESTS=true npm run test:e2e:setup npx playwright test tests/src"
"test:e2e": "cross-env E2E_TESTS=true DEBUG=pw:channel:response,pw:channel:event npm run test:e2e:setup npx playwright test tests/src"
},
"dependencies": {
"@podman-desktop/api": "^1.14.1",
Expand Down
70 changes: 70 additions & 0 deletions tests/src/model/pages/sso-authentication-page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**********************************************************************
* Copyright (C) 2025 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 test, { expect as playExpect } from '@playwright/test';
import { BasePage } from '@podman-desktop/tests-playwright';

export class SSOAuthenticationProviderCardPage extends BasePage {
readonly parent: Locator;
readonly providerInformation: Locator;
readonly providerActions: Locator;
readonly signinButton: Locator;
readonly providerName: Locator;
readonly providerStatus: Locator;
readonly logoutButton: Locator;
readonly userName: Locator;
readonly signoutButton: Locator;

constructor(page: Page) {
super(page);
this.parent = this.page.getByRole('listitem', { name: 'Red Hat SSO' });
this.providerInformation = this.parent.getByLabel('Provider Information');
this.providerActions = this.parent.getByLabel('Provider Actions');
this.signinButton = this.providerActions.getByRole('button', { name: 'Sign in' });
this.providerName = this.providerInformation.getByLabel('Provider Name');
this.providerStatus = this.providerInformation.getByLabel('Provider Status');
this.userName = this.providerInformation.getByLabel('Logged In Username');
this.signoutButton = this.providerInformation.getByRole('button', { name: 'Sign out of ', exact: false });
}

public async signIn(): Promise<void> {
await test.step('Perform Sign In', async () => {
console.log(`Signin Button is enabled`);
await playExpect(this.signinButton).toBeEnabled();
console.log(`Clicking on the button...`);
await this.signinButton.click();
console.log(`Button clicked`);
});
}

public async logout(): Promise<void> {
await test.step('Perform Sign Out', async () => {
await playExpect(this.signoutButton).toBeEnabled();
await this.signoutButton.click();
});
}

public async checkUserIsLoggedIn(loggedIn = true): Promise<void> {
await test.step(loggedIn ? 'User si logged In' : 'User is logged out', async () => {
await playExpect(this.providerStatus).toBeVisible();
console.log(`Status text: ${await this.providerStatus.innerText()}`);
await playExpect(this.providerStatus).toContainText(loggedIn ? 'logged in' : 'logged out', { ignoreCase: true });
});
}
}
Loading