Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

2.8 KB
Raw Blame
import { expect, test } from '@playwright/test'

test.use({
  extraHTTPHeaders: {
    Authorization: `Basic ${Buffer.from('viewer:viewer').toString('base64')}`,
  },
})

test.beforeEach(async ({ page }) => {
  const settingsLoaded = page.waitForResponse((response) =>
    response.url().endsWith('/api/ui_settings/')
  )
  await page.goto('/dashboard')
  expect((await settingsLoaded).status()).toBe(200)
})

test('should not allow user to edit settings', async ({ page }) => {
  await expect(page.getByRole('link', { name: 'Settings' })).not.toBeAttached()
  await page.goto('/settings')
  await expect(page.locator('body')).toHaveText(
    /You don't have permissions to do that/i
  )
})

test('should not allow user to view documents', async ({ page }) => {
  await expect(
    page.locator('nav').getByRole('link', { name: 'Documents' })
  ).not.toBeAttached()
  await page.goto('/documents')
  await expect(page.locator('body')).toHaveText(
    /You don't have permissions to do that/i
  )
  await page.goto('/documents/1')
  await expect(page.locator('body')).toHaveText(
    /You don't have permissions to do that/i
  )
})

test('should not allow user to view correspondents', async ({ page }) => {
  await expect(
    page.getByRole('link', { name: 'Attributes' })
  ).not.toBeAttached()
  await page.goto('/attributes/correspondents')
  await expect(page.locator('body')).toHaveText(
    /You don't have permissions to do that/i
  )
})

test('should not allow user to view tags', async ({ page }) => {
  await expect(
    page.getByRole('link', { name: 'Attributes' })
  ).not.toBeAttached()
  await page.goto('/attributes/tags')
  await expect(page.locator('body')).toHaveText(
    /You don't have permissions to do that/i
  )
})

test('should not allow user to view document types', async ({ page }) => {
  await expect(
    page.getByRole('link', { name: 'Attributes' })
  ).not.toBeAttached()
  await page.goto('/attributes/documenttypes')
  await expect(page.locator('body')).toHaveText(
    /You don't have permissions to do that/i
  )
})

test('should not allow user to view storage paths', async ({ page }) => {
  await expect(
    page.getByRole('link', { name: 'Attributes' })
  ).not.toBeAttached()
  await page.goto('/attributes/storagepaths')
  await expect(page.locator('body')).toHaveText(
    /You don't have permissions to do that/i
  )
})

test('should not allow user to view logs', async ({ page }) => {
  await expect(page.getByRole('link', { name: 'Logs' })).not.toBeAttached()
  await page.goto('/logs')
  await expect(page.locator('body')).toHaveText(
    /You don't have permissions to do that/i
  )
})

test('should not allow user to view tasks', async ({ page }) => {
  await expect(page.getByRole('link', { name: 'Tasks' })).not.toBeAttached()
  await page.goto('/tasks')
  await expect(page.locator('body')).toHaveText(
    /You don't have permissions to do that/i
  )
})