Skip to content

[types/nightwatch] Add PageObjectModel types to support POM pattern in Nightwatch test suites#59626

Merged
typescript-bot merged 5 commits intoDefinitelyTyped:masterfrom
reallymello:PageObjectModel
Apr 1, 2022
Merged

[types/nightwatch] Add PageObjectModel types to support POM pattern in Nightwatch test suites#59626
typescript-bot merged 5 commits intoDefinitelyTyped:masterfrom
reallymello:PageObjectModel

Conversation

@reallymello
Copy link
Copy Markdown
Contributor

Please fill in this template.

If changing an existing definition:

  • Provide a URL to documentation or source code which provides context for the suggested changes:

The addition of the PageObjectModel and PageElements interface will allow for stricter type checking when using Nightwatch's implementation of the page object model pattern in TypeScript. Below is an example.

import { EnhancedPageObject, PageElements, PageObjectModel } from "nightwatch";

const elements: PageElements = {
  submitButton: "#submitBtn", // shorthand string selector pattern using configured global locator strategy
  pageHeader: { // longhand version allowing explicit type-safe locator strategy
    locateStrategy: "css selector",
    selector: "#ctl00_lblPageHeader",
  },
};

const nameAddressAndTelephone: PageObjectModel = {
  url(this: EnhancedPageObject) {
    return `${this.api.launch_url}/default.aspx`;
  },
  elements: elements,
};

export default nameAddressAndTelephone;

export type NameAddressAndTelephonePage =
  EnhancedPageObject<PageObjectModel>;

Usage in a Nightwatch test

const telephonePage: NameAddressAndTelephonePage = browser.page.myself.persona.NameAddressAndTelephone();
telephonePage.waitForElementVisible("@pageHeader", 15000);

@typescript-bot
Copy link
Copy Markdown
Contributor

typescript-bot commented Mar 31, 2022

@reallymello Thank you for submitting this PR! I see this is your first time submitting to DefinitelyTyped 👋 — I'm the local bot who will help you through the process of getting things through.

This is a live comment which I will keep updated.

1 package in this PR

Code Reviews

Because you edited one package and updated the tests (👏), I can help you merge this PR once someone else signs off on it.

You can test the changes of this PR in the Playground.

Status

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • ✅ Most recent commit is approved by type definition owners, DT maintainers or others

All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes.


Diagnostic Information: What the bot saw about this PR
{
  "type": "info",
  "now": "-",
  "pr_number": 59626,
  "author": "reallymello",
  "headCommitOid": "4d8638baa955ce1d867df8e82efcd9a5ff4c46c2",
  "mergeBaseOid": "d6b527de9f5bf07aa905597563ec1dc995f84ac1",
  "lastPushDate": "2022-03-31T16:13:45.000Z",
  "lastActivityDate": "2022-04-01T15:04:40.000Z",
  "mergeOfferDate": "2022-04-01T15:04:12.000Z",
  "mergeRequestDate": "2022-04-01T15:04:40.000Z",
  "mergeRequestUser": "vaibhavsingh97",
  "hasMergeConflict": false,
  "isFirstContribution": true,
  "tooManyFiles": false,
  "hugeChange": false,
  "popularityLevel": "Well-liked by everyone",
  "pkgInfo": [
    {
      "name": "nightwatch",
      "kind": "edit",
      "files": [
        {
          "path": "types/nightwatch/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/nightwatch/test/nightwatch-tests.ts",
          "kind": "test"
        }
      ],
      "owners": [
        "rkavalap",
        "schlesiger",
        "ClaytonAstrom",
        "lloiser",
        "vaibhavsingh97",
        "beatfactor",
        "AutomatedTester",
        "gravityvi",
        "swrdfish",
        "harshit-bs",
        "literallyMello",
        "lukebickell"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Well-liked by everyone"
    }
  ],
  "reviews": [
    {
      "type": "approved",
      "reviewer": "vaibhavsingh97",
      "date": "2022-04-01T15:03:32.000Z",
      "isMaintainer": false
    }
  ],
  "mainBotCommentID": 1084836811,
  "ciResult": "pass"
}

@typescript-bot
Copy link
Copy Markdown
Contributor

🔔 @rkavalap @schlesiger @ClaytonAstrom @lloiser @vaibhavsingh97 @beatfactor @AutomatedTester @gravityvi @swrdfish @harshit-bs @literallyMello @lukebickell — please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

@DangerBotOSS
Copy link
Copy Markdown

Inspecting the JavaScript source for this package found some properties that are not in the .d.ts files.
The check for missing properties isn't always right, so take this list as advice, not a requirement.

nightwatch (unpkg)

was missing the following properties:

  1. createClient
  2. client
  3. cli
  4. runTests
  5. CliRunner
as well as these 2 other properties...

initClient, runner

Generated by 🚫 dangerJS against 4d8638b

@typescript-bot typescript-bot added Owner Approved A listed owner of this package signed off on the pull request. Self Merge This PR can now be self-merged by the PR author or an owner labels Apr 1, 2022
@typescript-bot
Copy link
Copy Markdown
Contributor

@reallymello: Everything looks good here. I am ready to merge this PR (at 4d8638b) on your behalf whenever you think it's ready.

If you'd like that to happen, please post a comment saying:

Ready to merge

and I'll merge this PR almost instantly. Thanks for helping out! ❤️

(@rkavalap, @schlesiger, @ClaytonAstrom, @lloiser, @vaibhavsingh97, @beatfactor, @AutomatedTester, @gravityvi, @swrdfish, @harshit-bs, @literallyMello, @lukebickell: you can do this too.)

@vaibhavsingh97
Copy link
Copy Markdown
Contributor

Ready to merge

@typescript-bot typescript-bot merged commit d4f7c07 into DefinitelyTyped:master Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Owner Approved A listed owner of this package signed off on the pull request. Self Merge This PR can now be self-merged by the PR author or an owner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants