-
Notifications
You must be signed in to change notification settings - Fork 158
Expand file tree
/
Copy pathnavigation.cy.js
More file actions
103 lines (84 loc) · 3.15 KB
/
navigation.cy.js
File metadata and controls
103 lines (84 loc) · 3.15 KB
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
93
94
95
96
97
98
99
100
101
102
103
/**
* Copyright 2026 GitProxy Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Navigation & Shell
* Strategy: Mix of real navigation and intercepts.
*/
describe('Navigation & Shell', () => {
beforeEach(() => {
cy.login('admin', 'admin');
});
afterEach(() => {
cy.logout();
});
// --- 8.1 Sidebar renders all visible links ---
it('8.1 — Sidebar renders all visible links', () => {
cy.visit('/dashboard/repo');
// Sidebar links should be present
cy.contains('Repositories').should('be.visible');
cy.contains('Dashboard').should('be.visible');
});
// --- 8.2 Sidebar links navigate correctly ---
it('8.2 — Sidebar links navigate correctly', () => {
cy.visit('/dashboard/repo');
// Navigate to push dashboard
cy.contains('Dashboard').click();
cy.url().should('include', '/dashboard/push');
// Navigate back to repos
cy.contains('Repositories').click();
cy.url().should('include', '/dashboard/repo');
});
// --- 8.3 Active sidebar item highlights ---
it('8.3 — Active sidebar item highlights', () => {
cy.visit('/dashboard/repo');
// The active nav link should have aria-current="page"
cy.get('[aria-current="page"]').should('exist');
});
// --- 8.4 Navbar renders ---
it('8.4 — Navbar renders correctly', () => {
cy.visit('/dashboard/repo');
cy.get('[data-testid="navbar"]').should('be.visible');
});
// --- 8.5 Footer renders ---
it('8.5 — Footer renders', () => {
cy.visit('/dashboard/repo');
cy.get('[data-testid="footer"]').should('exist');
cy.get('[data-testid="footer"]').scrollIntoView();
cy.get('[data-testid="footer"]').should('be.visible');
});
// --- 8.6 Unauthenticated user redirected ---
// NOTE: This test must run WITHOUT a login session, otherwise cy.session()
// caches authenticated cookies and restores them on cy.visit() despite
// cy.clearCookies() / cy.clearLocalStorage(). We place it in its own
// describe block that has no beforeEach login hook.
// --- 8.7 Root redirects to dashboard/repo ---
it('8.7 — / redirects to /dashboard/repo', () => {
cy.logout();
cy.visit('/');
// Root should redirect (either to login if not authenticated, or to dashboard/repo)
cy.url().should('match', /\/(login|dashboard)/);
});
});
describe('Unauthenticated access', () => {
it('8.6 — Unauthenticated user is redirected to /login', () => {
// Clear any saved Cypress sessions so no auth cookies are restored
Cypress.session.clearAllSavedSessions();
cy.clearCookies();
cy.clearLocalStorage();
cy.visit('/dashboard/profile');
cy.url().should('include', '/login');
});
});