Skip to content

Commit

Permalink
test: Refactor EditAccountNameView for E2E tests (#11765)
Browse files Browse the repository at this point in the history
This PR refactors EditAccountNameView.js to adhere to E2E testing best
practices by removing static methods converting them to instance methods
and exporting an initialized class instance. The
change-account-name.spec.js file is updated accordingly. Changes include
refactoring EditAccountNameView.js updating change-account-name.spec.js
and improving code readability. These modifications enhance the
maintainability and consistency of the E2E tests for the account name
editing functionality.

---------

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Curtis <Curtis.David7@gmail.com>
  • Loading branch information
devin-ai-integration[bot] and cortisiko authored Oct 11, 2024
1 parent 247686d commit 1a2d5a7
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 22 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/e2e-merge-queue-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: E2E Merge Queue Check

on:
push:
branches: main
pull_request:
merge_group:
types: [checks_requested]

jobs:
apply-smoke-label:
runs-on: ubuntu-latest
steps:
- name: Apply "Run Smoke E2E" label
uses: octokit/request-action@v2.x
with:
route: POST /repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels
labels: 'Run Smoke E2E'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

run-e2e-check:
needs: apply-smoke-label
uses: ./.github/workflows/run-bitrise-e2e-check.yml # Reuse the bitrise check workflow
with:
pr_number: ${{ github.event.number || github.event.pull_request.number }}
e2e_label: 'Run Smoke E2E'
e2e_pipeline: 'pr_smoke_e2e_pipeline'
secrets:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BITRISE_BUILD_TRIGGER_TOKEN: ${{ secrets.BITRISE_BUILD_TRIGGER_TOKEN }}
BITRISE_APP_ID: ${{ secrets.BITRISE_APP_ID }}
33 changes: 23 additions & 10 deletions .github/workflows/run-bitrise-e2e-check.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,46 @@
name: Run Bitrise E2E Check

on:
issue_comment:
types: [edited, deleted]
pull_request:
workflow_call: # Allow workflow to be called by another workflow
inputs:
pr_number:
required: true
type: number
e2e_label:
required: false
type: string
default: 'Run Smoke E2E'
e2e_pipeline:
required: false
type: string
default: 'pr_smoke_e2e_pipeline'
secrets:
GITHUB_TOKEN:
required: true
BITRISE_BUILD_TRIGGER_TOKEN:
required: true
BITRISE_APP_ID:
required: true

pull_request: # Allow workflow to be triggered directly on pull requests
types: [opened, reopened, labeled, unlabeled, synchronize]

env:
E2E_LABEL: 'Run Smoke E2E'
E2E_PIPELINE: 'pr_smoke_e2e_pipeline'
WORKFLOW_NAME: 'run-bitrise-e2e-check'

jobs:
is-fork-pull-request:
name: Determine pull request source
if: ${{ github.event.issue.pull_request || github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
outputs:
IS_FORK: ${{ steps.is-fork.outputs.IS_FORK }}
steps:
- uses: actions/checkout@v3
- name: Determine whether this PR is from a fork
id: is-fork
run: echo "IS_FORK=$(gh pr view --json isCrossRepository --jq '.isCrossRepository' "${PR_NUMBER}" )" >> "$GITHUB_OUTPUT"
run: echo "IS_FORK=$(gh pr view --json isCrossRepository --jq '.isCrossRepository' "${{ inputs.pr_number || github.event.number }}" )" >> "$GITHUB_OUTPUT"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number || github.event.issue.number }}

run-bitrise-e2e-check:
needs: is-fork-pull-request
Expand Down Expand Up @@ -53,7 +68,5 @@ jobs:
BITRISE_BUILD_TRIGGER_TOKEN: ${{ secrets.BITRISE_BUILD_TRIGGER_TOKEN }}
BITRISE_APP_ID: ${{ secrets.BITRISE_APP_ID }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# The status check created under this workflow may be bucketed under another check suite in Github actions. This is a result of workflows with the same triggers.
# For example, the status check may show as `CLA Signature Bot / Bitrise E2E Status`. This is a bug on Github's UI. https://github.com/orgs/community/discussions/24616
run: yarn run run-bitrise-e2e-check
working-directory: '.github/scripts'
24 changes: 13 additions & 11 deletions e2e/pages/EditAccountNameView.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@ import Matchers from '../utils/Matchers';
import Gestures from '../utils/Gestures';
import EditAccountNameSelectorIDs from '../selectors/EditAccountName.selectors';

export default class EditAccountNameView {
static async saveButton() {
return await Matchers.getElementByID(
EditAccountNameSelectorIDs.EDIT_ACCOUNT_NAME_SAVE,
);
class EditAccountNameView {
get saveButton() {
return Matchers.getElementByID(EditAccountNameSelectorIDs.EDIT_ACCOUNT_NAME_SAVE);
}

static async tapSave() {
await Gestures.waitAndTap(this.saveButton());
async tapSave() {
await Gestures.waitAndTap(this.saveButton);
}

static async accountNameInput() {
return await Matchers.getElementByID(
EditAccountNameSelectorIDs.ACCOUNT_NAME_INPUT,
);
get accountNameInput() {
return Matchers.getElementByID(EditAccountNameSelectorIDs.ACCOUNT_NAME_INPUT);
}

async typeAccountName(name) {
await Gestures.typeText(this.accountNameInput, name);
}
}

export default new EditAccountNameView();
2 changes: 1 addition & 1 deletion e2e/specs/accounts/change-account-name.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe(Regression('Change Account Name'), () => {
// Open account actions and edit account name
await WalletView.tapMainWalletAccountActions();
await AccountActionsModal.tapEditAccount();
await Gestures.clearField(EditAccountNameView.accountNameInput());
await Gestures.clearField(EditAccountNameView.accountNameInput);
await TestHelpers.typeTextAndHideKeyboard(
EditAccountNameSelectorIDs.ACCOUNT_NAME_INPUT,
NEW_ACCOUNT_NAME,
Expand Down

0 comments on commit 1a2d5a7

Please sign in to comment.