Skip to content
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

Selenium tests failing when run locally - fix #1825

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions src/WrapperApp/components/NavDrawer/NavDrawer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,24 @@ describe('NavDrawer component', () => {
await driver.quit();
}, 30000);

// this function hides the react error overlay, as its presence interferes with the tests when running locally
async function hideErrorOverlay() {
try {
const overlay = await driver.wait(
until.elementLocated(By.id('webpack-dev-server-client-overlay')),
1000 // short timeout to avoid unnecessary waiting
);
await driver.executeScript("arguments[0].style.display = 'none';", overlay);
} catch (error) {
// overlay not found within timeout, proceed without hiding it
}
}

//this test checks if the menu button (upper left corner, next to the yaptide logo) has rendered
test('renders a menu button', async () => {
await driver.get('http://localhost:3000');
//hide react overlay if present
await hideErrorOverlay();
const menuButton = await driver.findElement(
By.xpath("//button[@aria-label = 'Toggle drawer button']")
);
Expand All @@ -28,6 +43,8 @@ describe('NavDrawer component', () => {
//this test check if the menu button works (closes and opens the menu drawer)
test('closes and opens the drawer on click', async () => {
await driver.get('http://localhost:3000');
//hide react overlay if present
await hideErrorOverlay();

//find the menu button and then click it
const menuButton = await driver.findElement(
Expand Down
16 changes: 16 additions & 0 deletions src/__tests__/FlukaConverter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,26 @@ describe('Fluka Converter', () => {
await driver.quit();
}, 30_000);

// this function hides the react error overlay, as its presence interferes with the tests when running locally
async function hideErrorOverlay() {
try {
const overlay = await driver.wait(
until.elementLocated(By.id('webpack-dev-server-client-overlay')),
1000 // short timeout to avoid unnecessary waiting
);
await driver.executeScript("arguments[0].style.display = 'none';", overlay);
} catch (error) {
// overlay not found within timeout, proceed without hiding it
}
}

//this test checks if converter works correctly - opens an example and generates config files
test('converter generates correct files', async () => {
await driver.get('http://localhost:3000');

//hide react overlay if present
await hideErrorOverlay();

// Wait for the application to load
expect(
await driver.wait(
Expand Down
16 changes: 16 additions & 0 deletions src/__tests__/ShieldhitConverter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,26 @@ describe('ShieldhitConverter', () => {
await driver.quit();
}, 30_000);

// this function hides the react error overlay, as its presence interferes with the tests when running locally
async function hideErrorOverlay() {
try {
const overlay = await driver.wait(
until.elementLocated(By.id('webpack-dev-server-client-overlay')),
1000 // short timeout to avoid unnecessary waiting
);
await driver.executeScript("arguments[0].style.display = 'none';", overlay);
} catch (error) {
// overlay not found within timeout, proceed without hiding it
}
}

//this test checks if converter works correctly - opens an example and generates config files
test('converter generates correct files', async () => {
await driver.get('http://localhost:3000');

//hide react overlay if present
await hideErrorOverlay();

// Wait for the application to load
expect(
await driver.wait(
Expand Down
16 changes: 16 additions & 0 deletions src/__tests__/TopasConverter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,27 @@ describe('TopasConverter', () => {
await driver.quit();
}, 30_000);

// this function hides the react error overlay, as its presence interferes with the tests when running locally
async function hideErrorOverlay() {
try {
const overlay = await driver.wait(
until.elementLocated(By.id('webpack-dev-server-client-overlay')),
1000 // short timeout to avoid unnecessary waiting
);
await driver.executeScript("arguments[0].style.display = 'none';", overlay);
} catch (error) {
// overlay not found within timeout, proceed without hiding it
}
}

//this test checks if converter works correctly - opens an example and generates config files
// expected to fail because Topas was temporarily removed from the project
xtest('converter generates correct files', async () => {
await driver.get('http://localhost:3000');

//hide react overlay if present
await hideErrorOverlay();

// Wait for the application to load
expect(
await driver.wait(
Expand Down
Loading