File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#! /bin/bash
22
3- npx playwright install --with-deps ${BROWSERS}
3+ set -e
4+
5+ # Install Playwright browsers
6+ # If _REMOTE_USER is set and not root, install as that user
7+ # Otherwise install as root (test scenarios)
8+ if [ -n " ${_REMOTE_USER} " ] && [ " ${_REMOTE_USER} " != " root" ] && id -u " ${_REMOTE_USER} " > /dev/null 2>&1 ; then
9+ su " ${_REMOTE_USER} " -c " npx playwright install --with-deps ${BROWSERS} "
10+ else
11+ npx playwright install --with-deps ${BROWSERS}
12+ fi
Original file line number Diff line number Diff line change 1414 "browsers" : " firefox chromium"
1515 }
1616 }
17+ },
18+ "test_user_install" : {
19+ "image" : " ubuntu:focal" ,
20+ "features" : {
21+ "playwright" : {
22+ "browsers" : " chromium"
23+ }
24+ }
1725 }
1826}
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ set -e
4+
5+ source dev-container-features-test-lib
6+
7+ # Test that Playwright is installed
8+ check " Playwright is available" npx playwright --version
9+
10+ # Check that browsers are installed in user's home directory (not root)
11+ CURRENT_USER=$( whoami)
12+ USER_HOME=$( eval echo ~ ${CURRENT_USER} )
13+
14+ # Verify browser cache exists in the user's home directory
15+ check " Browser cache in user home" test -d " ${USER_HOME} /.cache/ms-playwright"
16+
17+ # Verify the cache directory is owned by the current user
18+ check " Browser cache owned by user" bash -c " [ \"\$ (stat -c '%U' ${USER_HOME} /.cache/ms-playwright)\" = \" ${CURRENT_USER} \" ]"
19+
20+ # Verify browsers are not installed in root directory (if we're not root)
21+ if [ " ${CURRENT_USER} " != " root" ]; then
22+ check " Browser cache not in root" bash -c " ! test -d /root/.cache/ms-playwright || [ \"\$ (ls -A /root/.cache/ms-playwright 2>/dev/null | wc -l)\" = \" 0\" ]"
23+ fi
24+
25+ # Test that browsers can be listed (validates installation)
26+ check " Can list browsers" npx playwright install --list
27+
28+ # Verify the user can run playwright commands without permission issues
29+ check " User can run playwright" bash -c ' npx playwright --help | grep -q "Usage"'
30+
31+ reportResults
You can’t perform that action at this time.
0 commit comments