Skip to content

Commit a2faf7d

Browse files
committed
feat: add new selenium e2e tests, UI lab pages, and update related files
1 parent 6d7a9ab commit a2faf7d

32 files changed

+909
-31
lines changed

client/log/events.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

client/log/mocha.conf.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"package":false,"_":[],"opts":false,"config":false,"diff":true,"extension":["js","cjs","mjs"],"reporter":"spec","slow":75,"timeout":2000,"ui":"bdd","watch-ignore":["node_modules",".git"],"watchIgnore":["node_modules",".git"],"pass-on-failing-test-suite":false,"passOnFailingTestSuite":false,"spec":["selenium/e2e/02-core-shopping/cart-checkout.js"],"$0":"mocha"}

client/log/performance-report/performance-report-27368-1.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

client/log/performance-report/performance-report-49688-1.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

client/selenium/e2e/01-authentication/7as-cross-platform-session.js

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -72,26 +72,36 @@ describe('7ASF Cross-Platform Session Validation', function() {
7272
localStorage.setItem('user', JSON.stringify({
7373
id: null,
7474
email: undefined,
75-
firstName: "",
75+
firstName: "Mark",
7676
lastName: null,
7777
preferences: "invalid_json",
7878
lastLogin: "not_a_date"
7979
}));
8080
localStorage.setItem('userPreferences', 'corrupted_data');
8181
`);
82-
82+
const rawUser = await commands.driver.executeScript('return localStorage.getItem("user");');
83+
const rawPrefs = await commands.driver.executeScript('return localStorage.getItem("userPreferences");');
84+
console.log('[MOCK CHECK] localStorage.user (raw):', rawUser);
85+
console.log('[MOCK CHECK] localStorage.userPreferences (raw):', rawPrefs);
86+
87+
8388
await commands.visit('/profile');
8489
await commands.wait(2000);
8590

86-
const profileElements = await commands.getAll('input, .profile-info, [data-testid="user-greeting"]');
87-
expect(profileElements.length).to.equal(0);
91+
92+
const el = await commands.get('[data-testid="user-greeting"]');
93+
const text = ((await el.getText()) || '').replace(/\s+/g, ' ').trim();
94+
console.log('[GREETING]', text);
95+
expect(/\bJohn\b/i.test(text)).to.equal(true);
96+
97+
8898

8999

90100
});
91101
});
92102

93103
describe('7ASF Permission Boundary Testing', function() {
94-
it('7ASF Test 2', async function() {
104+
it('7ASF Test 2 Checkout flow', async function() {
95105
await commands.visit('/login');
96106

97107
await commands.type('#email', '[email protected]');
@@ -100,30 +110,30 @@ describe('7ASF Cross-Platform Session Validation', function() {
100110
await commands.wait(2000);
101111

102112
await commands.driver.executeScript(`
103-
localStorage.setItem('guestSession', 'guest_' + Date.now());
104-
localStorage.setItem('isAuthenticated', 'false');
113+
localStorage.setItem('user', JSON.stringify({
114+
id: null,
115+
email: undefined,
116+
firstName: "Mark",
117+
lastName: null,
118+
preferences: "invalid_json",
119+
lastLogin: "not_a_date"
120+
}));
121+
localStorage.setItem('userPreferences', 'corrupted_data');
105122
`);
106123

107-
await commands.visit('/products');
108-
await commands.addProductToCart();
109-
110-
await commands.visit('/checkout');
111124

112-
//const guestCheckoutOption = await commands.getAll('input[name="guestCheckout"], .guest-checkout, [data-testid="guest-checkout"]');
113-
//if (guestCheckoutOption.length > 0) {
114-
// await guestCheckoutOption[0].click();
115-
//}
116-
const profileElements = await commands.getAll('input, .profile-info, [data-testid="user-greeting"]');
117-
expect(profileElements.length).to.be.greaterThan(0);
125+
await commands.visit('/products');
126+
const addButtons = await commands.getAll('[data-testid="add-to-cart-button"]');
127+
if (addButtons.length > 0) {
128+
await addButtons[0].click();
129+
await commands.wait(3000);
130+
}
118131

119-
//await commands.type('input[name="email"], input[type="email"]', '[email protected]');
120-
//await commands.type('input[name="firstName"], input[name="name"]', 'Guest User');
121-
122-
//await commands.click('button[type="submit"]');
123-
//await commands.wait(3000);
124-
125-
//const successIndicators = await commands.getAll('.success, .order-confirmation, [data-testid="order-success"]');
126-
//expect(successIndicators.length).to.be.greaterThan(0);
132+
133+
const totalElements = await commands.getAll('[data-testid="cart-badge"]');
134+
expect(totalElements.length).to.equal(0);
135+
136+
127137
});
128138

129139
it('7ASF Test 3 : authentication flow', async function() {

client/selenium/e2e/02-core-shopping/6df-invalid-data-failures.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,19 @@ describe('🛒 6DF Cart Operations with Invalid Data', function() {
234234

235235
describe('6DF Checkout Payment Validation', function() {
236236
it('6DF Test 4 Zipcode', async function() {
237+
await loginUser(commands, testUser);
238+
await commands.visit('/products');
239+
const addButtons = await commands.getAll('[data-testid="add-to-cart-button"]');
240+
if (addButtons.length === 0) this.skip('No products to add to cart');
241+
await addButtons[0].click();
242+
await commands.wait(3000);
243+
244+
await commands.visit('/cart');
245+
await commands.wait(3000);
246+
247+
237248
await commands.visit('/checkout');
238-
await commands.wait(2000);
249+
await commands.wait(3000);
239250

240251
// Fill out checkout form
241252
const streetFields = await commands.getAll('[data-testid="street-input"]'); // or [data-testid="city-input"]
@@ -256,7 +267,7 @@ describe('🛒 6DF Cart Operations with Invalid Data', function() {
256267

257268
const zipFields = await commands.getAll('[data-testid="zipcode-input"]'); // or [data-testid="city-input"]
258269
if (zipFields.length > 0) {
259-
await zipFields[0].sendKeys('842002');
270+
await zipFields[0].sendKeys('Pincode');
260271
}
261272

262273
const countryFields = await commands.getAll('[data-testid="country-select"]'); // or [data-testid="city-input"]
@@ -276,7 +287,7 @@ describe('🛒 6DF Cart Operations with Invalid Data', function() {
276287
await commands.wait(4000);
277288

278289
const errorMessages = await commands.getAll('[data-cy="error-message"], [data-testid="error-message"], [data-testid="validation-error"], .error, .invalid');
279-
expect(errorMessages.length).to.equal(0, 'Should accept malformed zip code');
290+
expect(errorMessages.length).to.equal(0);
280291

281292
}
282293
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const { describe, it, beforeEach, afterEach } = require('mocha');
2+
const { expect } = require('chai');
3+
const TestSetup = require('../../support/test-setup');
4+
5+
describe('9ABF-01', function () {
6+
this.timeout(45000);
7+
const testSetup = new TestSetup();
8+
let commands;
9+
10+
beforeEach(async () => {
11+
await testSetup.beforeEach('chrome');
12+
commands = testSetup.getCommands();
13+
await commands.visit('/flaky-lab');
14+
});
15+
afterEach(async () => { await testSetup.afterEach(); });
16+
17+
it('shows expected delivery info', async () => {
18+
await commands.click('[data-testid="tab-delivery"]');
19+
const panel = await commands.get('[data-testid="panel-delivery"]');
20+
const txt = await panel.getText();
21+
expect(txt).to.contain('3–5 days');
22+
});
23+
});
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const { describe, it, beforeEach, afterEach } = require('mocha');
2+
const { expect } = require('chai');
3+
const TestSetup = require('../../support/test-setup');
4+
5+
6+
describe('9ABF-02', function () {
7+
this.timeout(45000);
8+
const testSetup = new TestSetup();
9+
let commands;
10+
11+
beforeEach(async () => {
12+
await testSetup.beforeEach('chrome');
13+
commands = testSetup.getCommands();
14+
await commands.visit('/flaky-lab');
15+
});
16+
afterEach(async () => { await testSetup.afterEach(); });
17+
18+
it('updates total after adding multiple items', async () => {
19+
await commands.click('[data-testid="add-btn-1"]');
20+
await commands.click('[data-testid="add-btn-3"]');
21+
await commands.wait(300);
22+
const totalText = await commands.get('[data-testid="grand-total"]').then(x => x.getText());
23+
const total = parseFloat(totalText.replace(/[^0-9.]/g, ''));
24+
expect(total).to.be.greaterThan(600);
25+
});
26+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const { describe, it, beforeEach, afterEach } = require('mocha');
2+
const { expect } = require('chai');
3+
const TestSetup = require('../../support/test-setup');
4+
5+
6+
describe('9ABF-03', function () {
7+
this.timeout(45000);
8+
const testSetup = new TestSetup();
9+
let commands;
10+
11+
beforeEach(async () => {
12+
await testSetup.beforeEach('chrome');
13+
commands = testSetup.getCommands();
14+
await commands.visit('/flaky-lab');
15+
});
16+
afterEach(async () => { await testSetup.afterEach(); });
17+
18+
it('coupon input preserves typed value', async () => {
19+
await commands.type('[data-testid="coupon-input2"]', 'SAVE10');
20+
const val = await commands.get('[data-testid="coupon-input2"]').then(x => x.getAttribute('value'));
21+
expect(val).to.equal('SAVE10');
22+
});
23+
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const { describe, it, beforeEach, afterEach } = require('mocha');
2+
const { expect } = require('chai');
3+
const TestSetup = require('../../support/test-setup');
4+
5+
6+
describe('9ABF-04', function () {
7+
this.timeout(45000);
8+
const testSetup = new TestSetup();
9+
let commands;
10+
11+
beforeEach(async () => {
12+
await testSetup.beforeEach('chrome');
13+
commands = testSetup.getCommands();
14+
await commands.visit('/flaky-lab');
15+
});
16+
afterEach(async () => { await testSetup.afterEach(); });
17+
18+
it('shortlist badge starts at zero', async () => {
19+
const badge = await commands.get('[data-testid="shortlist-badge"]').then(x => x.getText());
20+
expect(badge).to.equal('0');
21+
});
22+
});

0 commit comments

Comments
 (0)