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

testpr2 #122

Closed
wants to merge 17 commits into from
71 changes: 71 additions & 0 deletions .github/workflows/run-nala.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Run Nala Tests

on:
push:
branches:
- main
pull_request:
branches:
- main
types: [opened, synchronize, reopened]

jobs:
run-nala-tests:
name: Running Nala E2E UI Tests
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
env:
labels: ${{ join(github.event.pull_request.labels.*.name, ' ') }}
branch: ${{ github.event.pull_request.head.ref }}
repoName: ${{ github.repository }}
prUrl: ${{ github.event.pull_request.head.repo.html_url }}
prOrg: ${{ github.event.pull_request.head.repo.owner.login }}
prRepo: ${{ github.event.pull_request.head.repo.name }}
prBranch: ${{ github.event.pull_request.head.ref }}
prBaseBranch: ${{ github.event.pull_request.base.ref }}
GITHUB_ACTION_PATH: ${{ github.workspace }}
IMS_EMAIL: ${{ secrets.IMS_EMAIL }}
IMS_PASS: ${{ secrets.IMS_PASS }}

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Set execute permission for nalarun.sh
run: chmod +x ./nala/utils/pr.run.sh

- name: Run Nala Tests via pr.run.sh
run: ./nala/utils/pr.run.sh
env:
labels: ${{ join(github.event.pull_request.labels.*.name, ' ') }}
branch: ${{ github.event.pull_request.head.ref }}
repoName: ${{ github.repository }}
prUrl: ${{ github.event.pull_request.head.repo.html_url }}
prOrg: ${{ github.event.pull_request.head.repo.owner.login }}
prRepo: ${{ github.event.pull_request.head.repo.name }}
prBranch: ${{ github.event.pull_request.head.ref }}
prBaseBranch: ${{ github.event.pull_request.base.ref }}
GITHUB_ACTION_PATH: ${{ github.workspace }}
IMS_EMAIL: ${{ secrets.IMS_EMAIL }}
IMS_PASS: ${{ secrets.IMS_PASS }}

- name: Upload screenshots
uses: actions/upload-artifact@v3
if: failure()
with:
name: screenshots-studio
path: screenshots/studio
retention-days: 7
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ swc.json
studio.json
*.key
*.crt
test-html-results/
test-results/

# IO Runtime Config
config.json
Expand Down
25 changes: 25 additions & 0 deletions nala/.nala-snippets/spec-snippet.code-snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"Create Nala Spec": {
"prefix": "create nala spec",
"body": [
"module.exports = {",
" FeatureName: '${1:Block or Feature Name}',",
" features: [",
" {",
" tcid: '0',",
" name: '@${2:spec-name}',",
" path: '/drafts/nala/[${3:test-page-path}]',",
" data: {",
" attribute-1: '${4:value}',",
" attribute-2: '${5:value}',",
" attribute-3: '${6:value}',",
" },",
" tags: '@Block @smoke @regression @dme',",
" },",
" ],",
"};"
],
"description": "Create a Nala spec with block name or feature name"
}
}

19 changes: 19 additions & 0 deletions nala/libs/baseurl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

import pkg from 'axios';

const { head } = pkg;
export async function isBranchURLValid(url) {
try {
const response = await head(url);
if (response.status === 200) {
console.info(`\nURL (${url}) returned a 200 status code. It is valid.`);
return true;
} else {
console.info(`\nURL (${url}) returned a non-200 status code (${response.status}). It is invalid.`);
return false;
}
} catch (error) {
console.info(`\nError checking URL (${url}): returned a non-200 status code (${response.status})`);
return false;
}
}
31 changes: 31 additions & 0 deletions nala/libs/imslogin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* eslint-disable import/no-import-module-exports */
import { expect } from '@playwright/test';

async function fillOutSignInForm(props, page) {
expect(process.env.IMS_EMAIL, 'ERROR: No environment variable for email provided for IMS Test.').toBeTruthy();
expect(process.env.IMS_PASS, 'ERROR: No environment variable for password provided for IMS Test.').toBeTruthy();

await expect(page).toHaveTitle(/Adobe ID/);
let heading = await page.locator('.spectrum-Heading1').first().innerText();
expect(heading).toBe('Sign in');

// Fill out Sign-in Form
await expect(async () => {
await page.locator('#EmailPage-EmailField').fill(process.env.IMS_EMAIL);
await page.locator('[data-id=EmailPage-ContinueButton]').click();
await expect(page.locator('text=Reset your password')).toBeVisible({ timeout: 45000 }); // Timeout accounting for how long IMS Login page takes to switch form
}).toPass({
intervals: [1_000],
timeout: 10_000,
});

heading = await page.locator('.spectrum-Heading1', { hasText: 'Enter your password' }).first().innerText();
expect(heading).toBe('Enter your password');
await page.locator('#PasswordPage-PasswordField').fill(process.env.IMS_PASS);
await page.locator('[data-id=PasswordPage-ContinueButton]').click();
//await page.locator('div.ActionList-Item:nth-child(1)').click();
await page.waitForURL(`${props.url}#`);
await expect(page).toHaveURL(`${props.url}#`);
}

export default { fillOutSignInForm };
25 changes: 25 additions & 0 deletions nala/libs/screenshot/take.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Take a screenshot of a page
* @param {Page} page - The page object
* @param {string} folderPath - The folder path to save the screenshot, e.g., screenshots/milo
* @param {string} fileName - The file name of the screenshot
* @param {object} options - The screenshot options, see https://playwright.dev/docs/api/class-page#page-screenshot
* @returns {object} The screenshot result
*/
async function take(page, folderPath, fileName, options = {}) {
const urls = [];
const result = {};
const name = `${folderPath}/${fileName}.png`;
urls.push(page.url());
options.path = name;
if (options.selector) {
await page.locator(options.selector).screenshot(options);
} else {
await page.screenshot(options);
}
result.a = name;
result.urls = urls.join(' | ');
return result;
}

export default { take };
Loading
Loading