Skip to content
Snippets Groups Projects
Commit cfa6e5a3 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Merge branch 'Jest_UploadPage' into 'v1.1.1'

GUI tests for uploadPage

See merge request !672
parents 84fe5b65 87c21aa7
Branches
No related tags found
1 merge request!672GUI tests for uploadPage
Pipeline #132510 passed
...@@ -24,10 +24,37 @@ import { ...@@ -24,10 +24,37 @@ import {
startAPI, startAPI,
closeAPI closeAPI
} from '../conftest.spec' } from '../conftest.spec'
import { within, waitFor } from '@testing-library/dom'
import UploadPage from './UploadPage' import UploadPage from './UploadPage'
import {fireEvent, waitFor, within, act} from '@testing-library/react'
import userEvent from '@testing-library/user-event' import userEvent from '@testing-library/user-event'
const testShownColumnsAction = async () => {
await screen.findByTitle('Change the shown columns.')
expect(screen.queryByText('Parser name')).not.toBeInTheDocument()
expect(screen.queryByText('Comment')).not.toBeInTheDocument()
expect(screen.queryByText('References')).not.toBeInTheDocument()
expect(screen.queryByText('Datasets')).not.toBeInTheDocument()
let uploadPageRows = screen.queryAllByTestId('datatable-row')
expect(uploadPageRows.length).toBe(1)
expect(within(uploadPageRows[0]).queryByText('Mocked')).not.toBeInTheDocument()
expect(within(uploadPageRows[0]).queryByText('doi')).not.toBeInTheDocument()
expect(within(uploadPageRows[0]).queryByText('no datasets')).not.toBeInTheDocument()
act(() => { fireEvent.click(screen.getByTitle('Change the shown columns.')) })
await waitFor(() => expect(screen.queryByText('Datasets')).toBeInTheDocument())
await waitFor(() => expect(screen.queryByText('Comment')).toBeInTheDocument())
await waitFor(() => expect(screen.queryByText('References')).toBeInTheDocument())
await waitFor(() => expect(screen.queryByText('Parser name')).toBeInTheDocument())
act(() => { fireEvent.click(screen.getByText('Comment')) })
act(() => { fireEvent.click(screen.getByText('References')) })
act(() => { fireEvent.click(screen.getByText('Datasets')) })
await waitFor(() => expect(within(uploadPageRows[0]).queryByText('Mocked')).toBeInTheDocument())
await waitFor(() => expect(within(uploadPageRows[0]).queryByText('doi')).toBeInTheDocument())
await waitFor(() => expect(within(uploadPageRows[0]).queryByText('no datasets')).toBeInTheDocument())
}
const testPublishedWritePermissions = async () => { const testPublishedWritePermissions = async () => {
// Wait to load the page, i.e. wait for some text to appear // Wait to load the page, i.e. wait for some text to appear
await screen.findByText('unnamed upload') await screen.findByText('unnamed upload')
...@@ -125,6 +152,7 @@ test.each([ ...@@ -125,6 +152,7 @@ test.each([
await startAPI(state, snapshot, username, password) await startAPI(state, snapshot, username, password)
render(<UploadPage uploadId={uploadId}/>) render(<UploadPage uploadId={uploadId}/>)
await testPublishedWritePermissions() await testPublishedWritePermissions()
await testShownColumnsAction()
closeAPI() closeAPI()
}) })
...@@ -169,6 +197,7 @@ test.each([ ...@@ -169,6 +197,7 @@ test.each([
await startAPI(state, snapshot, username, password) await startAPI(state, snapshot, username, password)
render(<UploadPage uploadId={uploadId}/>) render(<UploadPage uploadId={uploadId}/>)
await testReadOnlyPermissions() await testReadOnlyPermissions()
await testShownColumnsAction()
closeAPI() closeAPI()
}) })
...@@ -192,11 +221,12 @@ test.each([ ...@@ -192,11 +221,12 @@ test.each([
await startAPI(state, snapshot, username, password) await startAPI(state, snapshot, username, password)
render(<UploadPage uploadId={uploadId}/>) render(<UploadPage uploadId={uploadId}/>)
await testUnpublishedWritePermissions() await testUnpublishedWritePermissions()
await testShownColumnsAction()
closeAPI() closeAPI()
}) })
test('Render upload page: multiple entries', async () => { test('Render upload page: multiple entries', async () => {
await startAPI('tests.states.uploads.multiple_entries', 'tests/data/uploads/multiple_entries', 'test', 'password') await startAPI('tests.states.uploads.multiple_entries', 'tests/data/uploads/multiple_entries')
render(<UploadPage uploadId="dft_upload_1"/>) render(<UploadPage uploadId="dft_upload_1"/>)
// Wait to load the page, i.e. wait for some text to appear // Wait to load the page, i.e. wait for some text to appear
...@@ -307,8 +337,7 @@ test.each([ ...@@ -307,8 +337,7 @@ test.each([
'dft_upload', 'dft_upload',
'test', 'test',
'password' 'password'
], ], [
[
'Published with embargo and logged in as coauthor', 'Published with embargo and logged in as coauthor',
'tests.states.uploads.published_with_embargo', 'tests.states.uploads.published_with_embargo',
'tests/data/uploads/uploadpage-published-with-embargo-coauthor', 'tests/data/uploads/uploadpage-published-with-embargo-coauthor',
...@@ -320,26 +349,27 @@ test.each([ ...@@ -320,26 +349,27 @@ test.each([
await startAPI(state, snapshot, username, password) await startAPI(state, snapshot, username, password)
render(<UploadPage uploadId={uploadId}/>) render(<UploadPage uploadId={uploadId}/>)
await testEmbargoedPublishesWritePermissions() await testEmbargoedPublishesWritePermissions()
await testShownColumnsAction()
closeAPI() closeAPI()
}) })
test.each([ test.each([
[ [
'unpublished, logged in as neither reviewer nor coauthor or main author', 'unpublished, not authenticated',
'tests.states.uploads.unpublished', 'tests.states.uploads.unpublished',
'tests/data/uploads/uploadpage-unpublished-external', 'tests/data/uploads/uploadpage-unpublished-noauth',
'dft_upload', 'dft_upload',
'admin', '',
'password', '',
'You do not have access to the specified upload - not published yet.' 'You do not have access to the specified upload - not published yet.'
], ],
[ [
'unpublished, not authenticated', 'unpublished, logged in as neither reviewer nor coauthor or main author',
'tests.states.uploads.unpublished', 'tests.states.uploads.unpublished',
'tests/data/uploads/uploadpage-unpublished-noauth', 'tests/data/uploads/uploadpage-unpublished-external',
'dft_upload', 'dft_upload',
'', 'admin',
'', 'password',
'You do not have access to the specified upload - not published yet.' 'You do not have access to the specified upload - not published yet.'
], ],
[ [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment