test: rework ui tests for new layout

This commit is contained in:
Thea Schöbl
2022-08-25 14:40:33 +00:00
committed by Rainer Killinger
parent 0bce9e5452
commit de10654675
11 changed files with 143 additions and 132 deletions

View File

@@ -69,75 +69,73 @@ unit:
coverage_format: cobertura coverage_format: cobertura
path: coverage/cobertura-coverage.xml path: coverage/cobertura-coverage.xml
# Disabled until redesign is settled .e2e-chrome:
# image: cypress/browsers:node14.19.0-chrome100-ff99-edge
# .e2e-chrome: stage: test
# image: cypress/browsers:node14.19.0-chrome100-ff99-edge script:
# stage: test - npm run e2e -- --watch=false --headless=true --browser=chrome
# script: artifacts:
# - npm run e2e -- --watch=false --headless=true --browser=chrome when: on_failure
# artifacts: paths:
# when: on_failure - cypress/videos
# paths: - cypress/screenshots
# - cypress/videos
# - cypress/screenshots .e2e-firefox:
# image: cypress/browsers:node14.19.0-chrome100-ff99-edge
# .e2e-firefox: stage: test
# image: cypress/browsers:node14.19.0-chrome100-ff99-edge script:
# stage: test - npm run e2e -- --watch=false --headless=true --browser=firefox
# script: artifacts:
# - npm run e2e -- --watch=false --headless=true --browser=firefox when: on_failure
# artifacts: paths:
# when: on_failure - cypress/videos
# paths: - cypress/screenshots
# - cypress/videos
# - cypress/screenshots ui-chrome:
# extends: .e2e-chrome
# ui-chrome: rules:
# extends: .e2e-chrome - if: $CI_PIPELINE_SOURCE == "merge_request_event"
# rules: when: never
# - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: ($CI_COMMIT_REF_NAME == "develop" || $CI_COMMIT_REF_NAME == "master")
# when: never when: always
# - if: ($CI_COMMIT_REF_NAME == "develop" || $CI_COMMIT_REF_NAME == "master") allow_failure: false
# when: always - if: ($CI_COMMIT_REF_NAME != "develop" && $CI_COMMIT_REF_NAME != "master")
# allow_failure: false when: never
# - if: ($CI_COMMIT_REF_NAME != "develop" && $CI_COMMIT_REF_NAME != "master")
# when: never ui-firefox:
# extends: .e2e-firefox
# ui-firefox: rules:
# extends: .e2e-firefox - if: $CI_PIPELINE_SOURCE == "merge_request_event"
# rules: when: never
# - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: ($CI_COMMIT_REF_NAME == "develop" || $CI_COMMIT_REF_NAME == "master")
# when: never when: always
# - if: ($CI_COMMIT_REF_NAME == "develop" || $CI_COMMIT_REF_NAME == "master") allow_failure: false
# when: always - if: ($CI_COMMIT_REF_NAME != "develop" && $CI_COMMIT_REF_NAME != "master")
# allow_failure: false when: never
# - if: ($CI_COMMIT_REF_NAME != "develop" && $CI_COMMIT_REF_NAME != "master")
# when: never e2e-chrome:
# extends: .e2e-chrome
# e2e-chrome: stage: ui test
# extends: .e2e-chrome rules:
# stage: ui test - if: $CI_PIPELINE_SOURCE == "merge_request_event"
# rules: when: never
# - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: ($CI_COMMIT_REF_NAME == "develop" || $CI_COMMIT_REF_NAME == "master")
# when: never when: never
# - if: ($CI_COMMIT_REF_NAME == "develop" || $CI_COMMIT_REF_NAME == "master") - if: ($CI_COMMIT_REF_NAME != "develop" && $CI_COMMIT_REF_NAME != "master")
# when: never when: manual
# - if: ($CI_COMMIT_REF_NAME != "develop" && $CI_COMMIT_REF_NAME != "master") allow_failure: false
# when: manual
# allow_failure: false e2e-firefox:
# extends: .e2e-firefox
# e2e-firefox: stage: ui test
# extends: .e2e-firefox rules:
# stage: ui test - if: $CI_PIPELINE_SOURCE == "merge_request_event"
# rules: when: never
# - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: ($CI_COMMIT_REF_NAME == "develop" || $CI_COMMIT_REF_NAME == "master")
# when: never when: never
# - if: ($CI_COMMIT_REF_NAME == "develop" || $CI_COMMIT_REF_NAME == "master") - if: ($CI_COMMIT_REF_NAME != "develop" && $CI_COMMIT_REF_NAME != "master")
# when: never when: manual
# - if: ($CI_COMMIT_REF_NAME != "develop" && $CI_COMMIT_REF_NAME != "master") allow_failure: false
# when: manual
# allow_failure: false
audit: audit:
stage: test stage: test

View File

@@ -28,21 +28,4 @@ describe('catalog', function () {
.should('contain', 'Studium der Pflichtfächer (1. bis 5. Semester)'); .should('contain', 'Studium der Pflichtfächer (1. bis 5. Semester)');
}); });
}); });
it('should have default back nav', function () {
cy.visit('/data-detail/ae3cf884-4dc4-526b-9213-6850135591ab');
cy.intercept('POST', 'https://mobile.server.uni-frankfurt.de/search', {
fixture: 'search/types/catalog/catalog-1.json',
});
cy.get('h1').should(
'contain',
'Studium der Pflichtfächer (1. bis 5. Semester)',
);
cy.intercept('POST', 'https://mobile.server.uni-frankfurt.de/search', {
fixture: 'search/types/catalog/catalog-2.json',
});
cy.get('.show-back-button').click();
cy.get('h1').should('contain', 'FB 1 - Rechtswissenschaft');
});
}); });

View File

@@ -26,9 +26,9 @@ describe('context menu', function () {
fixture: 'search/multi-result.json', fixture: 'search/multi-result.json',
}, },
); );
cy.get('ion-searchbar').type('test{enter}'); cy.get('ion-searchbar').type('test');
cy.wait('@search'); cy.wait('@search');
cy.get('ion-buttons').last().find('ion-menu-button').click(); cy.get('ion-searchbar > ion-menu-button').click();
}); });
it('should sort', function () { it('should sort', function () {

View File

@@ -15,13 +15,17 @@
describe('favorites', function () { describe('favorites', function () {
it('should add a favorite', function () { it('should add a favorite', function () {
cy.intercept('POST', 'https://mobile.server.uni-frankfurt.de/search', {
fixture: 'search/test.json',
}).as('search');
cy.visit('/search'); cy.visit('/search');
cy.get('ion-searchbar').type('test'); cy.get('ion-searchbar').type('test');
let text!: string; let text!: string;
cy.get('stapps-data-list-item') cy.get('stapps-data-list-item')
.first() .first()
.within(() => { .within(() => {
cy.get('h2') cy.get('.title')
.invoke('text') .invoke('text')
.then(it => { .then(it => {
text = it; text = it;
@@ -30,7 +34,7 @@ describe('favorites', function () {
}); });
cy.visit('/favorites'); cy.visit('/favorites');
cy.get('stapps-data-list-item').within(() => { cy.get('stapps-data-list-item').within(() => {
cy.get('h2').should('contain', text); cy.get('.title').should('contain', text);
cy.get('stapps-favorite-button').click(); cy.get('stapps-favorite-button').click();
}); });
cy.get('stapps-data-list').contains('Keine Ergebnisse'); cy.get('stapps-data-list').contains('Keine Ergebnisse');

View File

@@ -29,7 +29,7 @@ describe('ical', function () {
it('should export a single event', function () { it('should export a single event', function () {
cy.visit('/search'); cy.visit('/search');
cy.get('ion-searchbar').click().type('test{enter}'); cy.get('ion-searchbar').click().type('test');
cy.contains('ion-item', 'UNIcert (Test)') cy.contains('ion-item', 'UNIcert (Test)')
.contains('ion-chip', 'Termine Auswählen') .contains('ion-chip', 'Termine Auswählen')
.click(); .click();

View File

@@ -1,16 +1,16 @@
/* /*
* Copyright (C) 2022 StApps * Copyright (C) 2022 StApps
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
describe('news', function () { describe('news', function () {
@@ -28,6 +28,7 @@ describe('news', function () {
it('should have infinite scroll', function () { it('should have infinite scroll', function () {
cy.visit('/news'); cy.visit('/news');
cy.get('stapps-news-item').should('have.length', 6); cy.get('stapps-news-item').should('have.length', 6);
cy.wait(500);
cy.get('stapps-news-page > ion-content') cy.get('stapps-news-page > ion-content')
.shadow() .shadow()
.find('main') .find('main')
@@ -49,7 +50,7 @@ describe('news', function () {
}).as('search'); }).as('search');
cy.visit('/data-detail/c90c7d30-410f-5aea-a67b-ea1f98929b93'); cy.visit('/data-detail/c90c7d30-410f-5aea-a67b-ea1f98929b93');
cy.contains('ion-card', 'Ursprünglicher Link') cy.contains('ion-card', 'Ursprünglicher Link')
.find('ion-icon[name="open-outline"]') .find('ion-icon[name="open_in_browser"]')
.should('exist'); .should('exist');
}); });
}); });

View File

@@ -27,25 +27,31 @@ describe('schedule', function () {
); );
}); });
it('should respect the url', function () {
cy.visit('/schedule/calendar/2022-01-19');
cy.get('#date-select-button0').should('contain', '19.01.22');
});
it('should navigate a full page', function () { it('should navigate a full page', function () {
cy.visit('/schedule/calendar/2022-01-19'); cy.visit('/schedule/calendar/2022-01-19');
cy.get('.swiper-slide-active').should('contain', '19. Jan. 2022');
cy.get('.swiper-slide-active').should('contain', 'Mi');
cy.get('.left-button').click(); cy.get('.left-button').click();
cy.wait(2000); cy.wait(2000);
cy.get('.swiper-slide-active').should('not.contain', '19. Jan. 2022'); cy.get('.swiper-slide-active').should('contain', 'So');
cy.get('.right-button').click(); cy.get('.right-button').click();
cy.wait(2000); cy.wait(2000);
cy.get('.swiper-slide-active').should('contain', '19. Jan. 2022'); cy.get('.swiper-slide-active').should('contain', 'Mi');
cy.get('.right-button').click(); cy.get('.right-button').click();
cy.wait(2000); cy.wait(2000);
cy.get('.swiper-slide-active').should('not.contain', '19. Jan. 2022'); cy.get('.swiper-slide-active').should('contain', 'Sa');
}); });
for (const [width, count] of [ for (const [width, count] of [
[760, 1], [760, 3],
[770, 3], [770, 3],
[1700, 7], [1700, 7],
]) { ]) {
@@ -53,24 +59,24 @@ describe('schedule', function () {
it(`should have ${count} slides for ${width}px`, function () { it(`should have ${count} slides for ${width}px`, function () {
cy.visit('/schedule/calendar/2022-01-19'); cy.visit('/schedule/calendar/2022-01-19');
cy.viewport(width, 550); cy.viewport(width, 550);
cy.get('ion-content') cy.get('.schedule-wrapper > .infinite-swiper-wrapper')
.find('.swiper-slide') .find('.swiper-slide')
.should('have.length', slideMultiplier * count) .should('have.length', slideMultiplier * count)
.first() .first()
.invoke('outerWidth') .invoke('outerWidth')
.should('be.gt', 170); .should('be.gt', 140);
}); });
} }
it('should navigate to a specific date', function () { it('should navigate to a specific date', function () {
cy.visit('/schedule/calendar/2022-01-19'); cy.visit('/schedule/calendar/2022-01-19');
cy.contains('.swiper-slide-active', '19. Jan. 2022').click(); cy.contains('#date-select-button0', '19.01.22').click();
cy.wait(2000); cy.wait(2000);
cy.get('button[data-day=1][data-month=1][data-year=2022]', { cy.get('button[data-day=1][data-month=1][data-year=2022]', {
includeShadowDom: true, includeShadowDom: true,
}).click(); }).click();
cy.wait(2000); cy.wait(2000);
cy.get('.swiper-slide-active').should('contain', '1. Jan. 2022'); cy.contains('#date-select-button0', '01.01.22').click();
}); });
it('should add events', function () { it('should add events', function () {

View File

@@ -14,7 +14,7 @@
*/ */
describe('Settings Page', () => { describe('Settings Page', () => {
it('should have a proper title', () => { it('should have a proper title', () => {
cy.visit('/app/settings'); cy.visit('/settings');
cy.get('ion-title').contains('Einstellungen'); cy.get('ion-title').contains('Einstellungen');
}); });

View File

@@ -14,9 +14,10 @@
*/ */
/** /**
* Something akin to a.b.c but never a... * Something akin to a.b.c a.b.C but never a... or a.AbC
*/ */
const probablyBadTranslationPattern = /^\s*\w+\.(\w+\.?)+\s*(?!\.\.\.)\s*$/; const probablyBadTranslationPattern =
/^\s*([a-z_]+|[A-Z_]+)\.(([a-z_]+|[A-Z_]+)\.)([a-z_]+|[A-Z_]+)$/;
describe('translations', function () { describe('translations', function () {
for (const path of [ for (const path of [
@@ -46,6 +47,7 @@ describe('translations', function () {
'canteen', 'canteen',
'catalog', 'catalog',
'schedule', 'schedule',
'dashboard',
[ [
'schedule add modal', 'schedule add modal',
() => { () => {
@@ -68,6 +70,8 @@ describe('translations', function () {
cy.visit(`/${path}`); cy.visit(`/${path}`);
} }
cy.wait(500);
cy.get('ion-app *').each($element => { cy.get('ion-app *').each($element => {
const text = $element.text(); const text = $element.text();
if (text) { if (text) {

View File

@@ -1,16 +1,16 @@
/* /*
* Copyright (C) 2021 StApps * Copyright (C) 2022 StApps
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free * under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3. * Software Foundation, version 3.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {Component, Input, OnDestroy, OnInit} from '@angular/core'; import {Component, Input, OnDestroy, OnInit} from '@angular/core';
import {ActivatedRoute} from '@angular/router'; import {ActivatedRoute} from '@angular/router';
@@ -126,13 +126,6 @@ export class CalendarComponent implements OnInit, OnDestroy {
} }
onInit() { onInit() {
this.dateRange.startDate = this.calculateDateFromIndex(0, 0, 'DD.MM.YY');
this.dateRange.endDate = this.calculateDateFromIndex(
0,
this.layout.days - 1,
'DD.MM.YY',
);
let dayString: string | number | null = let dayString: string | number | null =
this.activatedRoute.snapshot.paramMap.get('date'); this.activatedRoute.snapshot.paramMap.get('date');
if (dayString == undefined || dayString === 'now') { if (dayString == undefined || dayString === 'now') {
@@ -154,6 +147,13 @@ export class CalendarComponent implements OnInit, OnDestroy {
}, },
); );
}); });
this.dateRange.startDate = this.calculateDateFromIndex(0, 0, 'DD.MM.YY');
this.dateRange.endDate = this.calculateDateFromIndex(
0,
this.layout.days - 1,
'DD.MM.YY',
);
} }
onDestroy() { onDestroy() {

View File

@@ -1,3 +1,18 @@
/*!
* Copyright (C) 2022 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
// Ionic Variables and Theming. For more info, please see: // Ionic Variables and Theming. For more info, please see:
// http://ionicframework.com/docs/theming/ // http://ionicframework.com/docs/theming/
@@ -100,8 +115,8 @@
--shadow-cards: 0 0 8px 1px #ddd; --shadow-cards: 0 0 8px 1px #ddd;
--shadow-cards-hover: 5px 5px 8px 4px #ccc; --shadow-cards-hover: 5px 5px 8px 4px #ccc;
--shadow-profile-card: 0 2px 6px 6px rgba(0,0,0,0.06), --shadow-profile-card: 0 2px 6px 6px rgba(0,0,0,0.06),
0 4px 5px 12px rgba(0,0,0,0.04), 0 4px 5px 12px rgba(0,0,0,0.04),
0 5px 6px 20px rgba(0,0,0,0.02); 0 5px 6px 20px rgba(0,0,0,0.02);
// Fonts // Fonts
--ion-font-family: "Barlow",Helvetica,Arial,sans-serif; --ion-font-family: "Barlow",Helvetica,Arial,sans-serif;