diff --git a/tests/integration/test_api_gateway.py b/tests/integration/test_api_gateway.py deleted file mode 100644 index b96e803..0000000 --- a/tests/integration/test_api_gateway.py +++ /dev/null @@ -1,45 +0,0 @@ -import os - -import boto3 -import pytest -import requests - -""" -Make sure env variable AWS_SAM_STACK_NAME exists with the name of the stack we are going to test. -""" - - -class TestApiGateway: - - @pytest.fixture() - def api_gateway_url(self): - """ Get the API Gateway URL from Cloudformation Stack outputs """ - stack_name = os.environ.get("AWS_SAM_STACK_NAME") - - if stack_name is None: - raise ValueError('Please set the AWS_SAM_STACK_NAME environment variable to the name of your stack') - - client = boto3.client("cloudformation") - - try: - response = client.describe_stacks(StackName=stack_name) - except Exception as e: - raise Exception( - f"Cannot find stack {stack_name} \n" f'Please make sure a stack with the name "{stack_name}" exists' - ) from e - - stacks = response["Stacks"] - stack_outputs = stacks[0]["Outputs"] - api_outputs = [output for output in stack_outputs if output["OutputKey"] == "HelloWorldApi"] - - if not api_outputs: - raise KeyError(f"HelloWorldAPI not found in stack {stack_name}") - - return api_outputs[0]["OutputValue"] # Extract url from stack outputs - - def test_api_gateway(self, api_gateway_url): - """ Call the API Gateway endpoint and check the response """ - response = requests.get(api_gateway_url) - - assert response.status_code == 200 - assert response.json() == {"message": "hello world"} diff --git a/tests/playwright-tests/features/ui_tests.feature b/tests/playwright-tests/features/ui_tests.feature new file mode 100644 index 0000000..844975b --- /dev/null +++ b/tests/playwright-tests/features/ui_tests.feature @@ -0,0 +1,5 @@ +Feature: Load resume page + + Scenario: Check if the resume page loads + Given the resume page is loaded + Then the page title should be "Anthony Coughlin - QA Manager" diff --git a/tests/playwright-tests/pytest.ini b/tests/playwright-tests/pytest.ini new file mode 100644 index 0000000..4a804df --- /dev/null +++ b/tests/playwright-tests/pytest.ini @@ -0,0 +1,4 @@ +[pytest] +addopts = --maxfail=1 -v +markers = + ui_test: marks tests as ui tests diff --git a/tests/playwright-tests/steps/test_ui.py b/tests/playwright-tests/steps/test_ui.py new file mode 100644 index 0000000..b425097 --- /dev/null +++ b/tests/playwright-tests/steps/test_ui.py @@ -0,0 +1,28 @@ +import pytest +from pytest_bdd import scenarios, given, then +from playwright.sync_api import sync_playwright + +# Load the feature file +scenarios('../features/ui_tests.feature') + +@pytest.fixture(scope='module') +def browser(): + with sync_playwright() as p: + browser = p.chromium.launch(headless=True) + yield browser + browser.close() + +@pytest.fixture(scope='module') +def page(browser): + context = browser.new_context() + page = context.new_page() + yield page + context.close() + +@given("the resume page is loaded") +def load_resume_page(page): + page.goto("https://anthony-coughlin-resume.com/") + +@then('the page title should be "Anthony Coughlin - QA Manager"') +def check_page_title(page): + assert page.title() == "Anthony Coughlin - QA Manager"