Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
7273fca
Upgrade to nightwatch to 3.12.
cvacalares Mar 31, 2025
32659fa
Add missing flag.
cvacalares Apr 1, 2025
00e62f1
Add chromedriver.
cvacalares Apr 2, 2025
75088b6
Move action inside the callback.
cvacalares Apr 2, 2025
dea2ecc
Disable to workers flag.
cvacalares Apr 6, 2025
b1e5065
Disable the chrome driver.
cvacalares Apr 6, 2025
cb508ad
Update configuration file.
cvacalares Apr 7, 2025
5f3cafc
Update the user data location.
cvacalares Apr 7, 2025
f4108b4
Update configuration.
cvacalares Apr 7, 2025
34bd1d8
add troubleshooting configuration.
cvacalares Apr 7, 2025
c3d7e5b
Add chrome driver.
cvacalares Apr 7, 2025
bc987a9
Set chromedriver to 134.
cvacalares Apr 7, 2025
e3a4255
Add options to log the version.
cvacalares Apr 7, 2025
86bc3b6
Move the google options.
cvacalares Apr 7, 2025
04c3923
Update page object references.
cvacalares Apr 10, 2025
9d55c7c
Refactoring due to nightwatchjs upgrade.
cvacalares Apr 18, 2025
085a03f
Add headless flag.
cvacalares Apr 18, 2025
22fd476
Add window maximized.
cvacalares Apr 18, 2025
c9fe0be
Add check of cucumber_report.json for test failure.
cvacalares Apr 18, 2025
93cf09e
Delete temp folder.
cvacalares Apr 18, 2025
631f3f4
Remove temp dir.
cvacalares Apr 18, 2025
db70280
Log the temp dir.
cvacalares Apr 18, 2025
e66e73a
Modify the desired capabilities.
cvacalares Apr 18, 2025
96f668a
Headless is a must on github.
cvacalares Apr 18, 2025
200fef1
Update variable reference.
cvacalares Apr 19, 2025
2f46e60
Combine the After hook.
cvacalares Apr 19, 2025
caf11cf
Remove the .api.
cvacalares Apr 19, 2025
f5e398a
Add test case name logging.
cvacalares Apr 19, 2025
839f0a7
Remove incorrect method call.
cvacalares Apr 19, 2025
9957b66
Include test as SmokeTests for debugging.
cvacalares Apr 19, 2025
b38964b
Wait for the control to disappear.
cvacalares Apr 19, 2025
3fe3ced
Update program name variable.
cvacalares Apr 19, 2025
b80d381
Extend eventlistener.
cvacalares Apr 19, 2025
790723b
Remove reporter.js. Not in use anymore.
cvacalares Apr 19, 2025
c25c7d1
Update reporter.js.
cvacalares Apr 20, 2025
ec0a858
Wrap into promise.
cvacalares Apr 20, 2025
a14b305
Split the report generation.
cvacalares Apr 26, 2025
4ba4c55
Use the assert.
cvacalares Apr 26, 2025
aa25a43
Fix failing tests due to incorrect seletor.
cvacalares Apr 27, 2025
1f06af2
Update application name.
cvacalares Apr 27, 2025
010ba62
Merge branch 'develop' into feature/BI-2502
cvacalares May 3, 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
3 changes: 3 additions & 0 deletions .github/workflows/daily-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ jobs:
if: (github.event.inputs.suite=='smoke')
run: npm run test:chromeDaily

- name: Run HTML Report generator
run: npm run report

- name: Publish Report Artifact
uses: actions/upload-artifact@v4
if: always()
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ jobs:
if: (github.event.inputs.suite=='smoke')
run: npm run test:chromeDaily

- name: Run HTML Report generator
run: npm run report

- id: biWebBranch
run: INPUT=${{ github.event.inputs.biweb }} && echo "::set-output name=branch::${INPUT/\//-}"

Expand Down
31 changes: 14 additions & 17 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug",
"name": "Debug Cucumber Tests",
"program": "${workspaceRoot}/node_modules/@cucumber/cucumber/bin/cucumber-js",
"args": [
"${workspaceRoot}/src/features",
"--require",
"cucumber.conf.js",
"--require",
"src/step_definitions",
"--world-parameters",
"{\"browser\":\"chrome\",\"launch_url\":\"http://localhost\"}",
"--format",
"json:report/cucumber_report.json",
"--tags",
"@debug"
]
"--require", "cucumber.conf.js",
"--require", "src/step_definitions",
"src/features",
"--format", "json:report/cucumber_report.json",
"--tags", "@debug"
],
"console": "integratedTerminal",
"skipFiles": ["<node_internals>/**"],
"env": {
"NODE_ENV": "test"
},
"runtimeArgs": ["--inspect-brk"]
}
]
}
}
172 changes: 105 additions & 67 deletions cucumber.conf.js
Original file line number Diff line number Diff line change
@@ -1,82 +1,120 @@
const fs = require("fs");
const Nightwatch = require("nightwatch");
const {
setDefaultTimeout,
After,
AfterAll,
BeforeAll,
Before,
setDefaultTimeout,
} = require("@cucumber/cucumber");
const {
createSession,
closeSession,
startWebDriver,
stopWebDriver,
getNewScreenshots,
saveScreenshot,
} = require("nightwatch-api");
const fs = require("fs");
const fsPromises = fs.promises;
const path = require("path");
const os = require("os");
const reporter = require("cucumber-html-reporter");
const { client } = require("nightwatch-api");
const run = {
browserName: "",
platform: "",
version: "",
BreedingInsight: "",
};

setDefaultTimeout(600000);
global.__basedir = __dirname;

Before(async function () {
await createSession({ env: this.parameters.browser });
await client.resizeWindow(1900, 1200);
this.parameters.timeStamp = Date.now();
if (process.env.npm_config_url != undefined) {
this.parameters.launch_url = process.env.npm_config_url;

require("events").EventEmitter.defaultMaxListeners = 20;
setDefaultTimeout(300000);

Before(async function ({ pickle }) {
fs.mkdirSync("report", { recursive: true });
fs.mkdirSync("screenshots", { recursive: true });

this.tmpUserDataDir = fs.mkdtempSync(
path.join(os.tmpdir(), "nw-chrome-profile-")
);
console.log("tmpUserDataDir:", this.tmpUserDataDir);

const chromeArgs = [
"--no-sandbox",
"--disable-dev-shm-usage",
"--disable-extensions",
"--disable-gpu",
"--disable-background-networking",
"--disable-sync",
"--metrics-recording-only",
"--disable-default-apps",
"--mute-audio",
"--no-first-run",
"--ignore-certificate-errors",
"--allow-insecure-localhost",
"--window-size=1920,1080",
"--headless=new",
];

const webdriver = {};
if (this.parameters["webdriver-host"])
webdriver.host = this.parameters["webdriver-host"];
if (this.parameters["webdriver-port"])
webdriver.port = this.parameters["webdriver-port"];
if (typeof this.parameters["start-process"] !== "undefined")
webdriver.start_process = this.parameters["start-process"];

const globals = {};
if (this.parameters["retry-interval"]) {
globals.waitForConditionPollInterval = this.parameters["retry-interval"];
}
});

BeforeAll(async () => {
await startWebDriver();
});
this.client = Nightwatch.createClient({
headless: this.parameters.headless,
env: this.parameters.env,
timeout: this.parameters.timeout,
parallel: !!this.parameters.parallel,
output: !this.parameters["disable-output"],
enable_global_apis: true,
silent: !this.parameters.verbose,
always_async_commands: true,
webdriver,
persist_globals: this.parameters["persist-globals"],
config: this.parameters.config,
globals: {
run: {},
},
desiredCapabilities: {
browserName: "chrome",
"goog:chromeOptions": {
args: chromeArgs,
},
},
});

AfterAll(async () => {
run.browserName = client.capabilities.browserName;
switch (client.capabilities.browserName) {
case "msedge": //same as chrome
case "chrome-headless-shell":
case "chrome":
run.version = client.capabilities.version;
run.platform = client.capabilities.platform;
break;
case "firefox":
run.version = client.capabilities.browserVersion;
run.platform = client.capabilities.platformName;
break;
default:
throw new Error("Unrecognized browser.");
if (this.client.settings.sync_test_names) {
this.client.updateCapabilities({ name: pickle.name });
}
await stopWebDriver();

// convert JSON object to string
const data = JSON.stringify(run);
console.log("Launching Chrome with args: ", chromeArgs);
console.log("Executing test : " + pickle.name);

// write JSON string to a file
fs.writeFile("run.json", data, (err) => {
if (err) {
throw err;
}
console.log("JSON data is saved.");
});
this.browser = await this.client.launchBrowser();
this.browser.globals.timestamp = Date.now();
});

After(function () {
if (run.BreedingInsight == "") {
run.BreedingInsight = client.globals.breedingInsightVersion;
After(async function (testCase) {
if (testCase.result.status === "FAILED" && this.browser) {
const filename = `screenshots/${testCase.pickle.name}-${Date.now()}.png`;
await this.browser.saveScreenshot(filename);
this.attach(fs.readFileSync(filename), "image/png");
}

getNewScreenshots().forEach((file) =>
this.attach(fs.readFileSync(file), "image/png")
);
//Note: The following line can be commented out to keep browsers open for debugging purposes on local
closeSession();
});

if (this.browser) {
await this.browser.quit();
}

if (this.tmpUserDataDir) {
fs.rmSync(this.tmpUserDataDir, { recursive: true, force: true });
}

if (!this.browser?.globals?.run?.browserName) {
const caps = this.browser.capabilities;
const globalsRun = this.browser.globals.run;

globalsRun.browserName = caps.browserName;
globalsRun.version = caps.browserVersion;
globalsRun.platform = caps.platformName;

try {
await fsPromises.writeFile("report/run.json", JSON.stringify(globalsRun));
console.log("Saved run metadata.");
} catch (err) {
console.error("Error saving run metadata:", err);
}
}
});
Loading