skillbox/client/cypress/integration/login-page-spec.js

63 lines
1.8 KiB
JavaScript

describe('The Login Page', () => {
it('sets auth cookie when logging in via form submission', () => {
const username = 'test';
const password = 'test';
cy.visit('/');
cy.get('#id_username').type(username);
cy.get('#id_password').type(`${password}{enter}`);
cy.getCookie('sessionid').should('exist');
cy.get('.start-page__header').should('exist')
});
// it('logs in programmatically without using the UI', () => {
// cy.visit('/accounts/login/'); // have to get a csrf token by getting the base page first
//
// const username = 'test';
// const password = 'test';
//
// cy.getCookie('csrftoken').then(token => {
// const options = {
// url: '/accounts/login/',
// method: 'POST',
// headers: {
// 'X-CSRFToken': token.value,
// 'content-type': 'multipart/form-data'
// },
// from: true,
// body: {
// username: username,
// password: password,
// // csrfmiddlewaretoken: token.value
// }
// };
//
// cy.request(options);
// cy.getCookie('sessionid').should('exist');
// cy.visit('/');
//
// cy.get('.start-page__title').should('contain', 'skillbox')
//
//
// // cy.visit('/');
// // cy.getCookie('csrftoken')
// // .then((csrftoken) => {
// // const response = cy.request({
// // method: 'POST',
// // url: '/login/',
// // form: true,
// // body: {
// // identification: username,
// // password: password,
// // csrfmiddlewaretoken: csrftoken.value
// // }
// // });
// // });
//
// });
// })
})