Skip to content

Commit

Permalink
adjust for failing message tests
Browse files Browse the repository at this point in the history
  • Loading branch information
erikacolette29 committed Sep 23, 2024
1 parent c1e0734 commit 375e236
Show file tree
Hide file tree
Showing 9 changed files with 241 additions and 117 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export BROWSERSTACK_USERNAME="etidwell_MODuZE"
export BROWSERSTACK_ACCESS_KEY="xhvfXLoLYtVfFLXRPbwu"
101 changes: 101 additions & 0 deletions .github/workflows/broswerstack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# This job is to test different maven profiles in sdk branch against full commit-id provided
# This workflow targets Playwright execution

name: NodeJS SDK Test workflow on workflow_dispatch

on:
workflow_dispatch:
inputs:
commit_sha:
description: 'The full commit id to build'
required: true
package_url:
description: 'Staging package url'
required: false

jobs:
comment-run:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
max-parallel: 3
matrix:
node: ['14', '16', '18', '20']
os: [ macos-latest, windows-latest, ubuntu-latest ]
name: NodeJS Playwright Repo ${{ matrix.node }} - ${{ matrix.os }} Sample
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
PACKAGE_URL: ${{ github.event.inputs.package_url }}

steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.commit_sha }}
- uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
id: status-check-in-progress
env:
job_name: NodeJS Playwright Repo ${{ matrix.node }} - ${{ matrix.os }} Sample
commit_sha: ${{ github.event.inputs.commit_sha }}
with:
github-token: ${{ github.token }}
script: |
const result = await github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
name: process.env.job_name,
head_sha: process.env.commit_sha,
status: 'in_progress'
}).catch((err) => ({status: err.status, response: err.response}));
console.log(`The status-check response : ${result.status} Response : ${JSON.stringify(result.response)}`)
if (result.status !== 201) {
console.log('Failed to create check run')
}
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Setup staging npm package
if: ${{ github.event.inputs.package_url != '' }}
run: |
echo 'Publishing tar.gz to local registry'
curl -o staging_package.tgz "$PACKAGE_URL"
npm install verdaccio -g
verdaccio &
npm config set registry http://localhost:4873
npm install -g npm-cli-adduser && npm-cli-adduser -u dummy -p dummy -e [email protected] -r http://localhost:4873
npm publish staging_package.tgz --registry http://localhost:4873/
shell: bash

- name: Install dependencies
run: npm install

- name: Run sample tests
run: npm run sample-test

- name: Run local tests
run: npm run sample-local-test

- if: always()
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
id: status-check-completed
env:
conclusion: ${{ job.status }}
job_name: NodeJS Playwright Repo ${{ matrix.node }} - ${{ matrix.os }} Sample
commit_sha: ${{ github.event.inputs.commit_sha }}
with:
github-token: ${{ github.token }}
script: |
const result = await github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
name: process.env.job_name,
head_sha: process.env.commit_sha,
status: 'completed',
conclusion: process.env.conclusion
}).catch((err) => ({status: err.status, response: err.response}));
console.log(`The status-check response : ${result.status} Response : ${JSON.stringify(result.response)}`)
if (result.status !== 201) {
console.log('Failed to create check run')
}
27 changes: 24 additions & 3 deletions tests/playwright/pages/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,32 @@ export const baseTest = base.extend({
};
await use(navigate);
},

// Fixture for running Axe accessibility checks
runAxeCoreScan: async ({ page }, use) => {
const runAxeCoreScan = async element => {
messageAxeCoreScan: async ({ page }, use) => {
const runAxeCoreScan = async (element, type) => {

Check failure on line 29 in tests/playwright/pages/base.js

View workflow job for this annotation

GitHub Actions / Lint and Unit Tests

'element' is defined but never used

Check failure on line 29 in tests/playwright/pages/base.js

View workflow job for this annotation

GitHub Actions / Lint and Unit Tests

'type' is defined but never used
const tags = ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'best-practice'];
const results = await new AxeBuilder({ page }).include(element).withTags(tags).analyze();
const results = await new AxeBuilder({ page })
.include('body') // Include everything inside iframe
.withTags(tags)
.disableRules(['page-has-heading-one', 'landmark-one-main'])
// evaluating a message on a larger page on merchant website, does not need level one heading
// does not need landmark because it is a button that opens a modal that has a landmark
.analyze();

expect(results.violations).toEqual([]);
};
await use(runAxeCoreScan);
},

modalAxeCoreScan: async ({ page }, use) => {
const runAxeCoreScan = async (element, type) => {

Check failure on line 45 in tests/playwright/pages/base.js

View workflow job for this annotation

GitHub Actions / Lint and Unit Tests

'element' is defined but never used

Check failure on line 45 in tests/playwright/pages/base.js

View workflow job for this annotation

GitHub Actions / Lint and Unit Tests

'type' is defined but never used
const tags = ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'best-practice'];
const results = await new AxeBuilder({ page })
.include('body') // Include everything inside iframe
.withTags(tags)
.analyze();

expect(results.violations).toEqual([]);
};
await use(runAxeCoreScan);
Expand Down
28 changes: 14 additions & 14 deletions tests/playwright/tests/sdk/messages/longTerm.spec.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
import { messageTest } from '../../../pages/messages_fixture';

messageTest.describe('@US Long Term', () => {
messageTest('US Message long term non qualifying', async ({ navigatePage, loadMessage, runAxeCoreScan }) => {
messageTest('US Message long term non qualifying', async ({ navigatePage, loadMessage, messageAxeCoreScan }) => {
await navigatePage({ account: 'DEV_US_LONG_TERM', amount: 29, offer: 'PAY_LATER_LONG_TERM' });
const messageIFrame = await loadMessage();
await runAxeCoreScan(messageIFrame);
await messageAxeCoreScan(messageIFrame);
});
messageTest('US Message long term qualifying', async ({ navigatePage, loadMessage, runAxeCoreScan }) => {
messageTest('US Message long term qualifying', async ({ navigatePage, loadMessage, messageAxeCoreScan }) => {
await navigatePage({ account: 'DEV_US_LONG_TERM', amount: 100, offer: 'PAY_LATER_LONG_TERM' });
const messageIFrame = await loadMessage();
await runAxeCoreScan(messageIFrame);
await messageAxeCoreScan(messageIFrame);
});
messageTest('US Message long term checkout', async ({ navigatePage, loadMessage, runAxeCoreScan }) => {
messageTest('US Message long term checkout', async ({ navigatePage, loadMessage, messageAxeCoreScan }) => {
await navigatePage({ account: 'DEV_US_LONG_TERM_CHECKOUT', amount: 100, offer: 'PAY_LATER_LONG_TERM' });
const messageIFrame = await loadMessage();
await runAxeCoreScan(messageIFrame);
await messageAxeCoreScan(messageIFrame);
});
});
messageTest.describe('@DE Long Term', () => {
messageTest('DE Message long term qualifying', async ({ navigatePage, loadMessage, runAxeCoreScan }) => {
messageTest('DE Message long term qualifying', async ({ navigatePage, loadMessage, messageAxeCoreScan }) => {
await navigatePage({ account: 'DEV_DE_LONG_TERM', amount: 100, offer: 'PAY_LATER_LONG_TERM' });
const messageIFrame = await loadMessage();
await runAxeCoreScan(messageIFrame);
await messageAxeCoreScan(messageIFrame);
});
messageTest('DE Message long term non qualifying', async ({ navigatePage, loadMessage, runAxeCoreScan }) => {
messageTest('DE Message long term non qualifying', async ({ navigatePage, loadMessage, messageAxeCoreScan }) => {
await navigatePage({ account: 'DEV_DE_LONG_TERM', amount: 29, offer: 'PAY_LATER_LONG_TERM' });
const messageIFrame = await loadMessage();
await runAxeCoreScan(messageIFrame);
await messageAxeCoreScan(messageIFrame);
});
messageTest('DE Message long term 0APR non qualifying', async ({ navigatePage, loadMessage, runAxeCoreScan }) => {
messageTest('DE Message long term 0APR non qualifying', async ({ navigatePage, loadMessage, messageAxeCoreScan }) => {

Check failure on line 31 in tests/playwright/tests/sdk/messages/longTerm.spec.js

View workflow job for this annotation

GitHub Actions / Lint and Unit Tests

Replace `'DE·Message·long·term·0APR·non·qualifying',` with `⏎········'DE·Message·long·term·0APR·non·qualifying',⏎·······`
await navigatePage({ account: 'DEV_DE_LONG_TERM_0APR', amount: 29, offer: 'PAY_LATER_LONG_TERM' });

Check failure on line 32 in tests/playwright/tests/sdk/messages/longTerm.spec.js

View workflow job for this annotation

GitHub Actions / Lint and Unit Tests

Replace `········` with `············`
const messageIFrame = await loadMessage();

Check failure on line 33 in tests/playwright/tests/sdk/messages/longTerm.spec.js

View workflow job for this annotation

GitHub Actions / Lint and Unit Tests

Insert `····`
await runAxeCoreScan(messageIFrame);
await messageAxeCoreScan(messageIFrame);

Check failure on line 34 in tests/playwright/tests/sdk/messages/longTerm.spec.js

View workflow job for this annotation

GitHub Actions / Lint and Unit Tests

Insert `····`
});

Check failure on line 35 in tests/playwright/tests/sdk/messages/longTerm.spec.js

View workflow job for this annotation

GitHub Actions / Lint and Unit Tests

Replace `}` with `····}⏎····`
messageTest('DE Message long term 0APR qualifying', async ({ navigatePage, loadMessage, runAxeCoreScan }) => {
messageTest('DE Message long term 0APR qualifying', async ({ navigatePage, loadMessage, messageAxeCoreScan }) => {
await navigatePage({ account: 'DEV_DE_LONG_TERM_0APR', amount: 100, offer: 'PAY_LATER_LONG_TERM' });
const messageIFrame = await loadMessage();
await runAxeCoreScan(messageIFrame);
await messageAxeCoreScan(messageIFrame);
});
});
36 changes: 18 additions & 18 deletions tests/playwright/tests/sdk/messages/multi.spec.js
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
import { messageTest } from '../../../pages/messages_fixture';

messageTest.describe('@US Multi Messages', () => {
messageTest('US long term non qualifying', async ({ navigatePage, loadMessage, runAxeCoreScan }) => {
messageTest('US long term non qualifying', async ({ navigatePage, loadMessage, messageAxeCoreScan }) => {
await navigatePage({ account: 'DEV_US_MULTI', amount: 20001, offer: 'PAY_LATER_LONG_TERM' });
const messageIframe = await loadMessage();
await runAxeCoreScan(messageIframe);
await messageAxeCoreScan(messageIframe);
});

messageTest('US long term qualifying', async ({ navigatePage, loadMessage, runAxeCoreScan }) => {
messageTest('US long term qualifying', async ({ navigatePage, loadMessage, messageAxeCoreScan }) => {
await navigatePage({ account: 'DEV_US_MULTI', amount: 1501, offer: 'PAY_LATER_LONG_TERM' });
const messageIframe = await loadMessage();
await runAxeCoreScan(messageIframe);
await messageAxeCoreScan(messageIframe);
});

messageTest('US product list', async ({ navigatePage, loadMessage, runAxeCoreScan }) => {
messageTest('US product list', async ({ navigatePage, loadMessage, messageAxeCoreScan }) => {
await navigatePage({ account: 'DEV_US_MULTI', amount: 200, offer: '' });
const messageIframe = await loadMessage();
await runAxeCoreScan(messageIframe);
await messageAxeCoreScan(messageIframe);
});

messageTest('US short term non qualifying', async ({ navigatePage, loadMessage, runAxeCoreScan }) => {
messageTest('US short term non qualifying', async ({ navigatePage, loadMessage, messageAxeCoreScan }) => {
await navigatePage({ account: 'DEV_US_MULTI', amount: 29, offer: 'PAY_LATER_SHORT_TERM' });
const messageIframe = await loadMessage();
await runAxeCoreScan(messageIframe);
await messageAxeCoreScan(messageIframe);
});

messageTest('US short term qualifying', async ({ navigatePage, loadMessage, runAxeCoreScan }) => {
messageTest('US short term qualifying', async ({ navigatePage, loadMessage, messageAxeCoreScan }) => {
await navigatePage({ account: 'DEV_US_MULTI', amount: 200, offer: 'PAY_LATER_SHORT_TERM' });
const messageIframe = await loadMessage();
await runAxeCoreScan(messageIframe);
await messageAxeCoreScan(messageIframe);
});
});

messageTest.describe('@DE Multi Messages', () => {
messageTest('DE multi qualifying', async ({ navigatePage, loadMessage, runAxeCoreScan }) => {
messageTest('DE multi qualifying', async ({ navigatePage, loadMessage, messageAxeCoreScan }) => {
await navigatePage({ account: 'DEV_DE_MULTI', amount: 200, offer: 'PAY_LATER_SHORT_TERM' });
const messageIframe = await loadMessage();
await runAxeCoreScan(messageIframe);
await messageAxeCoreScan(messageIframe);
});

messageTest('DE multi non qualifying', async ({ navigatePage, loadMessage, runAxeCoreScan }) => {
messageTest('DE multi non qualifying', async ({ navigatePage, loadMessage, messageAxeCoreScan }) => {
await navigatePage({ account: 'DEV_DE_MULTI', amount: 29, offer: 'PAY_LATER_SHORT_TERM' });
const messageIframe = await loadMessage();
await runAxeCoreScan(messageIframe);
await messageAxeCoreScan(messageIframe);
});
messageTest('DE pay in 1 qualifying', async ({ navigatePage, loadMessage, runAxeCoreScan }) => {
messageTest('DE pay in 1 qualifying', async ({ navigatePage, loadMessage, messageAxeCoreScan }) => {
await navigatePage({ account: 'DEV_DE_PAY_IN_1', amount: 200, offer: 'PAY_LATER_PAY_IN_1' });
const messageIframe = await loadMessage();
await runAxeCoreScan(messageIframe);
await messageAxeCoreScan(messageIframe);
});
messageTest('DE pay in 1 non qualifying', async ({ navigatePage, loadMessage, runAxeCoreScan }) => {
messageTest('DE pay in 1 non qualifying', async ({ navigatePage, loadMessage, messageAxeCoreScan }) => {
await navigatePage({ account: 'DEV_DE_PAY_IN_1', amount: 1001.1, offer: 'PAY_LATER_PAY_IN_1' });
const messageIframe = await loadMessage();
await runAxeCoreScan(messageIframe);
await messageAxeCoreScan(messageIframe);
});
});
Loading

0 comments on commit 375e236

Please sign in to comment.