diff --git a/package.json b/package.json index a33cbc3fbfb..79504d4e6c5 100644 --- a/package.json +++ b/package.json @@ -81,12 +81,12 @@ "prettier --write" ], "*.robot": [ - "pipenv run robotidy --config tests/robot-tests/robotidy.toml" + "python3 -m pipenv run robotidy --config tests/robot-tests/robotidy.toml" ], "*.py": [ - "pipenv run flake8", - "pipenv run black", - "pipenv run isort" + "python3 -m pipenv run flake8", + "python3 -m pipenv run black", + "python3 -m pipenv run isort" ] } } diff --git a/src/explore-education-statistics-admin/src/pages/release/data/components/DataFilesTable.module.scss b/src/explore-education-statistics-admin/src/pages/release/data/components/DataFilesTable.module.scss new file mode 100644 index 00000000000..78e4ca7c7d5 --- /dev/null +++ b/src/explore-education-statistics-admin/src/pages/release/data/components/DataFilesTable.module.scss @@ -0,0 +1,22 @@ +@import '~govuk-frontend/dist/govuk/base'; + +.table { + td { + padding-bottom: govuk-spacing(2); + padding-top: govuk-spacing(2); + vertical-align: middle; + } + + .fileSize { + width: 5rem; + text-align: right; + } + + .fileStatus { + max-width: 164px; + } + + .actions { + margin-bottom: 0; + } +} diff --git a/src/explore-education-statistics-admin/src/pages/release/data/components/DataFilesTable.tsx b/src/explore-education-statistics-admin/src/pages/release/data/components/DataFilesTable.tsx new file mode 100644 index 00000000000..71e716066c1 --- /dev/null +++ b/src/explore-education-statistics-admin/src/pages/release/data/components/DataFilesTable.tsx @@ -0,0 +1,239 @@ +import Link from '@admin/components/Link'; +import DataFileDetailsTable from '@admin/pages/release/data/components/DataFileDetailsTable'; +import DataUploadCancelButton from '@admin/pages/release/data/components/DataUploadCancelButton'; +import ImporterStatus, { + terminalImportStatuses, +} from '@admin/pages/release/data/components/ImporterStatus'; +import { + releaseApiDataSetDetailsRoute, + releaseDataFileReplaceRoute, + ReleaseDataFileReplaceRouteParams, + releaseDataFileRoute, + ReleaseDataFileRouteParams, + ReleaseDataSetRouteParams, +} from '@admin/routes/releaseRoutes'; +import { + DataFile, + DataFileImportStatus, +} from '@admin/services/releaseDataFileService'; +import ButtonGroup from '@common/components/ButtonGroup'; +import ButtonText from '@common/components/ButtonText'; +import Modal from '@common/components/Modal'; +import ReorderableList from '@common/components/ReorderableList'; +import reorder from '@common/utils/reorder'; +import React, { useEffect, useState } from 'react'; +import { generatePath } from 'react-router'; +import styles from './DataFilesTable.module.scss'; + +interface Props { + dataFiles: DataFile[]; + publicationId: string; + releaseId: string; + canUpdateRelease?: boolean; + isReordering: boolean; + onCancelReordering: () => void; + onConfirmReordering: (nextSeries: DataFile[]) => void; + onDeleteFile: (dataFile: DataFile) => Promise; + onStatusChange: ( + dataFile: DataFile, + { totalRows, status }: DataFileImportStatus, + ) => Promise; +} + +const DataFilesTable = ({ + dataFiles: initialDataFiles, + publicationId, + releaseId, + canUpdateRelease, + isReordering, + onCancelReordering, + onConfirmReordering, + onDeleteFile, + onStatusChange, +}: Props) => { + const [dataFiles, setDataFiles] = useState(initialDataFiles); + + useEffect(() => { + setDataFiles(initialDataFiles); + }, [initialDataFiles]); + + if (isReordering) { + return ( + ({ + id, + label: title, + }))} + onCancel={() => { + setDataFiles(initialDataFiles); + onCancelReordering(); + }} + onConfirm={() => onConfirmReordering(dataFiles)} + onMoveItem={({ prevIndex, nextIndex }) => { + const reordered = reorder(dataFiles, prevIndex, nextIndex); + setDataFiles(reordered); + }} + onReverse={() => { + setDataFiles(dataFiles.toReversed()); + }} + /> + ); + } + + return ( + + + + + + + + + + + + {dataFiles.map(dataFile => ( + + + + + + + ))} + +
Subject titleSizeStatusActions
{dataFile.title} + {dataFile.fileSize.size.toLocaleString()} {dataFile.fileSize.unit} + + + + + View details} + > + + + {canUpdateRelease && + terminalImportStatuses.includes(dataFile.status) && ( + <> + {dataFile.status === 'COMPLETE' && ( + <> + ( + releaseDataFileRoute.path, + { + publicationId, + releaseId, + fileId: dataFile.id, + }, + )} + > + Edit title + + {dataFile.publicApiDataSetId ? ( + Replace data + } + > +

+ This data file has an API data set linked to it. + Please remove the API data set before replacing + the data. +

+

+ ( + releaseApiDataSetDetailsRoute.path, + { + publicationId, + releaseId, + dataSetId: dataFile.publicApiDataSetId, + }, + )} + > + Go to API data set + +

+
+ ) : ( + ( + releaseDataFileReplaceRoute.path, + { + publicationId, + releaseId, + fileId: dataFile.id, + }, + )} + > + Replace data + + )} + + )} + {dataFile.publicApiDataSetId ? ( + + Delete files + + } + > +

+ This data file has an API data set linked to it. + Please remove the API data set before deleting. +

+

+ ( + releaseApiDataSetDetailsRoute.path, + { + publicationId, + releaseId, + dataSetId: dataFile.publicApiDataSetId, + }, + )} + > + Go to API data set + +

+
+ ) : ( + onDeleteFile(dataFile)} + variant="warning" + > + Delete files + + )} + + )} + {dataFile.permissions.canCancelImport && ( + + )} +
+
+ ); +}; + +export default DataFilesTable; diff --git a/src/explore-education-statistics-admin/src/pages/release/data/components/ImporterStatus.tsx b/src/explore-education-statistics-admin/src/pages/release/data/components/ImporterStatus.tsx index bcc76be7166..3a1aa271f45 100644 --- a/src/explore-education-statistics-admin/src/pages/release/data/components/ImporterStatus.tsx +++ b/src/explore-education-statistics-admin/src/pages/release/data/components/ImporterStatus.tsx @@ -87,11 +87,13 @@ interface ImporterStatusProps { releaseId: string; dataFile: DataFile; onStatusChange?: ImporterStatusChangeHandler; + className?: string; } const ImporterStatus = ({ releaseId, dataFile, onStatusChange, + className, }: ImporterStatusProps) => { const [currentStatus, setCurrentStatus] = useState({ status: dataFile.status, @@ -130,7 +132,7 @@ const ImporterStatus = ({ ); return ( -
+
{ const [deleteDataFile, setDeleteDataFile] = useState(); - const [activeFileIds, setActiveFileIds] = useState(); const [dataFiles, setDataFiles] = useState([]); const [bulkUploadPlan, setBulkUploadPlan] = useState(); + const [isReordering, toggleReordering] = useToggle(false); const { data: initialDataFiles, @@ -89,22 +75,15 @@ const ReleaseDataUploadsSection = ({ const confirmBulkUploadPlan = useCallback( async (archiveDataSetFiles: ArchiveDataSetFile[]) => { - const newFiles = await releaseDataFileService.importBulkZipDataFile( + await releaseDataFileService.importBulkZipDataFile( releaseId, archiveDataSetFiles, ); setBulkUploadPlan(undefined); - setActiveFileIds([...dataFiles, ...newFiles].map(file => file.id)); refetchDataFiles(); }, - [ - releaseId, - setBulkUploadPlan, - setActiveFileIds, - dataFiles, - refetchDataFiles, - ], + [releaseId, setBulkUploadPlan, refetchDataFiles], ); const handleStatusChange = async ( @@ -124,8 +103,6 @@ const ReleaseDataUploadsSection = ({ dataFile.id, ); - setActiveFileIds([]); - setDataFiles(currentDataFiles => currentDataFiles.map(file => file.fileName !== dataFile.fileName @@ -140,6 +117,17 @@ const ReleaseDataUploadsSection = ({ ); }; + const handleDeleteFile = async (dataFile: DataFile) => { + releaseDataFileService + .getDeleteDataFilePlan(releaseId, dataFile) + .then(plan => { + setDeleteDataFile({ + plan, + file: dataFile, + }); + }); + }; + const handleSubmit = useCallback( async (values: DataFileUploadFormValues) => { const newFiles: DataFile[] = []; @@ -185,7 +173,6 @@ const ReleaseDataUploadsSection = ({ default: break; } - setActiveFileIds(newFiles.map(file => file.id)); }, [releaseId, refetchDataFiles], ); @@ -242,159 +229,34 @@ const ReleaseDataUploadsSection = ({ {dataFiles.length > 0 ? ( - { - setDataFiles( - await releaseDataFileService.updateDataFilesOrder( - releaseId, - fileIds, - ), - ); - }} - > - {dataFiles.map(dataFile => ( - -
- {dataFile.isDeleting && ( - - )} - - {canUpdateRelease && - terminalImportStatuses.includes(dataFile.status) && ( - <> - {dataFile.status === 'COMPLETE' && ( - <> - ( - releaseDataFileRoute.path, - { - publicationId, - releaseId, - fileId: dataFile.id, - }, - )} - > - Edit title - - {dataFile.publicApiDataSetId ? ( - Replace data - } - > -

- This data file has an API data set linked to - it. Please remove the API data set before - replacing the data. -

-

- ( - releaseApiDataSetDetailsRoute.path, - { - publicationId, - releaseId, - dataSetId: - dataFile.publicApiDataSetId, - }, - )} - > - Go to API data set - -

-
- ) : ( - ( - releaseDataFileReplaceRoute.path, - { - publicationId, - releaseId, - fileId: dataFile.id, - }, - )} - > - Replace data - - )} - - )} - {dataFile.publicApiDataSetId ? ( - - Delete files - - } - > -

- This data file has an API data set linked to it. - Please remove the API data set before deleting. -

-

- ( - releaseApiDataSetDetailsRoute.path, - { - publicationId, - releaseId, - dataSetId: dataFile.publicApiDataSetId, - }, - )} - > - Go to API data set - -

-
- ) : ( - - releaseDataFileService - .getDeleteDataFilePlan(releaseId, dataFile) - .then(plan => { - setDeleteDataFile({ - plan, - file: dataFile, - }); - }) - } - > - Delete files - - )} - - )} - {dataFile.permissions.canCancelImport && ( - - )} -
-
-
- ))} -
+ <> +

Uploaded data files

+ { + setDataFiles( + await releaseDataFileService.updateDataFilesOrder( + releaseId, + nextDataFiles.map(file => file.id), + ), + ); + toggleReordering.off(); + }} + onStatusChange={handleStatusChange} + onDeleteFile={handleDeleteFile} + publicationId={publicationId} + releaseId={releaseId} + /> + + {isReordering ? undefined : ( + + )} + ) : ( No data files have been uploaded. )} diff --git a/src/explore-education-statistics-admin/src/pages/release/data/components/__tests__/ReleaseDataUploadsSection.test.tsx b/src/explore-education-statistics-admin/src/pages/release/data/components/__tests__/ReleaseDataUploadsSection.test.tsx index fcf8607f330..74235870048 100644 --- a/src/explore-education-statistics-admin/src/pages/release/data/components/__tests__/ReleaseDataUploadsSection.test.tsx +++ b/src/explore-education-statistics-admin/src/pages/release/data/components/__tests__/ReleaseDataUploadsSection.test.tsx @@ -144,56 +144,27 @@ describe('ReleaseDataUploadsSection', () => { 'release-1', ); - expect(screen.getAllByTestId('accordionSection')).toHaveLength(2); + expect(screen.getAllByRole('row')).toHaveLength(3); }); - const sections = screen.getAllByTestId('accordionSection'); - const section1 = within(sections[0]); + const fileTableRows = screen.getAllByRole('row'); + const fileTableRow1 = within(fileTableRows[1]); - expect( - section1.getByRole('button', { name: /Test data 1/ }), - ).toBeInTheDocument(); - - expect(section1.getByTestId('Subject title')).toHaveTextContent( + expect(fileTableRow1.getByTestId('Subject title')).toHaveTextContent( 'Test data 1', ); - expect(section1.getByTestId('Data file')).toHaveTextContent('data-1.csv'); - expect(section1.getByTestId('Metadata file')).toHaveTextContent( - 'data-1.meta.csv', - ); - expect(section1.getByTestId('Data file size')).toHaveTextContent('50 Kb'); - expect(section1.getByTestId('Number of rows')).toHaveTextContent('100'); - expect(section1.getByTestId('Status')).toHaveTextContent('Complete'); - expect(section1.getByTestId('Uploaded by')).toHaveTextContent( - 'user1@test.com', + expect(fileTableRow1.getByTestId('Data file size')).toHaveTextContent( + '50 Kb', ); - expect(section1.getByTestId('Date uploaded')).toHaveTextContent( - '12 June 2020 12:00', - ); - - const section2 = within(sections[1]); + expect(fileTableRow1.getByTestId('Status')).toHaveTextContent('Complete'); - expect( - section2.getByRole('button', { name: /Test data 2/ }), - ).toBeInTheDocument(); + const fileTableRow2 = within(fileTableRows[2]); - expect(section2.getByTestId('Subject title')).toHaveTextContent( + expect(fileTableRow2.getByTestId('Subject title')).toHaveTextContent( 'Test data 2', ); - expect(section2.getByTestId('Data file')).toHaveTextContent('data-2.csv'); - expect(section2.getByTestId('Metadata file')).toHaveTextContent( - 'data-2.meta.csv', - ); - expect(section2.getByTestId('Data file size')).toHaveTextContent('100 Kb'); - expect(section2.getByTestId('Number of rows')).toHaveTextContent('200'); - expect(section2.getByTestId('Status')).toHaveTextContent('Complete'); - expect(section2.getByTestId('Uploaded by')).toHaveTextContent( - 'user2@test.com', - ); - expect(section2.getByTestId('Date uploaded')).toHaveTextContent( - '1 July 2020 12:00', - ); + expect(fileTableRow2.getByTestId('Status')).toHaveTextContent('Complete'); }); test("renders data file details with status of 'Replacement in progress' if being replaced", async () => { @@ -222,16 +193,16 @@ describe('ReleaseDataUploadsSection', () => { 'release-1', ); - expect(screen.getAllByTestId('accordionSection')).toHaveLength(1); + expect(screen.getAllByRole('row')).toHaveLength(2); }); - const section1 = getAccordionSection(0); + const fileTableRow1 = getTableRow(1); - expect( - section1.getByRole('button', { name: /Test data 1/ }), - ).toBeInTheDocument(); + expect(fileTableRow1.getByTestId('Subject title')).toHaveTextContent( + 'Test data 1', + ); - expect(section1.getByTestId('Status')).toHaveTextContent( + expect(fileTableRow1.getByTestId('Status')).toHaveTextContent( 'Data replacement in progress', ); }); @@ -281,21 +252,21 @@ describe('ReleaseDataUploadsSection', () => { ); await waitFor(() => { - expect(screen.getAllByTestId('accordionSection')).toHaveLength(2); + expect(screen.getAllByRole('row')).toHaveLength(3); }); - const sections = screen.getAllByTestId('accordionSection'); + const fileTableRows = screen.getAllByRole('row'); - const section1 = within(sections[0]); - expect(section1.getByTestId('Status')).toHaveTextContent('Queued'); + const fileTableRow1 = within(fileTableRows[1]); + expect(fileTableRow1.getByTestId('Status')).toHaveTextContent('Queued'); expect( - section1.queryByRole('button', { name: 'Delete files' }), + fileTableRow1.queryByRole('button', { name: 'Delete files' }), ).not.toBeInTheDocument(); - const section2 = within(sections[1]); - expect(section2.getByTestId('Status')).toHaveTextContent('Complete'); + const fileTableRow2 = within(fileTableRows[2]); + expect(fileTableRow2.getByTestId('Status')).toHaveTextContent('Complete'); expect( - section2.getByRole('button', { name: 'Delete files' }), + fileTableRow2.getByRole('button', { name: 'Delete files' }), ).toBeInTheDocument(); }); @@ -339,19 +310,19 @@ describe('ReleaseDataUploadsSection', () => { ); await waitFor(() => { - expect(screen.getAllByTestId('accordionSection')).toHaveLength(2); + expect(screen.getAllByRole('row')).toHaveLength(3); }); - const sections = screen.getAllByTestId('accordionSection'); + const fileTableRows = screen.getAllByRole('row'); expect( - within(sections[1]).getByRole('button', { + within(fileTableRows[2]).getByRole('button', { name: 'Delete files', }), ).toBeInTheDocument(); await user.click( - within(sections[1]).getByRole('button', { + within(fileTableRows[2]).getByRole('button', { name: 'Delete files', }), ); @@ -423,19 +394,19 @@ describe('ReleaseDataUploadsSection', () => { ); await waitFor(() => { - expect(screen.getAllByTestId('accordionSection')).toHaveLength(2); + expect(screen.getAllByRole('row')).toHaveLength(3); }); - const sections = screen.getAllByTestId('accordionSection'); + const fileTableRows = screen.getAllByRole('row'); expect( - within(sections[1]).getByRole('button', { + within(fileTableRows[2]).getByRole('button', { name: 'Delete files', }), ).toBeInTheDocument(); await user.click( - within(sections[1]).getByRole('button', { + within(fileTableRows[2]).getByRole('button', { name: 'Delete files', }), ); @@ -453,14 +424,12 @@ describe('ReleaseDataUploadsSection', () => { ); await waitFor(() => { - expect(screen.getAllByTestId('accordionSection')).toHaveLength(1); + expect(screen.getAllByRole('row')).toHaveLength(2); }); - expect( - within(screen.getByTestId('accordionSection')).getByRole('button', { - name: /Test data 1/, - }), - ).toBeInTheDocument(); + expect(getTableRow(1).getByTestId('Subject title')).toHaveTextContent( + 'Test data 1', + ); }); test('does not allow deleting files when linked to an API data set', async () => { @@ -482,13 +451,13 @@ describe('ReleaseDataUploadsSection', () => { ); await waitFor(() => { - expect(screen.getAllByTestId('accordionSection')).toHaveLength(1); + expect(screen.getAllByRole('row')).toHaveLength(2); }); - const sections = screen.getAllByTestId('accordionSection'); + const fileTableRows = screen.getAllByRole('row'); await user.click( - within(sections[0]).getByRole('button', { + within(fileTableRows[1]).getByRole('button', { name: 'Delete files', }), ); @@ -535,22 +504,21 @@ describe('ReleaseDataUploadsSection', () => { ); await waitFor(() => { - expect(screen.getAllByTestId('accordionSection')).toHaveLength(2); + expect(screen.getAllByRole('row')).toHaveLength(3); }); - const sections = screen.getAllByTestId('accordionSection'); - expect(sections).toHaveLength(2); + const fileTableRows = screen.getAllByRole('row'); - const section1 = within(sections[0]); - expect(section1.getByTestId('Status')).toHaveTextContent('Queued'); + const fileTableRow1 = within(fileTableRows[1]); + expect(fileTableRow1.getByTestId('Status')).toHaveTextContent('Queued'); expect( - section1.queryByRole('link', { name: 'Replace data' }), + fileTableRow1.queryByRole('link', { name: 'Replace data' }), ).not.toBeInTheDocument(); - const section2 = within(sections[1]); - expect(section2.getByTestId('Status')).toHaveTextContent('Complete'); + const fileTableRow2 = within(fileTableRows[2]); + expect(fileTableRow2.getByTestId('Status')).toHaveTextContent('Complete'); expect( - section2.getByRole('link', { name: 'Replace data' }), + fileTableRow2.getByRole('link', { name: 'Replace data' }), ).toBeInTheDocument(); }); @@ -574,14 +542,14 @@ describe('ReleaseDataUploadsSection', () => { ); await waitFor(() => { - expect(screen.getAllByTestId('accordionSection')).toHaveLength(2); + expect(screen.getAllByRole('row')).toHaveLength(3); }); - const sections = screen.getAllByTestId('accordionSection'); + const fileTableRows = screen.getAllByRole('row'); - const section2 = within(sections[1]); + const fileTableRow2 = within(fileTableRows[2]); expect( - section2.getByRole('link', { name: 'Replace data' }), + fileTableRow2.getByRole('link', { name: 'Replace data' }), ).toHaveAttribute( 'href', '/publication/publication-1/release/release-1/data/data-2/replace', @@ -607,13 +575,13 @@ describe('ReleaseDataUploadsSection', () => { ); await waitFor(() => { - expect(screen.getAllByTestId('accordionSection')).toHaveLength(1); + expect(screen.getAllByRole('row')).toHaveLength(2); }); - const sections = screen.getAllByTestId('accordionSection'); + const fileTableRows = screen.getAllByRole('row'); await user.click( - within(sections[0]).getByRole('button', { name: 'Replace data' }), + within(fileTableRows[1]).getByRole('button', { name: 'Replace data' }), ); await waitFor(() => { @@ -994,7 +962,8 @@ describe('ReleaseDataUploadsSection', () => { }); }); - test('updates the number of rows after uploading CSV file when status changes', async () => { + test('updates the file size after uploading CSV file when status changes', async () => { + // we don't display rows :/ releaseDataFileService.uploadDataFiles.mockResolvedValue( testUploadedDataFile, ); @@ -1061,8 +1030,8 @@ describe('ReleaseDataUploadsSection', () => { ); }); - const sections = screen.getAllByTestId('accordionSection'); - const section3 = within(sections[2]); + const fileTableRows = screen.getAllByRole('row'); + const fileTableRow3 = within(fileTableRows[3]); await waitFor(() => expect( @@ -1070,11 +1039,13 @@ describe('ReleaseDataUploadsSection', () => { ).toHaveBeenCalledWith('release-1', testUploadedDataFile2), ); await waitFor(() => { - expect(section3.getByTestId('Number of rows')).toHaveTextContent('100'); + expect(fileTableRow3.getByTestId('Data file size')).toHaveTextContent( + '150 Kb', + ); }); }); - test('updates the number of rows after uploading ZIP file when status changes', async () => { + test('updates the file size after uploading ZIP file when status changes', async () => { releaseDataFileService.uploadZipDataFile.mockResolvedValue({ ...testUploadedZipFile, }); @@ -1132,8 +1103,8 @@ describe('ReleaseDataUploadsSection', () => { ), ); - const sections = screen.getAllByTestId('accordionSection'); - const section3 = within(sections[2]); + const fileTableRows = screen.getAllByRole('row'); + const fileTableRow3 = within(fileTableRows[3]); await waitFor(() => expect( @@ -1141,7 +1112,9 @@ describe('ReleaseDataUploadsSection', () => { ).toHaveBeenCalledWith('release-1', testUploadedDataFile2), ); await waitFor(() => { - expect(section3.getByTestId('Number of rows')).toHaveTextContent('100'); + expect(fileTableRow3.getByTestId('Data file size')).toHaveTextContent( + '150 Kb', + ); }); }); @@ -1169,14 +1142,12 @@ describe('ReleaseDataUploadsSection', () => { , ); - await waitFor(() => - expect(screen.getAllByTestId('accordionSection')).toHaveLength(1), - ); + await waitFor(() => expect(screen.getAllByRole('row')).toHaveLength(2)); - const section = getAccordionSection(0); + const fileTableRow = getTableRow(1); expect( - section.getByRole('button', { name: 'Cancel' }), + fileTableRow.getByRole('button', { name: 'Cancel' }), ).toBeInTheDocument(); }); @@ -1203,14 +1174,12 @@ describe('ReleaseDataUploadsSection', () => { , ); - await waitFor(() => - expect(screen.getAllByTestId('accordionSection')).toHaveLength(1), - ); + await waitFor(() => expect(screen.getAllByRole('row')).toHaveLength(2)); - const section = getAccordionSection(0); + const fileTableRow = getTableRow(1); expect( - section.queryByRole('button', { name: 'Cancel' }), + fileTableRow.queryByRole('button', { name: 'Cancel' }), ).not.toBeInTheDocument(); }); }); @@ -1238,13 +1207,11 @@ describe('ReleaseDataUploadsSection', () => { , ); - await waitFor(() => - expect(screen.getAllByTestId('accordionSection')).toHaveLength(1), - ); + await waitFor(() => expect(screen.getAllByRole('row')).toHaveLength(2)); - const section = getAccordionSection(0); + const fileTableRow = getTableRow(1); - await user.click(section.getByRole('button', { name: 'Cancel' })); + await user.click(fileTableRow.getByRole('button', { name: 'Cancel' })); await waitFor(() => { expect( @@ -1286,13 +1253,11 @@ describe('ReleaseDataUploadsSection', () => { , ); - await waitFor(() => - expect(screen.getAllByTestId('accordionSection')).toHaveLength(1), - ); + await waitFor(() => expect(screen.getAllByRole('row')).toHaveLength(2)); - const section = getAccordionSection(0); + const fileTableRow = getTableRow(1); - await user.click(section.getByRole('button', { name: 'Cancel' })); + await user.click(fileTableRow.getByRole('button', { name: 'Cancel' })); await waitFor(() => { expect( @@ -1318,7 +1283,7 @@ describe('ReleaseDataUploadsSection', () => { expect(screen.queryByRole('dialog')).not.toBeInTheDocument(); expect( - section.queryByRole('button', { name: 'Cancel' }), + fileTableRow.queryByRole('button', { name: 'Cancel' }), ).not.toBeInTheDocument(); }); @@ -1337,13 +1302,11 @@ describe('ReleaseDataUploadsSection', () => { , ); - await waitFor(() => - expect(screen.getAllByTestId('accordionSection')).toHaveLength(1), - ); + await waitFor(() => expect(screen.getAllByRole('row')).toHaveLength(2)); - const section = getAccordionSection(0); + const fileTableRow = getTableRow(1); - await user.click(section.getByRole('button', { name: 'Cancel' })); + await user.click(fileTableRow.getByRole('button', { name: 'Cancel' })); await waitFor(() => { expect( @@ -1364,7 +1327,7 @@ describe('ReleaseDataUploadsSection', () => { expect(screen.queryByRole('dialog')).not.toBeInTheDocument(); expect( - section.getByRole('button', { name: 'Cancel' }), + fileTableRow.getByRole('button', { name: 'Cancel' }), ).toBeInTheDocument(); }); @@ -1385,13 +1348,11 @@ describe('ReleaseDataUploadsSection', () => { , ); - await waitFor(() => - expect(screen.getAllByTestId('accordionSection')).toHaveLength(1), - ); + await waitFor(() => expect(screen.getAllByRole('row')).toHaveLength(2)); - const section = getAccordionSection(0); + const fileTableRow = getTableRow(1); - await user.click(section.getByRole('button', { name: 'Cancel' })); + await user.click(fileTableRow.getByRole('button', { name: 'Cancel' })); await waitFor(() => { expect( @@ -1418,14 +1379,14 @@ describe('ReleaseDataUploadsSection', () => { expect(screen.queryByRole('dialog')).not.toBeInTheDocument(); expect( - section.queryByRole('button', { name: 'Cancel' }), + fileTableRow.queryByRole('button', { name: 'Cancel' }), ).not.toBeInTheDocument(); expect(screen.getByText('Cancellation failed')).toBeInTheDocument(); }); }); - function getAccordionSection(index: number) { - return within(screen.getAllByTestId('accordionSection')[index]); + function getTableRow(index: number) { + return within(screen.getAllByRole('row')[index]); } }); diff --git a/src/explore-education-statistics-common/src/components/Tag.module.scss b/src/explore-education-statistics-common/src/components/Tag.module.scss index ddbc3cca79d..ab6dda7af92 100644 --- a/src/explore-education-statistics-common/src/components/Tag.module.scss +++ b/src/explore-education-statistics-common/src/components/Tag.module.scss @@ -3,4 +3,5 @@ // https://github.com/alphagov/govuk-frontend/issues/4626 .tag { max-width: none; + text-wrap: balance; } diff --git a/tests/robot-tests/tests/admin/bau/delete_subject.robot b/tests/robot-tests/tests/admin/bau/delete_subject.robot index 88f32f7fb58..54299295800 100644 --- a/tests/robot-tests/tests/admin/bau/delete_subject.robot +++ b/tests/robot-tests/tests/admin/bau/delete_subject.robot @@ -154,8 +154,7 @@ Navigate back to 'Data and files' page Delete UI test subject user clicks link Data uploads user waits until h2 is visible Add data file to release %{WAIT_SMALL} - user waits until page contains accordion section UI test subject %{WAIT_SMALL} - user opens accordion section UI test subject + user waits until data upload is completed UI test subject user clicks button Delete files user waits until h2 is visible Confirm deletion of selected data files %{WAIT_SMALL} @@ -166,5 +165,5 @@ Delete UI test subject user checks page contains dfe-logo.jpg user clicks button Confirm - user waits until page does not contain accordion section UI test subject + user waits until page does not contain data uploads table user waits until h2 is visible Add data file to release %{WAIT_SMALL} diff --git a/tests/robot-tests/tests/admin/bau/release_status.robot b/tests/robot-tests/tests/admin/bau/release_status.robot index 2b34f8b88ef..4efa4117920 100644 --- a/tests/robot-tests/tests/admin/bau/release_status.robot +++ b/tests/robot-tests/tests/admin/bau/release_status.robot @@ -41,7 +41,7 @@ Validate checklist errors and warnings user checks checklist errors contains link ... Release must contain a key statistic or a non-empty headline text block - user checks page does not contain testid releaseChecklist-success + user waits until page does not contain testid releaseChecklist-success Add headline text block to Content page user navigates to content page ${PUBLICATION_NAME} @@ -58,8 +58,8 @@ Validate checklist errors and warnings after adding headline text block user checks checklist warnings contains link No data files uploaded user checks checklist warnings contains link A public pre-release access list has not been created - user checks page does not contain testid releaseChecklist-errors - user checks page does not contain testid releaseChecklist-success + user waits until page does not contain testid releaseChecklist-errors + user waits until page does not contain testid releaseChecklist-success Add empty Summary section text block to the page user navigates to content page ${PUBLICATION_NAME} @@ -131,8 +131,8 @@ Validate checklist errors and warnings after adding content to text blocks user checks checklist warnings contains link No data files uploaded user checks checklist warnings contains link A public pre-release access list has not been created - user checks page does not contain testid releaseChecklist-errors - user checks page does not contain testid releaseChecklist-success + user waits until page does not contain testid releaseChecklist-errors + user waits until page does not contain testid releaseChecklist-success Submit release for Higher Review user clicks radio Ready for higher review (this will notify approvers) @@ -155,8 +155,8 @@ Verify release checklist has not been updated by status user checks checklist warnings contains link No data files uploaded user checks checklist warnings contains link A public pre-release access list has not been created - user checks page does not contain testid releaseChecklist-errors - user checks page does not contain testid releaseChecklist-success + user waits until page does not contain testid releaseChecklist-errors + user waits until page does not contain testid releaseChecklist-success Add public prerelease access list via release checklist user clicks link A public pre-release access list has not been created @@ -170,8 +170,8 @@ Verify release checklist has been updated user checks checklist warnings contains link An in-EES methodology page has not been linked to this publication user checks checklist warnings contains link No data files uploaded - user checks page does not contain testid releaseChecklist-errors - user checks page does not contain testid releaseChecklist-success + user waits until page does not contain testid releaseChecklist-errors + user waits until page does not contain testid releaseChecklist-success Approve release user clicks radio Approved for publication @@ -284,7 +284,7 @@ Verify the checklist errors and warnings for amendment user checks checklist errors contains link ... A public release note for this amendment is required, add this near the top of the content page - user checks page does not contain testid releaseChecklist-success + user waits until page does not contain testid releaseChecklist-success Navigate to contents page and add a release note user clicks link Content @@ -307,12 +307,8 @@ Create third release Upload data files user uploads subject and waits until complete Dates test subject dates.csv dates.meta.csv user clicks link Data and files - user waits until h2 is visible Uploaded data files %{WAIT_MEDIUM} - user waits until page contains accordion section Dates test subject - user opens accordion section Dates test subject - - ${section} user gets accordion section content element Dates test subject - user clicks link Replace data ${section} + user waits until page contains data uploads table + user clicks link Replace data user waits until h2 is visible Data file details user checks headed table body row contains Status Complete wait=%{WAIT_LONG} @@ -341,16 +337,13 @@ Validate checklist errors user checks checklist errors contains link ... Release must contain a key statistic or a non-empty headline text block - user checks page does not contain testid releaseChecklist-success + user waits until page does not contain testid releaseChecklist-success Navigate to data upload and confirm data replacement user clicks link Data and files - user waits until h2 is visible Uploaded data files %{WAIT_MEDIUM} - user waits until page contains accordion section Dates test subject - user opens accordion section Dates test subject + user waits until page contains data uploads table - ${section} user gets accordion section content element Dates test subject - user clicks link Replace data ${section} + user clicks link Replace data user waits until page contains Footnotes: OK user waits until page contains Data blocks: OK user waits until button is enabled Confirm data replacement @@ -374,7 +367,7 @@ Validate checklist errors (3rd release) ... All summary information must be completed on the data guidance page user checks checklist errors contains link ... Release must contain a key statistic or a non-empty headline text block - user checks page does not contain testid releaseChecklist-success + user waits until page does not contain testid releaseChecklist-success Add data guidance to subject user clicks link Data and files diff --git a/tests/robot-tests/tests/admin/bau/upload_files.robot b/tests/robot-tests/tests/admin/bau/upload_files.robot index 0b152e0cdef..14c921fde1d 100644 --- a/tests/robot-tests/tests/admin/bau/upload_files.robot +++ b/tests/robot-tests/tests/admin/bau/upload_files.robot @@ -35,23 +35,19 @@ Upload a ZIP file subject user clicks button Upload data files user waits until h2 is visible Uploaded data files - user waits until page contains accordion section Absence in PRUs - user opens accordion section Absence in PRUs - - ${section}= user gets accordion section content element Absence in PRUs + user waits until page contains data uploads table # To ensure "Data file size" and "Number of rows" will be filled user waits until page does not contain Queued %{WAIT_MEDIUM} - - user checks headed table body row contains Subject title Absence in PRUs ${section} - user checks headed table body row contains Data file absence_in_prus.csv ${section} - user checks headed table body row contains Metadata file absence_in_prus.meta.csv ${section} - user checks headed table body row contains Data file size 141 Kb ${section} - user checks headed table body row contains Number of rows 612 ${section} - user checks headed table body row contains Status Complete ${section} %{WAIT_DATA_FILE_IMPORT} + user checks table cell contains row=1 column=1 expected=Absence in PRUs parent=testid:Data files table + user checks table cell contains row=1 column=2 expected=141 Kb parent=testid:Data files table + user checks table cell contains row=1 column=3 expected=Complete parent=testid:Data files table + user checks table cell contains row=1 column=4 expected=View details parent=testid:Data files table + user checks table cell contains row=1 column=4 expected=Edit title parent=testid:Data files table + user checks table cell contains row=1 column=4 expected=Replace data parent=testid:Data files table + user checks table cell contains row=1 column=4 expected=Delete files parent=testid:Data files table Change subject title - user waits until page contains accordion section Absence in PRUs user clicks link Edit title user waits until h2 is visible Edit data file details @@ -62,11 +58,9 @@ Change subject title Validate subject title has been updated user waits until h2 is visible Uploaded data files - user waits until page contains accordion section Updated Absence in PRUs - user opens accordion section Absence in PRUs - ${section}= user gets accordion section content element Absence in PRUs - user checks headed table body row contains Subject title Updated Absence in PRUs ${section} + user checks table cell contains row=1 column=1 expected=Updated Absence in PRUs + ... parent=testid:Data files table Check subject appears in 'Data blocks' page user clicks link Data blocks diff --git a/tests/robot-tests/tests/admin_and_public/bau/archive_publication.robot b/tests/robot-tests/tests/admin_and_public/bau/archive_publication.robot index 443c712cf36..4bb19ccbf06 100644 --- a/tests/robot-tests/tests/admin_and_public/bau/archive_publication.robot +++ b/tests/robot-tests/tests/admin_and_public/bau/archive_publication.robot @@ -31,7 +31,8 @@ Navigate to archive-publication release ... ${RELEASE_NAME_ARCHIVE} Import archive-publication subject to release - user uploads subject and waits until complete ${SUBJECT_NAME_ARCHIVE} upload-file-test.csv upload-file-test.meta.csv + user uploads subject and waits until complete ${SUBJECT_NAME_ARCHIVE} upload-file-test.csv + ... upload-file-test.meta.csv Add data guidance to archive-publication subject user clicks link Data guidance @@ -127,16 +128,16 @@ Generate permalink for archive-publication user waits until table tool wizard step is available 4 Choose time period user checks previous table tool step contains 3 Regional North East - user chooses select option id:timePeriodForm-start 2005 - user chooses select option id:timePeriodForm-end 2016 + user chooses select option id:timePeriodForm-start 2005 + user chooses select option id:timePeriodForm-end 2016 user clicks element id:timePeriodForm-submit user waits until table tool wizard step is available 5 Choose your filters user checks previous table tool step contains 4 Time period 2005 to 2016 user clicks element id:filtersForm-submit Sleep 5 - - user waits until page finishes loading + + user waits until page finishes loading user waits until results table appears %{WAIT_LONG} user waits until page contains button Generate shareable link @@ -157,14 +158,17 @@ Generate permalink for archive-publication Check that archive-publication subject appears correctly on Data catalogue page user navigates to data catalogue page on public frontend - user wait for option to be available and select it css:select[id="filters-form-theme"] %{TEST_THEME_NAME} - - user checks select contains option css:select[id="filters-form-publication"] ${PUBLICATION_NAME_ARCHIVE} - user checks select does not contain option css:select[id="filters-form-publication"] ${PUBLICATION_NAME_SUPERSEDE} + user wait for option to be available and select it css:select[id="filters-form-theme"] %{TEST_THEME_NAME} + + user checks select contains option css:select[id="filters-form-publication"] ${PUBLICATION_NAME_ARCHIVE} + user checks select does not contain option css:select[id="filters-form-publication"] + ... ${PUBLICATION_NAME_SUPERSEDE} - user wait for option to be available and select it css:select[id="filters-form-publication"] ${PUBLICATION_NAME_ARCHIVE} - sleep 1 # wait a moment to wait for release filter options to get updated - user wait for option to be available and select it css:select[id="filters-form-release"] ${RELEASE_NAME_ARCHIVE} + user wait for option to be available and select it css:select[id="filters-form-publication"] + ... ${PUBLICATION_NAME_ARCHIVE} + sleep 1 # wait a moment to wait for release filter options to get updated + user wait for option to be available and select it css:select[id="filters-form-release"] + ... ${RELEASE_NAME_ARCHIVE} user checks page contains button ${RELEASE_NAME_ARCHIVE} user checks element contains testid:release-info ${RELEASE_NAME_ARCHIVE} @@ -176,7 +180,8 @@ Navigate to superseding-publication release on Admin site ... ${RELEASE_NAME_SUPERSEDE} Import superseding-publication subject to release - user uploads subject and waits until complete ${SUBJECT_NAME_SUPERSEDE} upload-file-test.csv upload-file-test.meta.csv + user uploads subject and waits until complete ${SUBJECT_NAME_SUPERSEDE} upload-file-test.csv + ... upload-file-test.meta.csv Add data guidance to superseding-publication subject user clicks link Data guidance @@ -252,13 +257,14 @@ Check data catalogue page contains archive and superseding publication subjects user wait for option to be available and select it css:select[id="filters-form-theme"] %{TEST_THEME_NAME} - user checks select contains option css:select[id="filters-form-publication"] ${PUBLICATION_NAME_ARCHIVE} - user checks select contains option css:select[id="filters-form-publication"] ${PUBLICATION_NAME_SUPERSEDE} - - user wait for option to be available and select it css:select[id="filters-form-publication"] ${PUBLICATION_NAME_SUPERSEDE} - sleep 1 # wait a moment to wait for release filter options to get updated - user wait for option to be available and select it css:select[id="filters-form-release"] ${RELEASE_NAME_SUPERSEDE} + user checks select contains option css:select[id="filters-form-publication"] ${PUBLICATION_NAME_ARCHIVE} + user checks select contains option css:select[id="filters-form-publication"] ${PUBLICATION_NAME_SUPERSEDE} + user wait for option to be available and select it css:select[id="filters-form-publication"] + ... ${PUBLICATION_NAME_SUPERSEDE} + sleep 1 # wait a moment to wait for release filter options to get updated + user wait for option to be available and select it css:select[id="filters-form-release"] + ... ${RELEASE_NAME_SUPERSEDE} user checks page contains button ${RELEASE_NAME_SUPERSEDE} user checks element contains testid:release-info ${RELEASE_NAME_SUPERSEDE} @@ -267,9 +273,11 @@ Check data catalogue page contains archive and superseding publication subjects user checks element contains testid:release-info This is the latest data user waits until page contains ${SUBJECT_NAME_SUPERSEDE} - user wait for option to be available and select it css:select[id="filters-form-publication"] ${PUBLICATION_NAME_ARCHIVE} - sleep 1 # wait a moment to wait for release filter options to get updated - user wait for option to be available and select it css:select[id="filters-form-release"] ${RELEASE_NAME_ARCHIVE} + user wait for option to be available and select it css:select[id="filters-form-publication"] + ... ${PUBLICATION_NAME_ARCHIVE} + sleep 1 # wait a moment to wait for release filter options to get updated + user wait for option to be available and select it css:select[id="filters-form-release"] + ... ${RELEASE_NAME_ARCHIVE} user checks page contains button ${RELEASE_NAME_ARCHIVE} user checks element contains testid:release-info ${RELEASE_NAME_ARCHIVE} @@ -278,11 +286,10 @@ Check data catalogue page contains archive and superseding publication subjects user waits until page contains ${SUBJECT_NAME_ARCHIVE} Check data set page shows 'Not the latest data' for archived publication subject - user clicks link ${SUBJECT_NAME_ARCHIVE} + user clicks link ${SUBJECT_NAME_ARCHIVE} user waits until page contains Data set from ${PUBLICATION_NAME_ARCHIVE} user checks page contains Not the latest data - Check archive-publication permalink has out-of-date warning [Documentation] Failing due to https://dfedigital.atlassian.net/browse/EES-4269 [Tags] Failing @@ -306,7 +313,7 @@ Set archive-publication to be no longer be superseded user clicks button Edit publication details user waits until page contains element id:publicationDetailsForm-supersede - user chooses select option id:publicationDetailsForm-supersededById None selected + user chooses select option id:publicationDetailsForm-supersededById None selected user clicks button Update publication details ${modal}= user waits until modal is visible Confirm publication changes @@ -375,7 +382,7 @@ Check data catalogue page is correct after archive-publication has been unarchiv user checks select contains option id:filters-form-publication ${PUBLICATION_NAME_ARCHIVE} user checks select contains option id:filters-form-publication ${PUBLICATION_NAME_SUPERSEDE} - user wait for option to be available and select it id:filters-form-publication ${PUBLICATION_NAME_ARCHIVE} + user wait for option to be available and select it id:filters-form-publication ${PUBLICATION_NAME_ARCHIVE} user wait for option to be available and select it id:filters-form-release ${RELEASE_NAME_ARCHIVE} user checks page contains button ${RELEASE_NAME_ARCHIVE} diff --git a/tests/robot-tests/tests/admin_and_public/bau/data_reordering.robot b/tests/robot-tests/tests/admin_and_public/bau/data_reordering.robot index 9fc9da93d75..5b8d6b0b1cc 100644 --- a/tests/robot-tests/tests/admin_and_public/bau/data_reordering.robot +++ b/tests/robot-tests/tests/admin_and_public/bau/data_reordering.robot @@ -223,9 +223,8 @@ Cancel reordering indicators Replace subject data user clicks link Data uploads - user waits until h2 is visible Uploaded data files - ${section} user gets accordion section content element ${SUBJECT_NAME} - user clicks link Replace data ${section} + user waits until page contains data uploads table + user clicks link Replace data user chooses file id:dataFileUploadForm-dataFile ${FILES_DIR}grouped-filters-and-indicators-replacement.csv user chooses file id:dataFileUploadForm-metadataFile ... ${FILES_DIR}grouped-filters-and-indicators-replacement.meta.csv diff --git a/tests/robot-tests/tests/admin_and_public/bau/subject_reordering.robot b/tests/robot-tests/tests/admin_and_public/bau/subject_reordering.robot index db7d103156e..d01b01144c3 100644 --- a/tests/robot-tests/tests/admin_and_public/bau/subject_reordering.robot +++ b/tests/robot-tests/tests/admin_and_public/bau/subject_reordering.robot @@ -48,25 +48,27 @@ Upload subjects to release ... ordering-test-2.meta.csv Validate order of subjects after upload - user checks there are x accordion sections 4 id:uploadedDataFiles - user checks accordion is in position Four 1 id:uploadedDataFiles - user checks accordion is in position Three 2 id:uploadedDataFiles - user checks accordion is in position One 3 id:uploadedDataFiles - user checks accordion is in position Two 4 id:uploadedDataFiles + user waits until page contains data uploads table + user checks table body has x rows count=4 parent=testid:Data files table + + user checks table cell contains row=1 column=1 expected=Four parent=testid:Data files table + user checks table cell contains row=2 column=1 expected=Three parent=testid:Data files table + user checks table cell contains row=3 column=1 expected=One parent=testid:Data files table + user checks table cell contains row=4 column=1 expected=Two parent=testid:Data files table Validate order of subjects after refreshing Data and files page user reloads page - user waits until page contains element id:uploadedDataFiles + user waits until page contains data uploads table + user checks table body has x rows count=4 parent=testid:Data files table - user checks there are x accordion sections 4 id:uploadedDataFiles - user checks accordion is in position Four 1 id:uploadedDataFiles - user checks accordion is in position Three 2 id:uploadedDataFiles - user checks accordion is in position One 3 id:uploadedDataFiles - user checks accordion is in position Two 4 id:uploadedDataFiles + user checks table cell contains row=1 column=1 expected=Four parent=testid:Data files table + user checks table cell contains row=2 column=1 expected=Three parent=testid:Data files table + user checks table cell contains row=3 column=1 expected=One parent=testid:Data files table + user checks table cell contains row=4 column=1 expected=Two parent=testid:Data files table Order subjects - user clicks button Reorder - user waits until page contains button Save order + user clicks button Reorder data files + user waits until page contains button Confirm order click element xpath://div[text()="Four"] CTRL user presses keys ${SPACE} @@ -82,27 +84,25 @@ Order subjects user presses keys ARROW_DOWN user presses keys ${SPACE} - user clicks button Save order + user clicks button Confirm order user waits until page contains button Reorder - user checks accordion is in position One 1 id:uploadedDataFiles - user checks accordion is in position Two 2 id:uploadedDataFiles - user checks accordion is in position Four 3 id:uploadedDataFiles - user checks accordion is in position Three 4 id:uploadedDataFiles + user checks table cell contains row=1 column=1 expected=One parent=testid:Data files table + user checks table cell contains row=2 column=1 expected=Two parent=testid:Data files table + user checks table cell contains row=3 column=1 expected=Four parent=testid:Data files table + user checks table cell contains row=4 column=1 expected=Three parent=testid:Data files table Validate new order is preserved after refresh user reloads page - user waits until page contains element id:uploadedDataFiles + user waits until page contains data uploads table - user checks accordion is in position One 1 id:uploadedDataFiles - user checks accordion is in position Two 2 id:uploadedDataFiles - user checks accordion is in position Four 3 id:uploadedDataFiles - user checks accordion is in position Three 4 id:uploadedDataFiles + user checks table cell contains row=1 column=1 expected=One parent=testid:Data files table + user checks table cell contains row=2 column=1 expected=Two parent=testid:Data files table + user checks table cell contains row=3 column=1 expected=Four parent=testid:Data files table + user checks table cell contains row=4 column=1 expected=Three parent=testid:Data files table Start replacing last subject in order - user opens accordion section Three - ${THREE_CONTENT} user gets accordion section content element Three id:uploadedDataFiles - user clicks link Replace data ${THREE_CONTENT} + user clicks link in table cell row=4 column=4 link_text=Replace data parent=testid:Data files table user chooses file id:dataFileUploadForm-dataFile ${FILES_DIR}ordering-test-3-replacement.csv user chooses file id:dataFileUploadForm-metadataFile ... ${FILES_DIR}ordering-test-3-replacement.meta.csv @@ -117,28 +117,26 @@ Start replacing last subject in order Reorder subject that is being replaced user clicks link Data and files - user waits until page contains element id:uploadedDataFiles + user waits until page contains data uploads table - user clicks button Reorder - user waits until page contains button Save order + user clicks button Reorder data files + user waits until page contains button Confirm order click element xpath://div[text()="Three"] CTRL user presses keys ${SPACE} user presses keys ARROW_UP user presses keys ${SPACE} - user clicks button Save order - user waits until page contains button Reorder + user clicks button Confirm order + user waits until page contains button Reorder data files - user checks accordion is in position One 1 id:uploadedDataFiles - user checks accordion is in position Two 2 id:uploadedDataFiles - user checks accordion is in position Three 3 id:uploadedDataFiles - user checks accordion is in position Four 4 id:uploadedDataFiles + user checks table cell contains row=1 column=1 expected=One parent=testid:Data files table + user checks table cell contains row=2 column=1 expected=Two parent=testid:Data files table + user checks table cell contains row=3 column=1 expected=Three parent=testid:Data files table + user checks table cell contains row=4 column=1 expected=Four parent=testid:Data files table Complete data replacement - user opens accordion section Three - ${THREE_CONTENT} user gets accordion section content element Three id:uploadedDataFiles - user clicks link Replace data ${THREE_CONTENT} + user clicks link in table cell row=3 column=4 link_text=Replace data parent=testid:Data files table user waits until page contains Data blocks: OK user waits until page contains Footnotes: OK @@ -147,12 +145,12 @@ Complete data replacement Validate subject order is correct after replacement user clicks link Data and files - user waits until page contains element id:uploadedDataFiles + user waits until page contains data uploads table - user checks accordion is in position One 1 id:uploadedDataFiles - user checks accordion is in position Two 2 id:uploadedDataFiles - user checks accordion is in position Three 3 id:uploadedDataFiles - user checks accordion is in position Four 4 id:uploadedDataFiles + user checks table cell contains row=1 column=1 expected=One parent=testid:Data files table + user checks table cell contains row=2 column=1 expected=Two parent=testid:Data files table + user checks table cell contains row=3 column=1 expected=Three parent=testid:Data files table + user checks table cell contains row=4 column=1 expected=Four parent=testid:Data files table Add data guidance for all subjects user clicks link Data guidance @@ -188,12 +186,12 @@ Publish release Check subjects can no longer be re-ordered after release has been published user clicks link Data and files - user waits until page contains element id:uploadedDataFiles + user waits until page contains data uploads table - user checks accordion is in position One 1 id:uploadedDataFiles - user checks accordion is in position Two 2 id:uploadedDataFiles - user checks accordion is in position Three 3 id:uploadedDataFiles - user checks accordion is in position Four 4 id:uploadedDataFiles + user checks table cell contains row=1 column=1 expected=One parent=testid:Data files table + user checks table cell contains row=2 column=1 expected=Two parent=testid:Data files table + user checks table cell contains row=3 column=1 expected=Three parent=testid:Data files table + user checks table cell contains row=4 column=1 expected=Four parent=testid:Data files table user checks element is not visible testid:reorder-files %{WAIT_SMALL} diff --git a/tests/robot-tests/tests/admin_and_public_2/bau/publish_amend_and_cancel.robot b/tests/robot-tests/tests/admin_and_public_2/bau/publish_amend_and_cancel.robot index f3bda5ff9ad..77b18e567cb 100644 --- a/tests/robot-tests/tests/admin_and_public_2/bau/publish_amend_and_cancel.robot +++ b/tests/robot-tests/tests/admin_and_public_2/bau/publish_amend_and_cancel.robot @@ -208,15 +208,8 @@ Change the Release type Navigate to data replacement page user clicks link Data and files - user waits until h2 is visible Uploaded data files %{WAIT_MEDIUM} - user waits until page contains accordion section Dates test subject - user opens accordion section Dates test subject - - ${section}= user gets accordion section content element Dates test subject - user clicks link Replace data ${section} - - user waits until h2 is visible Data file details - user checks headed table body row contains Status Complete wait=%{WAIT_LONG} + user waits until page contains data uploads table + user clicks link Replace data Upload replacement data user waits until h2 is visible Upload replacement data %{WAIT_MEDIUM} @@ -396,16 +389,11 @@ Revisit the Release after the cancellation to double check it remains unaffected Verify that the Data and Files are unchanged user clicks link Data and files - user waits until h2 is visible Uploaded data files %{WAIT_MEDIUM} - user waits until page contains accordion section Dates test subject - user opens accordion section Dates test subject - ${section}= user gets accordion section content element Dates test subject - user checks headed table body row contains Subject title Dates test subject - user checks headed table body row contains Data file dates.csv - user checks headed table body row contains Metadata file dates.meta.csv - user checks headed table body row contains Number of rows 118 wait=%{WAIT_SMALL} - user checks headed table body row contains Data file size 17 Kb wait=%{WAIT_SMALL} - user checks headed table body row contains Status Complete wait=%{WAIT_LONG} + user waits until page contains data uploads table + user checks table cell contains row=1 column=1 expected=Dates test subject + ... parent=testid:Data files table + user checks table cell contains row=1 column=2 expected=17 Kb parent=testid:Data files table + user checks table cell contains row=1 column=3 expected=Complete parent=testid:Data files table Verify that the ancillary file is unchanged user clicks link Data and files diff --git a/tests/robot-tests/tests/admin_and_public_2/bau/publish_release_and_amend.robot b/tests/robot-tests/tests/admin_and_public_2/bau/publish_release_and_amend.robot index 469366be842..2d26b1027be 100644 --- a/tests/robot-tests/tests/admin_and_public_2/bau/publish_release_and_amend.robot +++ b/tests/robot-tests/tests/admin_and_public_2/bau/publish_release_and_amend.robot @@ -489,12 +489,8 @@ Change the Release type Navigate to data replacement page user clicks link Data and files - user waits until h2 is visible Uploaded data files %{WAIT_MEDIUM} - user waits until page contains accordion section Dates test subject - user opens accordion section Dates test subject - - ${section}= user gets accordion section content element Dates test subject - user clicks link Replace data ${section} + user waits until page contains data uploads table + user clicks link Replace data user waits until h2 is visible Data file details user checks headed table body row contains Subject title Dates test subject diff --git a/tests/robot-tests/tests/admin_and_public_2/bau/publish_release_and_amend_2.robot b/tests/robot-tests/tests/admin_and_public_2/bau/publish_release_and_amend_2.robot index 37106388d74..d6d1a785a23 100644 --- a/tests/robot-tests/tests/admin_and_public_2/bau/publish_release_and_amend_2.robot +++ b/tests/robot-tests/tests/admin_and_public_2/bau/publish_release_and_amend_2.robot @@ -254,12 +254,8 @@ Create release amendment Replace subject data user clicks link Data and files user waits until page contains element id:dataFileUploadForm-subjectTitle - user waits until h2 is visible Uploaded data files - - user waits until page contains accordion section ${SUBJECT_NAME} - user opens accordion section ${SUBJECT_NAME} - ${section} user gets accordion section content element ${SUBJECT_NAME} - user clicks link Replace data ${section} + user waits until page contains data uploads table + user clicks link Replace data user chooses file id:dataFileUploadForm-dataFile ${FILES_DIR}dates.csv user chooses file id:dataFileUploadForm-metadataFile ${FILES_DIR}dates.meta.csv user clicks button Upload data files diff --git a/tests/robot-tests/tests/general_public/data_set_page_absence_in_prus.robot b/tests/robot-tests/tests/general_public/data_set_page_absence_in_prus.robot index 1766d414dc9..26c5e7b64de 100644 --- a/tests/robot-tests/tests/general_public/data_set_page_absence_in_prus.robot +++ b/tests/robot-tests/tests/general_public/data_set_page_absence_in_prus.robot @@ -22,7 +22,7 @@ Validate title Validate data set info user checks page contains Latest data user checks page contains ${PUPIL_ABSENCE_PUBLICATION_TITLE} - user checks page contains ${PUPIL_ABSENCE_RELEASE_NAME} + user checks page contains ${PUPIL_ABSENCE_RELEASE_NAME} Validate zip contains correct files [Documentation] EES-4147 @@ -30,19 +30,20 @@ Validate zip contains correct files sleep 8 # wait for file to download ${list}= create list data/absence_in_prus.csv data-guidance/data-guidance.txt - zip should contain directories and files seed-publication-pupil-absence-in-schools-in-england_2016-17.zip ${list} + zip should contain directories and files seed-publication-pupil-absence-in-schools-in-england_2016-17.zip + ... ${list} Validate data set details user checks summary list contains Theme ${PUPILS_AND_SCHOOLS_THEME_TITLE} user checks summary list contains Publication ${PUPIL_ABSENCE_PUBLICATION_TITLE} user checks summary list contains Release ${PUPIL_ABSENCE_RELEASE_NAME} - user checks summary list contains Release type Official statistics + user checks summary list contains Release type Official statistics user checks summary list contains Geographic levels Local authority, National, Regional user checks summary list contains Indicators Authorised absence rate user checks summary list contains Indicators Number of authorised absence sessions user checks summary list contains Indicators Number of authorised holiday sessions user checks summary list contains Indicators Show 24 more indicators - user checks summary list contains Time period 2013/14 to 2016/17 + user checks summary list contains Time period 2013/14 to 2016/17 Validate data set preview user checks table column heading contains 1 1 time_identifier testid:preview-table @@ -81,11 +82,11 @@ Validate data set variables Validate using this data user checks page contains button Download this data set (ZIP) user checks page contains link View or create your own tables - + Validate table tool link user clicks link View or create your own tables user waits until h1 is visible Create your own tables - user checks page contains Choose locations + user checks page contains Choose locations user checks previous table tool step contains 1 Publication ${PUPIL_ABSENCE_PUBLICATION_TITLE} user checks previous table tool step contains 2 Data set Absence in PRUs diff --git a/tests/robot-tests/tests/general_public/methodology_page_absence.robot b/tests/robot-tests/tests/general_public/methodology_page_absence.robot index 64fbd04cffa..cadc37b168d 100644 --- a/tests/robot-tests/tests/general_public/methodology_page_absence.robot +++ b/tests/robot-tests/tests/general_public/methodology_page_absence.robot @@ -26,7 +26,7 @@ Validate Published date user checks summary list contains Published 22 March 2018 Validate Last updated is not visible - user checks page does not contain testid Last updated + user waits until page does not contain testid Last updated Validate accordion sections order user checks accordion is in position 1. Overview of absence statistics 1 id:content diff --git a/tests/robot-tests/tests/general_public/prod_only/redirects.robot b/tests/robot-tests/tests/general_public/prod_only/redirects.robot index 2a702af2d45..a584c39b612 100644 --- a/tests/robot-tests/tests/general_public/prod_only/redirects.robot +++ b/tests/robot-tests/tests/general_public/prod_only/redirects.robot @@ -58,7 +58,7 @@ Verify that routes with search parameters retain them Verify that multiple rules work together user navigates to public frontend %{PUBLIC_URL}/data-catalogue/1000?foo=bar&baz=zod - user waits until page contains Data catalogue + user waits until page contains Data catalogue user checks url equals %{PUBLIC_URL}/data-catalogue?foo=bar&baz=zod user navigates to public frontend %{PUBLIC_URL}/data-catalogue/1000/?foo=bar diff --git a/tests/robot-tests/tests/general_public/prod_only/statistics_page.robot b/tests/robot-tests/tests/general_public/prod_only/statistics_page.robot index 9237010d028..c220d104639 100644 --- a/tests/robot-tests/tests/general_public/prod_only/statistics_page.robot +++ b/tests/robot-tests/tests/general_public/prod_only/statistics_page.robot @@ -33,7 +33,7 @@ Validate Related information section and links exist Validate themes filters exist user checks select contains option id:filters-form-theme All themes - user checks selected option label id:filters-form-theme All themes + user checks selected option label id:filters-form-theme All themes user checks select contains option id:filters-form-theme Children's social care user checks select contains option id:filters-form-theme COVID-19 user checks select contains option id:filters-form-theme Destination of pupils and students @@ -46,11 +46,9 @@ Validate themes filters exist user checks select contains option id:filters-form-theme Teachers and school workforce user checks select contains option id:filters-form-theme UK education and training statistics - - Validate release type filters exist user checks select contains option id:filters-form-release-type All release types - user checks selected option label id:filters-form-release-type All release types + user checks selected option label id:filters-form-release-type All release types user checks select contains option id:filters-form-release-type Accredited official statistics user checks select contains option id:filters-form-release-type Official statistics user checks select contains option id:filters-form-release-type Official statistics in development @@ -73,7 +71,7 @@ Filter by theme Remove theme filter user clicks button Pupils and schools user checks page does not contain button Pupils and schools - user checks selected option label id:filters-form-theme All themes + user checks selected option label id:filters-form-theme All themes Filter by release type user chooses select option id:filters-form-release-type Official statistics @@ -82,7 +80,7 @@ Filter by release type Remove release type filter user clicks button Official statistics user checks page does not contain button Official statistics - user checks selected option label id:filters-form-release-type All release types + user checks selected option label id:filters-form-release-type All release types Searching user clicks element id:searchForm-search @@ -92,7 +90,7 @@ Searching user clicks radio Relevance user waits until page finishes loading user checks page contains button pupil absence - user checks list item contains testid:publicationsList 1 Pupil absence in schools in England + user checks list item contains testid:publicationsList 1 Pupil absence in schools in England Removing search user clicks button pupil absence @@ -116,5 +114,5 @@ Reset all filters user checks page does not contain button Official statistics user checks page does not contain button Reset filters - user checks selected option label id:filters-form-theme All themes - user checks selected option label id:filters-form-release-type All release types + user checks selected option label id:filters-form-theme All themes + user checks selected option label id:filters-form-release-type All release types diff --git a/tests/robot-tests/tests/general_public/redirects.robot b/tests/robot-tests/tests/general_public/redirects.robot index f225e7510df..11bd90d3686 100644 --- a/tests/robot-tests/tests/general_public/redirects.robot +++ b/tests/robot-tests/tests/general_public/redirects.robot @@ -7,14 +7,15 @@ Test Setup fail test fast if required Force Tags GeneralPublic Local Dev Test Preprod + *** Variables *** -${PUBLIC_URL}= %{PUBLIC_URL} -${PUBLIC_URL_WITHOUT_AUTH} ${EMPTY} +${PUBLIC_URL}= %{PUBLIC_URL} +${PUBLIC_URL_WITHOUT_AUTH} ${EMPTY} #In local, public url contains authentication details. In order to make it work while running against dev- we need to get rid of it to compare public url against expected value. -*** Test Cases *** +*** Test Cases *** Parse and Store public url without auth details ${PUBLIC_URL_WITHOUT_AUTH}= remove auth from url %{PUBLIC_URL} set suite variable ${PUBLIC_URL_WITHOUT_AUTH} @@ -22,7 +23,7 @@ Parse and Store public url without auth details Verify that absolute paths with trailing slashes are redirected without them user navigates to public frontend %{PUBLIC_URL}/data-catalogue/ user waits until page contains Data catalogue - user checks url without auth equals ${PUBLIC_URL_WITHOUT_AUTH}/data-catalogue + user checks url without auth equals ${PUBLIC_URL_WITHOUT_AUTH}/data-catalogue user navigates to public frontend %{PUBLIC_URL}/glossary/?someRandomUrlParameter=123 user waits until page contains Glossary @@ -35,7 +36,7 @@ Verify that redirects do not affect browser history user navigates to public frontend %{PUBLIC_URL}/data-catalogue/ user waits until page contains Data catalogue - user checks url without auth equals ${PUBLIC_URL_WITHOUT_AUTH}/data-catalogue + user checks url without auth equals ${PUBLIC_URL_WITHOUT_AUTH}/data-catalogue user goes back user checks url equals about:blank diff --git a/tests/robot-tests/tests/general_public/statistics_page.robot b/tests/robot-tests/tests/general_public/statistics_page.robot index 0087eaaeace..930ebfd6b4e 100644 --- a/tests/robot-tests/tests/general_public/statistics_page.robot +++ b/tests/robot-tests/tests/general_public/statistics_page.robot @@ -35,13 +35,13 @@ Validate Related information section and links exist Validate themes filters exist user checks select contains option id:filters-form-theme All themes - user checks selected option label id:filters-form-theme All themes + user checks selected option label id:filters-form-theme All themes user checks select contains option id:filters-form-theme ${PUPILS_AND_SCHOOLS_THEME_TITLE} user checks select contains option id:filters-form-theme ${ROLE_PERMISSIONS_THEME_TITLE} Validate release type filters exist user checks select contains option id:filters-form-release-type All release types - user checks selected option label id:filters-form-release-type All release types + user checks selected option label id:filters-form-release-type All release types user checks select contains option id:filters-form-release-type Accredited official statistics user checks select contains option id:filters-form-release-type Official statistics user checks select contains option id:filters-form-release-type Official statistics in development @@ -64,7 +64,7 @@ Filter by theme Remove theme filter user clicks button ${PUPILS_AND_SCHOOLS_THEME_TITLE} user checks page does not contain button ${PUPILS_AND_SCHOOLS_THEME_TITLE} - user checks selected option label id:filters-form-theme All themes + user checks selected option label id:filters-form-theme All themes Filter by release type user chooses select option id:filters-form-release-type Official statistics @@ -73,13 +73,13 @@ Filter by release type Remove release type filter user clicks button Official statistics user checks page does not contain button Official statistics - user checks selected option label id:filters-form-release-type All release types + user checks selected option label id:filters-form-release-type All release types Searching # filter by theme first to make sure we get the seed publication on dev. user chooses select option id:filters-form-theme ${PUPILS_AND_SCHOOLS_THEME_TITLE} user checks page contains button ${PUPILS_AND_SCHOOLS_THEME_TITLE} - + user clicks element id:searchForm-search user presses keys pupil absence user clicks button Search @@ -108,5 +108,5 @@ Reset all filters user checks page does not contain button Official statistics user checks page does not contain button Reset filters - user checks selected option label id:filters-form-theme All themes - user checks selected option label id:filters-form-release-type All release types + user checks selected option label id:filters-form-theme All themes + user checks selected option label id:filters-form-release-type All release types diff --git a/tests/robot-tests/tests/libs/admin-common.robot b/tests/robot-tests/tests/libs/admin-common.robot index ff743643c7d..11d5deca2e4 100644 --- a/tests/robot-tests/tests/libs/admin-common.robot +++ b/tests/robot-tests/tests/libs/admin-common.robot @@ -486,11 +486,10 @@ user creates amendment for release user deletes subject file [Arguments] ${SUBJECT_NAME} - user waits until page contains accordion section ${SUBJECT_NAME} - user opens accordion section ${SUBJECT_NAME} - user scrolls to accordion section ${SUBJECT_NAME} - ${accordion}= user gets accordion section content element ${SUBJECT_NAME} - ${button}= user gets button element Delete files ${accordion} + user waits until page contains data uploads table + ${row}= user gets table row ${SUBJECT_NAME} testid:Data files table + user scrolls to element ${row} + ${button}= user gets button element Delete files ${row} user clicks element ${button} user clicks button Confirm @@ -575,25 +574,44 @@ user uploads subject user chooses file id:dataFileUploadForm-metadataFile ${FOLDER}${META_FILE} user clicks button Upload data files user waits until h2 is visible Uploaded data files %{WAIT_LONG} - user waits until page contains accordion section ${SUBJECT_NAME} %{WAIT_SMALL} - user scrolls to accordion section ${SUBJECT_NAME} - user opens accordion section ${SUBJECT_NAME} - ${section}= user gets accordion section content element ${SUBJECT_NAME} + user waits until page contains element testid:Data files table IF "${IMPORT_STATUS}" != "Importing" user waits until page finishes loading END - user checks headed table body row contains Status ${IMPORT_STATUS} ${section} %{WAIT_DATA_FILE_IMPORT} + user waits until page contains data uploads table + ${row}= user gets table row row_cell_text=${SUBJECT_NAME} parent=testid:Data files table + ... wait=%{WAIT_SMALL} + ${status_cell}= user gets testid element id=Status wait=%{WAIT_SMALL} parent=${row} + user scrolls to element ${status_cell} + user waits until element contains element=${status_cell} text=${IMPORT_STATUS} + ... wait=%{WAIT_DATA_FILE_IMPORT} user waits until data upload is completed [Arguments] ... ${SUBJECT_NAME} user clicks link Data and files user waits until h2 is visible Add data file to release - user opens accordion section ${SUBJECT_NAME} - ${section}= user gets accordion section content element ${SUBJECT_NAME} - user checks headed table body row contains Status Complete ${section} %{WAIT_DATA_FILE_IMPORT} + user waits until data file import is complete ${SUBJECT_NAME} + +user waits until data files table contains subject + [Arguments] + ... ${SUBJECT_NAME} + user gets table row ${SUBJECT_NAME} testid:Data files table %{WAIT_DATA_FILE_IMPORT} + +user waits until data file import is complete + [Arguments] + ... ${SUBJECT_NAME} + user waits until page contains data uploads table + ${row}= user gets table row ${SUBJECT_NAME} testid:Data files table %{WAIT_DATA_FILE_IMPORT} + user waits until element contains ${row} Complete + +user waits until page contains data uploads table + user waits until page contains testid Data files table %{WAIT_DATA_FILE_IMPORT} + +user waits until page does not contain data uploads table + user waits until page does not contain testid Data files table user puts release into draft [Arguments] diff --git a/tests/robot-tests/tests/libs/common.robot b/tests/robot-tests/tests/libs/common.robot index 742b5794980..df6d1b48822 100644 --- a/tests/robot-tests/tests/libs/common.robot +++ b/tests/robot-tests/tests/libs/common.robot @@ -353,9 +353,9 @@ user waits until page contains testid [Arguments] ${id} ${wait}=${timeout} user waits until page contains element css:[data-testid="${id}"] ${wait} -user checks page does not contain testid - [Arguments] ${id} - user checks page does not contain element css:[data-testid="${id}"] +user waits until page does not contain testid + [Arguments] ${id} ${wait}=${timeout} + user waits until page does not contain element css:[data-testid="${id}"] ${wait} user checks testid element contains [Arguments] ${id} ${text} diff --git a/tests/robot-tests/tests/libs/tables-common.robot b/tests/robot-tests/tests/libs/tables-common.robot index 825184f9bfa..0de36fc92fc 100644 --- a/tests/robot-tests/tests/libs/tables-common.robot +++ b/tests/robot-tests/tests/libs/tables-common.robot @@ -23,9 +23,10 @@ user checks table row heading contains user waits until element contains xpath://table/tbody/tr[${row}]/th[${column}] ${expected} user checks table cell contains - [Arguments] ${row} ${column} ${expected} ${parent}=css:table + [Arguments] ${row} ${column} ${expected} ${parent}=css:table ${wait}=%{WAIT_SMALL} user waits until parent contains element ${parent} ... xpath:.//tbody/tr[${row}]/td[${column}][contains(., "${expected}")] + ... timeout=${wait} user checks table cell does not contain [Arguments] ${row} ${column} ${expected} ${parent}=css:table @@ -58,7 +59,8 @@ user gets table row with heading [Return] ${elem} user gets table row - [Arguments] ${row_cell_text} ${parent}=css:table + [Arguments] ${row_cell_text} ${parent}=css:table ${wait}=%{WAIT_SMALL} + wait until page contains element ${parent} timeout=${wait} ${elem}= get child element ${parent} xpath:.//tbody/tr/td[text()="${row_cell_text}"]/.. [Return] ${elem}