Skip to content

Commit

Permalink
Merge 642521d into 928aa4a
Browse files Browse the repository at this point in the history
  • Loading branch information
kadel committed Mar 10, 2024
2 parents 928aa4a + 642521d commit 7e9fe41
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 10 deletions.
18 changes: 16 additions & 2 deletions .ibm/pipelines/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,23 @@ save_logs() {
RESULT="$3"

ansi2html <"/tmp/${LOGFILE}" >"/tmp/${LOGFILE}.html"

# Create a tarball of the playwright-report directory
tar -czvf /tmp/${LOGFILE}-report.tar.gz playwright-report/

CRN=$(ibmcloud resource service-instance ${IBM_COS} --output json | jq -r .[0].guid)
ibmcloud cos config crn --crn "${CRN}"
ibmcloud cos upload --bucket "${IBM_BUCKET}" --key "${LOGFILE}.html" --file "/tmp/${LOGFILE}.html" --content-type "text/html; charset=UTF-8"

ibmcloud cos upload --bucket "${IBM_BUCKET}" --key "${LOGFILE}-report.tar.gz" --file "/tmp/${LOGFILE}-report.tar.gz" --content-type "application/gzip"

# Loop through each file in the e2e-tests/playwright-report directory
find playwright-report -type f | while read FILE; do
# Extract the file path relative to the directory to maintain the structure in COS
RELATIVE_PATH=${FILE#$DIRECTORY_TO_UPLOAD}
# Upload the file
ibmcloud cos upload --bucket "${IBM_BUCKET}" --key "${LOGFILE}-report/${RELATIVE_PATH}" --file "${FILE}"
done


BASE_URL="https://s3.${IBM_REGION}.cloud-object-storage.appdomain.cloud/${IBM_BUCKET}"
if [[ $RESULT == "0" ]]; then
STATUS="successfully"
Expand All @@ -26,6 +38,8 @@ save_logs() {
cat <<EOF | pr-commenter -key-from-env-var ROBOT_KEY -application-id=${GITHUB_APP_PR_COMMENTER_ID} -pr-comment=${GIT_PR_NUMBER} -repository=${GITHUB_REPOSITORY_NAME} -org=${GITHUB_ORG_NAME}
${NAME} on commit ${GIT_COMMIT} finished **${STATUS}**.
View [test log](${BASE_URL}/${LOGFILE}.html)
View [Playwright report](${BASE_URL}/${LOGFILE}-report/playwright-report/index.html)
Download [Playwright report](${BASE_URL}/${LOGFILE}-report.tar.gz)
EOF
}

Expand Down
2 changes: 2 additions & 0 deletions e2e-tests/playwright/utils/Common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export class Common {
await this.page.goto('/');
await this.uiHelper.clickButton('Sign In');
await this.checkAndReauthorizeGithubApp();
// TODO: Remove this once the issue is fixed
await this.page.reload();
await this.uiHelper.waitForSideBarVisible();
}

Expand Down
48 changes: 40 additions & 8 deletions e2e-tests/playwright/utils/UIhelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ export class UIhelper {
async openSidebar(navBarText: string) {
const navLink = this.page.locator(`nav a:has-text("${navBarText}")`);
await navLink.waitFor({ state: 'visible' });
const href = navLink.getAttribute('href');
await navLink.click();
await this.page.waitForURL(`**/${href}`);
}

async selectMuiBox(label: string, value: string) {
Expand All @@ -98,14 +100,44 @@ export class UIhelper {
rowTexts: string[] | RegExp[],
exact: boolean = true,
) {
for (const rowText of rowTexts) {
const rowLocator = this.page
.locator(`tr>td`)
.getByText(rowText, { exact: exact })
.first();
await rowLocator.waitFor({ state: 'visible' });
await rowLocator.scrollIntoViewIfNeeded();
await expect(rowLocator).toBeVisible();
const foundTexts = new Set();

let hasNextPage = true;

// Loop through pages as long as a "Next" link is present
while (hasNextPage) {
for (const rowText of rowTexts) {
const rowLocator = this.page
.locator(`tr>td`)
.getByText(rowText, { exact: exact })
.first();
await rowLocator.waitFor({ state: 'visible' });
await rowLocator.scrollIntoViewIfNeeded();
if (rowLocator.isVisible()) {
foundTexts.add(rowText);
}
}

const nextPageButton = this.page.getByLabel('Next Page').nth(0);

if (await nextPageButton.isDisabled()) {
hasNextPage = false;
} else {
await nextPageButton.click();
}
}

rowTexts.forEach(item => {
expect(foundTexts.has(item)).toBeTruthy();
});

// Go to the first page
let previousPageButton = this.page.getByLabel('Previous Page').nth(0);
while (
(previousPageButton = this.page.getByLabel('Previous Page').nth(0)) &&
(await previousPageButton.isVisible())
) {
await previousPageButton.click();
}
}

Expand Down

0 comments on commit 7e9fe41

Please sign in to comment.