From 6462210a205f5b3bb97064200ff1e8bb6ae03c11 Mon Sep 17 00:00:00 2001 From: k3yi0 Date: Tue, 14 Jun 2022 10:43:29 +0200 Subject: [PATCH] test(cypress): add current org tests --- ui/cypress/fixtures/chronograf.json | 8 ++++ ui/cypress/integration/admin.test.ts | 66 +++++++++++++++++++++++++--- ui/cypress/support/commands.ts | 2 - ui/cypress/support/index.ts | 1 + 4 files changed, 69 insertions(+), 8 deletions(-) create mode 100644 ui/cypress/fixtures/chronograf.json diff --git a/ui/cypress/fixtures/chronograf.json b/ui/cypress/fixtures/chronograf.json new file mode 100644 index 000000000..ec6cc7f1c --- /dev/null +++ b/ui/cypress/fixtures/chronograf.json @@ -0,0 +1,8 @@ +{ + "user": { + "name": "Smiley", + "role": ["reader", "viewer"], + "oauthProvider": "oauth-mock", + "oauth-scheme": "oauth" + } +} \ No newline at end of file diff --git a/ui/cypress/integration/admin.test.ts b/ui/cypress/integration/admin.test.ts index 6680507d4..1780ce386 100644 --- a/ui/cypress/integration/admin.test.ts +++ b/ui/cypress/integration/admin.test.ts @@ -1,3 +1,5 @@ +import { createGzip } from "zlib" + describe('Use Admin tab', () => { let url: string let sourceId: string @@ -7,14 +9,66 @@ describe('Use Admin tab', () => { cy.createInfluxDBConnection() cy.get('@connections').then(sources => { sourceId = sources[0].id - cy.request('GET', `/chronograf/v1/sources/${sourceId}/users`).then( - ({body: responseBody}) => { - console.log(responseBody.users) - } - ) + url = `/sources/${sourceId}` }) }) + describe.only('Chronograf', () => { + let chronograf: any + + before(() => { + cy.fixture('chronograf').then(chronografData => { + chronograf = chronografData + }) + }) + + beforeEach(() => { + url += '/admin-chronograf' + }) + + describe('Current Org', () => { + beforeEach(() => { + cy.visit(url + '/current-organization') + }) + + it('create, edit, and delete a Chronograf user', () => { + cy.getByTestID('add-user--button').click() + cy.getByTestID('cancel-new-user--button').click() + cy.getByTestID('add-user--button').click() + cy.getByTestID('new-user--table-row').within(() => { + cy.getByTestID('confirm-new-user--button').should('be.disabled') + cy.getByTestID('username--input') + .type(chronograf.user.name) + .should('have.value', chronograf.user.name) + cy.getByTestID('confirm-new-user--button').should('be.disabled') + cy.getByTestID('dropdown-toggle').click() + cy.getByTestID(`${chronograf.user.role[0]}-dropdown-item`) + .click() + cy.get('.dropdown-selected').should( + 'contain.text', + chronograf.user.role[0] + ) + cy.getByTestID('oauth-provider--input') + .type(chronograf.user.oauthProvider) + .should('have.value', chronograf.user.oauthProvider) + cy.get('.dropdown-selected').should( + 'contain.text', + chronograf.user.role[0] + ) + cy.getByTestID('confirm-new-user--button') + .should('be.enabled') + .click() + }) + + // cy.getByTestID(`${chronograf.user.name}--table-row`).should('exist').within(() => { + // cy.getByTestID('dropdown-toggle').should('be.visible').click({force: true}) + // cy.get('.open').should('exist') + // }) + }) + }) + + }) + describe('InfluxDB', () => { let influxDB: any @@ -26,7 +80,7 @@ describe('Use Admin tab', () => { beforeEach(() => { cy.deleteInfluxDB(influxDB.db.name, sourceId) - url = `/sources/${sourceId}/admin-influxdb` + url = '/admin-influxdb' }) describe('Databases', () => { diff --git a/ui/cypress/support/commands.ts b/ui/cypress/support/commands.ts index 45e4ef523..df7d2772a 100644 --- a/ui/cypress/support/commands.ts +++ b/ui/cypress/support/commands.ts @@ -69,7 +69,6 @@ export const writePoints = ( tagValue: string, fieldValue: number ) => { - console.log({sourceID: sourceId, db: db}) cy.request({ method: 'POST', url: `${apiUrl}/sources/${sourceId}/write?db=${db}`, @@ -398,7 +397,6 @@ export const deleteInfluxDBUsers = (sourceId: string) => { return cy .request('GET', `${apiUrl}/sources/${sourceId}/users`) .then(({body: responseBody}) => { - console.log(responseBody.users) responseBody.users.forEach((user: any) => { if (user.name != Cypress.env('username')) { cy.request('DELETE', user.links.self) diff --git a/ui/cypress/support/index.ts b/ui/cypress/support/index.ts index 1c27b5d48..87145c5f9 100644 --- a/ui/cypress/support/index.ts +++ b/ui/cypress/support/index.ts @@ -15,6 +15,7 @@ // Import commands.js using ES2015 syntax: import './commands' +import 'cypress-wait-until' // import 'cypress-pipe' // import 'cypress-plugin-tab'