Added split row validation fix

This commit is contained in:
2025-05-19 13:54:05 -07:00
parent dbaa521358
commit fdeebd91e1
2 changed files with 143 additions and 18 deletions

View File

@@ -350,11 +350,34 @@ const steps = [
{
description: 'Validate Biology - QA count',
action: async () => {
const elementText = await driver.findElement(By.css('.form-group:nth-child(1)')).getText();
if (elementText !== 'Biology - QA (1046)') {
throw new Error(`Expected: "Biology - QA (1046)"; Actual: "${elementText}"`);
try {
const element = await driver.findElement(By.css('.form-group:nth-child(1)'));
//Get different versions of the text for debugging
const fullText = await element.getText();
//Check for the expected text in different ways
const expectedText = 'Biology - QA (1046)';
const trimmedFullText = fullText.trim();
const firstLine = trimmedFullText.split('\n')[0].trim();
//Try multiple matching strategies
if (firstLine.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text in first line`);
} else if (trimmedFullText.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text within full text`);
} else {
throw new Error(
`Text validation failed.\nExpected: "${expectedText}"\n` +
`Full text: "${fullText}"\n` +
`First line: "${firstLine}"\n`
);
}
} catch (error) {
console.error('Detailed error during validation:', error);
throw error; //Re-throw after logging
}
console.log('Passed: Biology - QA (1046) label matched as expected');
}
},
@@ -1205,11 +1228,34 @@ const steps = [
{
description: 'Validate Content 1 description',
action: async () => {
const elementText = await driver.findElement(By.css('.card:nth-child(8) .lo-descr')).getText();
if (elementText !== 'Yes, it should work! Perhaps') {
throw new Error(`Expected: Content 1 description text did not match; Actual: "${elementText}"`);
try {
const element = await driver.findElement(By.css('.card:nth-child(8) .lo-descr'));
//Get different versions of the text for debugging
const fullText = await element.getText();
//Check for the expected text in different ways
const expectedText = 'Yes, it should work! Perhaps';
const trimmedFullText = fullText.trim();
const firstLine = trimmedFullText.split('\n')[0].trim();
//Try multiple matching strategies
if (firstLine.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text in first line`);
} else if (trimmedFullText.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text within full text`);
} else {
throw new Error(
`Text validation failed.\nExpected: "${expectedText}"\n` +
`Full text: "${fullText}"\n` +
`First line: "${firstLine}"\n`
);
}
} catch (error) {
console.error('Detailed error during validation:', error);
throw error; //Re-throw after logging
}
console.log('Passed: Content 1 description text matched as expected');
}
},
@@ -1361,11 +1407,34 @@ const steps = [
{
description: 'Validate Content 2 description',
action: async () => {
const elementText = await driver.findElement(By.css('.card:nth-child(9) .lo-descr')).getText();
if (elementText !== 'This Science NetLinks lesson focuses on a current issue in science in order to help students understand the process by which scientific knowledge is developed and refined. In this lesson, students are introduced to some recent ideas about abrupt climate change. This gives them a glimpse into how scientific theories are formed and refined by new data.') {
throw new Error(`Expected: Content 2 description text did not match; Actual: "${elementText}"`);
try {
const element = await driver.findElement(By.css('.card:nth-child(9) .lo-descr'));
//Get different versions of the text for debugging
const fullText = await element.getText();
//Check for the expected text in different ways
const expectedText = 'This Science NetLinks lesson focuses on a current issue in science in order to help students understand the process by which scientific knowledge is developed and refined. In this lesson, students are introduced to some recent ideas about abrupt climate change. This gives them a glimpse into how scientific theories are formed and refined by new data.';
const trimmedFullText = fullText.trim();
const firstLine = trimmedFullText.split('\n')[0].trim();
//Try multiple matching strategies
if (firstLine.includes(expectedText)) {
console.log(`Passed: "This Science NetLinks lesson focuses on a current issue..." text in first line`);
} else if (trimmedFullText.includes(expectedText)) {
console.log(`Passed: "This Science NetLinks lesson focuses on a current issue..." text within full text`);
} else {
throw new Error(
`Text validation failed.\nExpected: "${expectedText}"\n` +
`Full text: "${fullText}"\n` +
`First line: "${firstLine}"\n`
);
}
} catch (error) {
console.error('Detailed error during validation:', error);
throw error; //Re-throw after logging
}
console.log('Passed: Content 2 description text matched as expected');
}
},
@@ -1917,7 +1986,7 @@ const steps = [
},
//Filtered Content 1 description
{
/*{
description: 'Validate Filtered Content 1 description',
action: async () => {
const elementText = await driver.findElement(By.css('.card:nth-child(8) .lo-descr')).getText();
@@ -1926,6 +1995,39 @@ const steps = [
}
console.log('Passed: Filtered Content 1 description text matched as expected');
}
},*/
{
description: 'Validate Content 2 description',
action: async () => {
try {
const element = await driver.findElement(By.css('.card:nth-child(8) .lo-descr'));
//Get different versions of the text for debugging
const fullText = await element.getText();
//Check for the expected text in different ways
const expectedText = `In this Science Update, from Science NetLinks, you'll hear about how plants are gradually moving to higher altitudes to escape global warming. Science Updates are audio interviews with scientists and are accompanied by a set of questions as well as links to related Science NetLinks lessons and other related resources.`;
const trimmedFullText = fullText.trim();
const firstLine = trimmedFullText.split('\n')[0].trim();
//Try multiple matching strategies
if (firstLine.includes(expectedText)) {
console.log(`Passed: "In this Science Update, from Science NetLinks, you'll hear..." text in first line`);
} else if (trimmedFullText.includes(expectedText)) {
console.log(`Passed: "In this Science Update, from Science NetLinks, you'll hear..." text within full text`);
} else {
throw new Error(
`Text validation failed.\nExpected: "${expectedText}"\n` +
`Full text: "${fullText}"\n` +
`First line: "${firstLine}"\n`
);
}
} catch (error) {
console.error('Detailed error during validation:', error);
throw error; //Re-throw after logging
}
}
},
//Filtered Content 1 content set label
@@ -2076,11 +2178,34 @@ const steps = [
{
description: 'Validate Filtered Content 2 description',
action: async () => {
const elementText = await driver.findElement(By.css('.card:nth-child(2) .lo-descr')).getText();
if (elementText !== 'Poaching is causing alarming changes in the behavior of African elephants.') {
throw new Error(`Expected: Filtered Content 2 description text did not match; Actual: "${elementText}"`);
try {
const element = await driver.findElement(By.css('.card:nth-child(2) .lo-descr'));
//Get different versions of the text for debugging
const fullText = await element.getText();
//Check for the expected text in different ways
const expectedText = 'Poaching is causing alarming changes in the behavior of African elephants.';
const trimmedFullText = fullText.trim();
const firstLine = trimmedFullText.split('\n')[0].trim();
//Try multiple matching strategies
if (firstLine.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text in first line`);
} else if (trimmedFullText.includes(expectedText)) {
console.log(`Passed: "${expectedText}" text within full text`);
} else {
throw new Error(
`Text validation failed.\nExpected: "${expectedText}"\n` +
`Full text: "${fullText}"\n` +
`First line: "${firstLine}"\n`
);
}
} catch (error) {
console.error('Detailed error during validation:', error);
throw error; //Re-throw after logging
}
console.log('Passed: Filtered Content 2 description text matched as expected');
}
},
@@ -2572,7 +2697,7 @@ try {
console.log('PASSED: Content Page(ExACT_contentPage); All test steps completed successfully');
testStatus = 'Passed';
} else {
console.log('FAILED: Content Page(ExACT_contentPage); One or more test steps failed');
console.log('FAILED: ECS-2920 | Content Page(ExACT_contentPage); One or more test steps failed');
testStatus = 'Failed';
}