diff --git a/ui/cypress/e2e/scrapers.test.ts b/ui/cypress/e2e/scrapers.test.ts index c90cdd31c4..2495be8cce 100644 --- a/ui/cypress/e2e/scrapers.test.ts +++ b/ui/cypress/e2e/scrapers.test.ts @@ -1,3 +1,5 @@ +import {Organization, Bucket} from '@influxdata/influx' + describe('Scrapers', () => { beforeEach(() => { cy.flush() @@ -5,7 +7,11 @@ describe('Scrapers', () => { cy.signin().then(({body}) => { const { org: {id}, + bucket, } = body + cy.wrap(body.org).as('org') + cy.wrap(bucket).as('bucket') + cy.fixture('routes').then(({orgs}) => { cy.visit(`${orgs}/${id}/scrapers_tab`) }) @@ -36,5 +42,25 @@ describe('Scrapers', () => { .should('have.length', 1) .and('contain', newScraper) }) + + it('can update scrapers name', () => { + const newScraperName = 'This is new name' + + const scraperName = 'New Scraper' + const url = 'http://google.com' + const type = 'Prometheus' + + cy.get('@org').then(({id}) => { + let orgID = id + cy.get('@bucket').then(({id}) => { + cy.createScraper(scraperName, url, type, orgID, id) + }) + }) + + cy.getByTestID('table-cell').within(() => { + cy.getByTestID('editable-name').click() + cy.getByTestID('input-field').type(`${newScraperName}{enter}`) + }) + }) }) }) diff --git a/ui/cypress/index.d.ts b/ui/cypress/index.d.ts index 627669bc1d..4d369ddb99 100644 --- a/ui/cypress/index.d.ts +++ b/ui/cypress/index.d.ts @@ -13,6 +13,7 @@ import { createVariable, createLabel, createBucket, + createScraper, } from './support/commands' declare global { @@ -31,6 +32,7 @@ declare global { getByTitle: typeof getByTitle createLabel: typeof createLabel createBucket: typeof createBucket + createScraper: typeof createScraper } } } diff --git a/ui/cypress/support/commands.ts b/ui/cypress/support/commands.ts index 9052fed3e2..49cc2b1684 100644 --- a/ui/cypress/support/commands.ts +++ b/ui/cypress/support/commands.ts @@ -148,6 +148,26 @@ export const createSource = ( }) } +export const createScraper = ( + scraperName?: string, + type?: string, + url?: string, + orgID?: string, + bucketID?: string +): Cypress.Chainable => { + return cy.request({ + method: 'POST', + url: '/api/v2/scrapers', + body: { + name: scraperName, + type, + url, + orgID, + bucketID, + }, + }) +} + // TODO: have to go through setup because we cannot create a user w/ a password via the user API export const setupUser = (): Cypress.Chainable => { return cy.fixture('user').then(({username, password, org, bucket}) => { @@ -199,6 +219,9 @@ Cypress.Commands.add('createOrg', createOrg) // buckets Cypress.Commands.add('createBucket', createBucket) +// scrapers +Cypress.Commands.add('createScraper', createScraper) + // general Cypress.Commands.add('flush', flush) diff --git a/ui/src/organizations/components/__snapshots__/Buckets.test.tsx.snap b/ui/src/organizations/components/__snapshots__/Buckets.test.tsx.snap index e5c4cea9c3..12eb733c13 100644 --- a/ui/src/organizations/components/__snapshots__/Buckets.test.tsx.snap +++ b/ui/src/organizations/components/__snapshots__/Buckets.test.tsx.snap @@ -58,6 +58,7 @@ Object {
{ public static defaultProps: DefaultProps = { hrefValue: '#', + testID: 'editable-name', } constructor(props: Props) { @@ -47,7 +49,7 @@ class EditableName extends Component { } public render() { - const {name, onEditName, hrefValue, noNameString} = this.props + const {name, onEditName, hrefValue, noNameString, testID} = this.props return (
@@ -57,6 +59,7 @@ class EditableName extends Component {