From d5e7b71d6201e20961af051b1154092f2784d3d8 Mon Sep 17 00:00:00 2001 From: Thoscellen Date: Fri, 23 Aug 2019 12:23:00 +0200 Subject: [PATCH] optimised a few test and prepare some feed for reader tests. --- cypress/fixtures/feeds.json | 14 ++++++++++++++ cypress/integration/login_spec.js | 18 +++++++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/cypress/fixtures/feeds.json b/cypress/fixtures/feeds.json index e69de29..e5ac170 100644 --- a/cypress/fixtures/feeds.json +++ b/cypress/fixtures/feeds.json @@ -0,0 +1,14 @@ +{ + "xkcd" : { + "rss" : "https://xkcd.com/rss.xml", + "website" : "https://xkcd.com/", + }, + "css-tricks" : { + "rss" : "https://css-tricks.com/feed/?post_type=newsletters", + "website" : "https://css-tricks.com/" + }, + "bbcnews" : { + "rss" : "http://feeds.bbci.co.uk/news/rss.xml", + "website" : "https://www.bbc.com/news" + } +} \ No newline at end of file diff --git a/cypress/integration/login_spec.js b/cypress/integration/login_spec.js index 94016f2..1e39d62 100644 --- a/cypress/integration/login_spec.js +++ b/cypress/integration/login_spec.js @@ -49,14 +49,16 @@ describe('As a visitor, I can only register the right way.', function () { it('Prevent to create an account with empty fields', function () { // Arrange cy.get('.menu-reg').first().find('a[href$="action=register"]').click(); + // Assert everything is fine before acting cy.get('input#register-email').should('have.not.class', 'input_error'); cy.get('input#register-password').should('have.not.class', 'input_error'); + cy.get('div#register-error').should("not.be.visible"); // Act cy.get('#register-form').find(":submit").click(); // Assert cy.get('div#register-error') // Message d'erreur .should('have.class', 'register__error') - .and('be.not.visible'); + .and('be.visible'); cy.get('input#register-email').should('have.class', 'input_error'); // Champs surlignés cy.get('input#register-password').should('have.class', 'input_error'); }) @@ -85,7 +87,7 @@ describe('As a visitor, I can only register the right way.', function () { }); }) - it.only('Check that it explain correclty to the user when he try to create an already existing account', function () { + it('Check that it explain correclty to the user when he try to create an already existing account', function () { cy.server(); cy.fixture("users.json").as("users").then((users) => { let mutoid = users["Mutoid"]; @@ -98,6 +100,8 @@ describe('As a visitor, I can only register the right way.', function () { failOnStatusCode: false, qs: { "t": new Date().getTime() } }).then((response) => { + cy.log(response); + cy.expect(response.status).to.be.eq(400); cy.expect(response.body.status).to.be.eq('error'); cy.expect(response.body.errors[0]).to.be.eq('This email is already registered, please choose another one.'); }); @@ -114,9 +118,6 @@ describe("As a user, I can only log in and out the right way", function () { before(function () { cy.fixture("users.json").as("users").then((users) => { mutoid = users["Mutoid"]; - //expect(mutoid.email).to.exist; - //expect(mutoid.password).to.exist; - //expect(mutoid.type).eq("user"); }); }) @@ -189,14 +190,16 @@ describe("As a user, I can only log in and out the right way", function () { // Assert cy.url().should('contain', '/online/#/reader/category/all/') cy.get("div#user").find("a.user__settings").click(); - cy.logout(); + cy.getCookie('session').should('exist'); }); - it.skip('Logs Mutoid in via API', function () { + it('Logs Mutoid in via API', function () { // act cy.login(mutoid); cy.visit("/online"); // assert + cy.url().should('contain', '/online/#/reader/category/all/') + cy.get("div#user").find("a.user__settings").click(); cy.getCookie('session').should('exist'); }); @@ -204,6 +207,7 @@ describe("As a user, I can only log in and out the right way", function () { // Arrange cy.login(mutoid) cy.visit('/online'); + cy.getCookie('session').should('exist'); // act cy.get("div#user").find("a.user__settings").click(); cy.get("div#user-menu").find('.logout').click();