mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-09 19:22:51 +00:00
feat: dashboard ui tests
This commit is contained in:
committed by
Rainer Killinger
parent
eb108c7414
commit
9f8ab5c7a1
191
cypress/integration/dashboard.spec.ts
Normal file
191
cypress/integration/dashboard.spec.ts
Normal file
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import {ScheduleProvider} from '../../src/app/modules/calendar/schedule.provider';
|
||||
|
||||
describe('dashboard', async function () {
|
||||
describe('schedule section', function () {
|
||||
it('should lead to the schedule', function () {
|
||||
cy.visit('/dashboard');
|
||||
cy.get('.schedule').contains('a', 'Stundenplan').click();
|
||||
cy.url().should('include', '/schedule/recurring');
|
||||
|
||||
cy.visit('/dashboard');
|
||||
cy.get('.schedule').contains('a', 'Kein Eintrag gefunden').click();
|
||||
cy.url().should('include', '/schedule/recurring');
|
||||
});
|
||||
|
||||
it('should display the next unit', function () {
|
||||
let angular: any;
|
||||
cy.intercept('POST', 'https://mobile.server.uni-frankfurt.de/search', {
|
||||
fixture: 'search/types/date-series/date-series-1.json',
|
||||
}).as('search');
|
||||
cy.visit('/dashboard');
|
||||
cy.get('.schedule-item-button').should('exist');
|
||||
cy.window()
|
||||
.then(win => (angular = (win as any).ng))
|
||||
.then(() =>
|
||||
cy.get('app-dashboard').then($dashboard => {
|
||||
const appComponent = angular.getComponent($dashboard[0]);
|
||||
const scheduleProvider =
|
||||
appComponent.scheduleProvider as ScheduleProvider;
|
||||
|
||||
scheduleProvider.restore(['abc']);
|
||||
}),
|
||||
);
|
||||
cy.wait('@search');
|
||||
cy.get('.schedule-item-button').should('contain', 'UNIcert (Test)');
|
||||
});
|
||||
});
|
||||
|
||||
describe('mensa section', function () {
|
||||
it('should have info when nothing is added', function () {
|
||||
cy.visit('/dashboard');
|
||||
|
||||
cy.get('stapps-mensa-section').within(() => {
|
||||
cy.get('.card').should('have.length', 1);
|
||||
cy.get('.card > ion-label > a').should(
|
||||
'have.text',
|
||||
'Übersicht der Mensen',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('should add a mensa', function () {
|
||||
cy.visit('/dashboard');
|
||||
cy.get('stapps-mensa-section').find('.card > ion-label > a').click();
|
||||
cy.intercept('POST', 'https://mobile.server.uni-frankfurt.de/search', {
|
||||
fixture: 'search/types/canteen/canteen-search-result.json',
|
||||
});
|
||||
cy.get('stapps-favorite-button').first().click();
|
||||
cy.intercept(
|
||||
'POST',
|
||||
'https://mobile.server.uni-frankfurt.de/search/multi',
|
||||
{
|
||||
fixture: 'search/types/dish/dish-2.json',
|
||||
},
|
||||
);
|
||||
cy.get('ion-back-button').click();
|
||||
cy.get('stapps-mensa-section')
|
||||
.find('.card')
|
||||
.should('have.length.greaterThan', 1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('news section', function () {
|
||||
beforeEach(function () {
|
||||
cy.intercept('POST', 'https://mobile.server.uni-frankfurt.de/search', {
|
||||
fixture: 'search/types/message/message-1.json',
|
||||
}).as('search');
|
||||
});
|
||||
|
||||
it('should have desktop navigation buttons', function () {
|
||||
cy.visit('/dashboard');
|
||||
|
||||
cy.get('stapps-news-section').within(function () {
|
||||
cy.get('.swiper-button-prev').should('exist');
|
||||
cy.get('.swiper-button-next').should('exist');
|
||||
});
|
||||
});
|
||||
|
||||
it('should have working desktop navigation', function () {
|
||||
cy.visit('/dashboard');
|
||||
|
||||
cy.get('stapps-news-section').within(function () {
|
||||
cy.get('.swiper-slide-active').should(
|
||||
'have.text',
|
||||
'DE for Students and Employees',
|
||||
);
|
||||
|
||||
cy.get('.swiper-button-next').click({scrollBehavior: false});
|
||||
|
||||
cy.get('.swiper-slide-active').should('have.text', 'DE for Students');
|
||||
});
|
||||
});
|
||||
|
||||
it('should have a link to the news page', function () {
|
||||
cy.visit('/dashboard');
|
||||
cy.wait('@search');
|
||||
cy.intercept('POST', 'https://mobile.server.uni-frankfurt.de/search', {
|
||||
fixture: 'search/types/message/single-message.json',
|
||||
}).as('search');
|
||||
|
||||
cy.get('stapps-news-section').contains('a', 'Mehr Nachrichten').click();
|
||||
cy.url().should('include', '/news');
|
||||
});
|
||||
});
|
||||
|
||||
describe('navigation section', function () {
|
||||
it('should have editable dashboard sections', function () {
|
||||
cy.visit('/dashboard');
|
||||
|
||||
const section = 'Vorlesungsv.';
|
||||
|
||||
cy.get('stapps-navigation-section').within(() => {
|
||||
cy.get('.card').should('contain.text', section);
|
||||
|
||||
cy.get('ion-icon[name=edit_square]').click();
|
||||
});
|
||||
|
||||
cy.get('stapps-dashboard-edit-modal').within(() => {
|
||||
cy.contains('ion-item', section).find('ion-toggle').click();
|
||||
|
||||
cy.contains('ion-button', 'Bestätigen').click();
|
||||
});
|
||||
|
||||
cy.get('stapps-navigation-section').within(() => {
|
||||
cy.get('.card').should('not.contain.text', section);
|
||||
|
||||
cy.get('ion-icon[name=edit_square]').click({scrollBehavior: false});
|
||||
});
|
||||
|
||||
cy.get('stapps-dashboard-edit-modal').within(() => {
|
||||
cy.contains('ion-item', section).find('ion-toggle').click();
|
||||
|
||||
cy.contains('ion-button', 'Bestätigen').click();
|
||||
});
|
||||
|
||||
cy.get('stapps-navigation-section')
|
||||
.find('.card')
|
||||
.should('contain.text', section);
|
||||
});
|
||||
});
|
||||
|
||||
describe('search section', function () {
|
||||
it('should lead to the search when hitting enter', function () {
|
||||
cy.visit('/dashboard');
|
||||
|
||||
cy.get('stapps-search-section')
|
||||
.find('.searchbar')
|
||||
.type('test', {scrollBehavior: false})
|
||||
.type('{enter}', {scrollBehavior: false});
|
||||
cy.url().should('eq', Cypress.config().baseUrl + '/search/test');
|
||||
cy.get('ion-searchbar').should('have.value', 'test');
|
||||
|
||||
cy.get('stapps-data-list-item').should('have.length.greaterThan', 0);
|
||||
});
|
||||
|
||||
it('should go to search when clicking the icon', function () {
|
||||
cy.visit('/dashboard');
|
||||
|
||||
cy.get('stapps-search-section').find('ion-icon[name=search]').click();
|
||||
cy.url().should('eq', Cypress.config().baseUrl + '/search/');
|
||||
cy.get('ion-searchbar').should('not.have.value');
|
||||
|
||||
cy.get('stapps-data-list-item').should('have.length', 0);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -31,12 +31,18 @@ describe('favorites', function () {
|
||||
text = it;
|
||||
});
|
||||
cy.get('stapps-favorite-button').click();
|
||||
cy.get('stapps-favorite-button > ion-button > ion-icon')
|
||||
.invoke('attr', 'ng-reflect-fill')
|
||||
.should('eq', 'true');
|
||||
});
|
||||
cy.visit('/favorites');
|
||||
cy.get('stapps-data-list-item').within(() => {
|
||||
cy.get('.title').should('contain', text);
|
||||
cy.get('stapps-favorite-button').click();
|
||||
});
|
||||
cy.get('stapps-data-list').contains('Keine Ergebnisse');
|
||||
cy.get('cdk-virtual-scroll-viewport').should('be.not.visible');
|
||||
cy.get('stapps-data-list')
|
||||
.contains('Keine Ergebnisse')
|
||||
.should('be.visible');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -39,7 +39,7 @@ describe('ical', function () {
|
||||
'have.attr',
|
||||
'disabled',
|
||||
);
|
||||
cy.contains('ion-item', /eine Stunde um 19. Jan. 2022, \d+:00/).click();
|
||||
cy.contains('ion-item', /eine Stunde um 19. Jan. 2059, \d+:00/).click();
|
||||
cy.get('ion-footer > ion-toolbar > ion-button').should(
|
||||
'not.have.attr',
|
||||
'disabled',
|
||||
@@ -49,7 +49,7 @@ describe('ical', function () {
|
||||
|
||||
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/);
|
||||
cy.contains('ion-item-group', /19. Jan. 2059, \d+:00/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -57,7 +57,7 @@ describe('schedule', function () {
|
||||
]) {
|
||||
const slideMultiplier = 3;
|
||||
it(`should have ${count} slides for ${width}px`, function () {
|
||||
cy.visit('/schedule/calendar/2022-01-19');
|
||||
cy.visit('/schedule/calendar/2022-01-59');
|
||||
cy.viewport(width, 550);
|
||||
cy.get('.schedule-wrapper > .infinite-swiper-wrapper')
|
||||
.find('.swiper-slide')
|
||||
@@ -69,18 +69,18 @@ describe('schedule', function () {
|
||||
}
|
||||
|
||||
it('should navigate to a specific date', function () {
|
||||
cy.visit('/schedule/calendar/2022-01-19');
|
||||
cy.contains('#date-select-button0', '19.01.22').click();
|
||||
cy.visit('/schedule/calendar/2059-01-19');
|
||||
cy.contains('#date-select-button0', '19.01.59').click();
|
||||
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=2059]', {
|
||||
includeShadowDom: true,
|
||||
}).click();
|
||||
cy.wait(2000);
|
||||
cy.contains('#date-select-button0', '01.01.22').click();
|
||||
cy.contains('#date-select-button0', '01.01.59').click();
|
||||
});
|
||||
|
||||
it('should add events', function () {
|
||||
cy.visit('/schedule/calendar/2022-01-19');
|
||||
cy.visit('/schedule/calendar/2059-01-19');
|
||||
cy.get('stapps-schedule-card').should('not.exist');
|
||||
|
||||
cy.get('ion-fab-button').click();
|
||||
@@ -98,7 +98,7 @@ describe('schedule', function () {
|
||||
});
|
||||
|
||||
cy.get('ion-app > ion-modal').within(() => {
|
||||
cy.contains('ion-item', /eine Stunde um 19. Jan. 2022, \d+:00/).click();
|
||||
cy.contains('ion-item', /eine Stunde um 19. Jan. 2059, \d+:00/).click();
|
||||
cy.wait(2000);
|
||||
cy.contains('ion-button', 'Bestätigen').click();
|
||||
cy.wait(2000);
|
||||
|
||||
Reference in New Issue
Block a user