Skip to content

flaky issue - testing #1034

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
82562ca
flaky issue - testing
Satish-Pothabathula Mar 20, 2025
2cb9122
flaky issue - testing
Satish-Pothabathula Mar 20, 2025
3dd6360
flaky test fixes
Satish-Pothabathula Mar 25, 2025
1a90888
flaky test fixes
Satish-Pothabathula Mar 25, 2025
380550b
flaky test fixes
Satish-Pothabathula Mar 25, 2025
56cd475
flaky test fixes - set screen size
Satish-Pothabathula Mar 25, 2025
04872ee
flaky test fixes - set screen size with screenshot
Satish-Pothabathula Mar 25, 2025
e191e9c
flaky test fixes - set screen size with screenshot
Satish-Pothabathula Mar 25, 2025
502d1d3
flaky test fixes - set screen size with screenshot
Satish-Pothabathula Mar 25, 2025
b7e866d
flaky test fixes - set screen size with screenshot
Satish-Pothabathula Mar 25, 2025
055d54a
flaky test fixes - set screen size with screenshot
Satish-Pothabathula Mar 25, 2025
8238095
flaky test fixes - set screen size with screenshot
Satish-Pothabathula Mar 25, 2025
3dc634f
flaky test fixes - set screen size with screenshot
Satish-Pothabathula Mar 26, 2025
9f0b8cf
flaky test fixes - set screen size with screenshot with scroll
Satish-Pothabathula Mar 26, 2025
4b1d83c
flaky test fixes - set screen size with screenshot with scroll
Satish-Pothabathula Mar 26, 2025
e772804
revrting the screensize and remaining page to load title time
Satish-Pothabathula Mar 26, 2025
831e0c1
scrolling value decrase
Satish-Pothabathula Mar 26, 2025
8017f21
removing scrolling value decrase
Satish-Pothabathula Mar 26, 2025
dfecdfd
CF test waiting for page load
Satish-Pothabathula Mar 26, 2025
ca6c6ed
removes browser pause it fix page load issue
Satish-Pothabathula Mar 26, 2025
bdb850a
retries page to load for 3 times
Satish-Pothabathula Mar 26, 2025
5175acf
IT test changes
Satish-Pothabathula Mar 26, 2025
ea33919
IT test changes
Satish-Pothabathula Mar 26, 2025
998b7ba
revert IT test & removing screenshot from test
Satish-Pothabathula Mar 26, 2025
1d5ab5c
updating IT test with reload time
Satish-Pothabathula Mar 26, 2025
47abb7c
IT test reloading page until it load max 30 sec
Satish-Pothabathula Mar 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,35 @@ public static void beforeClass() throws Exception {

@Test
public void testContentFragmenWithSampleData() throws ClientException {
SlingHttpResponse response = adminAuthor.doGet(COMMERCE_LIBRARY_PATH + "/product/sample-product.html/chaz-kangeroo-hoodie.html",
200);
long startTime = System.currentTimeMillis();
long maxWaitTime = 30000; // 30 seconds
boolean success = false;
SlingHttpResponse response = null;

while (!success && (System.currentTimeMillis() - startTime) < maxWaitTime) {
try {
response = adminAuthor.doGet(COMMERCE_LIBRARY_PATH + "/product/sample-product.html/chaz-kangeroo-hoodie.html", 200);
success = true;
} catch (ClientException e) {
// Wait for a short period before retrying
try {
Thread.sleep(2000);
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
throw new RuntimeException(ie);
}
}
}

if (!success) {
throw new ClientException("Failed to load the page within the maximum wait time.");
}

Document doc = Jsoup.parse(response.getContent());

// Check the number of content fragment elements in the content fragment component
Elements elements = doc.select(CONTENT_FRAGMENT_SELECTOR
+ ".cmp-contentfragment > .cmp-contentfragment__elements > .cmp-contentfragment__element");
Assert.assertEquals(1, elements.size());
}
}
}
73 changes: 59 additions & 14 deletions ui.tests/test-module/specs/cif-components-library/product-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const config = require('../../lib/config');
const commons = require('../../lib/commons');

describe('Product bundle in CIF components library', () => {

const product_page = `${config.aem.author.base_url}/content/core-components-examples/library/commerce/product/sample-product.html/sprite-yoga-companion-kit.html`;
const product_selector = '.cmp-examples-demo__top .product';

Expand All @@ -33,25 +32,71 @@ describe('Product bundle in CIF components library', () => {
});

beforeEach(() => {
// Set window size to desktop
browser.setWindowSize(1280, 960);
});

it('can customize a bundle product', () => {
// Go to the product page
browser.url(product_page);
// Max number of retries
let retries = 3;
let pageLoadedSuccessfully = false;

// Check that the customize button is displayed
const customizeButton = $(`${product_selector} .productFullDetail__customizeBundle button`);
expect(customizeButton).toBeDisplayed();
while (retries > 0 && !pageLoadedSuccessfully) {
try {
// Go to the product page
browser.url(product_page);

customizeButton.click();
// Scroll to the "Sprite Yoga Companion Kit" title
const titleElement = $('h1=Sprite Yoga Companion Kit'); // Find the title by its exact text
titleElement.scrollIntoView(); // Scroll the page to the title

browser.pause(2000);
// Wait for the title to be in view (for debugging purposes)
browser.pause(1000);

// Verify that we get 5 "options" fields
const options = $$(`${product_selector} .productFullDetail__bundleProduct`);
expect(options.length).toBe(5);
});
// Try finding the "Customize" button using the normal selector
let customizeButton = $(`${product_selector} .productFullDetail__customizeBundle button`);

// If the button is not found, try finding it by the button text
if (!customizeButton.isExisting()) {
customizeButton = $('button=Customize'); // Find the button by its text content
}

// Ensure the button is displayed and interactable
if (customizeButton.isDisplayedInViewport()) {
// Scroll to the button if it's not in view
customizeButton.scrollIntoView();

// Wait for the button to be clickable and click it
customizeButton.waitForClickable({ timeout: 20000 });
customizeButton.click();

// Pause to allow any post-click actions to complete
browser.pause(2000);

});
// Check for bundle product options after clicking the button
const options = $$(`${product_selector} .productFullDetail__bundleProduct`);

// Ensure there are exactly 5 options available
expect(options.length).toBe(5);

// If everything works, mark page as successfully loaded
pageLoadedSuccessfully = true;
} else {
throw new Error('Customize button is not visible in the viewport!');
}
} catch (error) {
retries--; // Decrease retry count

// If retries left, refresh the page and try again
if (retries > 0) {
browser.refresh();
browser.pause(3000); // Wait for 3 seconds before retrying
}
}
}

// Fail the test if the page is not loaded successfully after retries
if (!pageLoadedSuccessfully) {
throw new Error('Page could not be loaded successfully after 3 retries.');
}
});
});