2021-06-22 17:52:37 +00:00
|
|
|
Cypress.Commands.add('login', (email, password) => {
|
|
|
|
|
cy.visit('/login');
|
|
|
|
|
cy.get('[data-testid="emailField"]').type(email);
|
|
|
|
|
cy.get('[data-testid="passwordField"]').type(password);
|
|
|
|
|
cy.get('[data-testid="loginButton"').click();
|
|
|
|
|
})
|
|
|
|
|
|
2021-09-15 02:51:56 +00:00
|
|
|
|
|
|
|
|
|
2021-06-22 17:52:37 +00:00
|
|
|
Cypress.Commands.add('checkToastMessage', (toastId, message) => {
|
|
|
|
|
cy.get(`[id=${toastId}]`).should('contain', message);
|
2021-06-24 16:04:45 +00:00
|
|
|
});
|
2021-08-13 08:29:50 +00:00
|
|
|
|
|
|
|
|
Cypress.Commands.add('addPostgresDataSource', fn => {
|
|
|
|
|
|
|
|
|
|
cy.get('div[class="modal-title h4"] span[class="text-muted"]')
|
|
|
|
|
.should('have.text', 'Add new datasource')
|
|
|
|
|
.and('be.visible')
|
|
|
|
|
|
|
|
|
|
cy.get('.modal-body')
|
|
|
|
|
.find('div[class="row row-deck"]')
|
|
|
|
|
.find('h4[class="text-muted mb-2"]')
|
|
|
|
|
.should('have.text', 'DATABASES')
|
|
|
|
|
|
|
|
|
|
cy.get('.modal-body')
|
|
|
|
|
.find('.col-md-2')
|
|
|
|
|
.contains('PostgreSQL')
|
|
|
|
|
.and('be.visible')
|
|
|
|
|
.click()
|
|
|
|
|
|
|
|
|
|
cy.get('.row.mt-3')
|
|
|
|
|
.find('.col-md-4')
|
|
|
|
|
.find('.form-label')
|
|
|
|
|
.contains('Database Name')
|
|
|
|
|
|
|
|
|
|
cy.get('div[class="row mt-3"] div:nth-child(1)')
|
|
|
|
|
.find('.form-control')
|
|
|
|
|
.should('have.attr', 'type', 'text')
|
|
|
|
|
.type(Cypress.env('TEST_PG_DB'))
|
|
|
|
|
|
|
|
|
|
cy.get('.row.mt-3')
|
|
|
|
|
.find('.col-md-4')
|
|
|
|
|
.find('.form-label')
|
|
|
|
|
.contains('Username')
|
|
|
|
|
|
|
|
|
|
cy.get('div[class="row mt-3"] div:nth-child(2)')
|
|
|
|
|
.find('.form-control')
|
|
|
|
|
.should('have.attr', 'type', 'text')
|
|
|
|
|
.type(Cypress.env('TEST_PG_USERNAME'))
|
|
|
|
|
|
|
|
|
|
cy.get('.row.mt-3')
|
|
|
|
|
.find('.col-md-4')
|
|
|
|
|
.find('.form-label')
|
|
|
|
|
.contains('Password')
|
|
|
|
|
|
|
|
|
|
cy.get('div[class="row mt-3"] div:nth-child(3)')
|
|
|
|
|
.find('.form-control')
|
|
|
|
|
.should('have.attr', 'type', 'password')
|
|
|
|
|
.type(Cypress.env('TEST_PG_PASSWORD'))
|
|
|
|
|
|
2021-09-15 02:51:56 +00:00
|
|
|
cy.get('input[type="checkbox"]')
|
|
|
|
|
.uncheck()
|
|
|
|
|
|
2021-08-13 08:29:50 +00:00
|
|
|
cy.get('button[class="m-2 btn btn-success"]')
|
|
|
|
|
.should('have.text', 'Test Connection')
|
|
|
|
|
.click()
|
|
|
|
|
|
|
|
|
|
cy.get('.badge')
|
|
|
|
|
.should('have.text', 'connection verified')
|
|
|
|
|
|
|
|
|
|
cy.get('div[class="col-auto"] button[type="button"]')
|
|
|
|
|
.should('have.text', 'Save')
|
|
|
|
|
.click()
|
|
|
|
|
});
|
2021-09-12 04:22:29 +00:00
|
|
|
Cypress.Commands.add('createAppIfEmptyDashboard', fn => {
|
|
|
|
|
cy.get('body').then(($title => {
|
|
|
|
|
//check you are not running tests on empty dashboard state
|
|
|
|
|
if ($title.text().includes('You haven\'t created any apps yet.')) {
|
|
|
|
|
cy.get('a.btn').eq(0).should('have.text', 'Create your first app')
|
|
|
|
|
.click()
|
|
|
|
|
cy.go('back')
|
|
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add('deployAppWithSingleVersion', fn => {
|
|
|
|
|
cy.get('.navbar')
|
|
|
|
|
.find('.navbar-nav')
|
|
|
|
|
.find('.nav-item')
|
|
|
|
|
.find('button[class="btn btn-primary btn-sm"]')
|
|
|
|
|
.should('have.text', 'Deploy')
|
|
|
|
|
.and('be.visible')
|
|
|
|
|
.click();
|
|
|
|
|
|
|
|
|
|
cy.get('.modal-title.h4').should('have.text', 'Versions and deployments').and('be.visible');
|
|
|
|
|
cy.get('.btn.btn-primary.btn-sm.mx-2').contains('+ Version').click();
|
|
|
|
|
cy.get('input[placeholder="version name"]').type('1.0');
|
|
|
|
|
cy.get('button[class="btn btn-primary"]').should('have.text', 'Create').click();
|
|
|
|
|
cy.get('table').contains('td', 'save').click().contains('td', 'deploy').click();
|
|
|
|
|
});
|