feat: improved e2e tests

This commit is contained in:
2023-12-05 15:21:01 +01:00
committed by Thea Schöbl
parent bff2d985aa
commit d7a85b7fae
66 changed files with 6353 additions and 4471 deletions

View File

@@ -12,14 +12,26 @@
* 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';
import {DashboardComponent} from '../../src/app/modules/dashboard/dashboard.component';
describe('dashboard', async function () {
beforeEach(function () {
cy.interceptSearch({
extends: 'news/all',
fixture: 'news/all',
alias: 'newsSection',
});
cy.interceptSearch({
extends: {filter: {type: 'value', arguments: {field: 'type', value: 'job posting'}}},
fixture: 'no-results',
});
cy.visit('/overview');
cy.wait('@newsSection');
});
describe('schedule section', function () {
it('should lead to the week overview', function () {
cy.visit('/overview');
cy.get('.schedule')
.contains('a', /Wochen.*übersicht/)
.click();
@@ -27,40 +39,29 @@ describe('dashboard', async function () {
});
it('should lead to the calendar', function () {
cy.visit('/overview');
cy.get('.schedule').contains('a', 'Kein Eintrag gefunden').click();
cy.url().should('include', '/schedule/calendar');
});
// TODO: Reenable and stabilize tests
//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('/overview');
// 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;
it('should display the next unit', function () {
cy.interceptSearch({extends: 'dashboard/next-unit', fixture: 'dashboard/next-unit', alias: 'nextUnit'});
// scheduleProvider.restore(['abc']);
// }),
// );
// cy.wait('@search');
// cy.visit('/overview');
// cy.get('.schedule-item-button').should('contain', 'UNIcert (Test)');
//});
cy.get('.schedule-item-button').should('exist');
cy.get('app-dashboard')
.component<DashboardComponent>()
.its('scheduleProvider')
.its('_partialEvents$')
.runInsideAngular(events => {
events.next([{uid: 'abc'}]);
});
cy.wait('@nextUnit');
cy.get('.schedule-item-button').should('contain', 'UNIcert (Test)');
});
});
describe('mensa section', function () {
it('should have info when nothing is added', function () {
cy.visit('/overview');
cy.get('stapps-mensa-section').within(() => {
cy.get('swiper').should('not.exist');
cy.get('.nothing-selected > ion-label > a').should('have.text', 'Übersicht der Mensen');
@@ -68,28 +69,29 @@ describe('dashboard', async function () {
});
it('should add a mensa', function () {
cy.clock(new Date('2022-06-08'), ['Date']);
cy.interceptMultiSearch({
extends: 'canteen/dishes',
fixture: 'canteen/dishes',
alias: 'dishes',
});
cy.interceptSearch({
extends: 'canteen/all',
fixture: 'canteen/all',
alias: 'canteen',
});
cy.visit('/overview');
cy.get('stapps-mensa-section').find('.nothing-selected > ion-label > a').click();
cy.intercept('POST', 'https://mobile.server.uni-frankfurt.de/search', {
fixture: 'search/types/canteen/canteen-search-result.json',
});
cy.wait('@canteen');
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.wait('@dishes');
cy.get('stapps-mensa-section').find('simple-swiper > *').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');
});
// TODO: Cypress has no real way of setting the presence of a pointing device,
// which means the behavior is undefined and depends on the testing device
// it('should have desktop navigation buttons', function () {
@@ -109,8 +111,6 @@ describe('dashboard', async function () {
// });
it('should have working desktop navigation', function () {
cy.visit('/overview');
cy.get('stapps-news-section').within(function () {
cy.get('simple-swiper > *').eq(0).should('be.visible');
@@ -123,15 +123,10 @@ describe('dashboard', async function () {
});
it('should have a link to the news page', function () {
cy.visit('/overview');
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('ion-item', 'Mehr Nachrichten')
.click({scrollBehavior: false, force: true});
cy.wait('@newsSection');
cy.url().should('include', '/news');
});
});