2022-11-22 01:37:26 -08:00
|
|
|
import { DEFAULT_USER_EMAIL, DEFAULT_USER_PASSWORD } from "../constants";
|
|
|
|
import { randFirstName, randLastName } from "@ngneat/falso";
|
|
|
|
import { CredentialsPage, CredentialsModal } from '../pages';
|
|
|
|
|
2022-11-28 09:11:33 -08:00
|
|
|
const email = DEFAULT_USER_EMAIL;
|
2022-11-22 01:37:26 -08:00
|
|
|
const password = DEFAULT_USER_PASSWORD;
|
|
|
|
const firstName = randFirstName();
|
|
|
|
const lastName = randLastName();
|
|
|
|
const credentialsPage = new CredentialsPage();
|
|
|
|
const credentialsModal = new CredentialsModal();
|
|
|
|
|
|
|
|
describe('Credentials', () => {
|
2022-11-28 02:11:39 -08:00
|
|
|
before(() => {
|
2022-11-28 09:11:33 -08:00
|
|
|
cy.resetAll();
|
|
|
|
cy.setup({ email, firstName, lastName, password });
|
2022-11-28 02:11:39 -08:00
|
|
|
});
|
|
|
|
|
2022-11-22 01:37:26 -08:00
|
|
|
beforeEach(() => {
|
|
|
|
cy.on('uncaught:exception', (err, runnable) => {
|
|
|
|
expect(err.message).to.include('Not logged in');
|
|
|
|
|
|
|
|
return false;
|
|
|
|
})
|
|
|
|
|
2022-11-28 09:11:33 -08:00
|
|
|
cy.signin({ email, password });
|
2022-11-22 01:37:26 -08:00
|
|
|
cy.visit(credentialsPage.url);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should create a new credential using empty state', () => {
|
|
|
|
credentialsPage.getters.emptyListCreateCredentialButton().click();
|
|
|
|
|
|
|
|
credentialsModal.getters.newCredentialModal().should('be.visible');
|
|
|
|
credentialsModal.getters.newCredentialTypeSelect().should('be.visible');
|
|
|
|
credentialsModal.getters.newCredentialTypeOption('Notion API').click();
|
|
|
|
|
|
|
|
credentialsModal.getters.newCredentialTypeButton().click();
|
|
|
|
|
|
|
|
credentialsModal.getters.connectionParameter('API Key').type('1234567890');
|
|
|
|
|
|
|
|
credentialsModal.actions.setName('My awesome Notion account');
|
|
|
|
credentialsModal.actions.save();
|
2022-11-28 02:11:39 -08:00
|
|
|
credentialsModal.actions.close();
|
|
|
|
|
|
|
|
credentialsPage.getters.credentialCards().should('have.length', 1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should create a new credential using Add Credential button', () => {
|
|
|
|
credentialsPage.getters.createCredentialButton().click();
|
|
|
|
|
|
|
|
credentialsModal.getters.newCredentialModal().should('be.visible');
|
|
|
|
credentialsModal.getters.newCredentialTypeSelect().should('be.visible');
|
|
|
|
credentialsModal.getters.newCredentialTypeOption('Airtable API').click();
|
|
|
|
|
|
|
|
credentialsModal.getters.newCredentialTypeButton().click();
|
|
|
|
|
|
|
|
credentialsModal.getters.connectionParameter('API Key').type('1234567890');
|
|
|
|
|
|
|
|
credentialsModal.actions.setName('Airtable Account');
|
|
|
|
credentialsModal.actions.save();
|
|
|
|
credentialsModal.actions.close();
|
|
|
|
|
|
|
|
credentialsPage.getters.credentialCards().should('have.length', 2);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should search credentials', () => {
|
|
|
|
// Search by name
|
|
|
|
credentialsPage.actions.search('Notion');
|
|
|
|
credentialsPage.getters.credentialCards().should('have.length', 1);
|
|
|
|
|
|
|
|
// Search by Credential type
|
|
|
|
credentialsPage.actions.search('Airtable API');
|
|
|
|
credentialsPage.getters.credentialCards().should('have.length', 1);
|
|
|
|
|
|
|
|
// No results
|
|
|
|
credentialsPage.actions.search('Google');
|
|
|
|
credentialsPage.getters.credentialCards().should('have.length', 0);
|
|
|
|
credentialsPage.getters.emptyList().should('be.visible');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should sort credentials', () => {
|
|
|
|
credentialsPage.actions.search('');
|
|
|
|
credentialsPage.actions.sortBy('nameDesc');
|
|
|
|
credentialsPage.getters.credentialCards().eq(0).should('contain.text', 'Notion');
|
|
|
|
credentialsPage.actions.sortBy('nameAsc');
|
2022-11-22 01:37:26 -08:00
|
|
|
});
|
|
|
|
});
|