-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
app.spec.ts
92 lines (84 loc) · 2.71 KB
/
app.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import {
getToolbar,
getNavigationLinks,
getPrimaryButton,
} from '../support/app.po';
describe('responsive-app', () => {
it('should show toolbar', () => {
cy.visit('/');
getToolbar().contains('Responsive demo');
});
it('should redirect to dashboard on desktop', () => {
cy.viewport('macbook-13');
cy.visit('/');
cy.url().should('eq', 'http://localhost:4200/dashboard');
});
it('should not redirect to dashboard on mobile', () => {
cy.viewport('iphone-6');
cy.visit('/');
cy.url().should('eq', 'http://localhost:4200/');
});
it('should redirect from dashboard to root when switching to mobile', () => {
cy.viewport('macbook-13');
cy.visit('/');
cy.viewport('iphone-6');
cy.url().should('eq', 'http://localhost:4200/');
});
it('should redirect from root to dashboard when switching to desktop', () => {
cy.viewport('iphone-6');
cy.visit('/');
cy.viewport('macbook-13');
cy.url().should('eq', 'http://localhost:4200/dashboard');
});
context('desktop resolution', () => {
beforeEach(() => {
cy.viewport('macbook-13');
cy.visit('/');
});
it('should show links and info on desktop', () => {
getNavigationLinks().should('have.length', 6);
cy.get('h2').contains('Select user profile!');
});
it('can click on link on desktop', () => {
getNavigationLinks().eq(2).click();
cy.url().should('eq', 'http://localhost:4200/3');
cy.get('h2').contains('User 3');
});
it('should show links on desktop profile', () => {
cy.visit('/3');
getNavigationLinks().should('have.length', 6);
});
it('should not show back button on desktop profile', () => {
cy.visit('/3');
getPrimaryButton().should('have.length', 0);
});
});
context('mobile resolution', () => {
beforeEach(() => {
cy.viewport('iphone-6');
cy.visit('/');
});
it('should show only links on mobile', () => {
getNavigationLinks().should('have.length', 5);
cy.get('h2').should('have.length', 0);
});
it('can click on link on mobile', () => {
getNavigationLinks().eq(2).click();
cy.url().should('eq', 'http://localhost:4200/3');
cy.get('h2').contains('User 3');
});
it('should not show links on mobile profile', () => {
cy.visit('/3');
getNavigationLinks().should('have.length', 0);
});
it('should show back button on mobile profile', () => {
cy.visit('/3');
getPrimaryButton().should('have.length', 1);
});
it('should navigate back to root on mobile after primary back button click', () => {
cy.visit('/3');
getPrimaryButton().click();
cy.url().should('eq', 'http://localhost:4200/');
});
});
});