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

@@ -28,21 +28,4 @@ describe('catalog', function () {
.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',
},
);
cy.get('ion-searchbar').type('test{enter}');
cy.get('ion-searchbar').type('test');
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 () {

View File

@@ -15,13 +15,17 @@
describe('favorites', 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.get('ion-searchbar').type('test');
let text!: string;
cy.get('stapps-data-list-item')
.first()
.within(() => {
cy.get('h2')
cy.get('.title')
.invoke('text')
.then(it => {
text = it;
@@ -30,7 +34,7 @@ describe('favorites', function () {
});
cy.visit('/favorites');
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-data-list').contains('Keine Ergebnisse');

View File

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

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('news', function () {
@@ -28,6 +28,7 @@ describe('news', function () {
it('should have infinite scroll', function () {
cy.visit('/news');
cy.get('stapps-news-item').should('have.length', 6);
cy.wait(500);
cy.get('stapps-news-page > ion-content')
.shadow()
.find('main')
@@ -49,7 +50,7 @@ describe('news', function () {
}).as('search');
cy.visit('/data-detail/c90c7d30-410f-5aea-a67b-ea1f98929b93');
cy.contains('ion-card', 'Ursprünglicher Link')
.find('ion-icon[name="open-outline"]')
.find('ion-icon[name="open_in_browser"]')
.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 () {
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.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.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.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 [
[760, 1],
[760, 3],
[770, 3],
[1700, 7],
]) {
@@ -53,24 +59,24 @@ describe('schedule', function () {
it(`should have ${count} slides for ${width}px`, function () {
cy.visit('/schedule/calendar/2022-01-19');
cy.viewport(width, 550);
cy.get('ion-content')
cy.get('.schedule-wrapper > .infinite-swiper-wrapper')
.find('.swiper-slide')
.should('have.length', slideMultiplier * count)
.first()
.invoke('outerWidth')
.should('be.gt', 170);
.should('be.gt', 140);
});
}
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.contains('#date-select-button0', '19.01.22').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');
cy.contains('#date-select-button0', '01.01.22').click();
});
it('should add events', function () {

View File

@@ -14,7 +14,7 @@
*/
describe('Settings Page', () => {
it('should have a proper title', () => {
cy.visit('/app/settings');
cy.visit('/settings');
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 () {
for (const path of [
@@ -46,6 +47,7 @@ describe('translations', function () {
'canteen',
'catalog',
'schedule',
'dashboard',
[
'schedule add modal',
() => {
@@ -68,6 +70,8 @@ describe('translations', function () {
cy.visit(`/${path}`);
}
cy.wait(500);
cy.get('ion-app *').each($element => {
const text = $element.text();
if (text) {