Skip to content

Commit

Permalink
JIRA-CHAL-17 #DONE Implement Selenium tests in Python for /home #17 (#23
Browse files Browse the repository at this point in the history
)

* commiting to fix the conflicts

* removed utils/supase files and configured .env file

* pushing the selinium tests with some issues

* today's progress, some flaky tests with h1,h2 tags they need to be accessed with section[1] from the list data structure.

* pushing some progress made today 1/2

* one test failing, concatenation issue, still need to refactor section into children class such that each method is unique to the child class

* all 25 tests are passing now, need to refactor them into class componenets into their repsective sections

* completed all 25 tests, need to refactor and define methods in a child class

* all 26 tests have passed, finished all the methods into child class in respect to the sections, next step would be utilizing proper naming convention for variables and unsure about comments yet

* removed myenv files and put it in gitignore

* added the myenv file in gitignore

* reverting back to functional componenents instead of class because of consistent reopening and closing of the browser

* readme updated with instructions to run selenium tests

* updated the readme.md file with some links to the relevant docs

* updated the readme, added some relevant links

* fixed a minor issue on gitignore

* updated the readme again, to make sure things are relevant

* added the test for the hamburger menu, did not verify all the contents because the UL tag basically checks if the content inside the UL is the parent of list

* removed the firebasedebug log file, created on my machine

* removed myenv files, updated readme with Linux venv activation instructions, updated style guide with python, updated homepage name, and removed unused imports and updated redundant variable names

* minor fixes on readme, and updated gitignore

* added python3 docs and updated python version documentation to make sure python3 is installed in the machine

* updated python3 on step no.7

* updated readme with the python notes on different OS
  • Loading branch information
Ris345 committed Aug 7, 2024
1 parent 70ed8e3 commit d210e9c
Show file tree
Hide file tree
Showing 6 changed files with 523 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ NEXT_PUBLIC_TURNSTILE_SITE_KEY=cloudflare_turnstile_site_key_goes_here
TURNSTILE_SECRET_KEY=cloudflare_turnstile_secret_key_goes_here
NEXT_PUBLIC_SUPABASE_URL=supabase_api_url_goes_here
NEXT_PUBLIC_SUPABASE_ANON_KEY=supabase_anon_key_goes_here
SUPABASE_SERVICE_ROLE_KEY=supabase_service_role_key_goes_here
SUPABASE_SERVICE_ROLE_KEY=supabase_service_role_key_goes_here
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
.pnp.js
.yarn/install-state.gz


# testing
/coverage

Expand Down Expand Up @@ -40,4 +41,13 @@ next-env.d.ts
# ide-specific folders
.vscode/
.idea/
*storybook.log
*storybook.log

# python
/venv
__pycache__
.pytest_cache




115 changes: 115 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,121 @@ Replace the values of the variables inside .env with appropriate entries. Values
Values for Supabase variables will be displayed in the terminal after running either `npm run supabase-dev:start` or `npm run supabase-test:start`. These values will be
the same for both commands, and will be the same each time you run these commands.

## Selenium Tests

### Prerequisites

- **Python**: Ensure Python is installed on your system.
[Documentation](https://www.python.org/).
- **Selenium**: Python package for browser automation.
[Documentation](https://selenium-python.readthedocs.io/installation.html#).
- **Pytest**: Python package for unit testing.
[Documentation](https://docs.pytest.org/en/stable/getting-started.html).
- **Drivers**: Included with Selenium version 4.6.0 and higher.
[Documentation](https://www.selenium.dev/documentation/selenium_manager/).


### Setup Instructions


### Python Version

While our project can run on different versions of Python, it is best practice to use Python 3 for better performance, security, and compatibility with modern libraries and frameworks.

### Installing Python 3

If you do not have Python 3 installed, you can download it from the [official Python website](https://www.python.org/downloads/).

```
python --version
```

### Note
The command to run Python might be `python3` on some systems (like Ubuntu and WSL), while in other environments it might just be `python`. Please adjust the commands accordingly based on your environment.

### Systems using Python 3
* Ubuntu (including WSL)
* CentOS/RHEL (recent versions)
* Fedora
* macOS (often default)

### Systems using Python (depends on configuration)
* Older Linux distributions (e.g., Ubuntu 12.04, CentOS 6)
* Conda Environments
* Docker Containers

### 1. Create Virtual Enviornment

`python3 -m venv venv`

### 2. Activate Virtual Enviornment

macOS
`source venv/bin/activate`

Windows
`venv\Scripts\activate`

Linux
`source venv/bin/activate`



### 3. Installing Selenium
Selenium does not need to be installed on a per-project basis. To see if you
already have it installed, you can run the following command:

```
pip show selenium
```

If installed, it will print information about the package. If the version is less
than 4.6.0, you should update it by running:

```
pip install -U selenium
```

Otherwise, you can install it by running the following command:

```
pip install selenium
```

For more information on installing Selenium, see [this](https://www.selenium.dev/documentation/webdriver/getting_started/install_library/).

For information on upgrading Selenium, see [this](https://www.selenium.dev/documentation/webdriver/troubleshooting/upgrade_to_selenium_4/).


### 4. Installing pytest

Be sure to install pytest:

```
pip install pytest
```

## 5. Before Running Selenium Tests

To ensure that Selenium tests run efficiently, it is recommended to first compile your project using `npm run build`. This step improves performance by compiling and optimizing the code, which can make the tests smoother.

I. **Build the Project:**
```
npm run build
```

II. **Start Development Server:**
```
npm run start
```

### 7. Run the tests

To run the Selenium tests, navigate into `src/__tests__/e2e` and run
`python3 -m pytest`.



## Contributing

New engineers should review [CONTRIBUTING.md](https://github.com/8by8-org/8by8-challenge/blob/development/CONTRIBUTING.md) for details about the recommended workflow and tools.
Expand Down
66 changes: 66 additions & 0 deletions STYLE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,69 @@ Semi-colons are required at the end of each statement. This requirement can be t
## Simplicity and Consistency

Prefer the simplest words possible (while maintaining precision and clarity) when naming your variables, functions, etc, and use those terms consistently. Follow the principle of least surprise: if two functions serve a similar purpose, or have similar parameters, try to structure their signatures in similar ways. By following this principle, we can create a codebase that is highly intuitive to work with.



# Python Style Guide

## Naming Conventions

### Variables
- Use `snake_case` for variable names.
```python
example_variable = 10
```

### Functions and Methods
- Use `snake_case` for function and method names.
```python
def example_function():
pass
```

## Documentation

### Docstrings
- Use docstrings to comment and document your code. Docstrings should be used for modules, classes, methods, and functions.
```python
def example_function(param1, param2):
"""
This is an example function.
Args:
param1 (int): The first parameter.
param2 (str): The second parameter.
Returns:
bool: The return value. True for success, False otherwise.
"""
return True
```

## Code Layout

### Indentation
- Use 4 spaces per indentation level.
```python
def example_function():
if True:
print("Hello, world!")
```


### Blank Lines
- Use blank lines to separate top-level functions and class definitions.
- Use blank lines sparingly inside functions to indicate logical sections.

```python
class ExampleClass:
def __init__(self, value):
self.value = value

def example_method(self):
if self.value:
return True

return False
```

Loading

0 comments on commit d210e9c

Please sign in to comment.