Skip to content
Merged
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
2 changes: 2 additions & 0 deletions apache/000-default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Listen 8080
RewriteRule ^/mock-holdings-api/v1/item_access /htapps/babel/mock-holdings-api/web/v1/item_access.not_held [L]
RewriteCond %{QUERY_STRING} item_id=test.ic_not_current
RewriteRule ^/mock-holdings-api/v1/item_access /htapps/babel/mock-holdings-api/web/v1/item_access.not_current [L]
RewriteCond %{QUERY_STRING} item_id=test.op_brlm
RewriteRule ^/mock-holdings-api/v1/item_access /htapps/babel/mock-holdings-api/web/v1/item_access.brlm [L]

### IMGSRV PROXY
<Directory "/htapps/babel/imgsrv/cgi">
Expand Down
13 changes: 8 additions & 5 deletions bin/run_playwright_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ switch_auth() {

echo -e "${color_cyan}Configuring mocked holdings API${color_reset}"
for app in pt imgsrv ssd; do
echo "holdings_api_url = http://apache-test:8080/mock-holdings-api" >> $babel_home/$app/lib/Config/local.conf
echo "holdings_api_url = http://apache:8080/mock-holdings-api" >> $babel_home/$app/lib/Config/local.conf
done

echo -e "Resetting ht_sessions database table "
docker compose exec mysql-sdr mariadb -u mdp-lib -pmdp-lib -h localhost ht -e "DELETE FROM ht_sessions;"
echo -e "Resetting ht_sessions & pt_exclusivity_ng database tables"
docker compose exec mysql-sdr mariadb -u mdp-lib -pmdp-lib -h localhost ht -e "DELETE FROM ht_sessions; DELETE FROM pt_exclusivity_ng;"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to clear pt_exclusivity_ng to start with a blank slate for ETAS and section 108 testing. Ideally, could clear it before every test; not sure we have a good way to do that; should work as-is though.

echo -e "Reloading Apache configuration"
docker compose exec apache-test kill -USR1 1
docker compose exec apache kill -HUP 1
sleep 1;
}

run_or_exit() {
Expand All @@ -43,7 +44,7 @@ run_test() {
else
# Run tests for the given kind of authenticated user
switch_auth $usertype
run_or_exit docker compose run --rm playwright npx playwright test $usertype --trace on
run_or_exit docker compose run --rm playwright npx playwright test $usertype --trace on --config playwright_auth.config.js
fi

}
Expand All @@ -52,6 +53,8 @@ if [ "$testset" == "all" ]; then
run_test unauthed
run_test ssd_user
run_test resource_sharing_user
run_test emergency_access_affiliate
run_test library_ipaddr_user
else
run_test $testset
fi
30 changes: 30 additions & 0 deletions common/docker/catalog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Optional service (not required for core functionality testing)
# As we want to test these via playwright, they could move into core.yml

x-healthcheck-defaults: &healthcheck-defaults
Copy link
Contributor

@Ronster2018 Ronster2018 Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need for these variables on line 4 to 8 in this file since the health checks are present on lines 25 to 30. I would opt for removing these lines instead of 20-30 so that it's simpler to read and maintain.

interval: 5s
timeout: 10s
start_period: 10s
retries: 5

services:
vufind:
build: ../../catalog #TODO: Use the built unstable container
hostname: 'catalog-dev'
volumes:
- ${BABEL_HOME}/catalog:/app
- ${BABEL_HOME}/firebird-common:/htapps/babel/firebird-common
- ${BABEL_HOME}/catalog/conf/authspecs-sample.yaml:/app/conf/authspecs.yaml
environment:
- FIREBIRD_HOME=/htapps/babel/firebird-common
depends_on:
mysql-sdr:
condition: service_healthy
solr-sdr-catalog:
condition: service_healthy
healthcheck:
interval: 5s
timeout: 10s
start_period: 10s
retries: 5
test: "service php8.4-fpm status | grep running"
49 changes: 2 additions & 47 deletions common/docker/core.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Services required for minimum babel functionality & used by tests

x-healthcheck-defaults: &healthcheck-defaults
interval: 5s
timeout: 10s
Expand All @@ -19,31 +21,6 @@ services:
retries: 5
test: "curl -f --retry-connrefused http://localhost:9033"

solr-lss-dev:
# This is another core service
image: solr:6.6.6-alpine
ports:
- "8983:8983"
user: ${CURRENT_USER}
volumes:
- ${BABEL_HOME}/lss_solr_configs/solr6_standalone/lss-dev/core-x:/opt/solr/server/solr/core-x
- ${BABEL_HOME}/lss_solr_configs/solr6_standalone/lss-dev/core-y:/opt/solr/server/solr/core-y
- ${BABEL_HOME}/lss_solr_configs/solr6_standalone:/opt/lss_solr_configs
- ${BABEL_HOME}/lss_solr_configs/solr6_standalone/lib:/opt/solr/server/solr/lib
- ${BABEL_HOME}/logs/solr:/opt/solr/server/logs
healthcheck:
<<: *healthcheck-defaults
test: "ping -c 1 solr-lss-dev:8983"

solr-ptsearch:
# This is a core service
build: ../../ptsearch-solr #TODO: Build from image in ghcr.io
ports:
- "8984:8983"
healthcheck:
<<: *healthcheck-defaults
test: "curl -f --retry-connrefused http://solr-ptsearch:8983/solr/ptsearch/admin/ping"

mysql-sdr:
# This is a core service
image: ghcr.io/hathitrust/db-image:latest
Expand Down Expand Up @@ -96,28 +73,6 @@ services:
retries: 5
test: "cgi-fcgi -bind -connect 127.0.0.1:31028"

vufind:
# A core service
build: ../../catalog #TODO: Use the built unstable container
hostname: 'catalog-dev'
volumes:
- ${BABEL_HOME}/catalog:/app
- ${BABEL_HOME}/firebird-common:/htapps/babel/firebird-common
- ${BABEL_HOME}/catalog/conf/authspecs-sample.yaml:/app/conf/authspecs.yaml
environment:
- FIREBIRD_HOME=/htapps/babel/firebird-common
depends_on:
mysql-sdr:
condition: service_healthy
solr-sdr-catalog:
condition: service_healthy
healthcheck:
interval: 5s
timeout: 10s
start_period: 10s
retries: 5
test: "service php7.4-fpm status | grep running"

volumes:
mysql_sdr_data:
solr_sdr_catalog:
34 changes: 34 additions & 0 deletions common/docker/solr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Optional services (not required for core functionality testing)
# As we want to test these via playwright, they should move into core.yml

x-healthcheck-defaults: &healthcheck-defaults
interval: 5s
timeout: 10s
start_period: 10s
retries: 5

services:
solr-lss-dev:
# This is another core service
image: solr:6.6.6-alpine
ports:
- "8983:8983"
user: ${CURRENT_USER}
volumes:
- ${BABEL_HOME}/lss_solr_configs/solr6_standalone/lss-dev/core-x:/opt/solr/server/solr/core-x
- ${BABEL_HOME}/lss_solr_configs/solr6_standalone/lss-dev/core-y:/opt/solr/server/solr/core-y
- ${BABEL_HOME}/lss_solr_configs/solr6_standalone:/opt/lss_solr_configs
- ${BABEL_HOME}/lss_solr_configs/solr6_standalone/lib:/opt/solr/server/solr/lib
- ${BABEL_HOME}/logs/solr:/opt/solr/server/logs
healthcheck:
<<: *healthcheck-defaults
test: "ping -c 1 solr-lss-dev:8983"

solr-ptsearch:
# This is a core service
build: ../../ptsearch-solr #TODO: Build from image in ghcr.io
ports:
- "8984:8983"
healthcheck:
<<: *healthcheck-defaults
test: "curl -f --retry-connrefused http://solr-ptsearch:8983/solr/ptsearch/admin/ping"
44 changes: 24 additions & 20 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
file: common/docker/playwright.yml
service: playwright
depends_on:
apache-test:
apache:
condition: service_healthy
profiles:
- playwright_testing
Expand All @@ -23,7 +23,6 @@ services:
profiles:
- playwright_testing


firebird:
extends:
file: common/docker/node.yml
Expand All @@ -37,18 +36,6 @@ services:
profiles:
- frontend

apache-test:
extends:
file: common/docker/apache.yml
service: apache
depends_on:
mysql-sdr:
condition: service_healthy
solr-sdr-catalog:
condition: service_healthy
imgsrv:
condition: service_healthy

# Backend Services
apache:
extends:
Expand All @@ -57,20 +44,15 @@ services:
depends_on:
mysql-sdr:
condition: service_healthy
solr-lss-dev:
condition: service_healthy
solr-sdr-catalog:
condition: service_healthy
solr-ptsearch:
condition: service_healthy
imgsrv:
condition: service_healthy
vufind:
condition: service_healthy
ports:
- "8080:8080"
profiles:
- backend
- playwright_testing

perl-test:
extends:
Expand All @@ -92,6 +74,28 @@ services:
profiles:
- backend

# Optional dependencies; not included in current playwright testing
vufind:
extends:
file: common/docker/catalog.yml
service: vufind
profiles:
- backend

solr-lss-dev:
extends:
file: common/docker/solr.yml
service: solr-lss-dev
profiles:
- backend

solr-ptsearch:
extends:
file: common/docker/solr.yml
service: solr-ptsearch
profiles:
- backend

# Indexing
traject:
extends:
Expand Down
2 changes: 1 addition & 1 deletion mdp-lib/PIFiller/Common/Globals.pm
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ sub handle_ACCESS_HOLDINGS_PI
}
$s .= wrap_string_in_tag($held, 'Held');
}
elsif ($user_access_type eq 'in_library_user') {
elsif ($access_type eq 'in_library_user') {
my $brittle_held = 'NO';
if (Access::Holdings::id_is_held_and_BRLM($C, $id, $inst)) {
$brittle_held = 'YES';
Expand Down
1 change: 1 addition & 0 deletions mock-holdings-api/web/v1/item_access.brlm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"brlm_count":1,"copy_count":1,"currently_held_count":1,"deposited":0,"format":"spm","n_enum":"","ocns":[123456]}
2 changes: 1 addition & 1 deletion pt/web/firebird/playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let testUrl;
if (process.env.LOCAL == 'local') {
testUrl = 'http://localhost:8080';
} else {
testUrl = 'http://apache-test:8080';
testUrl = 'http://apache:8080';
}

/**
Expand Down
60 changes: 60 additions & 0 deletions pt/web/firebird/playwright_auth.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// @ts-check
import { defineConfig, devices } from '@playwright/test';

let testUrl;
if (process.env.LOCAL == 'local') {
testUrl = 'http://localhost:8080';
} else {
testUrl = 'http://apache:8080';
}

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// import dotenv from 'dotenv';
// import path from 'path';
// dotenv.config({ path: path.resolve(__dirname, '.env') });

/**
* @see https://playwright.dev/docs/test-configuration
*/
export default defineConfig({
testDir: './tests',
testMatch: /(.+\.)?(test|spec)\.[jt]s/,
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry authed tests -- there may be occasional race conditions with apache reloading its config */
retries: 2,
/* Don't run authed tests in parallel -- sessions may interfere with each other, esp. for ETAS / section 108 */
workers: 1,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
// reporter: process.env.CI ? '["list", "html"]' : 'list',
reporter: [['list'], ['html', { open: 'never' }]],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: testUrl,

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'retain-on-failure',
// trace: 'on',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run babel',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});
37 changes: 37 additions & 0 deletions pt/web/firebird/tests/auth_emergency_access_affiliate.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { expect, test } from '@playwright/test';
import fs from 'fs';

test.describe('emergency_access_affiliate access to ic material', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/cgi/pt?id=test.pd_open');
await page.getByRole('button', { name: 'Allow all cookies' }).click();
});

test('pageturner loads image for ic_currently_held after checkout', async ({ page }) => {
await page.goto('/cgi/pt?id=test.ic_currently_held');

await expect(page.getByRole('figure')).toHaveCount(0);
await page.getByRole('link', { name: 'Check Out' }).click();
await expect(page.getByRole('figure')).toBeVisible();
await page.getByRole('link', { name: 'Return Early' }).click();
await expect(page.getByRole('figure')).toHaveCount(0);
});

// resource sharing users cannot see lost/missing/withdrawn material
test('pageturner loads image for ic_not_current after checkout', async ({ page }) => {
await page.goto('/cgi/pt?id=test.ic_not_current');

await expect(page.getByRole('figure')).toHaveCount(0);
await page.getByRole('link', { name: 'Check Out' }).click();
await expect(page.getByRole('figure')).toBeVisible();
await page.getByRole('link', { name: 'Return Early' }).click();
await expect(page.getByRole('figure')).toHaveCount(0);
});

test('pageturner does not load image or show checkout for ic_not_held', async ({ page }) => {
await page.goto('/cgi/pt?id=test.ic_not_held');
await expect(page.getByText('not available online')).toHaveCount(1);
await expect(page.getByRole('link', { name: 'Check Out' })).toHaveCount(0);
await expect(page.getByRole('figure')).toHaveCount(0);
});
});
Loading