diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 9fe6b87..c913313 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -7,7 +7,9 @@ // Features to add to the dev container. More info: https://containers.dev/features. "features": { - "ghcr.io/devcontainers-contrib/features/pre-commit:2": {} + "ghcr.io/devcontainers-contrib/features/pre-commit:2": {}, + "ghcr.io/devcontainers/features/docker-in-docker": {}, + "ghcr.io/devcontainers-contrib/features/act:1": {} }, // Use 'forwardPorts' to make a list of ports inside the container available locally. @@ -16,10 +18,11 @@ 4000, // Live reload server 35729 - ] + ], // Uncomment the next line to run commands after the container is created. - // "postCreateCommand": "jekyll --version" + // git config --global --add safe.directory /workspaces/blackpythondevs.github.io + "postCreateCommand": "python3 -m pip install black pytest-playwright && python3 -m playwright install --with-deps" // Configure tool-specific properties. // "customizations": {}, diff --git a/.gitattributes b/.gitattributes index e81c44d..8de86f8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,16 +1,18 @@ * text=auto -* .md text -* .html text -* .css text -* .js text -* .yml text -* .xml text +* .md text eol=lf +* .html text eol=lf +* .css text eol=lf +* .js text eol=lf +* .yml text eol=lf +* .xml text eol=lf -* .bat eol=crlf +* .bat text eol=crlf -* .sh eol=lf +* .sh text eol=lf * .png binary * .jpg binary * .gif binary + +_site/* -text -diff -merge diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 8e25401..22f10f6 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -1,9 +1,12 @@ name: Playwright Tests +# https://devblogs.microsoft.com/python/announcing-playwright-for-python-reliable-end-to-end-testing-for-the-web/ +# https://github.com/marketplace/actions/run-playwright-tests on: push: branches: - gh-pages + workflow_dispatch: jobs: test: @@ -17,10 +20,13 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install playwright pytest pytest-playwright + pip install -r requirements-dev.txt python -m playwright install --with-deps - - name: Sleep for 30 seconds - run: sleep 45s - shell: bash - - name: Run tests - run: python -m pytest + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + - name: Jekyll detached and pytest + run: | + bundle exec jekyll serve --detach + python -m pytest diff --git a/.gitignore b/.gitignore index 29ebeb7..840c086 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ _site venv .venv .jekyll-metadata -*/__pycache__ +**/__pycache__ .pytest_cache +bin/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 14bfd45..70a6f43 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,3 +27,7 @@ repos: hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] + - repo: https://github.com/psf/black + rev: 23.9.1 + hooks: + - id: black diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..be94e6f --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +3.2.2 diff --git a/_articles/es/community.md b/_articles/es/community.md new file mode 100644 index 0000000..1477491 --- /dev/null +++ b/_articles/es/community.md @@ -0,0 +1,9 @@ +--- +layout: index +lang: es +title: Comunidad +--- + +# Comunidad + +Esta es la página de ejemplo Comunidad diff --git a/_articles/es/conferences.md b/_articles/es/conferences.md new file mode 100644 index 0000000..d318782 --- /dev/null +++ b/_articles/es/conferences.md @@ -0,0 +1,9 @@ +--- +layout: index +lang: es +title: Conferencias +--- + +# Conferencias + +Esta es la página de ejemplo Conferencias diff --git a/_articles/es/events.md b/_articles/es/events.md new file mode 100644 index 0000000..57b460f --- /dev/null +++ b/_articles/es/events.md @@ -0,0 +1,9 @@ +--- +layout: index +lang: es +title: Eventos +--- + +# Eventos + +Esta es la página de ejemplo Eventos diff --git a/_config.yml b/_config.yml index f115e5f..3e3ca22 100644 --- a/_config.yml +++ b/_config.yml @@ -63,6 +63,8 @@ exclude: - vendor - venv - .venv + - requirements*.txt + - pytest.ini # timezone: America/Toronto permalink: "/:path/" diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..7f1d01e --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +python_files = *.py +addopts = -v diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..f2c92ba --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,3 @@ +black +pre-commit +pytest-playwright diff --git a/tests/test.py b/tests/test.py index f34455f..c970c23 100644 --- a/tests/test.py +++ b/tests/test.py @@ -1,9 +1,7 @@ - import pytest from playwright.sync_api import Page, expect - -live_server_url = "https://blackpythondevs.github.io" +live_server_url = "http://127.0.0.1:4000" routes = [ ("about.html"), @@ -12,18 +10,9 @@ ("events.html"), ] -@pytest.mark.parametrize("url", routes) -def test_destination_options( - page: Page, - url: str, -): - """Test that the destinations page loads with seeded data""" - # Create a destination - page.goto(f"{live_server_url}/{url}") - page.on("response", lambda response: expect(response.status).to_equal(200)) @pytest.mark.parametrize("url", routes) -def test_destination_( +def test_destination( page: Page, url: str, ) -> None: @@ -32,17 +21,23 @@ def test_destination_( page.goto(f"{live_server_url}/{url}") page.on("response", lambda response: expect(response.status).to_equal(200)) + @pytest.mark.parametrize( - "title, url",( - ("Acerca de", '/es/about/'), + "title, url", + ( + ("Acerca de", "/es/about/"), ("Inicio", "/es/"), ("Eventos", "/es/events/"), ("Comunidad", "/es/community/"), ("Conferencias", "/es/conferences/"), - ) + ), ) -def test_headers_in_language(page: Page, title:str, url:str) -> None: - page.goto("https://blackpythondevs.github.io/") +def test_headers_in_language(page: Page, title: str, url: str) -> None: + page.goto(live_server_url) + lang = page.evaluate("document.documentElement.lang") + assert lang == "en" page.get_by_label("Language").select_option("es") page.get_by_role("link", name=title).click() - expect(page).to_have_url(f"https://blackpythondevs.github.io{url}") + expect(page).to_have_url(f"{live_server_url}{url}") + lang = page.evaluate("document.documentElement.lang") + assert lang == "es"