Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions .github/workflows/js-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Javascript tests

on:
pull_request:
push:
branches:
- '**'

jobs:
run_tests:
name: JS
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node-version: [20]
python-version: ['3.11', '3.12']

steps:
- uses: actions/checkout@v4
- name: Fetch main to compare coverage
run: git fetch --depth=1 origin main

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Setup npm
run: npm i -g npm@10.7.x

- name: Install Firefox 123.0
run: |
sudo apt-get purge firefox
wget "https://ftp.mozilla.org/pub/firefox/releases/123.0/linux-x86_64/en-US/firefox-123.0.tar.bz2"
tar -xjf firefox-123.0.tar.bz2
sudo mv firefox /opt/firefox
sudo ln -s /opt/firefox/firefox /usr/bin/firefox

- name: Install Required System Packages
run: sudo apt-get update && sudo apt-get install -y libxmlsec1-dev ubuntu-restricted-extras xvfb

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Get pip cache dir
id: pip-cache-dir
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT

- name: Cache pip dependencies
id: cache-dependencies
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache-dir.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('requirements/edx/base.txt') }}
restore-keys: ${{ runner.os }}-pip-

- name: Install Required Python Dependencies
run: |
pip install -r requirements/base.txt

- name: Install npm
working-directory: ./xblocks_contrib/video
run: npm ci

- name: Run JS Tests
working-directory: ./xblocks_contrib/video
run: |
npm run test

- name: Save Job Artifacts
uses: actions/upload-artifact@v4
with:
name: Build-Artifacts
path: |
reports/**/*
test_root/log/*.png
test_root/log/*.log
**/TEST-*.xml
overwrite: true
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ __pycache__
/lib
/lib64

# node
node_modules
npm-debug.log

# Installer logs
pip-log.txt

Expand Down
5 changes: 4 additions & 1 deletion requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ django-statici18n
edx-i18n-tools
XBlock
openedx-django-pyfs
# TODO: Run python reqs update
edx-django-utils>=5.14.1
edxval
nh3
oauthlib
edx-opaque-keys
edx-opaque-keys
Empty file.
26 changes: 26 additions & 0 deletions xblocks_contrib/utils/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
def display_name_with_default(block):
"""
Calculates the display name for a block.

Default to the display_name if it isn't None, else fall back to creating
a name based on the URL.

Unlike the rest of this module's functions, this function takes an entire
course block/overview as a parameter. This is because a few test cases
(specifically, {Text|Image|Video}AnnotationModuleTestCase.test_student_view)
create scenarios where course.display_name is not None but course.location
is None, which causes calling course.url_name to fail. So, although we'd
like to just pass course.display_name and course.url_name as arguments to
this function, we can't do so without breaking those tests.

Note: This method no longer escapes as it once did, so the caller must
ensure it is properly escaped where necessary.

Arguments:
block (XModuleMixin|CourseOverview|BlockStructureBlockData):
Block that is being accessed
"""
return (
block.display_name if block.display_name is not None
else block.scope_ids.usage_id.block_id.replace('_', ' ')
)
Loading
Loading