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

chore: fix missing device definitions #708

Merged
merged 1 commit into from Jan 28, 2020
Merged

chore: fix missing device definitions #708

merged 1 commit into from Jan 28, 2020

Conversation

sotayamashita
Copy link
Contributor

@sotayamashita sotayamashita commented Jan 28, 2020

Background

related to #606

How has this been tested?

  1. Clone the repository including this patch
  2. Create a sample project
  3. Install local module as npm package with npm install -S /absolute-path/to/playwright
    package.json should be like this:
    "dependencies": {
        "playwright-core": "file:/path/to/playwright"
    }
  4. Create a main.js with following code:
    const devices = require("playwright-core").devices
    
    const deviceMap = new Map();
    for (const device of devices) {
      deviceMap.set(device.name, device);
    }
    
    for (const name of deviceMap.keys()) {
      if (name.endsWith(" landscape")) continue;
      const landscapeName = `${name} landscape`;
      if (!deviceMap.has(landscapeName)) {
        const landscapeDevice = deviceMap.get(name);
        const {width, height} = landscapeDevice.viewport;
        landscapeDevice.name = landscapeName;
        landscapeDevice.viewport.width = height;
        landscapeDevice.viewport.height = width;
        console.log(`Missing device for "${landscapeName}", expected: ${JSON.stringify(landscapeDevice,     null, 2)}`);
      }
    }
  5. It should not output log.

Question

  • I think it has a spec it to to avoid same error. What do you think?

@msftclas
Copy link

msftclas commented Jan 28, 2020

CLA assistant check
All CLA requirements met.

@sotayamashita sotayamashita marked this pull request as ready for review January 28, 2020 10:41
@aslushnikov aslushnikov merged commit a64fc0e into microsoft:master Jan 28, 2020
@aslushnikov
Copy link
Collaborator

Thank you!

I think it has a spec it to to avoid same error. What do you think?

Let's rely on code reviews for now - I think there are some devices that don't have landscape, so adding a lint check is not that straightforward

@sotayamashita sotayamashita deleted the add-missing-device-def branch January 29, 2020 02:31
sand4rt pushed a commit to sand4rt/playwright that referenced this pull request Dec 21, 2022
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants