test: increase ui test coverage

This commit is contained in:
2022-06-02 14:03:29 +02:00
committed by Rainer Killinger
parent 9e71efca9f
commit 8710ba43ff
35 changed files with 7201 additions and 209 deletions

View File

@@ -0,0 +1,47 @@
/*
* 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/>.
*/
describe('assessments', function () {
/*it('should have default back navigation', function () {
// TODO: Implement this
cy.visit(
'assessments/detail/02f065a6-6c02-58ab-97d9-a3febdbc91a1?token=mock',
);
cy.get('ion-back-button').click();
});*/
it('should always have a path', function () {
cy.visit(
'/assessments/detail/02f065a6-6c02-58ab-97d9-a3febdbc91a1?token=mock',
);
cy.get('stapps-data-path')
.should('contain', 'Basismodule')
.should('contain', 'Modellierung');
});
it('should have a collapsed path', function () {
cy.visit(
'/assessments/detail/02f065a6-6c02-58ab-97d9-a3febdbc91a1?token=mock',
);
cy.get('.breadcrumb-collapsed').click();
cy.get('ion-popover').within(() => {
cy.get('ion-item').should('have.length', 3);
cy.get('ion-item').first().should('contain', 'Basismodule');
cy.get('ion-item').last().should('contain', 'Modellierung');
});
});
});

View File

@@ -0,0 +1,61 @@
/*
* 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/>.
*/
describe('canteen', function () {
beforeEach(function () {
cy.intercept('POST', 'https://mobile.server.uni-frankfurt.de/search', {
fixture: 'search/types/canteen/canteen-1.json',
}).as('search');
cy.intercept(
'POST',
'https://mobile.server.uni-frankfurt.de/search/multi',
{
fixture: 'search/types/dish/dish-1.json',
},
);
});
it('should have a the default price', function () {
cy.visit('/data-detail/86464b64-da1e-5578-a5c4-eec23457f596');
cy.contains('4,40 €').should('exist');
});
it('should have a student price', function () {
cy.visit('/settings');
cy.contains('stapps-settings-item', 'Gruppe').find('ion-select').click();
cy.get('ion-popover').contains('ion-item', 'Student').click();
cy.wait(2000);
cy.visit('/data-detail/86464b64-da1e-5578-a5c4-eec23457f596');
cy.contains('3,30 €').should('exist');
});
it('should have an employee price', function () {
cy.visit('/settings');
cy.contains('stapps-settings-item', 'Gruppe').find('ion-select').click();
cy.get('ion-popover').contains('ion-item', 'Angestellter').click();
cy.wait(2000);
cy.visit('/data-detail/86464b64-da1e-5578-a5c4-eec23457f596');
cy.contains('1,10 €').should('exist');
});
it('should have a guest price', function () {
cy.visit('/settings');
cy.contains('stapps-settings-item', 'Gruppe').find('ion-select').click();
cy.get('ion-popover').contains('ion-item', 'Gast').click();
cy.wait(2000);
cy.visit('/data-detail/86464b64-da1e-5578-a5c4-eec23457f596');
cy.contains('2,20 €').should('exist');
});
});

View File

@@ -0,0 +1,48 @@
/*
* 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/>.
*/
describe('catalog', function () {
it('should have path', 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('stapps-data-path').within(() => {
cy.get('ion-breadcrumb')
.first()
.should('contain', 'FB 1 - Rechtswissenschaft');
cy.get('ion-breadcrumb')
.last()
.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

@@ -0,0 +1,78 @@
/*
* 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/>.
*/
describe('context menu', function () {
beforeEach(function () {
cy.visit('/search');
cy.intercept('POST', 'https://mobile.server.uni-frankfurt.de/search', {
fixture: 'search/test.json',
}).as('search');
cy.intercept(
'POST',
'https://mobile.server.uni-frankfurt.de/search/multi',
{
fixture: 'search/multi-result.json',
},
);
cy.get('ion-searchbar').type('test{enter}');
cy.wait('@search');
cy.get('ion-buttons').last().find('ion-menu-button').click();
});
it('should sort', function () {
cy.get('stapps-context').within(() => {
cy.contains('ion-item', 'Name').click();
cy.wait('@search');
});
});
it('should filter', function () {
cy.get('stapps-context').within(() => {
cy.contains('ion-item', '(27) Akademische Veranstaltung').click();
cy.wait('@search');
});
});
it('should have a working delete button', function () {
cy.get('stapps-context').within(() => {
cy.contains('ion-item', '(27) Akademische Veranstaltung').click();
cy.get('.checkbox-checked').should('have.length', 1);
cy.contains('ion-list-header', 'Filter').find('ion-button').click();
cy.wait('@search');
cy.get('.checkbox-checked').should('have.length', 0);
});
});
it('should truncate categories', function () {
cy.get('stapps-context').within(() => {
cy.contains('ion-item', '(4) Universitätsveranstaltung').should(
'not.exist',
);
cy.get('.context-filter > ion-button').click();
cy.contains('ion-item', '(4) Universitätsveranstaltung').should('exist');
});
});
it('should truncate long category items', function () {
cy.contains('ion-list', 'Kategorien | Akademische Veranstaltung').within(
() => {
cy.contains('ion-item', '(1) Tutorium').should('not.exist');
cy.get('div > ion-button').click();
cy.contains('ion-item', '(1) Tutorium').should('exist');
},
);
});
});

View File

@@ -0,0 +1,38 @@
/*
* 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/>.
*/
describe('favorites', function () {
it('should add a favorite', function () {
cy.visit('/search');
cy.get('ion-searchbar').type('test');
let text!: string;
cy.get('stapps-data-list-item')
.first()
.within(() => {
cy.get('h2')
.invoke('text')
.then(it => {
text = it;
});
cy.get('stapps-favorite-button').click();
});
cy.visit('/favorites');
cy.get('stapps-data-list-item').within(() => {
cy.get('h2').should('contain', text);
cy.get('stapps-favorite-button').click();
});
cy.get('stapps-data-list').contains('Keine Ergebnisse');
});
});

View File

@@ -0,0 +1,37 @@
/*
* 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/>.
*/
describe('feedback', function () {
it('should send feedback', function () {
cy.intercept('POST', 'https://mobile.server.uni-frankfurt.de/*').as(
'feedback',
);
cy.visit('/feedback');
cy.get('input[name=name]').type('test');
cy.get('input[name=email]').type('aaa@bbb.com');
cy.get('textarea[name=message]').type(
Array.from({length: 50}, () => 'a').join(''),
);
cy.get('ion-button[type=submit]').should('have.attr', 'disabled');
cy.get('ion-checkbox[name=termsAgree]').click();
cy.get('ion-button[type=submit]').should('not.have.attr', 'disabled');
// cy.get('ion-button[type=submit]').click();
// cy.wait('@feedback');
});
});

View File

@@ -0,0 +1,52 @@
/*
* 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/>.
*/
describe('ical', function () {
beforeEach(function () {
cy.intercept('POST', 'https://mobile.server.uni-frankfurt.de/search', {
fixture: 'search/types/academic-event/event-1.json',
}).as('search');
cy.intercept(
'POST',
'https://mobile.server.uni-frankfurt.de/search/multi',
{
fixture: 'search/types/date-series/date-series-for-event-1.json',
},
);
});
it('should export a single event', function () {
cy.visit('/search');
cy.get('ion-searchbar').click().type('test{enter}');
cy.contains('ion-item', 'UNIcert (Test)')
.contains('ion-chip', 'Termine Auswählen')
.click();
cy.get('ion-app > ion-popover').within(() => {
cy.get('.download-button > ion-button').should('have.attr', 'disabled');
cy.contains('ion-item', /eine Stunde um 19. Jan. 2022, \d+:00/).click();
cy.get('.download-button > ion-button').should(
'not.have.attr',
'disabled',
);
cy.get('.download-button > ion-button').click();
});
cy.get('add-event-review-modal').within(() => {
cy.get('ion-item-group').should('contain', 'UNIcert (Test)');
cy.contains('ion-item-group', /19. Jan. 2022, \d+:00/);
});
});
});

View File

@@ -0,0 +1,55 @@
/*
* 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/>.
*/
describe('news', function () {
beforeEach(function () {
cy.intercept('POST', 'https://mobile.server.uni-frankfurt.de/search', {
fixture: 'search/types/message/message-1.json',
}).as('search');
});
it('should show all articles by default', function () {
cy.visit('/news');
cy.get('stapps-news-item').should('have.length', 6);
});
it('should have infinite scroll', function () {
cy.visit('/news');
cy.get('stapps-news-item').should('have.length', 6);
cy.get('stapps-news-page > ion-content')
.shadow()
.find('main')
.scrollTo('bottom');
cy.wait('@search');
cy.get('stapps-news-item').should('have.length', 12);
});
it('should reload on filter change', function () {
cy.visit('/news');
cy.get('stapps-news-item').should('have.length', 6);
cy.get('stapps-news-settings-filter').first().click({force: true});
cy.wait('@search');
});
it('should have an external link indicator on detail pages', function () {
cy.intercept('POST', 'https://mobile.server.uni-frankfurt.de/search', {
fixture: 'search/types/message/single-message.json',
}).as('search');
cy.visit('/data-detail/c90c7d30-410f-5aea-a67b-ea1f98929b93');
cy.contains('ion-card', 'Ursprünglicher Link')
.find('ion-icon[name="open-outline"]')
.should('exist');
});
});

View File

@@ -0,0 +1,111 @@
/*
* 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/>.
*/
describe('schedule', function () {
beforeEach(function () {
cy.intercept('POST', 'https://mobile.server.uni-frankfurt.de/search', {
fixture: 'search/types/academic-event/event-1.json',
}).as('search');
cy.intercept(
'POST',
'https://mobile.server.uni-frankfurt.de/search/multi',
{
fixture: 'search/types/date-series/date-series-for-event-1.json',
},
);
});
it('should navigate a full page', function () {
cy.visit('/schedule/calendar/2022-01-19');
cy.get('.swiper-slide-active').should('contain', '19. Jan. 2022');
cy.get('.left-button').click();
cy.wait(2000);
cy.get('.swiper-slide-active').should('not.contain', '19. Jan. 2022');
cy.get('.right-button').click();
cy.wait(2000);
cy.get('.swiper-slide-active').should('contain', '19. Jan. 2022');
cy.get('.right-button').click();
cy.wait(2000);
cy.get('.swiper-slide-active').should('not.contain', '19. Jan. 2022');
});
for (const [width, count] of [
[760, 1],
[770, 3],
[1700, 7],
]) {
const slideMultiplier = 3;
it(`should have ${count} slides for ${width}px`, function () {
cy.visit('/schedule/calendar/2022-01-19');
cy.viewport(width, 550);
cy.get('ion-content')
.find('.swiper-slide')
.should('have.length', slideMultiplier * count)
.first()
.invoke('outerWidth')
.should('be.gt', 170);
});
}
it('should navigate to a specific date', function () {
cy.visit('/schedule/calendar/2022-01-19');
cy.contains('.swiper-slide-active', '19. Jan. 2022').click();
cy.wait(2000);
cy.get('button[data-day=1][data-month=1][data-year=2022]', {
includeShadowDom: true,
}).click();
cy.wait(2000);
cy.get('.swiper-slide-active').should('contain', '1. Jan. 2022');
});
it('should add events', function () {
cy.visit('/schedule/calendar/2022-01-19');
cy.get('stapps-schedule-card').should('not.exist');
cy.get('ion-fab-button').click();
cy.wait(2000);
cy.get('ion-modal').within(() => {
cy.get('ion-searchbar').click().type('test');
cy.contains('ion-item', 'UNIcert (Test)')
.contains('stapps-add-event-action-chip', 'Termine Auswählen')
.click();
cy.wait(2000);
});
cy.intercept('POST', 'https://mobile.server.uni-frankfurt.de/search', {
fixture: 'search/types/date-series/date-series-1.json',
});
cy.get('ion-app > ion-popover').within(() => {
cy.contains('ion-item', /eine Stunde um 19. Jan. 2022, \d+:00/).click();
cy.wait(2000);
cy.contains('ion-button', 'Ok').click();
cy.wait(2000);
});
cy.get('ion-modal').within(() => {
cy.contains('ion-item', 'UNIcert (Test)')
.contains('stapps-add-event-action-chip', 'Hinzugefügt')
.should('exist');
cy.contains('ion-button', 'Schließen').click();
cy.wait(2000);
});
cy.get('stapps-schedule-card').should('exist');
});
});

View File

@@ -0,0 +1,54 @@
/*
* 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/>.
*/
describe('search', function () {
beforeEach(function () {
cy.intercept('POST', 'https://mobile.server.uni-frankfurt.de/search', {
fixture: 'search/test.json',
});
cy.intercept(
'POST',
'https://mobile.server.uni-frankfurt.de/search/multi',
{
fixture: 'search/multi-result.json',
},
);
});
it('should have search results', function () {
cy.visit('/search');
cy.get('ion-searchbar').type('test');
cy.get('stapps-data-list-item').should('have.length.greaterThan', 1);
});
it('should display an error message when no results are found', function () {
cy.visit('/search');
cy.intercept('POST', 'https://mobile.server.uni-frankfurt.de/search', {
fixture: 'search/no-results.json',
});
cy.get('ion-searchbar').type(Array.from({length: 10}, () => 'a').join(''));
cy.get('stapps-data-list-item').should('have.length', 0);
cy.get('stapps-data-list').contains('Keine Ergebnisse');
});
it('should have a working clear button', function () {
cy.visit('/search');
cy.get('ion-searchbar').type('test');
cy.get('ion-searchbar').should('have.value', 'test');
cy.get('stapps-data-list-item').should('have.length.greaterThan', 1);
cy.get('.searchbar-clear-button').click();
cy.get('ion-searchbar').should('have.value', '');
});
});

View File

@@ -1,16 +1,16 @@
/*
* 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 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.
* 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/>.
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
describe('Settings Page', () => {
it('should have a proper title', () => {
@@ -18,4 +18,15 @@ describe('Settings Page', () => {
cy.get('ion-title').contains('Einstellungen');
});
it('should change language', () => {
cy.visit('/settings');
cy.contains('ion-select', 'Deutsch').click();
cy.get('ion-popover').contains('ion-item', 'English').click();
cy.get('ion-popover').should('not.exist');
cy.get('ion-title').contains('Settings');
cy.contains('ion-select', 'English').click();
cy.get('ion-popover').contains('ion-item', 'Deutsch').click();
cy.get('ion-title').contains('Einstellungen');
});
});

View File

@@ -0,0 +1,80 @@
/*
* 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/>.
*/
/**
* Something akin to a.b.c but never a...
*/
const probablyBadTranslationPattern = /^\s*\w+\.(\w+\.?)+\s*(?!\.\.\.)\s*$/;
describe('translations', function () {
for (const path of [
'settings',
'news',
[
'search',
() => {
cy.visit('/search');
cy.get('ion-searchbar').type('test');
cy.get('stapps-data-list-item').should('have.length.greaterThan', 1);
},
],
[
'context-menu',
() => {
cy.visit('/search');
cy.get('ion-searchbar').type('test');
cy.get('stapps-data-list-item').should('have.length.greaterThan', 1);
cy.get('ion-menu-button[menu=context]').click();
cy.get('stapps-context');
},
],
'map',
'feedback',
'about',
'canteen',
'catalog',
'schedule',
[
'schedule add modal',
() => {
cy.visit('/schedule');
cy.get('ion-fab').click();
cy.get('ion-modal');
},
],
'profile',
'favorites',
] as [string, () => void][]) {
const name = Array.isArray(path) ? path[0] : path;
const method = Array.isArray(path) ? path[1] : undefined;
describe(name, function () {
it('should not contain failed translation paths', function () {
if (method) {
method();
} else {
cy.visit(`/${path}`);
}
cy.get('ion-app *').each($element => {
const text = $element.text();
if (text) {
expect(text).not.to.match(probablyBadTranslationPattern);
}
});
});
});
}
});