Skip to content

Commit 705e2ad

Browse files
Refactor test cases for improved readability and consistency (#1652)
Closes https://github.com/SoftUni-Internal/exam-systems-issues/issues/your_issue_number **Summary of the changes made**: 1. {Describe your changes in the list} 2. --------- Co-authored-by: Georgi Georgiev <gogo4ds@gmail.com>
1 parent 8798776 commit 705e2ad

File tree

1 file changed

+170
-5
lines changed

1 file changed

+170
-5
lines changed
Lines changed: 170 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,195 @@
11
import { expect, test } from './fixtures/auth.fixture';
22

3-
test('has title', async ({ page }) => {
3+
test('Has title', async ({ page }) => {
44
await page.goto('/') ;
55

66
// Expect a title "to contain" a substring.
77
await expect(page).toHaveTitle(/SoftUni Judge Platform/);
88
});
99

10-
test('can log in', async ({ page, auth }) => {
10+
test('Can log in', async ({ page, auth }) => {
1111
await auth.loginDefaultTestUser();
1212
const response = await page.goto('/profile');
1313
expect(response?.status()).toBe(200);
1414
await expect(page).toHaveURL('/profile');
1515
});
1616

17-
test('can log out', async ({ page, auth }) => {
17+
test('Can log out', async ({ page, auth }) => {
1818
await auth.loginDefaultTestUser();
1919
await page.goto('/profile');
2020
await expect(page).toHaveURL('/profile');
2121

2222
await page.goto('/logout');
2323

2424
await expect(page.getByText('You are now successfully logged out')).toBeVisible();
25-
await page.waitForURL('/');
2625
await expect(page).toHaveURL('/');
2726

2827
const response = await page.goto('/profile');
29-
expect(response?.status()).not.toBe(200);
28+
await expect(page).toHaveURL('/login');
3029
});
30+
31+
test('Should contain the text "How to use SoftUni Judge Platform"', async ({ page }) => {
32+
await page.goto('/');
33+
34+
// Check if the text is present on the page
35+
const text = await page.locator('text=How to use SoftUni Judge Platform');
36+
await expect(text).toBeVisible();
37+
});
38+
39+
test('Should Check if the video is visible', async ({ page }) => {
40+
await page.goto('/');
41+
42+
const videoElement = await page.locator('[data-title="Guidelines for working with the SoftUni Judge platform"]');
43+
44+
// Check if the video is visible
45+
await expect(videoElement).toBeVisible();
46+
});
47+
48+
test('Verify Programming Basics dropdown contents', async ({ page }) => {
49+
// Navigate to the SoftUni Judge platform
50+
await page.goto('/');
51+
52+
// Wait for the dropdown to be visible and click it
53+
const dropdown = await page.getByText('Programming Basics', { exact: true }).click();
54+
55+
// Define the expected menu items in order
56+
const expectedItems = [
57+
'C# Basics',
58+
'Java Basics',
59+
'JS Basics',
60+
'Python Basics',
61+
'PB - More Exercises',
62+
'PB - Exams',
63+
'C++ Basics',
64+
'Go Basics'
65+
];
66+
67+
// Verify each menu item exists and is visible
68+
for (const itemText of expectedItems) {
69+
const item = await page.getByRole('link', { name: itemText });
70+
await expect(item).toBeVisible();
71+
}
72+
});
73+
74+
test('Verify Software Technologies dropdown contents', async ({ page }) => {
75+
// Navigate to the SoftUni Judge platform
76+
await page.goto('/');
77+
78+
// Wait for the dropdown to be visible and click it
79+
const dropdownQaulityAssurance = await page.getByText('Quality Assurance', { exact: true }).click();
80+
const dropdownQaFundamentals = await page.getByText('QA Fundamentals', { exact: true }).click();
81+
const dropdownSoftwareTechnologies = await page.getByText('Software Technologies', { exact: true }).click();
82+
// Define the expected menu items in order
83+
const expectedItems = [
84+
'Software Technologies - Exercises',
85+
'Software Technologies - Exams'
86+
];
87+
88+
// Verify each menu item exists and is visible
89+
for (const itemText of expectedItems) {
90+
const item = await page.getByRole('link', { name: itemText });
91+
await expect(item).toBeVisible();
92+
}
93+
});
94+
95+
test('Verify QA Fundamentals and Manual Testing dropdown contents', async ({ page }) => {
96+
// Navigate to the SoftUni Judge platform
97+
await page.goto('/');
98+
99+
// Wait for the dropdown to be visible and click it
100+
const dropdownQaulityAssurance = await page.getByText('Quality Assurance', { exact: true }).click();
101+
const dropdownQaFundamentals = await page.getByText('QA Fundamentals', { exact: true }).click();
102+
const dropdownSoftwareTechnologies = await page.getByText('QA Fundamentals and Manual Testing', { exact: true }).click();
103+
// Define the expected menu items in order
104+
const expectedItems = [
105+
'QA Fundamentals and Manual Testing - Exams'
106+
];
107+
108+
// Verify each menu item exists and is visible
109+
for (const itemText of expectedItems) {
110+
const item = await page.getByRole('link', { name: itemText });
111+
await expect(item).toBeVisible();
112+
}
113+
});
114+
115+
test('Verify Programming Fundamentals and Unit Testing dropdown contents', async ({ page }) => {
116+
// Navigate to the SoftUni Judge platform
117+
await page.goto('/');
118+
119+
// Wait for the dropdown to be visible and click it
120+
const dropdownQaulityAssurance = await page.getByText('Quality Assurance', { exact: true }).click();
121+
const dropdownQaFundamentals = await page.getByText('Programming for QA', { exact: true }).click();
122+
const dropdownSoftwareTechnologies = await page.getByText('Programming Fundamentals and Unit Testing', { exact: true }).click();
123+
// Define the expected menu items in order
124+
const expectedItems = [
125+
'Programming Fundamentals and Unit Testing - Exercises',
126+
'Programming Fundamentals and Unit Testing - Exams'
127+
];
128+
129+
// Verify each menu item exists and is visible
130+
for (const itemText of expectedItems) {
131+
const item = await page.getByRole('link', { name: itemText });
132+
await expect(item).toBeVisible();
133+
}
134+
});
135+
136+
test('Verify Programming Advanced for QA dropdown contents', async ({ page }) => {
137+
// Navigate to the SoftUni Judge platform
138+
await page.goto('/');
139+
140+
// Wait for the dropdown to be visible and click it
141+
const dropdownQaulityAssurance = await page.getByText('Quality Assurance', { exact: true }).click();
142+
const dropdownQaFundamentals = await page.getByText('Programming for QA', { exact: true }).click();
143+
const dropdownSoftwareTechnologies = await page.getByText('Programming Advanced for QA', { exact: true }).click();
144+
// Define the expected menu items in order
145+
const expectedItems = [
146+
'Programming Advanced for QA - Exercises',
147+
'Programming Advanced for QA - Exams'
148+
];
149+
150+
// Verify each menu item exists and is visible
151+
for (const itemText of expectedItems) {
152+
const item = await page.getByRole('link', { name: itemText });
153+
await expect(item).toBeVisible();
154+
}
155+
});
156+
157+
test('Verify Back-End Test Automation dropdown contents', async ({ page }) => {
158+
// Navigate to the SoftUni Judge platform
159+
await page.goto('/');
160+
161+
// Wait for the dropdown to be visible and click it
162+
const dropdownQaulityAssurance = await page.getByText('Quality Assurance', { exact: true }).click();
163+
const dropdownQaFundamentals = await page.getByText('Back-End Test Automation', { exact: true }).click();
164+
// Define the expected menu items in order
165+
const expectedItems = [
166+
'Back-End Technologies Basics - Exercises',
167+
'Back-End Technologies Basics - Exams'
168+
];
169+
170+
// Verify each menu item exists and is visible
171+
for (const itemText of expectedItems) {
172+
const item = await page.getByRole('link', { name: itemText });
173+
await expect(item).toBeVisible();
174+
}
175+
});
176+
177+
test('Contests page loads successfully', async ({ page }) => {
178+
await page.goto('/contests');
179+
await expect(page).toHaveTitle(/Contests/i);
180+
});
181+
182+
test('Contests list is visible', async ({ page }) => {
183+
await page.goto('/contests');
184+
const contestItems = await page.locator('._contestsListContainer_15pps_57');
185+
await expect(contestItems.first()).toBeVisible();
186+
});
187+
188+
test('Page works without JavaScript', async ({ browser }) => {
189+
const context = await browser.newContext({ javaScriptEnabled: false });
190+
const page = await context.newPage();
191+
await page.goto('/contests');
192+
const bodyText = await page.textContent('body');
193+
expect(bodyText).toContain('You need to enable JavaScript to run this app.');
194+
await context.close();
195+
});

0 commit comments

Comments
 (0)