feat: initial commit
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
export interface IUserData {
|
||||
Title: string;
|
||||
UserName: string;
|
||||
Password: string;
|
||||
Description: string;
|
||||
}
|
||||
@@ -0,0 +1,401 @@
|
||||
import '@testing-library/cypress/add-commands';
|
||||
import { IUserData } from './IUserData';
|
||||
|
||||
// ***********************************************
|
||||
// This example commands.js shows you how to
|
||||
// create various custom commands and overwrite
|
||||
// existing commands.
|
||||
//
|
||||
// For more comprehensive examples of custom
|
||||
// commands please read more here:
|
||||
// https://on.cypress.io/custom-commands
|
||||
// ***********************************************
|
||||
//
|
||||
//
|
||||
// -- This is a parent command --
|
||||
// Cypress.Commands.add('login', (email, password) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a child command --
|
||||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a dual command --
|
||||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This will overwrite an existing command --
|
||||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
||||
import '@testing-library/cypress/add-commands';
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
namespace Cypress {
|
||||
interface Chainable {
|
||||
logout(): Chainable<Element>;
|
||||
vaultLogin(admin?: boolean): Chainable<void>;
|
||||
vaultLoginByUserTitle(userTitle: string): Chainable<void>;
|
||||
switchUser(userTitle: string): Chainable<void>;
|
||||
deleteWorkbook(workbookName: string): Chainable<void>;
|
||||
addWorkbook(workbookName: string, workbookDescription: string, datamartName: string): Chainable<void>;
|
||||
goToWorkbook(workbookName: string): Chainable<void>;
|
||||
goToDataSource(dataMartName: string): Chainable<void>;
|
||||
goToStandardDataSource(dataMartName: string): Chainable<void>;
|
||||
verifyDataSourceExists(dataMartName: string): Chainable<void>;
|
||||
verifyDataSourceDoesNotExist(dataMartName: string): Chainable<void>;
|
||||
createDataSource(dataMartName: string, datamartDescription: string): Chainable<void>;
|
||||
deleteDataSource(dataMartName: string): Chainable<void>;
|
||||
addUserToDataSource(datamartName: string, userName: string, viewerOrEditor: string): Chainable<void>;
|
||||
addTableToDataSource(dataTableId: string, dataMartName: string): Chainable<void>;
|
||||
addUserToWorkbook(workbookName: string, userName: string, viewerOrEditor: string): Chainable<void>;
|
||||
addExtract(extractName: string, extractDescription: string, datamartName: string): Chainable<void>;
|
||||
goToExtract(extractName: string): Chainable<void>;
|
||||
deleteExtract(extractName: string): Chainable<void>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Cypress.Commands.add('logout', () => {
|
||||
cy.window().then((win) => {
|
||||
win.sessionStorage.clear();
|
||||
});
|
||||
cy.visit('/');
|
||||
});
|
||||
|
||||
// USE THIS FOR ALL TEST LOGINS TO PULL FROM VAULT
|
||||
Cypress.Commands.add('vaultLogin', (admin = true) => {
|
||||
document.cookie = 'StrataIdentityServerLogin=true';
|
||||
const userTitle = admin ? 'obAdmin' : 'capBasic';
|
||||
|
||||
cy.request({
|
||||
method: 'GET',
|
||||
url: `https://vault.sdt.local/api/searchpasswords/122?title=${userTitle}`,
|
||||
headers: {
|
||||
apiKey: 'a69d2e478c3f5b395b687ecdf34a3239'
|
||||
}
|
||||
})
|
||||
.then((response) => response.body[0])
|
||||
.then((user: IUserData) => {
|
||||
// Test against your own test user
|
||||
//cy.login(Cypress.env('username'), Cypress.env('password'), Cypress.env('dbguid'), Cypress.env('clientId'), '/');
|
||||
cy.login(user.UserName, user.Password, Cypress.env('dbguid'), Cypress.env('clientId'), '/');
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('vaultLoginByUserTitle', (userTitle: string) => {
|
||||
document.cookie = 'StrataIdentityServerLogin=true';
|
||||
|
||||
cy.request({
|
||||
method: 'GET',
|
||||
url: `https://vault.sdt.local/api/searchpasswords/122?title=${userTitle}`,
|
||||
headers: {
|
||||
apiKey: 'a69d2e478c3f5b395b687ecdf34a3239'
|
||||
}
|
||||
})
|
||||
.then((response) => response.body[0])
|
||||
.then((user: IUserData) => {
|
||||
// Test against your own test user
|
||||
//cy.login(Cypress.env('username'), Cypress.env('password'), Cypress.env('dbguid'), Cypress.env('clientId'), '/');
|
||||
cy.login(user.UserName, user.Password, Cypress.env('dbguid'), Cypress.env('clientId'), '/');
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('switchUser', (userTitle: string) => {
|
||||
cy.logout();
|
||||
cy.vaultLoginByUserTitle(userTitle);
|
||||
});
|
||||
|
||||
Cypress.Commands.add('deleteWorkbook', (workbookName: string) => {
|
||||
const token = JSON.parse(window.sessionStorage.getItem('oidc.user:https://identity.dev.stratanetwork.net/:StrataUI')).access_token;
|
||||
cy.request({
|
||||
method: 'GET',
|
||||
url: `${Cypress.env('apiUrl')}v1/workbooks`,
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
}).then((response) => {
|
||||
const workbooks = response.body as { workbookId: string; name: string }[];
|
||||
const matchingWorkbooks = workbooks.find((r) => r.name === workbookName);
|
||||
if (matchingWorkbooks === undefined) return;
|
||||
const workbookId = matchingWorkbooks.workbookId;
|
||||
cy.request({
|
||||
method: 'DELETE',
|
||||
url: `${Cypress.env('apiUrl')}v1/workbooks/${workbookId}`,
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('addWorkbook', (workbookName: string, workbookDescription: string, dataSourceName: string) => {
|
||||
const token = JSON.parse(window.sessionStorage.getItem('oidc.user:https://identity.dev.stratanetwork.net/:StrataUI')).access_token;
|
||||
cy.request({
|
||||
method: 'GET',
|
||||
url: `${Cypress.env('apiUrl')}v1/data-sources`,
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
}).then((response) => {
|
||||
const dataSources = response.body as { dataSourceId: string; name: string }[];
|
||||
const dataSourceId = dataSources.find((r) => r.name === dataSourceName).dataSourceId;
|
||||
cy.request({
|
||||
method: 'POST',
|
||||
url: `${Cypress.env('apiUrl')}v1/workbooks/`,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
body: {
|
||||
name: workbookName,
|
||||
description: workbookDescription,
|
||||
defaultDataSourceId: dataSourceId
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('goToWorkbook', (workbookName: string) => {
|
||||
const token = JSON.parse(window.sessionStorage.getItem('oidc.user:https://identity.dev.stratanetwork.net/:StrataUI')).access_token;
|
||||
cy.request({
|
||||
method: 'GET',
|
||||
url: `${Cypress.env('apiUrl')}v1/workbooks`,
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
}).then((response) => {
|
||||
const workbooks = response.body as { workbookId: string; name: string }[];
|
||||
const matchingWorkbooks = workbooks.find((r) => r.name === workbookName);
|
||||
if (matchingWorkbooks === undefined) return;
|
||||
const workbookId = matchingWorkbooks.workbookId;
|
||||
cy.visit(`/workbooks/${workbookId}`);
|
||||
});
|
||||
cy.get('h1').findByText(workbookName, { timeout: 25000 }).should('exist');
|
||||
});
|
||||
|
||||
Cypress.Commands.add('goToDataSource', (dataSourceName: string) => {
|
||||
const token = JSON.parse(window.sessionStorage.getItem('oidc.user:https://identity.dev.stratanetwork.net/:StrataUI')).access_token;
|
||||
cy.request({
|
||||
method: 'GET',
|
||||
url: `${Cypress.env('apiUrl')}v1/data-sources`,
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
}).then((response) => {
|
||||
const dataSources = response.body as { dataSourceId: string; name: string }[];
|
||||
const dataSourceId = dataSources.find((r) => r.name === dataSourceName).dataSourceId;
|
||||
cy.visit(`/datasources/${dataSourceId}`);
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('goToStandardDataSource', (dataSourceName: string) => {
|
||||
const token = JSON.parse(window.sessionStorage.getItem('oidc.user:https://identity.dev.stratanetwork.net/:StrataUI')).access_token;
|
||||
cy.request({
|
||||
method: 'GET',
|
||||
url: `${Cypress.env('apiUrl')}v1/standard-data-sources`,
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
}).then((response) => {
|
||||
const dataSources = response.body as { standardDataSourceId: string; name: string }[];
|
||||
const dataSourceId = dataSources.find((r) => r.name === dataSourceName).standardDataSourceId;
|
||||
cy.visit(`/standard-datasources/${dataSourceId}`);
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('verifyDataSourceExists', (dataSourceName: string) => {
|
||||
const token = JSON.parse(window.sessionStorage.getItem('oidc.user:https://identity.dev.stratanetwork.net/:StrataUI')).access_token;
|
||||
cy.request({
|
||||
method: 'GET',
|
||||
url: `${Cypress.env('apiUrl')}v1/data-sources`,
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
}).then((response) => {
|
||||
const dataSources = response.body as { dataSourceId: string; name: string }[];
|
||||
const dataSource = dataSources.find((r) => r.name === dataSourceName);
|
||||
expect(dataSource.name).to.eq(dataSourceName);
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('verifyDataSourceDoesNotExist', (dataSourceName: string) => {
|
||||
const token = JSON.parse(window.sessionStorage.getItem('oidc.user:https://identity.dev.stratanetwork.net/:StrataUI')).access_token;
|
||||
cy.request({
|
||||
method: 'GET',
|
||||
url: `${Cypress.env('apiUrl')}v1/data-sources`,
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
}).then((response) => {
|
||||
const dataSources = response.body as { dataSourceId: string; name: string }[];
|
||||
const dataSource = dataSources.find((r) => r.name === dataSourceName);
|
||||
expect(dataSource).to.be(null);
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('createDataSource', (dataSourceName: string, dataSourceDescription: string) => {
|
||||
const token = JSON.parse(window.sessionStorage.getItem('oidc.user:https://identity.dev.stratanetwork.net/:StrataUI')).access_token;
|
||||
cy.request({
|
||||
method: 'POST',
|
||||
url: `${Cypress.env('apiUrl')}v1/data-sources`,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
body: {
|
||||
name: dataSourceName,
|
||||
description: dataSourceDescription
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('deleteDataSource', (dataSourceName: string) => {
|
||||
const token = JSON.parse(window.sessionStorage.getItem('oidc.user:https://identity.dev.stratanetwork.net/:StrataUI')).access_token;
|
||||
cy.request({
|
||||
method: 'GET',
|
||||
url: `${Cypress.env('apiUrl')}v1/data-sources`,
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
}).then((response) => {
|
||||
const dataSources = response.body as { dataSourceId: string; name: string }[];
|
||||
const matchingDataSources = dataSources.find((r) => r.name === dataSourceName);
|
||||
if (matchingDataSources === undefined) return;
|
||||
const dataSourceId = matchingDataSources.dataSourceId;
|
||||
cy.request({
|
||||
method: 'DELETE',
|
||||
url: `${Cypress.env('apiUrl')}v1/data-sources/${dataSourceId}`,
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('addUserToDataSource', (dataSourceName: string, userName: string, viewerOrEditor: string) => {
|
||||
const token = JSON.parse(window.sessionStorage.getItem('oidc.user:https://identity.dev.stratanetwork.net/:StrataUI')).access_token;
|
||||
cy.request({
|
||||
method: 'GET',
|
||||
url: `${Cypress.env('apiUrl')}v1/users`,
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
}).then((response) => {
|
||||
const users = response.body as { userGuid: string; username: string }[];
|
||||
|
||||
const matchingUsers = users.find((r) => r.username === userName);
|
||||
if (matchingUsers === undefined) return;
|
||||
const userGuid = matchingUsers.userGuid;
|
||||
cy.request({
|
||||
method: 'GET',
|
||||
url: `${Cypress.env('apiUrl')}v1/data-sources`,
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
}).then((response) => {
|
||||
const dataSources = response.body as { dataSourceId: string; name: string }[];
|
||||
const matchingDataSources = dataSources.find((r) => r.name === dataSourceName);
|
||||
if (matchingDataSources === undefined) return;
|
||||
const dataSourceId = matchingDataSources.dataSourceId;
|
||||
cy.request({
|
||||
method: 'POST',
|
||||
url: `${Cypress.env('apiUrl')}v1/data-sources/${dataSourceId}/role-assignments/batch`,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
body: {
|
||||
updates: [
|
||||
{
|
||||
identityGuid: userGuid,
|
||||
identityName: userName,
|
||||
identityType: 'user',
|
||||
role: viewerOrEditor
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('addTableToDataSource', (dataTableId: string, dataSourceName: string) => {
|
||||
const token = JSON.parse(window.sessionStorage.getItem('oidc.user:https://identity.dev.stratanetwork.net/:StrataUI')).access_token;
|
||||
cy.request({
|
||||
method: 'GET',
|
||||
url: `${Cypress.env('apiUrl')}v1/data-sources`,
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
}).then((response) => {
|
||||
const dataSources = response.body as { dataSourceId: string; name: string }[];
|
||||
const dataSourceId = dataSources.find((r) => r.name === dataSourceName).dataSourceId;
|
||||
cy.request({
|
||||
method: 'POST',
|
||||
url: `${Cypress.env('apiUrl')}v1/data-sources/${dataSourceId}/tables/${dataTableId}`,
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('addUserToWorkbook', (workbookName: string, userName: string, viewerOrEditor: string) => {
|
||||
const token = JSON.parse(window.sessionStorage.getItem('oidc.user:https://identity.dev.stratanetwork.net/:StrataUI')).access_token;
|
||||
cy.request({
|
||||
method: 'GET',
|
||||
url: `${Cypress.env('apiUrl')}v1/users`,
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
}).then((response) => {
|
||||
const users = response.body as { userGuid: string; username: string }[];
|
||||
|
||||
const matchingUsers = users.find((r) => r.username === userName);
|
||||
if (matchingUsers === undefined) return;
|
||||
const userGuid = matchingUsers.userGuid;
|
||||
cy.request({
|
||||
method: 'GET',
|
||||
url: `${Cypress.env('apiUrl')}v1/workbooks`,
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
}).then((response) => {
|
||||
const workbooks = response.body as { workbookId: string; name: string }[];
|
||||
const matchingWorkbooks = workbooks.find((r) => r.name === workbookName);
|
||||
if (matchingWorkbooks === undefined) return;
|
||||
const workbookId = matchingWorkbooks.workbookId;
|
||||
cy.request({
|
||||
method: 'POST',
|
||||
url: `${Cypress.env('apiUrl')}v1/workbooks/${workbookId}/role-assignments/batch`,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
body: {
|
||||
updates: [
|
||||
{
|
||||
identityGuid: userGuid,
|
||||
identityName: userName,
|
||||
identityType: 'user',
|
||||
role: viewerOrEditor
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('addExtract', (extractName: string, extractDescription: string, dataMartName: string) => {
|
||||
const token = JSON.parse(window.sessionStorage.getItem('oidc.user:https://identity.dev.stratanetwork.net/:StrataUI')).access_token;
|
||||
cy.request({
|
||||
method: 'GET',
|
||||
url: `${Cypress.env('apiUrl')}v1/data-sources`,
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
}).then((response) => {
|
||||
const datamarts = response.body as { dataSourceId: string; name: string }[];
|
||||
const dataSourceId = datamarts.find((r) => r.name === dataMartName).dataSourceId;
|
||||
cy.request({
|
||||
method: 'POST',
|
||||
url: `${Cypress.env('apiUrl')}v1/extracts/`,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
body: {
|
||||
name: extractName,
|
||||
description: extractDescription,
|
||||
defaultdataSourceId: dataSourceId
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('goToExtract', (extractName: string) => {
|
||||
const token = JSON.parse(window.sessionStorage.getItem('oidc.user:https://identity.dev.stratanetwork.net/:StrataUI')).access_token;
|
||||
cy.request({
|
||||
method: 'GET',
|
||||
url: `${Cypress.env('apiUrl')}v1/extracts`,
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
}).then((response) => {
|
||||
const extracts = response.body as { extractId: string; name: string }[];
|
||||
const matchingExtracts = extracts.find((r) => r.name === extractName);
|
||||
if (matchingExtracts === undefined) return;
|
||||
const extractId = matchingExtracts.extractId;
|
||||
cy.visit(`/extracts/${extractId}`);
|
||||
});
|
||||
cy.get('h1').findByText(extractName, { timeout: 25000 }).should('exist');
|
||||
});
|
||||
|
||||
Cypress.Commands.add('deleteExtract', (extractName: string) => {
|
||||
const token = JSON.parse(window.sessionStorage.getItem('oidc.user:https://identity.dev.stratanetwork.net/:StrataUI')).access_token;
|
||||
cy.request({
|
||||
method: 'GET',
|
||||
url: `${Cypress.env('apiUrl')}v1/extracts`,
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
}).then((response) => {
|
||||
const extracts = response.body as { extractId: string; name: string }[];
|
||||
const matchingExtracts = extracts.find((r) => r.name === extractName);
|
||||
if (matchingExtracts === undefined) return;
|
||||
const extractId = matchingExtracts.extractId;
|
||||
cy.request({
|
||||
method: 'DELETE',
|
||||
url: `${Cypress.env('apiUrl')}v1/extracts/${extractId}`,
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
// ***********************************************************
|
||||
// This example support/index.js is processed and
|
||||
// loaded automatically before your test files.
|
||||
//
|
||||
// This is a great place to put global configuration and
|
||||
// behavior that modifies Cypress.
|
||||
//
|
||||
// You can change the location of this file or turn off
|
||||
// automatically serving support files with the
|
||||
// 'supportFile' configuration option.
|
||||
//
|
||||
// You can read more here:
|
||||
// https://on.cypress.io/configuration
|
||||
// ***********************************************************
|
||||
|
||||
// Import commands.js using ES2015 syntax:
|
||||
import './commands';
|
||||
import 'cypress-file-upload';
|
||||
import { expandTreeCommand, selectTreeCommand, checkTreeCommand } from '@strata/cypress/lib/tree';
|
||||
import { loginCommand } from '@strata/cypress/lib/login';
|
||||
|
||||
loginCommand();
|
||||
expandTreeCommand();
|
||||
selectTreeCommand();
|
||||
checkTreeCommand();
|
||||
|
||||
// Alternatively you can use CommonJS syntax:
|
||||
// require('./commands')
|
||||
Cypress.on('uncaught:exception', (err) => !err.message.includes('ResizeObserver loop limit exceeded'));
|
||||
Reference in New Issue
Block a user