Show read-only server reading hours in settings
This commit is contained in:
1 parent
de8e7ed988
commit
ddd9c62c40
9 files changed
+89
-7
No files matched your search
@@ -24,7 +24,22 @@ module.exports = async function testSettingsUI(url, cookie) {
|
||||
await page.goto(url + '/settings.html');
|
||||
await page.getByRole('heading', { name: 'Reading', exact: true, level: 1 }).waitFor();
|
||||
assert.equal(await page.locator('.settings-menu-group').count(), 2);
|
||||
assert.equal(requests.filter(p => p.startsWith('/api/admin')).length, 0, 'Personal settings fetched admin data');
|
||||
assert.equal(requests.filter(p => p.startsWith('/api/admin') && p !== '/api/admin/peering').length, 0,
|
||||
'Personal settings fetched admin data beyond the top navigation peer indicator');
|
||||
await clickSection('user/reading-hours', 'Reading hours');
|
||||
await page.getByRole('heading', { name: 'Server reading hours' }).waitFor();
|
||||
const schedule = await page.evaluate(() => fetch('/api/reading-schedule').then(r => r.json()));
|
||||
if (schedule.enabled) {
|
||||
await page.getByText(`Server timezone: ${schedule.timezone}`).waitFor();
|
||||
assert.equal(await page.locator('.reading-hours-day').count(), 7);
|
||||
} else await page.getByText('Reading is available at any time. No schedule is configured.').waitFor();
|
||||
assert.equal(await page.locator('[data-settings-section="user/reading-hours"] input').count(), 0);
|
||||
await page.screenshot({ path: path.join(shots, 'desktop-reading-hours.png'), fullPage: true });
|
||||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
await noOverflow();
|
||||
await page.screenshot({ path: path.join(shots, 'mobile-reading-hours.png'), fullPage: true });
|
||||
await page.setViewportSize({ width: 1280, height: 900 });
|
||||
await clickSection('user/reading', 'Reading');
|
||||
await page.getByLabel('Skip chapter cover pages', { exact: true }).check();
|
||||
await page.waitForFunction(async () => (await (await fetch('/api/me')).json()).settings.skipCovers === true);
|
||||
await page.screenshot({ path: path.join(shots, 'desktop-reading.png'), fullPage: true });
|
||||
@@ -96,6 +111,10 @@ module.exports = async function testSettingsUI(url, cookie) {
|
||||
await page.getByRole('heading', { name: 'Reading', exact: true, level: 1 }).waitFor();
|
||||
assert.equal(await page.locator('.settings-menu-group').count(), 1);
|
||||
assert.equal(await page.locator('.settings-menu a[href*="admin"]').count(), 0);
|
||||
await clickSection('user/reading-hours', 'Reading hours');
|
||||
await page.getByRole('heading', { name: 'Server reading hours' }).waitFor();
|
||||
assert.equal(await page.evaluate(() => fetch('/api/reading-schedule').then(r => r.status)), 200);
|
||||
await noOverflow();
|
||||
assert.equal(requests.slice(readerRequestStart).filter(p => p.startsWith('/api/admin')).length, 0, 'Ordinary reader fetched admin data');
|
||||
assert.equal(await page.evaluate(() => fetch('/api/admin').then(r => r.status)), 403);
|
||||
await noOverflow();
|
||||
|
||||
Reference in new issue
Block a user