Commit 36d70178 authored by Håvard Farestveit's avatar Håvard Farestveit
Browse files

Refactored boundary tests #22

Merged the different tests to two files
parent a0ed6d4b
Pipeline #114755 passed with stage
in 36 seconds
......@@ -51,7 +51,7 @@ class UserRegistration2WayTestCase(TestCase):
def setUp(self):
print("Running two way user registration")
self.client
self.client = Client()
self.testcases = []
default_testcase = {
'username': 'valid',
......
describe('Register new user', () => {
it('Checking for boundry error with phone number', () => {
cy.visit('http://localhost:3000/register.html');
cy.get('#form-register-user').within(($form) => {
cy.get('input[name="username"]').type('testUser' + Date.now());
cy.get('input[name="email"]').type('test@mail.it');
cy.get('input[name="password"]').type('123456789');
cy.get('input[name="password1"]').type('123456789');
cy.get('input[name="city"]').type('x'.repeat(51));
cy.get('input[name="street_address"]').type('Testing street');
})
cy.get('#btn-create-account').click();
cy.contains('Registration failed!')
});
});
describe('Register new user', () => {
it('Checking for n-1 boundary with phone number', () => {
cy.visit('http://localhost:3000/register.html');
cy.get('#form-register-user').within(($form) => {
cy.get('input[name="username"]').type('testUser' + Date.now());
cy.get('input[name="email"]').type('test@mail.it');
cy.get('input[name="password"]').type('123456789');
cy.get('input[name="password1"]').type('123456789');
cy.get('input[name="city"]').type('x'.repeat(50));
cy.get('input[name="street_address"]').type('Testing street');
})
cy.get('#btn-create-account').click();
cy.contains('View Workouts')
});
});
\ No newline at end of file
describe('Register new user', () => {
it('Checking for boundry error with phone number', () => {
cy.visit('http://localhost:3000/register.html');
cy.get('#form-register-user').within(($form) => {
cy.get('input[name="username"]').type('testUser' + Date.now());
cy.get('input[name="email"]').type('test@mail.it');
cy.get('input[name="password"]').type('123456789');
cy.get('input[name="password1"]').type('123456789');
cy.get('input[name="country"]').type('x'.repeat(51));
cy.get('input[name="city"]').type('Testheim');
cy.get('input[name="street_address"]').type('Testing street');
})
cy.get('#btn-create-account').click();
cy.contains('Registration failed!')
});
});
describe('Register new user', () => {
it('Checking for n-1 boundary with phone number', () => {
cy.visit('http://localhost:3000/register.html');
cy.get('#form-register-user').within(($form) => {
cy.get('input[name="username"]').type('testUser' + Date.now());
cy.get('input[name="email"]').type('test@mail.it');
cy.get('input[name="password"]').type('123456789');
cy.get('input[name="password1"]').type('123456789');
cy.get('input[name="country"]').type('x'.repeat(50));
cy.get('input[name="city"]').type('Testheim');
cy.get('input[name="street_address"]').type('Testing street');
})
cy.get('#btn-create-account').click();
cy.contains('View Workouts')
});
});
\ No newline at end of file
describe('Log in', () => {
it('Login to Secfit', () => {
// const disableSmoothScroll = () => {
cy.visit('http://localhost:3000/login.html');
cy.get('#form-login').within(($form) => {
cy.get('input[name="username"]').type('havfar');
cy.get('input[name="password"]').type('qwertyuiop');
})
cy.get('#btn-login').click();
cy.get('#btn-create-workout').click({force: true});
cy.get('#inputName').type('x'.repeat(101));
cy.get('#inputDateTime').then(input =>{
input[0].dispatchEvent(new Event('input', { bubbles: true }));
input.val('2021-03-30T13:00');
});
cy.get('#inputVisibility').select('PU');
cy.get('#inputNotes').type('Notes');
const filePath = './TestFile.txt';
cy.get('#customFile').attachFile(filePath);
cy.scrollTo('bottom');
// cy.get('input[name="sets"]').type('2')
cy.get('#div-exercises').within(($form) => {
cy.get('.form-select').select('1');
cy.get('input[name="sets"]').type('2');
cy.get('input[name="number"]').type('2');
});
cy.get('#btn-ok-workout').click()
cy.contains('Could not create new workout!')
});
});
describe('Log in', () => {
it('Login to Secfit', () => {
// const disableSmoothScroll = () => {
cy.visit('http://localhost:3000/login.html');
cy.get('#form-login').within(($form) => {
cy.get('input[name="username"]').type('havfar');
cy.get('input[name="password"]').type('qwertyuiop');
})
cy.get('#btn-login').click();
cy.get('#btn-create-workout').click({force: true});
cy.get('#inputName').type('x'.repeat(100));
cy.get('#inputDateTime').then(input =>{
input[0].dispatchEvent(new Event('input', { bubbles: true }));
input.val('2021-03-30T13:00');
});
cy.get('#inputVisibility').select('PR');
cy.get('#inputNotes').type('Notes');
const filePath = './TestFile.txt';
cy.get('#customFile').attachFile(filePath);
cy.scrollTo('bottom');
cy.get('#div-exercises').within(($form) => {
cy.get('.form-select').select('1');
cy.get('input[name="sets"]').type('2');
cy.get('input[name="number"]').type('2');
});
cy.get('#btn-ok-workout').click()
cy.contains('View Workouts')
});
});
\ No newline at end of file
describe('Register new user', () => {
it('Checking for boundry error with phone number', () => {
cy.visit('http://localhost:3000/register.html');
cy.get('#form-register-user').within(($form) => {
cy.get('input[name="username"]').type('testUser' + Date.now());
cy.get('input[name="email"]').type('test@mail.it');
cy.get('input[name="password"]').type('123456789');
cy.get('input[name="password1"]').type('123456789');
cy.get('input[name="phone_number"]').type('x'.repeat(51));
cy.get('input[name="country"]').type('Testonia');
cy.get('input[name="city"]').type('Testheim');
cy.get('input[name="street_address"]').type('Testing street');
})
cy.get('#btn-create-account').click();
cy.contains('Registration failed!')
});
});
describe('Register new user', () => {
it('Checking for n-1 boundary with phone number', () => {
cy.visit('http://localhost:3000/register.html');
cy.get('#form-register-user').within(($form) => {
cy.get('input[name="username"]').type('testUser' + Date.now());
cy.get('input[name="email"]').type('test@mail.it');
cy.get('input[name="password"]').type('123456789');
cy.get('input[name="password1"]').type('123456789');
cy.get('input[name="phone_number"]').type('x'.repeat(50));
cy.get('input[name="country"]').type('Testonia');
cy.get('input[name="city"]').type('Testheim');
cy.get('input[name="street_address"]').type('Testing street');
})
cy.get('#btn-create-account').click();
cy.contains('View Workouts')
});
});
\ No newline at end of file
describe('Register new user', () => {
it('Checking for boundry error with phone number', () => {
cy.visit('http://localhost:3000/register.html');
cy.get('#form-register-user').within(($form) => {
cy.get('input[name="username"]').type('testUser' + Date.now());
cy.get('input[name="email"]').type('test@mail.it');
cy.get('input[name="password"]').type('123456789');
cy.get('input[name="password1"]').type('123456789');
cy.get('input[name="street_address"]').type('x'.repeat(51));
})
cy.get('#btn-create-account').click();
cy.contains('Registration failed!')
});
});
describe('Register new user', () => {
it('Checking for n-1 boundary with phone number', () => {
cy.visit('http://localhost:3000/register.html');
cy.get('#form-register-user').within(($form) => {
cy.get('input[name="username"]').type('testUser' + Date.now());
cy.get('input[name="email"]').type('test@mail.it');
cy.get('input[name="password"]').type('123456789');
cy.get('input[name="password1"]').type('123456789');
cy.get('input[name="street_address"]').type('x'.repeat(50));
})
cy.get('#btn-create-account').click();
cy.contains('View Workouts')
});
});
\ No newline at end of file
describe("Register new user", () => {
it("Register with valid user", () => {
cy.register();
cy.get("#form-register-user").within(($form) => {
cy.get('input[name="username"]').type("testUser" + Date.now());
cy.get('input[name="email"]').type("email@mail.me");
cy.get('input[name="password"]').type("123456789");
cy.get('input[name="password1"]').type("123456789");
cy.get('input[name="phone_number"]').type("12345678");
cy.get('input[name="country"]').type("Testonia");
cy.get('input[name="city"]').type("Testheim");
cy.get('input[name="street_address"]').type("Testing street");
cy.get('input[name="username"]').type("testUser");
});
cy.get("#btn-create-account").click();
cy.url().should("include", "/workouts.html");
});
it("Register with blank fields", () => {
cy.register();
cy.get("#btn-create-account").click();
cy.get(".alert").contains("Registration failed!");
});
it("Register new user with max lenth username", () => {
cy.register();
cy.get("#form-register-user").within(($form) => {
let max_length_username = Date.now() + "x".repeat(137);
cy.get('input[name="username"]').type(max_length_username);
cy.get('input[name="email"]').type("test@mail.it");
cy.get('input[name="password"]').type("123456789");
cy.get('input[name="password1"]').type("123456789");
cy.get('input[name="phone_number"]').type("12345678");
cy.get('input[name="country"]').type("Testonia");
cy.get('input[name="city"]').type("Testheim");
cy.get('input[name="street_address"]').type("Testing street");
});
cy.get("#btn-create-account").click();
cy.url().should("include", "/workouts.html");
});
it("Testing for too long username", () => {
cy.register();
cy.get("#form-register-user").within(($form) => {
cy.get('input[name="username"]').type("x".repeat(151));
cy.get('input[name="email"]').type("test@mail.it");
cy.get('input[name="password"]').type("123456789");
cy.get('input[name="password1"]').type("123456789");
cy.get('input[name="phone_number"]').type("12345678");
cy.get('input[name="country"]').type("Testonia");
cy.get('input[name="city"]').type("Testheim");
cy.get('input[name="street_address"]').type("Testing street");
cy.get('input[name="username"]').type("testUser");
});
cy.get("#btn-create-account").click();
cy.contains("Registration failed!");
});
it("Testing for no username", () => {
cy.register();
cy.get("#form-register-user").within(($form) => {
cy.get('input[name="email"]').type("test@mail.it");
cy.get('input[name="password"]').type("123456789");
cy.get('input[name="password1"]').type("123456789");
cy.get('input[name="phone_number"]').type("12345678");
cy.get('input[name="country"]').type("Testonia");
cy.get('input[name="city"]').type("Testheim");
cy.get('input[name="street_address"]').type("Testing street");
cy.get('input[name="username"]').type("testUser");
});
cy.get("#btn-create-account").click();
cy.contains("Registration failed!");
});
it("Testing for no password", () => {
cy.register();
cy.get("#form-register-user").within(($form) => {
cy.get('input[name="email"]').type("test@mail.it");
cy.get('input[name="password1"]').type("123456789");
cy.get('input[name="phone_number"]').type("12345678");
cy.get('input[name="country"]').type("Testonia");
cy.get('input[name="city"]').type("Testheim");
cy.get('input[name="street_address"]').type("Testing street");
cy.get('input[name="username"]').type("testUser");
});
cy.get("#btn-create-account").click();
cy.contains("Registration failed!");
});
it("Testing for no password1", () => {
cy.register();
cy.get("#form-register-user").within(($form) => {
cy.get('input[name="email"]').type("test@mail.it");
cy.get('input[name="password"]').type("123456789");
cy.get('input[name="phone_number"]').type("12345678");
cy.get('input[name="country"]').type("Testonia");
cy.get('input[name="city"]').type("Testheim");
cy.get('input[name="street_address"]').type("Testing street");
cy.get('input[name="username"]').type("testUser");
});
cy.get("#btn-create-account").click();
cy.contains("Registration failed!");
});
it("Register with invalid email", () => {
cy.register();
cy.get("#form-register-user").within(($form) => {
cy.get('input[name="username"]').type("testUser" + Date.now());
cy.get('input[name="email"]').type("123456789");
cy.get('input[name="password"]').type("123456789");
cy.get('input[name="password1"]').type("123456789");
cy.get('input[name="phone_number"]').type("12345678");
cy.get('input[name="country"]').type("Testonia");
cy.get('input[name="city"]').type("Testheim");
cy.get('input[name="street_address"]').type("Testing street");
cy.get('input[name="username"]').type("testUser");
});
cy.get("#btn-create-account").click();
cy.get(".alert").contains("Registration failed!");
});
it("Checking for boundary error with country", () => {
cy.register();
cy.get("#form-register-user").within(($form) => {
cy.get('input[name="username"]').type("testUser" + Date.now());
cy.get('input[name="email"]').type("test@mail.it");
cy.get('input[name="password"]').type("123456789");
cy.get('input[name="password1"]').type("123456789");
cy.get('input[name="country"]').type("x".repeat(51));
cy.get('input[name="city"]').type("Testheim");
cy.get('input[name="street_address"]').type("Testing street");
});
cy.get("#btn-create-account").click();
cy.contains("Registration failed!");
});
it("Checking for boundry error with street", () => {
cy.register();
cy.get("#form-register-user").within(($form) => {
cy.get('input[name="username"]').type("testUser" + Date.now());
cy.get('input[name="email"]').type("test@mail.it");
cy.get('input[name="password"]').type("123456789");
cy.get('input[name="password1"]').type("123456789");
cy.get('input[name="street_address"]').type("x".repeat(51));
});
cy.get("#btn-create-account").click();
cy.contains("Registration failed!");
});
it("Checking for max length boundary for country", () => {
cy.register();
cy.get("#form-register-user").within(($form) => {
cy.get('input[name="username"]').type("testUser" + Date.now());
cy.get('input[name="email"]').type("test@mail.it");
cy.get('input[name="password"]').type("123456789");
cy.get('input[name="password1"]').type("123456789");
cy.get('input[name="country"]').type("x".repeat(50));
cy.get('input[name="city"]').type("Testheim");
cy.get('input[name="street_address"]').type("Testing street");
});
cy.get("#btn-create-account").click();
cy.contains("View Workouts");
});
it("Checking for max boundary with street", () => {
cy.register();
cy.get("#form-register-user").within(($form) => {
cy.get('input[name="username"]').type("testUser" + Date.now());
cy.get('input[name="email"]').type("test@mail.it");
cy.get('input[name="password"]').type("123456789");
cy.get('input[name="password1"]').type("123456789");
cy.get('input[name="street_address"]').type("x".repeat(50));
});
cy.get("#btn-create-account").click();
cy.contains("View Workouts");
});
it("Checking for boundry error with phone number", () => {
cy.register();
cy.get("#form-register-user").within(($form) => {
cy.get('input[name="username"]').type("testUser" + Date.now());
cy.get('input[name="email"]').type("test@mail.it");
cy.get('input[name="password"]').type("123456789");
cy.get('input[name="password1"]').type("123456789");
cy.get('input[name="street_address"]').type("x".repeat(51));
});
cy.get("#btn-create-account").click();
cy.contains("Registration failed!");
});
it("Checking for max length boundary with phone number", () => {
cy.register();
cy.get("#form-register-user").within(($form) => {
cy.get('input[name="username"]').type("testUser" + Date.now());
cy.get('input[name="email"]').type("test@mail.it");
cy.get('input[name="password"]').type("123456789");
cy.get('input[name="password1"]').type("123456789");
cy.get('input[name="street_address"]').type("x".repeat(50));
});
cy.get("#btn-create-account").click();
cy.contains("View Workouts");
});
});
describe("Boundary testing for new workouts", () => {
beforeEach(() => {
cy.login();
Cypress.Cookies.preserveOnce("access", "refresh");
});
it("Valid creation of new workout", () => {
cy.get("#btn-create-workout").click();
cy.get("#inputName").type("Test Workout");
cy.get("#inputDateTime").type("2021-03-30T13:00");
cy.get("#inputVisibility").select("PU");
cy.get("#inputNotes").type("Notes");
const filePath = "./TestFile.txt";
cy.get("#customFile").attachFile(filePath);
cy.scrollTo("bottom");
cy.get("#div-exercises").within(($form) => {
cy.get('select[name="type"]').select("1", { force: true });
cy.get('input[name="sets"]').type("1", { force: true });
cy.get('input[name="number"]').type("1", { force: true });
});
cy.get("#btn-ok-workout").click();
cy.url().should("include", "/workouts.html");
});
it("Valid creation of new workout with only mandatory fields", () => {
cy.get("#btn-create-workout").click();
cy.get("#inputName").type("Test Workout");
cy.get("#inputDateTime").type("2021-03-30T13:00");
cy.get("#inputVisibility").select("PU");
cy.get("#inputNotes").type("Notes");
cy.get("#btn-ok-workout").click();
cy.url().should("include", "/workouts.html");
});
it("Log workout with blank fields", () => {
cy.get("#btn-create-workout").click();
cy.get("#btn-ok-workout").click();
cy.url().should("include", "/workout.html");
});
it("Log workout with no name", () => {
cy.get("#btn-create-workout").click();
cy.get("#inputDateTime").type("2021-03-30T13:00");
cy.get("#inputVisibility").select("PU");
cy.get("#inputNotes").type("Notes");
const filePath = "./TestFile.txt";
cy.get("#customFile").attachFile(filePath);
cy.scrollTo("bottom");
cy.get("#div-exercises").within(($form) => {
cy.get('select[name="type"]').select("1", { force: true });
cy.get('input[name="sets"]').type("1", { force: true });
cy.get('input[name="number"]').type("1", { force: true });
});
cy.get("#btn-ok-workout").click();
cy.contains('This field may not be blank');
});
it("Log workout with too long name", () => {
cy.get("#btn-create-workout").click();
cy.get("#inputName").type("x".repeat(101));
cy.get("#inputDateTime").type("2021-03-30T13:00");
cy.get("#inputVisibility").select("PU");
cy.get("#inputNotes").type("Notes");
const filePath = "./TestFile.txt";
cy.get("#customFile").attachFile(filePath);
cy.scrollTo("bottom");
cy.get("#div-exercises").within(($form) => {
cy.get('select[name="type"]').select("1", { force: true });
cy.get('input[name="sets"]').type("1", { force: true });
cy.get('input[name="number"]').type("1", { force: true });
});
cy.get("#btn-ok-workout").click();
cy.contains("Ensure this field has no more than 100 characters");
});
it("Log workout with max length name", () => {
cy.get("#btn-create-workout").click();
cy.get("#inputName").type("x".repeat(100));
cy.get("#inputDateTime").type("2021-03-30T13:00");
cy.get("#inputVisibility").select("PU");
cy.get("#inputNotes").type("Notes");
const filePath = "./TestFile.txt";
cy.get("#customFile").attachFile(filePath);
cy.scrollTo("bottom");
cy.get("#div-exercises").within(($form) => {
cy.get('select[name="type"]').select("1", { force: true });
cy.get('input[name="sets"]').type("1", { force: true });
cy.get('input[name="number"]').type("1", { force: true });
});
cy.get("#btn-ok-workout").click();
cy.url().should("include", "/workouts.html");