Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ClientApp/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"src/assets"
],
"styles": [
"./node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css",
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/styles.css"
],
Expand Down Expand Up @@ -95,6 +96,7 @@
"src/assets"
],
"styles": [
"./node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css",
"src/styles.css"
],
"scripts": []
Expand Down
10 changes: 10 additions & 0 deletions ClientApp/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from "cypress";

export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
baseUrl: "https://localhost:44409/"
},
});
83 changes: 83 additions & 0 deletions ClientApp/cypress/e2e/sanctioned_entities.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
describe('Sanctioned entities', () => {
beforeEach(() => {
// Visiting the page before each test
cy.visit('https://localhost:44409/sanctioned-entities'); // Update with your application's URL if needed
});

it('should load and display the list of entities', () => {
// Wait for the entities to load (simulate API call response)
cy.wait(1000); // You can adjust this wait or use intercept to mock API calls

// Verify that the table is displayed after loading
cy.get('table[aria-labelledby="tableLabel"]').should('exist');
});

it('should open the Create Entity modal when clicking "Create Entity" button', () => {
// Click the Create Entity button
cy.get('button').contains('Create Entity').click();
cy.wait(2000);

// Verify the modal is open by checking the modal title
cy.get('h2').contains('Create Sanctioned Entity').should('be.visible');
cy.get('form').should('be.visible');
});

it('should close the modal when clicking "Cancel"', () => {
// Open the modal
cy.get('button').contains('Create Entity').click();

cy.wait(2000);

// Click the Cancel button in the modal
cy.get('button').contains('Cancel').click();

// Verify that the modal is closed (modal should no longer be visible)
cy.get('h2#mat-dialog-title-0').should('not.exist');
});

it('should create a new entity and close the modal', () => {
// Open the modal
cy.get('button').contains('Create Entity').click();
cy.wait(2000);

// Fill in the form fields (assuming you have input fields for entity name, etc.)
cy.get('input[formControlName="name"]').type('New Entity Name');
cy.get('input[formControlName="domicile"]').type('New Entity Name');
cy.get('input#statusSwitch').check();

cy.wait(2000);

// Click the Create button
cy.get('button[type="submit"]').click();

// Verify that the new entity is in the table (assuming the table updates after creation)
cy.get('table tbody tr').last().contains('New Entity Name');
});

it('should display the entity status correctly', () => {

// any td with text-success means Accepted and vice a versa
cy.get('table td.text-success').should('contain', 'Accepted');
cy.get('table td.text-danger').should('contain', 'Rejected');

});

it('should show an error message for required fields when the form is submitted without filling in the fields', () => {
cy.get('button').contains('Create Entity').click();
cy.wait(1000);

// Touch Name field
cy.get('input[formControlName="name"]').focus().blur();

// Touch Domicile field
cy.get('input[formControlName="domicile"]').focus().blur();

// Check for validation errors on Name and Domicile fields
cy.get('mat-error').should('contain', 'Name is required.');
cy.get('mat-error').should('contain', 'Domicile is required.');

//submit button should be disabled state
cy.get('button[type="submit"]').should('be.disabled');
cy.wait(1000);
});
});
5 changes: 5 additions & 0 deletions ClientApp/cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
37 changes: 37 additions & 0 deletions ClientApp/cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
17 changes: 17 additions & 0 deletions ClientApp/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ***********************************************************
// This example support/e2e.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'
Loading