Skip to content

Commit

Permalink
Fixes tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSCorey committed Aug 28, 2024
1 parent 98357a7 commit c0d5f34
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 18 deletions.
24 changes: 15 additions & 9 deletions cypress/e2e/awx/projects/project-details.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ describe('Projects', () => {
cy.get('[data-ouia-component-id="simple-table"]')
.scrollIntoView()
.within(() => {
cy.getByDataCy('rules-column-header').should('be.visible').and('contain', 'Rules');
cy.getByDataCy('rules-column-cell').should('have.descendants', 'ul');
cy.getByDataCy('next-occurrence-timestamps-column-header')
.should('be.visible')
.and('contain', 'Next occurrence timestamps');
cy.getByDataCy('next-occurrence-timestamps-column-cell').should('have.descendants', 'ul');
cy.get('tbody tr').should('have.length', 1); //First, 1 rule is showing
});
cy.getByDataCy('edit-schedule').click();
Expand All @@ -142,8 +144,10 @@ describe('Projects', () => {
cy.get('[data-ouia-component-id="simple-table"]')
.scrollIntoView()
.within(() => {
cy.getByDataCy('rules-column-header').should('be.visible').and('contain', 'Rules');
cy.getByDataCy('rules-column-cell').should('have.descendants', 'ul');
cy.getByDataCy('next-occurrence-timestamps-column-header')
.should('be.visible')
.and('contain', 'Next occurrence timestamps');
cy.getByDataCy('next-occurrence-timestamps-column-cell').should('have.descendants', 'ul');
cy.get('tbody tr').should('have.length', 2); //Now, 2 rules are showing
});
cy.getByDataCy('edit-schedule').click();
Expand All @@ -164,8 +168,10 @@ describe('Projects', () => {
cy.get('[data-ouia-component-id="simple-table"]')
.scrollIntoView()
.within(() => {
cy.getByDataCy('rules-column-header').should('be.visible').and('contain', 'Rules');
cy.getByDataCy('rules-column-cell').should('have.descendants', 'ul');
cy.getByDataCy('next-occurrence-timestamps-column-header')
.should('be.visible')
.and('contain', 'Next occurrence timestamps');
cy.getByDataCy('next-occurrence-timestamps-column-cell').should('have.descendants', 'ul');
cy.get('tbody tr').should('have.length', 1); //1 Rule is showing again
});
});
Expand All @@ -190,9 +196,9 @@ describe('Projects', () => {
cy.clickButton(/^Next$/);
cy.wait('@preview');
cy.getByDataCy('local-time-zone').should('contain', 'UTC');
cy.get('[data-cy="exceptions-column-header"]')
cy.get('[data-cy="next-exclusion-timestamps-column-header"]')
.should('be.visible')
.and('contain', 'Exceptions');
.and('contain', 'Next exclusion timestamps');
cy.intercept('PATCH', awxAPI`/schedules/${schedule.id.toString()}/`).as('edited');
cy.getByDataCy('Submit').click();
cy.intercept('GET', awxAPI`/projects/${project.id.toString()}/`).as('projectList');
Expand All @@ -219,7 +225,7 @@ describe('Projects', () => {
cy.intercept('PATCH', awxAPI`/schedules/${schedule.id.toString()}/`).as('editedAgain');
cy.getByDataCy('Submit').click();
cy.wait('@editedAgain');
cy.get('[data-cy="exceptions-column-header"]').should('not.exist');
cy.get('[data-cy="next-exclusion-timestamps-column-header"]').should('not.exist');
});

it('can toggle a schedule', () => {
Expand Down
18 changes: 12 additions & 6 deletions cypress/e2e/awx/schedules/schedules.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,9 @@ describe('Schedules - Create and Delete', () => {
);
});
cy.get('[data-ouia-component-id="simple-table"]').within(() => {
cy.getByDataCy('rules-column-header').should('be.visible').and('contain', 'Rules');
cy.getByDataCy('next-occurrence-timestamps-column-header')
.should('be.visible')
.and('contain', 'Rules');
cy.getByDataCy('rules-column-cell').should('have.descendants', 'ul');
cy.get('tbody tr').should('have.length', 1);
});
Expand All @@ -439,7 +441,7 @@ describe('Schedules - Create and Delete', () => {
);
});
cy.get('[data-ouia-component-id="simple-table"]').within(() => {
cy.getByDataCy('exceptions-column-header')
cy.getByDataCy('next-exclusion-timestamps-column-header')
.should('be.visible')
.and('contain', 'Exceptions');
cy.getByDataCy('exceptions-column-cell').should('have.descendants', 'ul');
Expand Down Expand Up @@ -489,7 +491,9 @@ describe('Schedules - Create and Delete', () => {
.first()
.scrollIntoView()
.within(() => {
cy.getByDataCy('rules-column-header').should('be.visible').and('contain', 'Rules');
cy.getByDataCy('next-occurrence-timestamps-column-header')
.should('be.visible')
.and('contain', 'Rules');
cy.getByDataCy('rules-column-cell').should('have.descendants', 'ul');
cy.get('tbody tr').should('have.length', 1);
});
Expand All @@ -498,7 +502,7 @@ describe('Schedules - Create and Delete', () => {
.last()
.scrollIntoView()
.within(() => {
cy.getByDataCy('exceptions-column-header')
cy.getByDataCy('next-exclusion-timestamps-column-header')
.should('be.visible')
.and('contain', 'Exceptions');
cy.getByDataCy('exceptions-column-cell').should('have.descendants', 'ul');
Expand Down Expand Up @@ -677,7 +681,9 @@ describe('Schedules - Edit', () => {
`RRULE:FREQ=MINUTELY;INTERVAL=1;WKST=SU;UNTIL=${date.replaceAll('-', '')}T`
);
cy.get('[data-ouia-component-id="simple-table"]').within(() => {
cy.getByDataCy('rules-column-header').should('be.visible').and('contain', 'Rules');
cy.getByDataCy('next-occurrence-timestamps-column-header')
.should('be.visible')
.and('contain', 'Next occurrence timestamps');
cy.getByDataCy('rules-column-cell').should('have.descendants', 'ul');
cy.get('tbody tr').should('have.length', 3);
});
Expand Down Expand Up @@ -823,7 +829,7 @@ describe('Schedules - Edit', () => {
'RRULE:FREQ=MONTHLY'
);
cy.get('[data-ouia-component-id="simple-table"]').within(() => {
cy.get('[data-cy="exceptions-column-header"]').should('not.exist');
cy.get("[data-cy='next-exclusion-timestamps-column-header']").should('not.exist');
cy.get('tbody tr').should('have.length', 1);
});
cy.intercept('PATCH', awxAPI`/schedules/*`).as('editedSchedule');
Expand Down
14 changes: 12 additions & 2 deletions frontend/awx/views/schedules/SchedulePage/ScheduleDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,19 @@ export function ScheduleDetails(props: { isSystemJobTemplateSchedule?: boolean }
)}

<PageDetail fullWidth>
<RulesList ruleType="rules" rules={rules} isLocalForDetails={isLocal} />
<RulesList
ruleType="rules"
timezone={schedule.timezone}
rules={rules}
isLocalForDetails={isLocal}
/>
{exceptions.length ? (
<RulesList ruleType="exceptions" rules={exceptions} isLocalForDetails={isLocal} />
<RulesList
ruleType="exceptions"
timezone={schedule.timezone}
rules={exceptions}
isLocalForDetails={isLocal}
/>
) : null}
</PageDetail>
</PageDetails>
Expand Down
2 changes: 1 addition & 1 deletion frontend/awx/views/schedules/components/RuleForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function RuleForm(
const rrulestring = `DTSTART;TZID=${timezone}:${dateString}`;
const ruleStart = RRule.fromString(rrulestring);
const rule = new RRule({ ...ruleStart.options, ...rest });
if (endType === 'until') {
if (until !== null) {
const untilTime = until?.time;
const untilDate = until?.date;
if (untilDate && untilTime) {
Expand Down

0 comments on commit c0d5f34

Please sign in to comment.