Skip to content

Commit

Permalink
Merge pull request #1130 from Aam-Digital/master
Browse files Browse the repository at this point in the history
Release 3.1.0
  • Loading branch information
TheSlimvReal authored Mar 3, 2022
2 parents d2376e4 + 78ed5ac commit 8ac29a0
Show file tree
Hide file tree
Showing 45 changed files with 2,770 additions and 1,795 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/master-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,19 @@ jobs:
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: snyk.sarif
run-e2e-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cypress run
uses: cypress-io/github-action@v2
with:
command: npm run e2e-ci
env:
# pass the Dashboard record key as an environment variable
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# pass GitHub token to allow accurately detecting a build vs a re-run build
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# pass the project ID from the secrets through environment variable
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}

16 changes: 16 additions & 0 deletions .github/workflows/pull-request-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,19 @@ jobs:
docker tag prod-image registry.heroku.com/${name}/web
docker push registry.heroku.com/${name}/web
heroku container:release -a ${name} web
run-e2e-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cypress run
uses: cypress-io/github-action@v2
with:
command: npm run e2e-ci
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# We set the commit message to the pull request title
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
# pass GitHub token to allow accurately detecting a build vs a re-run build
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# pass the project ID from the secrets through environment variable
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
[![Build Status](https://github.com/Aam-Digital/ndb-core/actions/workflows/master-push.yml/badge.svg)](https://github.com/Aam-Digital/ndb-core/actions/workflows/master-push.yml)
[![Code Climate](https://codeclimate.com/github/Aam-Digital/ndb-core/badges/gpa.svg)](https://codeclimate.com/github/Aam-Digital/ndb-core)
[![Test Coverage](https://api.codeclimate.com/v1/badges/4e4a7a6301064019b2c9/test_coverage)](https://codeclimate.com/github/Aam-Digital/ndb-core/test_coverage)
[![E2E Tests](https://img.shields.io/endpoint?url=https://dashboard.cypress.io/badge/simple/2petka/master&style=flat&logo=cypress)](https://dashboard.cypress.io/projects/2petka/runs)
[![Guides](https://img.shields.io/badge/Tutorial%20%26%20Guides-20-blue)](https://aam-digital.github.io/ndb-core/documentation/additional-documentation/overview.html)
[![Doc CoverageDocs](https://aam-digital.github.io/ndb-core/documentation/images/coverage-badge-documentation.svg)](https://aam-digital.github.io/ndb-core/documentation/modules.html)
[![Known Vulnerabilities](https://snyk.io/test/github/Aam-Digital/ndb-core/badge.svg)](https://snyk.io/test/github/Aam-Digital/ndb-core)
Expand Down
14 changes: 3 additions & 11 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,17 +239,6 @@
"exclude": []
}
},
"cypress-run": {
"builder": "@cypress/schematic:cypress",
"options": {
"devServerTarget": "ndb-core-e2e:serve"
},
"configurations": {
"production": {
"devServerTarget": "ndb-core-e2e:serve:production"
}
}
},
"cypress-open": {
"builder": "@cypress/schematic:cypress",
"options": {
Expand All @@ -268,6 +257,9 @@
"configurations": {
"production": {
"devServerTarget": "ndb-core-e2e:serve:production"
},
"ci": {
"record": true
}
}
}
Expand Down
49 changes: 49 additions & 0 deletions e2e/integration/LinkingChildToSchool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
describe("Scenario: Linking a child to a school - E2E test", () => {
before(() => {
// GIVEN I am on the details page of a child
cy.visit("");
cy.create("Children", "E2E Child");
cy.create("Schools", "E2E School");
cy.get("[ng-reflect-angulartics-label=Children]").click();
});

// WHEN I add an entry in the 'Previous Schools' section with a specific school
it("Add an entry in the Previous School section", function () {
// type to the input "Filter" the name of child
cy.get('[data-placeholder="e.g. name, age"]').type("E2E Child");

// Click on the Child in Table list
cy.get("tbody > :nth-child(1)").click();

// get the Education button and click on it
cy.contains("div", "Education").should("be.visible").click();

// get the Add School button and click on it
cy.get(
"app-previous-schools.ng-star-inserted > app-entity-subrecord > .mat-elevation-z1 > .mat-table > thead > .mat-header-row > .cdk-column-actions > .mat-focus-indicator"
)
.should("be.visible")
.click();

// choose the school to add
cy.get('[ng-reflect-placeholder="Select School"]')
.type("E2E School")
.click();

// save school in child profile
cy.contains("button", "Save").click();
// wait for the popup-close animation
cy.wait(100);
});

// THEN I can see that child in the 'Children Overview' of the details page of this school
it("Check for child in Children Overview of specific school", function () {
// Click on the school that was added to the child profile
cy.contains("span", "E2E School").click();
// Open the students overview
cy.contains("div", "Students").should("be.visible").click();

// Check if student is in the school students list
cy.contains("app-children-overview > app-entity-subrecord", "E2E Child");
});
});
61 changes: 0 additions & 61 deletions e2e/integration/LinkingChildToSchool/LinkingChildToSchool.ts

This file was deleted.

42 changes: 42 additions & 0 deletions e2e/integration/MarkingChildAsDropout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
describe("Scenario: Marking a child as dropout - E2E test", () => {
before(() => {
// GIVEN I am on the details page of a specific child
// go to the url with the Child
cy.visit("child/1");
// save the name of this Child to the variable
cy.get(".header-row > .header-title").invoke("text").as("childName");
});

// WHEN I select a dropout date for this child
it("Select a dropout date for the child", function () {
// click on "Dropout" menu
cy.contains("Dropout").click();
cy.get("#mat-tab-label-0-7").click();
// click on button with the content "Edit" in Dropout menu.
cy.contains("span", "Edit").should("be.visible").click();
// select today as the dropout date (which is initially marked as active)
cy.get(".mat-datepicker-toggle-default-icon").click();
cy.get(".mat-calendar-body-active").click();
// click on button with the content "Save"
cy.contains("span", "Save").should("be.visible").click();
});

// THEN I should not see this child in the list of all children at first
it("This child is not in the list of all children at first", function () {
// click on "Children" menu in navigation
cy.get('[ng-reflect-angulartics-label="Children"]').click();
// type to the input "Filter" the name of child
cy.get('[data-placeholder="e.g. name, age"]').type(this.childName);
// find at this table the name of child and it should not exist
cy.get("table").contains(this.childName.trim()).should("not.exist");
});

// AND I should see the child when I activate the 'inactive' filter
it("The child is seen when the 'inactive' filter activated", function () {
// click on the button with the content "Inactive"
cy.get('[ng-reflect-placeholder="isActive"]').click();
cy.contains("span", "Inactive").should("be.visible").click();
// find at this table the name of child and it should exist
cy.get("table").contains(this.childName.trim()).should("exist");
});
});
40 changes: 40 additions & 0 deletions e2e/integration/RecordingAttendanceOfChild.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
describe("Scenario: Recording attendance of a child - E2E test", () => {
before(() => {
// GIVEN A specific child is attending a specific class
cy.visit("attendance");
});

// WHEN I record attendance for this class
it("Record attendance for the class", function () {
cy.get(".mat-card", { timeout: 10000 }).should("be.visible").eq(0).click();
cy.contains("button", "Record").click();
});

// AND I set the attendance of the specific child to 'present'
it("set the attendance of the specific child to 'present'", function () {
cy.contains("button", "Show more").click({ scrollBehavior: "center" });
cy.contains("mat-card", "School Class")
.eq(0)
.click({ scrollBehavior: "center" });
cy.get(".options-wrapper > :nth-child(1)").click();
cy.get('[fxflex=""] > .ng-star-inserted > .mat-focus-indicator').click();
cy.contains("button", "Save").click();
});

// THEN in the details page of this child under 'attendance' for the specific class I should see a green background for the current day
it("In the details page of this child under 'attendance' for the specific class should be a green background for the current day", function () {
cy.get(".mat-card", { timeout: 10000 })
.should("be.visible")
.eq(0)
.click({ force: true });
// Click on ChildBlock inside roll-call to navigate to child
cy.get(".navigation-bar > :nth-child(1)").click();
cy.get(".child-block").click();
cy.get("#mat-tab-label-0-2").click();
cy.get(".attendance-P").should(
"have.css",
"background-color",
"rgb(200, 230, 201)"
);
});
});
40 changes: 29 additions & 11 deletions e2e/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,37 @@
// with Intellisense and code completion in your
// IDE or Text Editor.
// ***********************************************
// declare namespace Cypress {
// interface Chainable<Subject = any> {
// customCommand(param: any): typeof customCommand;
// }
// }
//
// function customCommand(param: any): void {
// console.warn(param);
// }
declare namespace Cypress {
interface Chainable<Subject = any> {
/**
* Create a child or school with the given name
* @param menuItem name e.g. 'Children' or 'Schools' where a entity should be created
* @param name of the entity that should be created
*/
create(menuItem: string, name: string): typeof create;
}
}

function create(menuItem: string, name: string): void {
cy.get(`[ng-reflect-angulartics-label="${menuItem}"]`).click();
cy.contains("button", "Add New").click();
cy.get("[ng-reflect-placeholder=Name]").type(name);
cy.contains("button", "Save").click();
}

//
// NOTE: You can use it like so:
// Cypress.Commands.add('customCommand', customCommand);
//
Cypress.Commands.add("create", create);
// Overwriting default visit function to wait for index creation
Cypress.Commands.overwrite("visit", (originalFun, url, options) => {
originalFun(url, options);
cy.get("app-search").should("be.visible");
cy.wait(4000);
cy.contains("button", "Continue in background", { timeout: 10000 }).should(
"not.exist"
);
});

// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
Expand Down
2 changes: 1 addition & 1 deletion e2e/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
// ***********************************************************

// When a command from ./commands is ready to use, import with `import './commands'` syntax
// import './commands';
import './commands';
Loading

0 comments on commit 8ac29a0

Please sign in to comment.