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

Nala pom and tests enhancements #91

Merged
merged 11 commits into from
Mar 28, 2023
Merged

Conversation

skumar09
Copy link
Contributor

@skumar09 skumar09 commented Mar 27, 2023

This PR is with respect to enhancement of Nala playwright framework and address few current issues, also provide few best practices and guidelines for tests, specs and pom.

  1. Test Structure
    In Current test structure
    • we are executing all specs or testcases inside a features for-loop, with increase in specs counts it
      is getting difficult to add new test and tweak the logic, it is not scalable.
    • it is also quite difficult to read, debug and understand the tests, steps and flows.
  2. With this PR , provided the following :
    • All tests are grouped under test.describe() that is something like suite ex: carousel-block test suite.
    • Each spec or testcase from .spec.js file corresponds to a separate test. (as below screenshot.)
    • Introduced test.step() under test()
      • This will introduce better readability, separation of code / logic for different tests and test steps
  3. Spec
    • Spec structure is simplified to the array as follows, (we can add items as required for the specs)
    • Parsing Spec.js is not required.
    • Env baseURL is taken from playwright.config.js. ( This part is still in enhancement )
  4. Page Objects.
    • Provided the sample for how to define selectors with reference to parent selector or element.
    • Provided method, guideline, and commenting format for page object methods.
  5. Dashboard Report Util.
    - Dashboard report utility was failing when the test name is changed, ( i.e. test name was tightly coupled to have four fixed parameters or arguments, and it was failing when test name has comma separator
    -
    - Above issue is now fixed,
    • Now test name can have comma, or space as a delimiter
    • Also test name can have parameters as many as required

Features/Specs

image

Tests

image

POM

image

Test results

  • are more readable with test steps

image

@skumar09 skumar09 added @carousel Run Carousel Block Tests Nala run-nala Run Nala Test Automation against PR/Branch labels Mar 27, 2023
@skumar09 skumar09 removed the run-nala Run Nala Test Automation against PR/Branch label Mar 27, 2023
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://localhost:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
baseURL: 'https://main--milo--adobecom.hlx.page',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can introduce profile concept, because the baseUrl is totally different per team

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JackySun9 : this one still work in progress,[ in the playwright world we can have multipleconfig.jsor globalsetup.js for environment, working on...]

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm considering this right, when Nala becomes a consumable tool teams should be able to configure the baseURL to their desired one for their team. Having so many profiles/configs will get bulky in my opinion and for core Nala, if it isn't going to be configurable I think this will become bulky and heavy on maintenance.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@skumar09 You mentioned in the PR description that Parse.js would not need to be used. The usage of baseURL, with how I understand it is for a default mostly used URL that can be used when you tell playwright's browsers to go to '/' in a page.goto() call, not as a addition to be attached to another array of path strings. Otherwise, what is the plan for tests that span over different environments for a team? I'm specifically considering Milo core block testing since Milo will need to be able to test against consumer sites. Also the parse.js was used to apply rules for when the ?milolibs parameter should be added as well as when "main" in the Franklin/Helix URL should be swapped out to a feature branch so that PR testing against specific branches could happen before merging code changes into live, i.e., main--milo--adobecom.hlx.live would be swapped out for myfeaturebranchname--milo--adobecom.hlx.live. This functionality is critical and necessary, if that is removed then we will not be supporting the needs of PR testing, which is one of the core features of Nala. If we want to remove the need for parsing then there needs to be something else in place that can be used on a core level for all consumers to be able to add the "milolibs?=" parameter against other consumer sites to ensure milo block changes doesn't break anything live on consumer sites as well as swapping out repository branches for Franklin/Helix URLs for PR testing against new code.

/* eslint-disable import/no-import-module-exports */
import { expect } from '@playwright/test';

exports.Carousel = class Carousel {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

POM is good, we might have some base pages, the purpose for this design is inheritance and reuse

});

// test step-2
await test.step('Verify Carousel container ', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if define some method, can we reuse it?

@skumar09 skumar09 added the run-nala Run Nala Test Automation against PR/Branch label Mar 27, 2023
@skumar09 skumar09 requested a review from JingleH March 28, 2023 17:31
Copy link
Contributor

@JingleH JingleH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

Copy link
Contributor

@Dli3 Dli3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link

@rgclayton rgclayton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a minor typo

/**
* Click carousel <lightbox modal close> button
*/
async closeLighboxModal() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo. Should be closeLightboxModal

await carousel.expandLighboxModal();

expect(await carousel.isLightboxCloseButtonVisible()).toBeTruthy();
await carousel.closeLighboxModal();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo. Should be closeLightboxModal

@skumar09 skumar09 requested a review from rgclayton March 28, 2023 18:43
Copy link
Collaborator

@amauch-adobe amauch-adobe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like adding the direction for more structured and readable test scripts by using the out-of-the-box playwright annotations, test.step() methods, etc. I think that is a great adjustment and move, I think having the baseURL configurable is the best option instead of creating more complex profiles and bulking up Nala with tons of different config files per team. I also think the baseURL is a default option to use if it works for your test, but shouldn't be always used (see my comments about PR testing, the usage of parse.js with feature branch testing, and the ?milolibs= URL parameter). I think the tcid addition to specs will also help with the TestRail integration. The POM model looks great, and fits exactly what we have already discussed with Daniel Chivesco with his PRs. I also don't want us to forget the other mission of Nala was to make it simple for all developer types and not just QEs or testers. One of the reasons for creating Nala was to bridge gaps between all team members to feel comfortable in using a tool to create End-to-End tests and to do so quickly. Whenever we add, change, or switch to a new way of doing things we need to make sure there is buy-in to the changes, don't remove key functionality that is core to Nala, and keep things simple for all developers. @skumar09, I think having a huddle on this one would be good for me so I can be on the same page for some of the changes.

name: '@Carousel(lightbox)',
path: '/drafts/nala/blocks/carousel/fullpage-carousel',
tags: '@carousel @carousel-container @smoke @regression @milo,',
envs: '@milo-live milo-prod',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing '@' symbol in front of milo-prod for envs

name: '@Carousel Multi slide(show-2)',
path: '/drafts/nala/blocks/carousel/carousel-show-2',
tags: '@carousel @carousel-container @regression @milo',
envs: '@milo-live milo-prod',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing '@' symbol in front of milo-prod for envs

/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
actionTimeout: 30000,
actionTimeout: 60000,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the logic/reason for needing an action timeout of a minute long? Just curious.

@@ -34,16 +34,17 @@ const config = {
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: process.env.CI
? [['github'], ['./utils/reporters/json-reporter.js'], ['./utils/reporters/api-reporter.js']]
: [['html', { outputFolder: 'test-html-results' }]],
: [['html', { outputFolder: 'test-html-results' }], ['./utils/reporters/json-reporter.js']],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are we using the JSON-reporter locally for? For GitHub, it is necessary so that the Nala Dashboard App can pull it down/download it for its reporting. As we move forward with reporting improvements I want to make sure we keep Jingle involved since I would hate all the work Jingle put forth per Chris/Ryan's direction and many other mangers/directors involvement for the Nala Dashboard App to become inconsequential.

/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://localhost:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
baseURL: 'https://main--milo--adobecom.hlx.page',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@skumar09 You mentioned in the PR description that Parse.js would not need to be used. The usage of baseURL, with how I understand it is for a default mostly used URL that can be used when you tell playwright's browsers to go to '/' in a page.goto() call, not as a addition to be attached to another array of path strings. Otherwise, what is the plan for tests that span over different environments for a team? I'm specifically considering Milo core block testing since Milo will need to be able to test against consumer sites. Also the parse.js was used to apply rules for when the ?milolibs parameter should be added as well as when "main" in the Franklin/Helix URL should be swapped out to a feature branch so that PR testing against specific branches could happen before merging code changes into live, i.e., main--milo--adobecom.hlx.live would be swapped out for myfeaturebranchname--milo--adobecom.hlx.live. This functionality is critical and necessary, if that is removed then we will not be supporting the needs of PR testing, which is one of the core features of Nala. If we want to remove the need for parsing then there needs to be something else in place that can be used on a core level for all consumers to be able to add the "milolibs?=" parameter against other consumer sites to ensure milo block changes doesn't break anything live on consumer sites as well as swapping out repository branches for Franklin/Helix URLs for PR testing against new code.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes more sense to rename the selectors directory to "pages" since POMs are more than just selectors but also methods for the page that may not just be against the said selectors. I think we already discussed this though and decided to have them under page/, I might have forgot though. :)

// Carousel blocks tests
test.describe('Milo Carousel block test suite', () => {
// Test - 1
test(`${features[0].name}, @milo-live, ${features[0].tags},https://milo.adobe.com `, async ({ page, baseURL }) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where the envs is being added as @milo_live and @milo_prod having "https://milo.adobe.com added to the test title would make it incorrect since @milo_live is actually https://main--milo--adobecom.hlx.live. So the resulting report would provide the incorrect URL it was tested against. Also if you are adding envs as a part of the spec for environments those paths should be tested against, how does the current test setup work to test against those different environments? Currently, from what I can see this will only test against what the base URL is which may not ever be any of those environments in the spec file. As mentioned in my previous comment the parse.js lib was setup so that you could test a block against many different environments for the same path since you could run a test against hlx.page or hlx.live or a production URL with the same path. I guess looking at the current commit for the spec, we would have to add a test() for every feature spec array we make and only have one env variable for them even though the tags and paths would be the same, that is one way of getting around this problem but it also adds a bit of redundancy in feature spec.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with the adjustments, I just want to ensure that things are still grouped correctly in the Nala Dashboard App for test results. I also want to ensure the filtering will still work. @JingleH do we know if that is the case?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was being lazy and simply hoping to see if this breaks the dashboard or not haha. If we decide to do things this way and merge this PR, I can make corresponding changes in the dashboard if needed. Looks like it's sending all the required params, so hopefully nothing breaks. Thanks for letting me know!

Copy link
Collaborator

@amauch-adobe amauch-adobe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, had huddle with @skumar09 everything looks good, and answered concerns.

@skumar09 skumar09 merged commit db99f16 into adobecom:main Mar 28, 2023
JFernandezAdobe pushed a commit to JFernandezAdobe/nala that referenced this pull request Apr 3, 2023
* Nala pom and tests enhancements

* update spec name and url in test title to stop reporter util failure

* temporary update to test title to debug reporter.js failure

* temporary update to test title to debug reporter.js failure_2

* temporary update to test title to debug reporter.js failure_3

* updatating title  back to first commit

* fixed the reporter.js failure for new test title update

* fixed the typo in lightbox method name

---------

Co-authored-by: nateekar <nateekar@adobe.com>
Co-authored-by: Aaron Mauchley <mauchley@adobe.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@carousel Run Carousel Block Tests Nala run-nala Run Nala Test Automation against PR/Branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants