Skip to content

Commit

Permalink
playwright fix and code clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
kaperoo committed Nov 1, 2023
1 parent fda5f36 commit c50a375
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
8 changes: 5 additions & 3 deletions cypress/integration/table/search.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ describe('Search', () => {
}).as('getSettings');

cy.visit('/', {
// For some reason this doesn't work with date pickers v6
// Commenting out for now
// need these to ensure Date picker media queries pass
// ref: https://mui.com/x/react-date-pickers/getting-started/#testing-caveats
// onBeforeLoad: (win) => {
Expand Down Expand Up @@ -1199,7 +1201,7 @@ describe('Search', () => {
);
});

// .clear doesn't work for some reason with datepickers in v6
// .clear doesn't work with datepickers in v6
// cy.findByLabelText('from, date-time input').clear();
cy.findByLabelText('from, date-time input').type('{ctrl+a}{backspace}');
cy.findByLabelText('from, date-time input').type('2022-01-11_00:00');
Expand All @@ -1213,7 +1215,7 @@ describe('Search', () => {

cy.clearMocks();

// .clear doesn't work for some reason with datepickers in v6
// .clear doesn't work with datepickers in v6
// cy.findByLabelText('from, date-time input').clear();
cy.findByLabelText('from, date-time input').type('{ctrl+a}{backspace}');
cy.findByLabelText('from, date-time input').type('2022-01-02_00:00');
Expand Down Expand Up @@ -1269,7 +1271,7 @@ describe('Search', () => {
expect(gte).equal('2022-01-02T00:00:00');
});

// .clear doesn't work for some reason with datepickers in v6
// .clear doesn't work with datepickers in v6
// cy.findByLabelText('from, date-time input').clear();
cy.findByLabelText('from, date-time input').type('{ctrl+a}{backspace}');
cy.findByLabelText('from, date-time input').type('2022-01-01_00:00');
Expand Down
19 changes: 13 additions & 6 deletions e2e/plotting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,19 @@ test('user can add from and to dates to timestamp on x-axis', async ({

await popup.locator('[aria-label="line chart"]').click();

await popup
.locator('[aria-label="from, date-time input"]')
.fill('2022-01-03 00:00:00');
await popup
.locator('[aria-label="to, date-time input"]')
.fill('2022-01-10 00:00:00');
// .fill doesn't work with date-pickers v6
// await popup
// .locator('[aria-label="from, date-time input"]')
// .fill('2022-01-03 00:00');
await popup.locator('[aria-label="to, date-time input"]').click();
await popup.keyboard.type('202201100000');

// .fill doesn't work with date-pickers v6
// await popup
// .locator('[aria-label="to, date-time input"]')
// .fill('2022-01-10 00:00');
await popup.locator('[aria-label="from, date-time input"]').click();
await popup.keyboard.type('202201030000');

await popup.locator('label:has-text("Search all channels")').fill('Shot Num');

Expand Down
4 changes: 2 additions & 2 deletions src/search/components/dateTime.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ const DateTimeSearch = (props: DateTimeSearchProps): React.ReactElement => {
format="yyyy-MM-dd HH:mm"
value={datePickerFromDate}
maxDateTime={datePickerToDate || new Date('2100-01-01 00:00:00')}
onChange={(date: Date | null) => {
onChange={(date) => {
setDatePickerFromDate(date);
resetTimeframe();
searchParamsUpdated();
Expand All @@ -299,7 +299,7 @@ const DateTimeSearch = (props: DateTimeSearchProps): React.ReactElement => {
});
}
}}
onAccept={(date: Date | null) => {
onAccept={(date) => {
setDatePickerFromDate(date);
resetTimeframe();
searchParamsUpdated();
Expand Down
6 changes: 3 additions & 3 deletions src/search/searchBar.component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('searchBar component', () => {
const dateFilterFromDate = screen.getByLabelText('from, date-time input');
const dateFilterToDate = screen.getByLabelText('to, date-time input');

// .clear doesn't work for some reason with datepickers in v6
// .clear doesn't work with datepickers in v6
await user.click(dateFilterFromDate);
await user.keyboard('{Control>}a{/Control}');
await user.keyboard('{Delete}');
Expand Down Expand Up @@ -358,7 +358,7 @@ describe('searchBar component', () => {

// only the From date is defined

// .clear doesn't work for some reason with datepickers in v6
// .clear doesn't work with datepickers in v6
await user.click(dateFilterFromDate);
await user.keyboard('{Control>}a{/Control}');
await user.keyboard('{Delete}');
Expand Down Expand Up @@ -569,7 +569,7 @@ describe('searchBar component', () => {
})
);

// .clear doesn't work for some reason with datepickers in v6
// .clear doesn't work with datepickers in v6
await user.click(dateFilterFromDate);
await user.keyboard('{Control>}a{/Control}');
await user.keyboard('{Delete}');
Expand Down

0 comments on commit c50a375

Please sign in to comment.