Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoalee committed Sep 23, 2024
1 parent 706ac08 commit fc22816
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,26 +95,26 @@ describe('ExtractionTable', () => {
cy.get('tbody > tr').should('have.length', 1);
});

it('should filter the table by doi', () => {
cy.wait('@studysetFixture').then((studysetFixture) => {
const studyset = studysetFixture?.response?.body as StudysetReturn;
const studysetStudies = studyset.studies as StudyReturn[];
cy.get('input').eq(4).click();
cy.get(`input`)
.eq(4)
.type(studysetStudies[0].doi || '');
});
// it('should filter the table by doi', () => {
// cy.wait('@studysetFixture').then((studysetFixture) => {
// const studyset = studysetFixture?.response?.body as StudysetReturn;
// const studysetStudies = studyset.studies as StudyReturn[];
// cy.get('input').eq(4).click();
// cy.get(`input`)
// .eq(4)
// .type(studysetStudies[0].doi || '');
// });

cy.get('tbody > tr').should('have.length', 1);
});
// cy.get('tbody > tr').should('have.length', 1);
// });

it('should filter the table by pmid', () => {
cy.wait('@studysetFixture').then((studysetFixture) => {
const studyset = studysetFixture?.response?.body as StudysetReturn;
const studysetStudies = studyset.studies as StudyReturn[];
cy.get('input').eq(5).click();
cy.get('input').eq(4).click();
cy.get(`input`)
.eq(5)
.eq(4)
.type(studysetStudies[0].pmid || '');
});

Expand Down Expand Up @@ -181,7 +181,7 @@ describe('ExtractionTable', () => {

it('should change the study status', () => {
// ARRANGE
cy.get('tbody > tr').eq(0).get('td').eq(6).as('getFirstRowStudyStatusCol');
cy.get('tbody > tr').eq(0).get('td').eq(5).as('getFirstRowStudyStatusCol');
cy.get('@getFirstRowStudyStatusCol').within(() => {
cy.get('button').eq(0).should('have.class', 'MuiButton-contained');
});
Expand Down Expand Up @@ -412,7 +412,7 @@ describe('ExtractionTable', () => {
// });

it('should sort by pmid desc', () => {
cy.get('[data-testid="ArrowDownwardIcon"]').eq(5).click();
cy.get('[data-testid="ArrowDownwardIcon"]').eq(4).click();

cy.wait('@studysetFixture').then((studysetFixture) => {
const studyset = studysetFixture.response?.body as StudysetReturn;
Expand Down Expand Up @@ -452,15 +452,15 @@ describe('ExtractionTable', () => {
cy.get('tbody > tr').each((tr, index) => {
cy.wrap(tr).within(() => {
cy.get('td')
.eq(5)
.eq(4)
.should('have.text', sortedStudies[index].pmid ?? '');
});
});
});
});

it('should sort by status desc', () => {
cy.get('[data-testid="ArrowDownwardIcon"]').eq(6).click();
cy.get('[data-testid="ArrowDownwardIcon"]').eq(5).click();

cy.wait('@projectFixture').then((projectFixture) => {
const project = projectFixture?.response?.body as INeurosynthProjectReturn;
Expand Down Expand Up @@ -516,8 +516,8 @@ describe('ExtractionTable', () => {
});

it('should sort by status asc', () => {
cy.get('[data-testid="ArrowDownwardIcon"]').eq(6).click();
cy.get('[data-testid="ArrowDownwardIcon"]').eq(6).click();
cy.get('[data-testid="ArrowDownwardIcon"]').eq(5).click();
cy.get('[data-testid="ArrowDownwardIcon"]').eq(5).click();
cy.get('[data-testid="ArrowUpwardIcon"]').should('exist');

cy.wait('@projectFixture').then((projectFixture) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,23 @@ const ExtractionTable: React.FC = () => {
/>
</Box>
<TableContainer sx={{ marginBottom: '2rem' }}>
<Table size="small">
<Table
size="small"
sx={{ tableLayout: 'fixed', width: 'fit-content', minWidth: '1200px' }}
>
<TableHead>
{table.getHeaderGroups().map((headerGroup) => (
<TableRow key={headerGroup.id}>
{headerGroup.headers.map((header) => (
<TableCell
key={header.id}
sx={{ maxWidth: `${header.column.getSize()}px` }}
sx={{
width:
header.column.id === 'name'
? '100%'
: `${header.column.getSize()}px`,
verticalAlign: 'bottom',
}}
>
<Box>
{flexRender(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,13 @@ export const ExtractionTableAuthorHeader: React.FC<
</Tooltip>
) : isSorted === 'asc' ? (
<IconButton size="small" onClick={() => table.resetSorting()}>
sx={{ width: '' }}
<ArrowUpwardIcon
sx={{ width: '0.9em', height: '0.9em', color: 'secondary.main' }}
/>
</IconButton>
) : (
<IconButton
size="small"
sx={{ width: '' }}
onClick={() => table.setSorting([{ id: 'authors', desc: false }])}
>
<ArrowDownward
Expand Down

0 comments on commit fc22816

Please sign in to comment.