From 566b9eb74da527052c39bb4fe6309e174922f6c0 Mon Sep 17 00:00:00 2001 From: Aurelijus Banelis Date: Sun, 10 Nov 2019 18:34:34 +0200 Subject: [PATCH 01/12] Building project and smoke tests So it would be easier to test, if all parts are connected correctly. Documentation: * https://help.github.com/en/actions/automating-your-workflow-with-github-actions * https://symfony.com/doc/current/routing.html#debugging-routes --- .github/workflows/symfony-hw-1.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/symfony-hw-1.yml diff --git a/.github/workflows/symfony-hw-1.yml b/.github/workflows/symfony-hw-1.yml new file mode 100644 index 000000000..75fbbd3c2 --- /dev/null +++ b/.github/workflows/symfony-hw-1.yml @@ -0,0 +1,23 @@ +name: Symfony 1 Homework +on: push +jobs: + build: + name: Build and test for Symfony 1 Homework + runs-on: ubuntu-latest + steps: + # Prepare dependencies + - uses: actions/checkout@v1 + - name: Start containers + run: ./scripts/start.sh + - name: Temporary fix for permissions (different docekr users) + run: chmod 777 . && chmod 777 public + - name: Install dependencies + run: ./scripts/install-prod.sh + + # Fast tests + - name: Smoke test for infrastructure + if: always() + run: curl -v http://127.0.0.1:8000 + - name: List used routes + if: always() + run: ./scripts/backend.sh bin/console debug:router \ No newline at end of file From b2d5f5f8143034d77a8012efb5cc909c29af7fbe Mon Sep 17 00:00:00 2001 From: Aurelijus Banelis Date: Sun, 10 Nov 2019 18:45:03 +0200 Subject: [PATCH 02/12] Running end to end (Browser) tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So it would be clear, that all parts are working correctly, leaving more time to Code review. Adding screenshots and debugging intermediate results, so it would be faster to evaluate and/or fix issues. Using Cypress as one of Headless browser based test framework. Cypress is running browser as a separate process, so it was needed for custom debug function to see intermediate results in GitHub actions as well. Using e2e-tests.sh to reach docker network used by docker-compose.yml. Initial idea was to use GitHub Checks Annotations, but Cypress already formats output with colors. So using just different indentation. Video recording disabled to not abuse GitHub – it already does tremendous job. Using GitHub Action "if: always()" to store screenshots for both successful builds and errors. Documentation: * https://www.cypress.io/ * https://github.com/cypress-io/cypress/issues/3199 * https://help.github.com/en/actions/automating-your-workflow-with-github-actions/development-tools-for-github-actions#set-a-warning-message-warning * https://help.github.com/en/actions/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#job-status-check-functions --- .github/workflows/symfony-hw-1.yml | 14 +++++++++++++- .gitignore | 7 +++++++ scripts/e2e-tests.sh | 16 ++++++++++++++++ tests/e2e/cypress.json | 5 +++++ tests/e2e/cypress/integration/symfony-hw1.js | 17 +++++++++++++++++ tests/e2e/cypress/plugins/index.js | 18 ++++++++++++++++++ tests/e2e/cypress/support/commands.js | 5 +++++ tests/e2e/cypress/support/index.js | 1 + 8 files changed, 82 insertions(+), 1 deletion(-) create mode 100755 scripts/e2e-tests.sh create mode 100755 tests/e2e/cypress.json create mode 100644 tests/e2e/cypress/integration/symfony-hw1.js create mode 100755 tests/e2e/cypress/plugins/index.js create mode 100755 tests/e2e/cypress/support/commands.js create mode 100755 tests/e2e/cypress/support/index.js diff --git a/.github/workflows/symfony-hw-1.yml b/.github/workflows/symfony-hw-1.yml index 75fbbd3c2..c813eee3b 100644 --- a/.github/workflows/symfony-hw-1.yml +++ b/.github/workflows/symfony-hw-1.yml @@ -20,4 +20,16 @@ jobs: run: curl -v http://127.0.0.1:8000 - name: List used routes if: always() - run: ./scripts/backend.sh bin/console debug:router \ No newline at end of file + run: ./scripts/backend.sh bin/console debug:router + + # Browser based tests + - name: Download Cypress dependencies + run: docker pull "cypress/included:3.2.0" + - name: Run end-to-end test + run: ./scripts/e2e-tests.sh + - name: Store cypress test results (screenshots) + uses: actions/upload-artifact@v1 + if: always() + with: + name: cypress-screenshots + path: tests/e2e/cypress/screenshots diff --git a/.gitignore b/.gitignore index 3a5a2a62d..3eded10c6 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,10 @@ yarn-error.log /.phpcs-cache /phpcs.xml ###< squizlabs/php_codesniffer ### + + +###> cypress ### +/tests/e2e/cypress/screenshots +/tests/e2e/cypress/videos +###< cypress ### + diff --git a/scripts/e2e-tests.sh b/scripts/e2e-tests.sh new file mode 100755 index 000000000..a82375787 --- /dev/null +++ b/scripts/e2e-tests.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +# Make us independent from working directory +pushd `dirname $0` > /dev/null +SCRIPT_DIR=`pwd` +popd > /dev/null + +NETWORK=$(docker inspect nginx.symfony --format='{{range $networkName, $details := .NetworkSettings.Networks}}{{$networkName}}{{end}}') + +docker run \ + --volume "${SCRIPT_DIR}/../tests/e2e:/e2e" \ + --workdir="/e2e" \ + --entrypoint=cypress \ + --network="${NETWORK}" \ + "cypress/included:3.2.0" \ + run --env "BASE_URL=http://nginx.symfony:80" diff --git a/tests/e2e/cypress.json b/tests/e2e/cypress.json new file mode 100755 index 000000000..a5f7a6010 --- /dev/null +++ b/tests/e2e/cypress.json @@ -0,0 +1,5 @@ +{ + "baseUrl": "https://hw1.nfq2019.online", + "projectId": "nfqacademy", + "video": false +} \ No newline at end of file diff --git a/tests/e2e/cypress/integration/symfony-hw1.js b/tests/e2e/cypress/integration/symfony-hw1.js new file mode 100644 index 000000000..66fbd583c --- /dev/null +++ b/tests/e2e/cypress/integration/symfony-hw1.js @@ -0,0 +1,17 @@ +const basePath = Cypress.env('BASE_URL') ? Cypress.env('BASE_URL') : 'https://hw1.nfq2019.online'; + +const d = async (message) => { + console.info('D', message); + await cy.ciDebug(message); +}; +const dd = async (message) => { + console.log('DD', message); + await cy.ciLog(message); +}; + +describe('First homework', function() { + it('Whole page', () => { + cy.visit(basePath); + cy.screenshot(); + }); +}); diff --git a/tests/e2e/cypress/plugins/index.js b/tests/e2e/cypress/plugins/index.js new file mode 100755 index 000000000..3771fddfc --- /dev/null +++ b/tests/e2e/cypress/plugins/index.js @@ -0,0 +1,18 @@ +module.exports = on => { + on('task', { + log(message) { + console.log(message); + return null + }, + /** @return {null} */ + LOG_DEBUG_CONSOLE(message) { + console.log(` : ${message}`); + return null; + }, + /** @return {null} */ + LOG_LOG_CONSOLE(message) { + console.log(` : ${message}`); + return null; + } + }); +}; diff --git a/tests/e2e/cypress/support/commands.js b/tests/e2e/cypress/support/commands.js new file mode 100755 index 000000000..ab2a5c218 --- /dev/null +++ b/tests/e2e/cypress/support/commands.js @@ -0,0 +1,5 @@ +Cypress.Commands.overwrite('log', (subject, message) => cy.task('log', message)); + + +Cypress.Commands.add('ciDebug', (message) => cy.task('LOG_DEBUG_CONSOLE', message)); +Cypress.Commands.add('ciLog', (message) => cy.task('LOG_LOG_CONSOLE', message)); diff --git a/tests/e2e/cypress/support/index.js b/tests/e2e/cypress/support/index.js new file mode 100755 index 000000000..43c03b759 --- /dev/null +++ b/tests/e2e/cypress/support/index.js @@ -0,0 +1 @@ +import './commands' From 41878c5467db35b4e68788b62fa6d795f3cb2b0f Mon Sep 17 00:00:00 2001 From: Aurelijus Banelis Date: Sun, 10 Nov 2019 18:47:44 +0200 Subject: [PATCH 03/12] Tests for Symfony 1 Homework Intention is to create similar project in symfony, as is deployed on https://hw1.nfq2019.online Note: https://hw1.nfq2019.online/students.json can be useful. --- tests/e2e/cypress/integration/symfony-hw1.js | 65 ++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/tests/e2e/cypress/integration/symfony-hw1.js b/tests/e2e/cypress/integration/symfony-hw1.js index 66fbd583c..503d4ef5f 100644 --- a/tests/e2e/cypress/integration/symfony-hw1.js +++ b/tests/e2e/cypress/integration/symfony-hw1.js @@ -10,8 +10,73 @@ const dd = async (message) => { }; describe('First homework', function() { + it('Have students block', () => { + cy.visit(basePath); + cy.contains("Studentai") + .parent() + .children('.list-group-item:not(.list-group-item-info)') + .then(data => data.map((index, element) => element.innerText).get()) + .then(students => { + cy.wrap(students).each(student => dd(`Student: ${student}`)); + }).then( students => { + assert.equal(students.length, 46, "Expected 46 elements of students"); + }).then( students => { + cy.wrap(students).each(e => { + expect(e).contain("Mentorius"); + }) + }); + + cy.contains("Studentai").parent().screenshot(); + }); + it('Have correct students-mentor data', () => { + cy.visit(basePath); + cy.contains("Studentai") + .parent() + .children('.list-group-item:not(.list-group-item-info)') + .first() + .contains("Tadas") + .parent() + .contains("Mantas"); + }); + + it('Have project block', () => { + cy.visit(basePath); + cy.contains("Projektai").parent().screenshot(); + }); + + it('Have form block', () => { + cy.visit(basePath); + cy.contains("Sužinoti vertinimą").parent().screenshot(); + }); + it('Whole page', () => { cy.visit(basePath); cy.screenshot(); }); + + it('Click on first student', () => { + cy.visit(basePath); + cy.contains("Studentai") + .parent() + .children('.list-group-item:not(.list-group-item-info)') + .first().children('a').click(); + + d("Expected inner page"); + cy.contains("Studentas"); + cy.contains("Projektas"); + cy.screenshot(); + + cy.contains("Visi studentai").click() + }); + + it('Click on Data file', () => { + cy.visit(basePath); + cy.contains("Duomenų failas").then( a => { + const link = a.attr('href'); + cy.wrap([link]).each(link => dd(`Data file link: ${link}`)) + }).then( links => { + const link = links[0]; + expect(link).to.eq("students.json"); + }) + }); }); From 852deab376ff9624fa473658269ad33828170538 Mon Sep 17 00:00:00 2001 From: Aurelijus Banelis Date: Sun, 10 Nov 2019 19:25:32 +0200 Subject: [PATCH 04/12] Run tests on Pull requests --- .github/workflows/symfony-hw-1.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/symfony-hw-1.yml b/.github/workflows/symfony-hw-1.yml index c813eee3b..73dc36362 100644 --- a/.github/workflows/symfony-hw-1.yml +++ b/.github/workflows/symfony-hw-1.yml @@ -1,5 +1,7 @@ name: Symfony 1 Homework -on: push +on: + - push + - pull_request jobs: build: name: Build and test for Symfony 1 Homework From 5a7fa65f892d5cfca8f4a7ae236c258775320503 Mon Sep 17 00:00:00 2001 From: Aurelijus Banelis Date: Sun, 10 Nov 2019 19:27:38 +0200 Subject: [PATCH 05/12] Run tests on Pull requests --- .github/workflows/symfony-hw-1.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/symfony-hw-1.yml b/.github/workflows/symfony-hw-1.yml index 73dc36362..600e4709a 100644 --- a/.github/workflows/symfony-hw-1.yml +++ b/.github/workflows/symfony-hw-1.yml @@ -1,6 +1,5 @@ name: Symfony 1 Homework on: - - push - pull_request jobs: build: From 6717585ed16e9f63d3c81ffbc76444f004f5ba72 Mon Sep 17 00:00:00 2001 From: Aurelijus Banelis Date: Mon, 11 Nov 2019 22:45:18 +0200 Subject: [PATCH 06/12] More tests To cover other edge cases. --- tests/e2e/cypress/integration/symfony-hw1.js | 59 ++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/tests/e2e/cypress/integration/symfony-hw1.js b/tests/e2e/cypress/integration/symfony-hw1.js index 503d4ef5f..f9672fc93 100644 --- a/tests/e2e/cypress/integration/symfony-hw1.js +++ b/tests/e2e/cypress/integration/symfony-hw1.js @@ -79,4 +79,63 @@ describe('First homework', function() { expect(link).to.eq("students.json"); }) }); + + it('Have properly escaped student', () => { + cy.visit(basePath); + cy.contains("Studentai") + .parent() + .children() + .last() + .contains(`Ir jo "geras" draug'as`) + .then( element => { + const link = element.get(0).href; + assert( + link.endsWith('?name=%3Cb%3EIr%3C/b%3E%20jo%20%22geras%22%20draug%27as&project=hack%3Cb%3Eer%3C/b%3E%27is%20po%20.mySubdomain%20%26project%3D123'), + 'Expected urlencoded Twig filter' + ); + }) + }); + + it('Have properly escaped Projektai', () => { + cy.visit(basePath); + cy.contains("Projektai") + .parent() + .children() + .last(). + contains(`' OR 1 -- DROP DATABASE`) + .parent() + .contains(`github.com/nfqakademija/hacker'is po .mySubdomain &project=123`) + .parent() + .parent() + .contains(`hacker'is po .mySubdomain &project=123.projektai.nfqakademija.lt/`) + .then( element => { + const link = element.get(0).href; + expect(link).to.eq(`http://hack%3Cb%3Eer%3C%2Fb%3E%27is%20po%20.mysubdomain%20%26project%3D123.projektai.nfqakademija.lt/`); + }) + .parent() + .parent() + .contains(`ssh hacker'is po .mySubdomain &project=123@deploy.nfqakademija.lt -p 2222`) + }); + + it('Have correct person with good evaluation', () => { + cy.visit(basePath); + cy.contains("Studentai") + .parent() + .children('.list-group-item:not(.list-group-item-info)') + .children("a") + .then( elements => { + cy.wrap(elements).each(element => { + let path = element.get(0).href; + cy.visit(path).get('.alert, .success').then( data => { + if (data.get(0).innerText === 'Dešimt balų') { + cy.screenshot() + cy.wrap([path]).each( path => { + dd(`Įvertinti: ${path}`); + }); + + } + }); + }); + }); + }); }); From 21aa76a7f18d7980e80170f8067d306390d912c9 Mon Sep 17 00:00:00 2001 From: Aurelijus Banelis Date: Thu, 14 Nov 2019 08:46:02 +0200 Subject: [PATCH 07/12] Git ignore for local Cypress --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 3eded10c6..656492125 100644 --- a/.gitignore +++ b/.gitignore @@ -37,5 +37,8 @@ yarn-error.log ###> cypress ### /tests/e2e/cypress/screenshots /tests/e2e/cypress/videos +tests/e2e/package.json +tests/e2e/yarn.lock +tests/e2e/node_modules ###< cypress ### From 8697c8cd65dabe2d7ba610da33cd5f4803dbc497 Mon Sep 17 00:00:00 2001 From: Aurelijus Banelis Date: Thu, 14 Nov 2019 08:58:06 +0200 Subject: [PATCH 08/12] Fix tests for students grouping There was an error in https://hw1.nfq2019.online/ There should be 51 real students instead of 46 unique names. --- tests/e2e/cypress/integration/symfony-hw1.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/e2e/cypress/integration/symfony-hw1.js b/tests/e2e/cypress/integration/symfony-hw1.js index f9672fc93..480d7cc79 100644 --- a/tests/e2e/cypress/integration/symfony-hw1.js +++ b/tests/e2e/cypress/integration/symfony-hw1.js @@ -1,4 +1,4 @@ -const basePath = Cypress.env('BASE_URL') ? Cypress.env('BASE_URL') : 'https://hw1.nfq2019.online'; +const basePath = Cypress.env('BASE_URL') ? Cypress.env('BASE_URL') : 'http://127.0.0.1:8000/'; const d = async (message) => { console.info('D', message); @@ -19,7 +19,7 @@ describe('First homework', function() { .then(students => { cy.wrap(students).each(student => dd(`Student: ${student}`)); }).then( students => { - assert.equal(students.length, 46, "Expected 46 elements of students"); + assert.equal(students.length, 51, "Expected 51 elements of students"); }).then( students => { cy.wrap(students).each(e => { expect(e).contain("Mentorius"); @@ -128,7 +128,7 @@ describe('First homework', function() { let path = element.get(0).href; cy.visit(path).get('.alert, .success').then( data => { if (data.get(0).innerText === 'Dešimt balų') { - cy.screenshot() + cy.screenshot(); cy.wrap([path]).each( path => { dd(`Įvertinti: ${path}`); }); From 09d2854ac519d04ba519c2f072550fcd536c0925 Mon Sep 17 00:00:00 2001 From: Indre Rakstele Date: Sun, 17 Nov 2019 17:03:34 +0200 Subject: [PATCH 09/12] test add --- assets/css/app.scss | 1 + public/students.json | 181 +++++++++++++++++++++++++++ src/Controller/HomeController.php | 23 +++- src/Controller/StudentController.php | 31 +++++ templates/home/index.html.twig | 60 ++++++++- templates/student/index.html.twig | 32 +++++ 6 files changed, 322 insertions(+), 6 deletions(-) create mode 100644 public/students.json create mode 100644 src/Controller/StudentController.php create mode 100644 templates/student/index.html.twig diff --git a/assets/css/app.scss b/assets/css/app.scss index f955fad8f..b4a73bdb7 100644 --- a/assets/css/app.scss +++ b/assets/css/app.scss @@ -1,3 +1,4 @@ +$body-bg: #ff622b; // customize some Bootstrap variables $primary: darken(#428bca, 20%); diff --git a/public/students.json b/public/students.json new file mode 100644 index 000000000..c06cff4d5 --- /dev/null +++ b/public/students.json @@ -0,0 +1,181 @@ +{ + "team1": { + "name": "Team1", + "mentors": [ + "Mantas" + ], + "students": [ + "Tadas", + "Gytis", + "Ričardas" + ] + }, + "baltichalatai": { + "name": "BaltiChalatai", + "mentors": [ + "Lukas" + ], + "students": [ + "Vytas", + "Lukas", + "Diana" + ] + }, + "nnizer": { + "name": "ePacientas", + "mentors": [ + "Tadas" + ], + "students": [ + "Kornelijus", + "Dominykas", + "Miglė" + ] + }, + "activegen": { + "name": "ActiveGen", + "mentors": [ + "Arnoldas" + ], + "students": [ + "Andrius", + "Nojus", + "Martynas", + "Edvinas" + ] + }, + "mms": { + "name": "Membership-management-system", + "mentors": [ + "Mindaugas" + ], + "students": [ + "Erika", + "Rokas", + "Valentinas", + "Eligijus" + ] + }, + "pamainos": { + "name": "NFQ pamainu sistema", + "mentors": [ + "Paulius" + ], + "students": [ + "Liudas", + "Justina", + "Andrius" + ] + }, + "receptai": { + "name": "Receptai", + "mentors": [ + "Mantas" + ], + "students": [ + "Arnoldas", + "Arentas", + "Tautvydas" + ] + }, + "pulse": { + "name": "NFQ pulse", + "mentors": [ + "Lorenas" + ], + "students": [ + "Arvydas", + "Titas", + "Kristijonas", + "Andrius" + ] + }, + "lita": { + "name": "NFQ Petro atrankos problema akademijai", + "mentors": [ + "Paulius" + ], + "students": [ + "Kristina", + "Indrė", + "Dmitri" + ] + }, + "myfleet": { + "name": "MyFleet", + "mentors": [ + "Laurynas" + ], + "students": [ + "Artūras", + "Ignas", + "Jonas" + ] + }, + "career": { + "name": "NFQ Career Criteria Assessment", + "mentors": [ + "Erikas" + ], + "students": [ + "Matas", + "Andrius", + "Ainis" + ] + }, + "carparking": { + "name": "NFQ Car parking", + "mentors": [ + "Andrejus" + ], + "students": [ + "Kęstas", + "Lukas", + "Lukas" + ] + }, + "podcast": { + "name": "Krepšinio podcastai", + "mentors": [ + "Eligijus" + ], + "students": [ + "Edvardas", + "Nerijus", + "Kazimieras" + ] + }, + "Barakas": { + "name": "barakas", + "mentors": [ + "Armandas" + ], + "students": [ + "Raimondas", + "Mantas", + "Tomas" + ] + }, + "devcollab": { + "name": "Education sharing platform", + "mentors": [ + "Viktoras" + ], + "students": [ + "Karolis", + "Arnas", + "Evaldas", + "Algirdas" + ] + }, + "hacker'is po .mySubdomain &project=123": { + "name": "' OR 1 -- DROP DATABASE", + "mentors": [ + "Ponas Programišius" + ], + "students": [ + "Aurelijus", + "Ir jo \"geras\" draug'as" + ] + } +} \ No newline at end of file diff --git a/src/Controller/HomeController.php b/src/Controller/HomeController.php index 90484f11f..9dcc5511a 100644 --- a/src/Controller/HomeController.php +++ b/src/Controller/HomeController.php @@ -3,17 +3,36 @@ namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\Routing\Annotation\Route; class HomeController extends AbstractController { /** * @Route("/", name="home") + * @param KernelInterface $kernel + * @return \Symfony\Component\HttpFoundation\Response */ - public function index() + public function index(KernelInterface $kernel) { + $projects = json_decode(file_get_contents($kernel->getProjectDir() . '/public/students.json'), true); + + $students = $this->groupByStudents($projects); return $this->render('home/index.html.twig', [ - 'someVariable' => 'NFQ Akademija', + 'someVariable' => $students, + 'projects' => $projects ]); } + + private function groupByStudents(array $projects) + { + $result = []; + foreach ($projects as $projectName => $project) { + foreach ($project['students'] as $student) { + $result[] = ['student' => $student, 'project' => $projectName, 'mentor' => $project['mentors'][0]]; + } + } + return $result; + } } + diff --git a/src/Controller/StudentController.php b/src/Controller/StudentController.php new file mode 100644 index 000000000..1b3d3eeb8 --- /dev/null +++ b/src/Controller/StudentController.php @@ -0,0 +1,31 @@ +get('name'); + $project = $request->get('project'); + + return $this->render('student/index.html.twig', [ + 'name' => $name, + 'project' => $project, + ]); + } +} + + + + diff --git a/templates/home/index.html.twig b/templates/home/index.html.twig index b1bd0115c..1be8b4aca 100644 --- a/templates/home/index.html.twig +++ b/templates/home/index.html.twig @@ -1,7 +1,59 @@ {% extends 'base.html.twig' %} -{% block title %}{{ someVariable }}{% endblock %} +{% block title %}Student{% endblock %} + + {% block body %} +
    +
  • Studentai
  • + {% for student in someVariable %} +
  • + {{ student.student|escape }} + ( Mentorius {{ student.mentor|escape }}) +
  • + {% endfor %} +
+ +
+
+ +
+ +
+
+ +
+ + +
+
+ + + + {% endblock %} + + + -{% block body %} -
{{ someVariable }}
-{% endblock %} diff --git a/templates/student/index.html.twig b/templates/student/index.html.twig new file mode 100644 index 000000000..06437e23e --- /dev/null +++ b/templates/student/index.html.twig @@ -0,0 +1,32 @@ +{% extends 'base.html.twig' %} + +{% block body %} +
+ + + + + + + + + + + +
ProjektasStudentas
{{ project|escape }}{{ name|escape }}
+ + {% if name == 'Indrė' %} + + {% else %} + + {% endif %} +
+ + +{% endblock %} From 025042cb30838a71a065bf07a5f477abca1b67c2 Mon Sep 17 00:00:00 2001 From: Indre Rakstele Date: Sun, 17 Nov 2019 17:15:08 +0200 Subject: [PATCH 10/12] code style --- src/Controller/HomeController.php | 1 - src/Controller/StudentController.php | 4 ---- 2 files changed, 5 deletions(-) diff --git a/src/Controller/HomeController.php b/src/Controller/HomeController.php index 9dcc5511a..3ae4b419e 100644 --- a/src/Controller/HomeController.php +++ b/src/Controller/HomeController.php @@ -35,4 +35,3 @@ private function groupByStudents(array $projects) return $result; } } - diff --git a/src/Controller/StudentController.php b/src/Controller/StudentController.php index 1b3d3eeb8..148dd4f93 100644 --- a/src/Controller/StudentController.php +++ b/src/Controller/StudentController.php @@ -25,7 +25,3 @@ public function index(Request $request) ]); } } - - - - From 984e18e75edd6383e9aa6c58680818d36d4875a1 Mon Sep 17 00:00:00 2001 From: Indre Rakstele Date: Wed, 20 Nov 2019 18:18:01 +0200 Subject: [PATCH 11/12] test --- .github/workflows/symfony-hw-1.yml | 36 ------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 .github/workflows/symfony-hw-1.yml diff --git a/.github/workflows/symfony-hw-1.yml b/.github/workflows/symfony-hw-1.yml deleted file mode 100644 index 600e4709a..000000000 --- a/.github/workflows/symfony-hw-1.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Symfony 1 Homework -on: - - pull_request -jobs: - build: - name: Build and test for Symfony 1 Homework - runs-on: ubuntu-latest - steps: - # Prepare dependencies - - uses: actions/checkout@v1 - - name: Start containers - run: ./scripts/start.sh - - name: Temporary fix for permissions (different docekr users) - run: chmod 777 . && chmod 777 public - - name: Install dependencies - run: ./scripts/install-prod.sh - - # Fast tests - - name: Smoke test for infrastructure - if: always() - run: curl -v http://127.0.0.1:8000 - - name: List used routes - if: always() - run: ./scripts/backend.sh bin/console debug:router - - # Browser based tests - - name: Download Cypress dependencies - run: docker pull "cypress/included:3.2.0" - - name: Run end-to-end test - run: ./scripts/e2e-tests.sh - - name: Store cypress test results (screenshots) - uses: actions/upload-artifact@v1 - if: always() - with: - name: cypress-screenshots - path: tests/e2e/cypress/screenshots From f714bec22d48d34510ece10a5fb705746badbf2e Mon Sep 17 00:00:00 2001 From: Aurelijus Banelis Date: Sat, 14 Dec 2019 17:04:33 +0200 Subject: [PATCH 12/12] Ignore Symfony 1 tests --- tests/e2e/cypress/integration/symfony-hw1.js | 141 ------------------- 1 file changed, 141 deletions(-) delete mode 100644 tests/e2e/cypress/integration/symfony-hw1.js diff --git a/tests/e2e/cypress/integration/symfony-hw1.js b/tests/e2e/cypress/integration/symfony-hw1.js deleted file mode 100644 index 480d7cc79..000000000 --- a/tests/e2e/cypress/integration/symfony-hw1.js +++ /dev/null @@ -1,141 +0,0 @@ -const basePath = Cypress.env('BASE_URL') ? Cypress.env('BASE_URL') : 'http://127.0.0.1:8000/'; - -const d = async (message) => { - console.info('D', message); - await cy.ciDebug(message); -}; -const dd = async (message) => { - console.log('DD', message); - await cy.ciLog(message); -}; - -describe('First homework', function() { - it('Have students block', () => { - cy.visit(basePath); - cy.contains("Studentai") - .parent() - .children('.list-group-item:not(.list-group-item-info)') - .then(data => data.map((index, element) => element.innerText).get()) - .then(students => { - cy.wrap(students).each(student => dd(`Student: ${student}`)); - }).then( students => { - assert.equal(students.length, 51, "Expected 51 elements of students"); - }).then( students => { - cy.wrap(students).each(e => { - expect(e).contain("Mentorius"); - }) - }); - - cy.contains("Studentai").parent().screenshot(); - }); - it('Have correct students-mentor data', () => { - cy.visit(basePath); - cy.contains("Studentai") - .parent() - .children('.list-group-item:not(.list-group-item-info)') - .first() - .contains("Tadas") - .parent() - .contains("Mantas"); - }); - - it('Have project block', () => { - cy.visit(basePath); - cy.contains("Projektai").parent().screenshot(); - }); - - it('Have form block', () => { - cy.visit(basePath); - cy.contains("Sužinoti vertinimą").parent().screenshot(); - }); - - it('Whole page', () => { - cy.visit(basePath); - cy.screenshot(); - }); - - it('Click on first student', () => { - cy.visit(basePath); - cy.contains("Studentai") - .parent() - .children('.list-group-item:not(.list-group-item-info)') - .first().children('a').click(); - - d("Expected inner page"); - cy.contains("Studentas"); - cy.contains("Projektas"); - cy.screenshot(); - - cy.contains("Visi studentai").click() - }); - - it('Click on Data file', () => { - cy.visit(basePath); - cy.contains("Duomenų failas").then( a => { - const link = a.attr('href'); - cy.wrap([link]).each(link => dd(`Data file link: ${link}`)) - }).then( links => { - const link = links[0]; - expect(link).to.eq("students.json"); - }) - }); - - it('Have properly escaped student', () => { - cy.visit(basePath); - cy.contains("Studentai") - .parent() - .children() - .last() - .contains(`Ir jo "geras" draug'as`) - .then( element => { - const link = element.get(0).href; - assert( - link.endsWith('?name=%3Cb%3EIr%3C/b%3E%20jo%20%22geras%22%20draug%27as&project=hack%3Cb%3Eer%3C/b%3E%27is%20po%20.mySubdomain%20%26project%3D123'), - 'Expected urlencoded Twig filter' - ); - }) - }); - - it('Have properly escaped Projektai', () => { - cy.visit(basePath); - cy.contains("Projektai") - .parent() - .children() - .last(). - contains(`' OR 1 -- DROP DATABASE`) - .parent() - .contains(`github.com/nfqakademija/hacker'is po .mySubdomain &project=123`) - .parent() - .parent() - .contains(`hacker'is po .mySubdomain &project=123.projektai.nfqakademija.lt/`) - .then( element => { - const link = element.get(0).href; - expect(link).to.eq(`http://hack%3Cb%3Eer%3C%2Fb%3E%27is%20po%20.mysubdomain%20%26project%3D123.projektai.nfqakademija.lt/`); - }) - .parent() - .parent() - .contains(`ssh hacker'is po .mySubdomain &project=123@deploy.nfqakademija.lt -p 2222`) - }); - - it('Have correct person with good evaluation', () => { - cy.visit(basePath); - cy.contains("Studentai") - .parent() - .children('.list-group-item:not(.list-group-item-info)') - .children("a") - .then( elements => { - cy.wrap(elements).each(element => { - let path = element.get(0).href; - cy.visit(path).get('.alert, .success').then( data => { - if (data.get(0).innerText === 'Dešimt balų') { - cy.screenshot(); - cy.wrap([path]).each( path => { - dd(`Įvertinti: ${path}`); - }); - - } - }); - }); - }); - }); -});