Skip to content

Commit

Permalink
fix(ui/checks): checks render once they've been created
Browse files Browse the repository at this point in the history
  • Loading branch information
asalem1 committed Oct 23, 2019
1 parent 0bd6852 commit 947df21
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
33 changes: 33 additions & 0 deletions ui/cypress/e2e/checks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,37 @@ describe('Checks', () => {
})
})
})

describe('Check should be viewable once created', () => {
beforeEach(() => {
// creates a check before each iteration
// TODO: refactor into a request
cy.getByTestID('create-check').click()
cy.getByTestID('create-threshold-check').click()
cy.getByTestID(`selector-list ${measurement}`).click()
cy.getByTestID('save-cell--button').should('be.disabled')
cy.getByTestID(`selector-list ${field}`).click()
cy.getByTestID('save-cell--button').should('be.disabled')
cy.getByTestID('checkeo--header alerting-tab').click()
cy.getByTestID('add-threshold-condition-WARN').click()
cy.getByTestID('save-cell--button').click()
cy.getByTestID('check-card').should('have.length', 1)
})

it('should allow created checks to be selected and routed to the edit page', () => {
cy.getByTestID('check-card--name').should('have.length', 1)
cy.getByTestID('check-card--name').click()
cy.get('@org').then(({id}: Organization) => {
cy.fixture('routes').then(({orgs, alerting, checks}) => {
cy.url()
.then(url => {
Cypress.minimatch(
url,
`${Cypress.config().baseUrl}${orgs}/${id}${alerting}${checks}/*/edit`
)
})
})
})
})
})
})
6 changes: 5 additions & 1 deletion ui/src/alerting/actions/checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ export const saveCheckFromTimeMachine = () => async (
...check,
query: draftQueries[0],
orgID,
labels: check.labels.map(l => l.id),
labels: (check
&& check.labels
&& Array.isArray(check.labels)
&& check.labels.map(l => l.id)
) || [],
} as PostCheck

const resp = check.id
Expand Down

0 comments on commit 947df21

Please sign in to comment.