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

Linting and formatting fixes for test files #2739

Merged
merged 9 commits into from
Aug 29, 2024
Merged
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
1 change: 0 additions & 1 deletion biome.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"reports",
".gauge",
"examples",
"test",
".local-chromium",
"types",
"lib/api.json"
Expand Down
2 changes: 1 addition & 1 deletion test/docs-tests/gauge/tests/assert.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const assert = require("assert");
const assert = require("node:assert");
import { Step, type Table } from "gauge-ts";
import { below, evaluate, text, textBox, title, toLeftOf } from "taiko";
import { getElements } from "./selectors";
Expand Down
4 changes: 2 additions & 2 deletions test/docs-tests/gauge/tests/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { basename, join } from "path";
import { basename, join } from "node:path";
import {
AfterScenario,
AfterSuite,
Expand Down Expand Up @@ -26,7 +26,7 @@ export default class Hooks {
@CustomScreenshotWriter()
public async takeScreenshot(): Promise<string> {
const fileName = join(
process.env["gauge_screenshots_dir"],
process.env.gauge_screenshots_dir,
`screenshot${Date.now()}.png`,
);
await screenshot({ path: fileName });
Expand Down
35 changes: 17 additions & 18 deletions test/docs-tests/gauge/tests/htmlElementAPI.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert = require("assert");
import _path = require("path");
import assert = require("node:assert");
import _path = require("node:path");
import {
$,
type DialogHandler,
Expand Down Expand Up @@ -40,8 +40,8 @@ export default class HtmlElementAPI {
@Step("Navigate to <url> with basic auth <username> and <password>")
public async navigateWithBasicAuth(
url: string,
username: any,
password: any,
username: string,
password: string,
) {
const encodedCredentials = Buffer.from(`${username}:${password}`).toString(
"base64",
Expand All @@ -63,7 +63,7 @@ export default class HtmlElementAPI {
public async selectDropDownValue(
value: string | number,
dropDownName: string,
fieldValue: any,
fieldValue: string,
) {
const box = dropDown(dropDownName);
await box.select(value);
Expand Down Expand Up @@ -99,7 +99,7 @@ export default class HtmlElementAPI {
}

@Step("Get value <text> of Text Box <textBoxName>")
public async getTextboxValue(text: any, textBoxName: string) {
public async getTextboxValue(text: string, textBoxName: string) {
const field = textBox(textBoxName);
assert.equal(await field.value(), text);
}
Expand All @@ -111,17 +111,17 @@ export default class HtmlElementAPI {
}

@Step("Write <text> into Text Box <textBoxName>")
public async writeInto(text: string, textBoxName: any) {
public async writeInto(text: string, textBoxName: string) {
await write(text, into(textBoxName));
}

@Step("Write <text> into TextBox with name <textboxName>")
public async writeWithName(text: string, textBoxName: any) {
public async writeWithName(text: string, textBoxName: string) {
await write(text, into(textBox({ name: textBoxName })));
}

@Step("Write <text> to Text Box <textBoxName>")
public async writeTo(text: string, textBoxName: any) {
public async writeTo(text: string, textBoxName: string) {
await write(text, to(textBoxName));
}

Expand Down Expand Up @@ -169,7 +169,7 @@ export default class HtmlElementAPI {
}

@Step("Respond to <url> with <responseBody>")
public async interceptResponse(url: string, responseBody: any) {
public async interceptResponse(url: string, responseBody: string) {
await intercept(url, { body: responseBody });
}

Expand All @@ -179,7 +179,7 @@ export default class HtmlElementAPI {
}

@Step("Intercept <url> and continue with postData <mockData>")
public async interceptRequest(url: string, mockData: any) {
public async interceptRequest(url: string, mockData: string) {
await intercept(url, (request) => {
request.continue({ postData: mockData });
});
Expand All @@ -188,15 +188,14 @@ export default class HtmlElementAPI {
@Step("Navigate to relative path <relativePath>")
public async navigateToPath(relativePath: string) {
const absolutePath = _path.resolve(relativePath);
await goto("file:///" + absolutePath);
await goto(`file:///${absolutePath}`);
}

@Step("Navigate to relative API reference page for <functionName>")
public async navigateToApiRefPage(functionName: string) {
const relativePath =
"../tmp/docs/_site/api/" + functionName + "/index.html";
const relativePath = `../tmp/docs/_site/api/${functionName}/index.html`;
const absolutePath = _path.resolve(relativePath);
await goto("file:///" + absolutePath);
await goto(`file:///${absolutePath}`);
}

@ContinueOnFailure()
Expand Down Expand Up @@ -259,15 +258,15 @@ export default class HtmlElementAPI {
}

@Step("Navigate to relative path <path> with timeout <timeout> ms")
public async navigateToPathWithTimeout(path: string, timeout: any) {
public async navigateToPathWithTimeout(path: string, timeout: number) {
const absolutePath = _path.resolve(path);
await goto("file:///" + absolutePath, {
await goto(`file:///${absolutePath}`, {
navigationTimeout: timeout,
});
}

@Step("Navigate to <url> with timeout <timeout> ms")
public async navigateToURLWithTimeout(url: string, timeout: any) {
public async navigateToURLWithTimeout(url: string, timeout: number) {
await goto(url, { navigationTimeout: timeout });
}

Expand Down
5 changes: 3 additions & 2 deletions test/docs-tests/gauge/tests/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { $, button, link, text, textBox } from "taiko";

function getElementWithSelector(element: string, selector: string) {
let selectedElement = null;
// biome-ignore lint: Required for testing
let selectedItem;
try {
selectedItem = JSON.parse(selector);
Expand Down Expand Up @@ -32,10 +33,10 @@ function getElementWithSelector(element: string, selector: string) {
export function getElements(table: Table) {
const referenceElements = [];
const headers = table.getColumnNames();
table.getTableRows().forEach((row) => {
for (const row of table.getTableRows()) {
referenceElements.push(
getElementWithSelector(row.getCell(headers[0]), row.getCell(headers[1])),
);
});
}
return referenceElements;
}
6 changes: 3 additions & 3 deletions test/docs-tests/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ const chai = require("chai");
// const expect = chai.expect;
const chaiAsPromised = require("chai-as-promised");
chai.use(chaiAsPromised);
const fs = require("fs");
const util = require("util");
const path = require("path");
const fs = require("node:fs");
const util = require("node:util");
const path = require("node:path");
const { jsDocToJson } = require("../../lib/documentation");
const _ncp = require("ncp").ncp;
_ncp.limit = 16;
Expand Down
2 changes: 1 addition & 1 deletion test/functional-tests/tests/alert.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// eslint-disable-next-line no-unused-vars
import { type DataStore, DataStoreFactory, Step } from "gauge-ts";
import { accept, alert, prompt } from "taiko";
const assert = require("assert");
const assert = require("node:assert");
const scenarioStore: DataStore = DataStoreFactory.getSpecDataStore();

export default class Alert {
Expand Down
2 changes: 1 addition & 1 deletion test/functional-tests/tests/assert.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const assert = require("assert");
const assert = require("node:assert");
import { Step, type Table } from "gauge-ts";
import { evaluate, text, textBox, title, toLeftOf } from "taiko";
import { getElements } from "./selectors";
Expand Down
10 changes: 5 additions & 5 deletions test/functional-tests/tests/browserAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
setLocation,
switchTo,
} from "taiko";
const assert = require("assert");
const assert = require("node:assert");
const cwd = process.cwd();

export default class Assert {
Expand Down Expand Up @@ -80,7 +80,7 @@ export default class Assert {

@Step("Navigate to file with relative Path <filePath>")
public async navigateToFileWithRelativePath(filePath: string) {
await goto("file:///" + cwd + filePath);
await goto(`file:///${cwd}${filePath}`);
}

@Step("Override browser permission with <geolocation> for site <url>")
Expand All @@ -98,7 +98,7 @@ export default class Assert {

@Step("Assert location longitude as <longitude> and latitude as <latitude>")
public async function(longitude: string, latitude: string) {
const geolocation: any = await evaluate(
const geolocation = (await evaluate(
() =>
new Promise((resolve) =>
navigator.geolocation.getCurrentPosition((position) => {
Expand All @@ -108,7 +108,7 @@ export default class Assert {
});
}),
),
);
)) as { latitude: number; longitude: number };
assert.equal(geolocation.longitude, Number.parseFloat(longitude));
assert.equal(geolocation.latitude, Number.parseFloat(latitude));
}
Expand All @@ -119,7 +119,7 @@ export default class Assert {
}

@Step("Assert width is <width> and height is <height>")
public async assertWidthAndHeight(width: any, height: any) {
public async assertWidthAndHeight(width: number, height: number) {
const innerWidth = await evaluate(() => window.innerWidth);
const innerHeight = await evaluate(() => window.innerHeight);
assert.equal(innerWidth, width);
Expand Down
2 changes: 1 addition & 1 deletion test/functional-tests/tests/dropDown.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const assert = require("assert");
const assert = require("node:assert");
import { getElements } from "./selectors";

import { Step, type Table } from "gauge-ts";
Expand Down
4 changes: 2 additions & 2 deletions test/functional-tests/tests/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { basename, join } from "path";
import { basename, join } from "node:path";
import {
AfterScenario,
AfterSuite,
Expand Down Expand Up @@ -37,7 +37,7 @@ export default class Hooks {
@CustomScreenshotWriter()
public async takeScreenshot(): Promise<string> {
const fileName = join(
process.env["gauge_screenshots_dir"],
process.env.gauge_screenshots_dir,
`screenshot${Date.now()}.png`,
);
await screenshot({ path: fileName });
Expand Down
30 changes: 15 additions & 15 deletions test/functional-tests/tests/htmlElementAPI.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert = require("assert");
import _path = require("path");
import assert = require("node:assert");
import _path = require("node:path");
import {
$,
type DialogHandler,
Expand Down Expand Up @@ -41,8 +41,8 @@ export default class HtmlElementAPI {
@Step("Navigate to <url> with basic auth <username> and <password>")
public async navigateWithBasicAuth(
url: string,
username: any,
password: any,
username: string,
password: string,
) {
const encodedCredentials = Buffer.from(`${username}:${password}`).toString(
"base64",
Expand All @@ -64,7 +64,7 @@ export default class HtmlElementAPI {
public async selectDropDownValue(
value: string | number,
dropDownName: string,
fieldValue: any,
fieldValue: string,
) {
const box = dropDown(dropDownName);
await box.select(value);
Expand Down Expand Up @@ -119,7 +119,7 @@ export default class HtmlElementAPI {
}

@Step("Get value <text> of Text Box <textBoxName>")
public async getTextboxValue(text: any, textBoxName: string) {
public async getTextboxValue(text: string, textBoxName: string) {
const field = textBox(textBoxName);
assert.equal(await field.value(), text);
}
Expand All @@ -131,17 +131,17 @@ export default class HtmlElementAPI {
}

@Step("Write <text> into Text Box <textBoxName>")
public async writeInto(text: string, textBoxName: any) {
public async writeInto(text: string, textBoxName: string) {
await write(text, into(textBoxName));
}

@Step("Write <text> into TextBox with name <textboxName>")
public async writeWithName(text: string, textBoxName: any) {
public async writeWithName(text: string, textBoxName: string) {
await write(text, into(textBox({ name: textBoxName })));
}

@Step("Write <text> to Text Box <textBoxName>")
public async writeTo(text: string, textBoxName: any) {
public async writeTo(text: string, textBoxName: string) {
await write(text, to(textBoxName));
}

Expand Down Expand Up @@ -189,7 +189,7 @@ export default class HtmlElementAPI {
}

@Step("Respond to <url> with <responseBody>")
public async interceptResponse(url: string, responseBody: any) {
public async interceptResponse(url: string, responseBody: string) {
await intercept(url, { body: responseBody });
}

Expand All @@ -199,7 +199,7 @@ export default class HtmlElementAPI {
}

@Step("Intercept <url> and continue with postData <mockData>")
public async interceptRequest(url: string, mockData: any) {
public async interceptRequest(url: string, mockData: string) {
await intercept(url, (request) => {
request.continue({ postData: mockData });
});
Expand All @@ -215,7 +215,7 @@ export default class HtmlElementAPI {
@Step("Navigate to relative path <relativePath>")
public async navigateToPath(relativePath: string) {
const absolutePath = _path.resolve(relativePath);
await goto("file:///" + absolutePath);
await goto(`file:///${absolutePath}`);
}

@ContinueOnFailure()
Expand Down Expand Up @@ -278,15 +278,15 @@ export default class HtmlElementAPI {
}

@Step("Navigate to relative path <path> with timeout <timeout> ms")
public async navigateToPathWithTimeout(path: string, timeout: any) {
public async navigateToPathWithTimeout(path: string, timeout: number) {
const absolutePath = _path.resolve(path);
await goto("file:///" + absolutePath, {
await goto(`file:///${absolutePath}`, {
navigationTimeout: timeout,
});
}

@Step("Navigate to <url> with timeout <timeout> ms")
public async navigateToURLWithTimeout(url: string, timeout: any) {
public async navigateToURLWithTimeout(url: string, timeout: number) {
await goto(url, { navigationTimeout: timeout });
}

Expand Down
Loading