Skip to content

Commit

Permalink
Merge branch 'main' into Cypress-test-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume-Lachapelle committed Apr 12, 2024
2 parents f0cd24c + ee0592a commit cc0dc43
Show file tree
Hide file tree
Showing 23 changed files with 982 additions and 284 deletions.
8 changes: 4 additions & 4 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
"maximumWarning": "5mb",
"maximumError": "8mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
"maximumWarning": "5kb",
"maximumError": "8kb"
}
],
"outputHashing": "all"
Expand Down
39 changes: 39 additions & 0 deletions cypress/e2e/BudgetReport.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { login } from './utils.cy';
describe('Budget Report Component', () => {
beforeEach(() => {
login('[email protected]', '123456');
cy.url().should('eq', 'http://localhost:4200/');
cy.visit('/budget-report');
});

it('should display the title correctly', () => {
// Check if the title container exists and has the correct text
cy.get('.title').should('be.visible').and('contain.text', 'Budget Report');
});


it('should display the table with data', () => {
// Check if the table wrapper exists
cy.get('.table-wrapper').should('be.visible');

// Check if the table has at least one row
cy.get('table').find('tr').should('have.length.gt', 1);

// Check if the table headers are correct
cy.get('table').find('th').should('have.length', 4);
cy.get('table').find('th').eq(0).should('contain.text', 'Building');
cy.get('table').find('th').eq(1).should('contain.text', 'Condo Fee Revenue');
cy.get('table').find('th').eq(2).should('contain.text', 'Operation Costs');
cy.get('table').find('th').eq(3).should('contain.text', 'Profit');
});

it('should display the total row with correct totals', () => {
cy.get('.total-row').should('be.visible');

// Check if the total row contains the correct total values
cy.get('.total-condo-fee').should('contain.text', '$0.00');
cy.get('.total-operation-cost').should('contain.text', '$92.00');
cy.get('.total-profit').should('contain.text', '-$92.00');
});
});

6 changes: 3 additions & 3 deletions cypress/e2e/IndividualCondoPageTest.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ function checkCondoDetails() {
cy.get('.property-images img')
.should('have.attr', 'src')
.should('not.be.empty');
cy.get('.icon-favorite').should('be.visible');
cy.get('.icon-share').should('be.visible');
cy.get('.icon-refresh').should('be.visible');
cy.get('.icon-favorite').scrollIntoView().should('be.visible');
cy.get('.icon-share').scrollIntoView().should('be.visible');
cy.get('.icon-refresh').scrollIntoView().should('be.visible');
cy.get('app-condo-features').scrollIntoView().should('be.visible');
cy.get('app-description').scrollIntoView().should('be.visible');
cy.get('app-location').scrollIntoView().should('be.visible');
Expand Down
172 changes: 172 additions & 0 deletions cypress/e2e/Key-Registration.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
import { login } from './utils.cy';

describe('Key Registration Component', () => {
beforeEach(() => {
login('[email protected]', 'Mosalah99');
cy.wait(5000);
cy.visit('/key-registration');
});


it('should display visit the page', () => {
cy.visit('/key-registration');
});

it('should register Condo key when input is filled and register button is clicked', () => {
// Type a registration key
const registrationKey = 'olxoxbbx02n1712215786582';
cy.get('input[name="registrationKey"]')
.type(registrationKey)
.should('have.value', registrationKey);

// Wait for registration type dropdown to be visible and then select a registration type
cy.get('.registrationType', { timeout: 10000 })
.should('be.visible')
.click({ force: true });
cy.contains('.condo', 'Condo').click({ force: true }); // Select the desired registration type

// Click the register button
cy.contains('button', 'Register').click({ force: true });

cy.on('window:alert', (str) => {
expect(str).to.equal('Successfully registered!'); // Assert the alert message
});
});

it('should register Parking key when input is filled and register button is clicked', () => {
// Type a registration key
const registrationKey = 'zn9ii2r6z3p1712215786584';
cy.get('input[name="registrationKey"]')
.type(registrationKey)
.should('have.value', registrationKey);

// Wait for registration type dropdown to be visible and then select a registration type
cy.get('.registrationType', { timeout: 10000 })
.should('be.visible')
.click({ force: true });
cy.contains('.parking', 'Parking').click({ force: true }); // Select the desired registration type

// Click the register button
cy.contains('button', 'Register').click({ force: true });

cy.on('window:alert', (str) => {
expect(str).to.equal('Successfully registered!'); // Assert the alert message
});
});

it('should register Locker key when input is filled and register button is clicked', () => {
// Type a registration key
const registrationKey = 'gfcaeu208jw1712215786583';
cy.get('input[name="registrationKey"]')
.type(registrationKey)
.should('have.value', registrationKey);

// Wait for registration type dropdown to be visible and then select a registration type
cy.get('.registrationType', { timeout: 10000 })
.should('be.visible')
.click({ force: true });
cy.contains('.locker', 'Locker').click({ force: true }); // Select the desired registration type

// Click the register button
cy.contains('button', 'Register').click({ force: true });

cy.on('window:alert', (str) => {
expect(str).to.equal('Successfully registered!'); // Assert the alert message
});
});

it('should display an error message if input value is empty', () => {
// Click the register button without entering a key
cy.contains('button', 'Register').click({ force: true });

// Assert error message is shown
cy.on('window:alert', (str) => {
expect(str).to.equal('Input value is empty!');
});
});

it('should handle empty registration key input', () => {
// Click the register button without entering a key
cy.get('input[name="registrationKey"]').clear();
cy.contains('button', 'Register').click({ force: true });

// Assert error message is shown
cy.on('window:alert', (str) => {
expect(str).to.equal('Input value is empty!');
});
});

it('should handle special characters in registration key input', () => {
// Type a registration key with special characters
const registrationKey = '!@#$%^&*()';
cy.get('.registrationType', { timeout: 10000 })
.should('be.visible')
.click({ force: true });
cy.contains('button', 'Register').click({ force: true });

// Assert error message is shown
cy.on('window:alert', (str) => {
expect(str).to.equal('Invalid registration key!');
});
});

it('should display an error message if registration key is invalid for condo registration', () => {
// Type an invalid registration key
const registrationKey = 'invalid-key';
cy.get('input[name="registrationKey"]').type(registrationKey);

// Select condo registration type
cy.get('.registrationType', { timeout: 10000 })
.should('be.visible')
.click({ force: true });
cy.contains('.condo', 'Condo').click({ force: true }); // Select the desired registration type

// Click the register button
cy.contains('button', 'Register').click({ force: true });

// Assert error message is shown
cy.on('window:alert', (str) => {
expect(str).to.equal('Invalid registration key!');
});
});

it('should display an error message if registration key is invalid for parking registration', () => {
// Type an invalid registration key
const registrationKey = 'invalid-key';
cy.get('input[name="registrationKey"]').type(registrationKey);

// Select parking registration type
cy.get('.registrationType', { timeout: 10000 })
.should('be.visible')
.click({ force: true });
cy.contains('.parking', 'Parking').click({ force: true }); // Select the desired registration type

// Click the register button
cy.contains('button', 'Register').click({ force: true });

// Assert error message is shown
cy.on('window:alert', (str) => {
expect(str).to.equal('Invalid registration key!');
});
});

it('should display an error message if registration key is invalid for locker registration', () => {
// Type an invalid registration key
const registrationKey = 'invalid-key';
cy.get('input[name="registrationKey"]').type(registrationKey);

// Select locker registration type
cy.get('.registrationType', { timeout: 10000 })
.should('be.visible')
.click({ force: true });
cy.contains('.locker', 'Locker').click({ force: true }); // Select the desired registration type

// Click the register button
cy.contains('button', 'Register').click({ force: true });

// Assert error message is shown
cy.on('window:alert', (str) => {
expect(str).to.equal('Invalid registration key!');
});
});
});
4 changes: 2 additions & 2 deletions cypress/e2e/LoginAndProfilePage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ describe('Test Profile Page', () => {
// Click on the profile icon and then on the profile button
cy.get('#p-icon')
.click();
cy.get('#p-btn', { timeout: 10000 }).should('exist');
cy.get('#p-btn')
cy.get('#user-profile', { timeout: 10000 }).should('exist');
cy.get('#user-profile')
.click({ force: true });
cy.url().should('eq', 'http://localhost:4200/user-profile');

Expand Down
16 changes: 8 additions & 8 deletions cypress/e2e/NotificationBarAndPage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { login } from './utils.cy';

const checkBadge = (badgeHidden: boolean, value: string) => {
if (badgeHidden) {
cy.get('.nav-item a.notifications button').should(
cy.get('a.notifications button').should(
'not.have.attr',
'matBadgeHidden'
);
}
cy.get('.nav-item a.notifications button mat-icon')
cy.get('a.notifications button mat-icon')
.invoke('attr', 'data-badge')
.should('equal', value);
};
Expand All @@ -21,8 +21,8 @@ describe('Test Notifications', () => {
it('Check notification button', () => {
login('[email protected]', '123456');

cy.get('.nav-item a.notifications').should('be.visible');
cy.get('.nav-item a.notifications').click({ force: true });
cy.get('a.notifications').should('be.visible');
cy.get('a.notifications').click({ force: true });

cy.url().should('eq', 'http://localhost:4200/notifications');
});
Expand All @@ -34,9 +34,9 @@ describe('Test Notifications', () => {
it('Check notification bar badge', () => {
login('[email protected]', '123456');

cy.get('.nav-item a.notifications').should('be.visible');
cy.get('a.notifications').should('be.visible');

cy.get('.nav-item a.notifications').should('be.visible');
cy.get('a.notifications').should('be.visible');
checkBadge(true, '1');
});

Expand All @@ -50,7 +50,7 @@ describe('Test Notifications', () => {
it('Check mark as read', () => {
login('[email protected]', '123456');

cy.get('.nav-item a.notifications').click({ force: true });
cy.get('a.notifications').click({ force: true });

cy.wait(2000);

Expand All @@ -76,7 +76,7 @@ describe('Test Notifications', () => {
it('Check mark as unread', () => {
login('[email protected]', '123456');

cy.get('.nav-item a.notifications').click({ force: true });
cy.get('a.notifications').click({ force: true });

cy.wait(2000);

Expand Down
Loading

0 comments on commit cc0dc43

Please sign in to comment.