docbrown/cypress/integration/loginFlows/initialAdminLogin.spec.js
Nick Taylor f6278a9106
Add Cypress to Travis (#11867)
* Added test run artifacts to git ignore.

* Added Cypress run to Travis.

* Added the start-server-and-test package.

* Added e2e ci scripts.

* Split up commands.

* Testing e2e after rspecs on same build node.

* Move Cypress back to node 0 for Knapsack.

* Added folders for build artifacts for failed E2E tests.

* Simplified e2e for CI

* Using knapsack-pro-cypress now.

* Added data-testid to sign up form for tests.

* Added forem secret for CI

* Updated initial admin fixture.

* Reworked test to be a signup test. wip.

* Added cypress file upload package.

* added fixture for admin profile image.

* Updated forem secret for tests.

* Added Cypress file upload to Cypress commands.

* Changed test to initial sign up for the first admin user.

* Fixed test to ensure there are no signup errors.

* Added some logging to see what's up.

* Added some comments to the test.

* Set Chrome web security to false to prevent CORS errors.

Co-authored-by: rhymes <rhymes@hey.com>
2020-12-15 21:26:34 -05:00

48 lines
1.7 KiB
JavaScript

// Note if you are running these tests locallly, this test will fail
// if the first admin has already gone through the onboarding process.
describe('Initial admin signup', () => {
it('should sign up the initial Forem instance administrator', () => {
// This is the happy path.
cy.fixture('logins/initialAdmin.json').as('admin');
cy.log('baseUrl', Cypress.config().baseUrl);
// Go to home page which redirects to the registration form.
cy.visit('/');
cy.findByTestId('registration-form').as('registrationForm');
cy.get('@registrationForm')
.findByLabelText(/Profile image/i)
.attachFile('images/admin-image.png');
cy.get('@admin').then((admin) => {
// Enter credentials for the initial administrator user
cy.get('@registrationForm')
.findByLabelText(/^Name$/i)
.type(admin.name);
cy.get('@registrationForm')
.findByLabelText(/Username/i)
.type(admin.username);
cy.get('@registrationForm').findByLabelText(/Email/i).type(admin.email);
cy.get('@registrationForm')
.findByLabelText('Password')
.type(admin.password);
cy.get('@registrationForm')
.findByLabelText(/Password Confirmation/i)
.type(admin.password);
cy.get('@registrationForm')
.findByLabelText(/New Forem Secret/i)
.type(admin.foremSecret);
});
// Submit the form
cy.get('@registrationForm').findByText('Sign up').click();
cy.log('Submitting signup form');
cy.url().should('eq', Cypress.config().baseUrl + '/users');
// We want to ensure that the form submitted without errors
cy.findByTestId('signup-errors').should('not.exist');
});
});