Skip to content
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

[1.1.x] [e2e-test] Enhance loginAsGithubUser() to Handle Intermittent Pop-up Visibility Issues & Fix Quay test #997

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
2 changes: 1 addition & 1 deletion .ibm/pipelines/openshift-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

cleanup() {
echo "Cleaning up before exiting"
helm uninstall ${RELEASE_NAME} -n ${NAME_SPACE}
# leave the namespace for debugging purpose. A new PR will refresh the namespace anyways.
# helm uninstall ${RELEASE_NAME} -n ${NAME_SPACE}
# oc delete namespace ${NAME_SPACE}
rm -rf ~/tmpbin
}
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/playwright/e2e/plugins/quay/quay.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test.describe('Test Quay.io plugin', () => {
await uiHelper.clickTab('Image Registry');

const allGridColumnsText = ImageRegistry.getAllGridColumnsText();
await uiHelper.verifyTableHeaders(allGridColumnsText);
await uiHelper.verifyColumnHeading(allGridColumnsText);
await uiHelper.verifyHeading(`Quay repository: ${QUAY_REPOSITORY}`);

const allCellsIdentifier = ImageRegistry.getAllCellsIdentifier();
Expand Down
16 changes: 12 additions & 4 deletions e2e-tests/playwright/utils/Common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,30 @@ export class Common {
await this.logintoGithub();
await this.page.goto(process.env.BASE_URL);
await this.uiHelper.clickButton('Sign In');
await this.checkAndReauthorizeGithubApp();
await this.uiHelper.waitForSideBarVisible();
}

async checkAndReauthorizeGithubApp() {
await new Promise<void>(resolve => {
this.page.once('popup', async popup => {
await popup.waitForLoadState();

// Check for popup closure for up to 10 seconds before proceeding
for (let attempts = 0; attempts < 10 && !popup.isClosed(); attempts++) {
await this.page.waitForTimeout(1000); // Using page here because if the popup closes automatically, it throws an error during the wait
}

const locator = popup.locator('#js-oauth-authorize-btn');
if (await locator.isVisible()) {
if (!popup.isClosed() && (await locator.isVisible())) {
await popup.locator('body').click();
await locator.waitFor();
await locator.click();
}
resolve();
});
});

await this.uiHelper.waitForSideBarVisible();
}

async googleSignIn(email: string) {
await new Promise<void>(resolve => {
this.page.once('popup', async popup => {
Expand All @@ -87,6 +94,7 @@ export class Common {

async clickOnGHloginPopup() {
await this.uiHelper.clickButton('Log in');
await this.checkAndReauthorizeGithubApp();
await this.page.waitForSelector(this.uiHelper.getButtonSelector('Log in'), {
state: 'hidden',
timeout: 100000,
Expand Down
19 changes: 12 additions & 7 deletions e2e-tests/playwright/utils/UIhelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,18 @@ export class UIhelper {
await this.page.click(`nav a:has-text("${navBarText}")`);
}

async verifyTableHeaders(expectedHeaders: string[]) {
for (const header of expectedHeaders) {
const headerLocator = this.page.locator(
`${UIhelperPO.MuiTable} thead th span div >> text="${header}"`,
);
const isVisible = await headerLocator.isVisible();
expect(isVisible).toBeTruthy();
async verifyColumnHeading(
rowTexts: string[] | RegExp[],
exact: boolean = true,
) {
for (const rowText of rowTexts) {
const rowLocator = this.page
.locator(`tr>th`)
.getByText(rowText, { exact: exact })
.first();
await rowLocator.waitFor({ state: 'visible' });
await rowLocator.scrollIntoViewIfNeeded();
await expect(rowLocator).toBeVisible();
}
}

Expand Down
Loading