This project was bootstrapped with
[Create React App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the app in the development mode.<br /> Open
[http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.<br /> You will also see any lint errors
in the console.

### `npm test`

Launches the test runner in the interactive watch mode.<br /> See the section
about
[running tests](https://facebook.github.io/create-react-app/docs/running-tests)
for more information.

### `npm run build`

Builds the app for production to the `build` folder.<br /> It correctly bundles
React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.<br /> Your app is
ready to be deployed!

See the section about
[deployment](https://facebook.github.io/create-react-app/docs/deployment) for
more information.

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can
`eject` at any time. This command will remove the single build dependency from
your project.

Instead, it will copy all the configuration files and the transitive
dependencies (webpack, Babel, ESLint, etc) right into your project so you have
full control over them. All of the commands except `eject` will still work, but
they will point to the copied scripts so you can tweak them. At this point
you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for
small and middle deployments, and you shouldn’t feel obligated to use this
feature. However we understand that this tool wouldn’t be useful if you couldn’t
customize it when you are ready for it.

## Learn More

You can learn more in the
[Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).



---

# Test Documentation (below)

## Setup
### Requirements
i) Install latest NodeJs version

ii) Any editor (recommend to use Visual Studio Code)

### Sample env file:
```
LOGIN_EMAIL="<sample_email>"
LOGIN_PASSWORD="<sample_pass>"
DSS_GRAPHQL_URL="https://staging.datasense.pgdss.com/api/pgds-platform/graphql"
DSS_WEBSITE_URL="https://staging.datasense.pgdss.com"

USE_CI_REPORTER="false"

DD_ENV="local"
DD_SERVICE="staging-ds-platform-regression"
DD_CIVISIBILITY_AGENTLESS_ENABLED="true"
DD_API_KEY=""
```

### How to create PAT (personal access token) - only `read:packages` scope is needed:
- https://docs.github.com/en/enterprise-server@3.4/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token

### Steps to run locally:

i) set `GH_PAT` as system env var (for MAC run export `GH_PAT="<insert_pat_here>"` (refer to instruction above to create PAT and required scope)

ii) reopen terminal & editor

iii) run `npm i` or `yarn install` in root directory

iv) navigate to `/test` folder

v) create `.env` file (inside `/test` folder)

vi) run `npx playwright test`

---

## How to run Tests

### Run all tests
- Format: `npx playwright test`

### Run single directory
- Format: `npx playwright test <directory-one>`
- Example: `npx playwright test tests/integration/`

### Run multiple directory
-  Format: `npx playwright test <directory-one> <directory-two>`
- Example: `npx playwright test tests/integration/ tests/e2e/`



### More info on running tests: https://playwright.dev/docs/running-tests

---
## Structure explanation

### ./tests/integration
- To add any integration tests

### ./tests/e2e
- To add end-to-end tests

---
## Approaches/Practices
- Page Object Model - https://playwright.dev/docs/pom
  - Description: We use this approach to add create an abstraction layer for our tests to ensure code can be reused and edited at a single place.
- Util library - https://github.com/propertyguru/pgds-qa-automation-utils
  - Description: Any utilities should be put into this library to ensure reusability and consistency of code updates across each QA automation repo.
- Naming convention
  - Files (classes)
    - Format: PascalCase
    - Example: `Header.js`
  - Classes (code)
    - Format: PascalCase
    - Example: `Header`
  - Methods/Functions
    - Format: camelCase
    - Example: `navigateToProfilePage`
  - Constants:
    - Format: All uppercase separated with underscores
    - Example: `DB_HOST`
  - Page Object locator
    - Format: Standard Prefix (see prefix list below) + locator name (camelCase)
    - Example: `btnLogin`

---

## Prefixes
#### Button - `btn`
#### Input - `input`
#### Dropdown - `dropdown`
#### Dropdown Menu Item - `dropdownMenuItem`

---
## Environment variable explanation
#### `LOGIN_EMAIL` - DS platform Login email
#### `LOGIN_PASSWORD` - DS platform Login password
#### `DSS_GRAPHQL_URL` -GraphQL url of DS platform
#### `DSS_WEBSITE_URL` - Base url of DS platform

#### `USE_CI_REPORTER` - `false` || `true` (setting to true will run the default reporter from the util library which sends data to DataDog)


---
## Useful references
- POM naming conventions practices
  - https://medium.com/ranorex-webtestit/5-tips-to-keep-your-page-objects-maintainable-3686bd539759
  - https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html

--- 
## Engineers to reach out to
- Yauri Maulana
- Joshua Rajandiran
- Sai Telukuntla