Skip to content

Commit

Permalink
chore: Cleanup after merge, move test dependencies to dev
Browse files Browse the repository at this point in the history
  • Loading branch information
meltyshev committed Oct 17, 2024
1 parent 90bbd0d commit be07d5f
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 162 deletions.
35 changes: 0 additions & 35 deletions client/cucumber.conf.js

This file was deleted.

19 changes: 0 additions & 19 deletions client/nightwatch.conf.js

This file was deleted.

161 changes: 128 additions & 33 deletions client/package-lock.json

Large diffs are not rendered by default.

16 changes: 6 additions & 10 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"lint": "eslint --ext js,jsx src config-overrides.js",
"start": "react-app-rewired start",
"test": "react-app-rewired test",
"test:acceptance": "cucumber-js --require cucumber.conf.js --require tests/acceptance/stepDefinitions/**/*.js --format @cucumber/pretty-formatter"
"test:acceptance": "cucumber-js --require tests/acceptance/cucumber.conf.js --require tests/acceptance/stepDefinitions/**/*.js --format @cucumber/pretty-formatter"
},
"browserslist": {
"production": [
Expand Down Expand Up @@ -105,20 +105,17 @@
"socket.io-client": "^2.5.0",
"validator": "^13.12.0",
"whatwg-fetch": "^3.6.20",
"zxcvbn": "^4.4.2",
"@cucumber/cucumber": "^7.3.1",
"@cucumber/pretty-formatter": "^1.0.1",
"@playwright/test": "^1.46.1",
"playwright": "^1.46.1",
"axios":"^1.6.2"
"zxcvbn": "^4.4.2"
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@cucumber/cucumber": "^7.3.1",
"@cucumber/pretty-formatter": "^1.0.0-alpha.1",
"@cucumber/pretty-formatter": "^1.0.1",
"@playwright/test": "^1.46.1",
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^15.0.7",
"@testing-library/user-event": "^14.5.2",
"axios": "^1.6.2",
"babel-preset-airbnb": "^5.0.0",
"chai": "^4.5.0",
"eslint": "^8.57.0",
Expand All @@ -127,8 +124,7 @@
"eslint-plugin-jsx-a11y": "^6.10.0",
"eslint-plugin-react": "^7.36.1",
"eslint-plugin-react-hooks": "^4.6.2",
"nightwatch": "^1.7.8",
"nightwatch-api": "^3.0.2",
"playwright": "^1.46.1",
"react-test-renderer": "18.2.0"
}
}
46 changes: 28 additions & 18 deletions client/tests/acceptance/cucumber.conf.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
const {
After,
Before,
AfterAll,
BeforeAll,
setDefaultTimeout,
} = require("@cucumber/cucumber");
const { createSession, closeSession } = require("nightwatch-api");
// cucumber.conf.js file

setDefaultTimeout(60000);
// runs before all scenarios
BeforeAll(async function () {});
const { Before, BeforeAll, AfterAll, After, setDefaultTimeout } = require('@cucumber/cucumber');
const { chromium } = require('playwright');
const { deleteProject } = require('./testHelpers/apiHelpers');
const config = require('./config');

// runs before each scenario
setDefaultTimeout(config.timeout);

// launch the browser
BeforeAll(async function () {
global.browser = await chromium.launch({
// makes true for CI
headless: config.headless,
slowMo: config.slowMo,
});
});

// close the browser
AfterAll(async function () {
await global.browser.close();
});

// Create a new browser context and page per scenario
Before(async function () {
await createSession();
global.context = await global.browser.newContext();
global.page = await global.context.newPage();
});

// runs after each scenario
// Cleanup after each scenario
After(async function () {
await closeSession();
await deleteProject();
await global.page.close();
await global.context.close();
});

// runs after all scenarios
AfterAll(async function () {});
36 changes: 16 additions & 20 deletions client/tests/acceptance/pageObjects/dashboardPage.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
module.exports = {
url: function () {
return this.api.launchUrl + "/dashboard";
},
commands: {
isDashboardPage: async function () {
let result = false;
await this.waitForElementVisible("@dashboardHeader");
await this.isVisible("@dashboardHeader", (res) => {
result = res.value;
});
return result;
},
},
elements: {
dashboardHeader: {
selector: "a.Header_title__3SEjb",
},
},
};
class dashboardPage {
constructor() {
this.createProjectIconSelector = `.Projects_addTitle__tXhB4`;
this.projectTitleInputSelector = `input[name="name"]`;
this.createProjectButtonSelector = `//button[text()="Create project"]`;
this.projectTitleSelector = `//div[@class="item Header_item__OOEY7 Header_title__l+wMf"][text()="%s"]`;
}

async createProject(project) {
await page.click(this.createProjectIconSelector);
await page.fill(this.projectTitleInputSelector, project);
await page.click(this.createProjectButtonSelector);
}
}

module.exports = dashboardPage;
64 changes: 38 additions & 26 deletions client/tests/acceptance/pageObjects/loginPage.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
module.exports = {
url: function () {
return this.api.launchUrl + "/login";
},
commands: {
logIn: function (email, password) {
return this.waitForElementVisible("@emailInput")
.setValue("@emailInput", email)
.waitForElementVisible("@passwordInput")
.setValue("@passwordInput", password)
.waitForElementVisible("@loginBtn")
.click("@loginBtn");
},
},
elements: {
emailInput: {
selector: "input[name=emailOrUsername]",
},
passwordInput: {
selector: "input[name=password]",
},
loginBtn: {
selector: "form button",
},
},
};
const config = require(`../config`);

class LoginPage {
constructor() {
// url
this.homeUrl = config.baseUrl;
this.loginUrl = `${this.homeUrl}login`;

// selectors
this.loginButtonSelector = `//i[@class="right arrow icon"]`;
this.usernameSelector = `//input[@name='emailOrUsername']`;
this.passwordSelector = `//input[@name='password']`;
this.errorMessageSelector = `//div[@class='ui error visible message']`;
this.userActionSelector = `//span[@class="User_initials__9Wp90"]`;
this.logOutSelector = `//a[@class="item UserStep_menuItem__5pvtT"][contains(text(),'Log Out')]`;
}

async goToLoginUrl() {
await page.goto(this.loginUrl);
}

async logOut() {
await page.click(this.userActionSelector);
await page.click(this.logOutSelector);
}

async login(username, password) {
await page.fill(this.usernameSelector, username);
await page.fill(this.passwordSelector, password);
await page.click(this.loginButtonSelector);
}

async getErrorMessage() {
return page.innerText(this.errorMessageSelector);
}
}

module.exports = LoginPage;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"test": "npm run server:test && npm run client:test"
},
"lint-staged": {
"client/**/*.{js,jsx}": [
"client/src/**/*.{js,jsx}": [
"npm run client:lint"
],
"server/**/*.js": [
Expand Down

0 comments on commit be07d5f

Please sign in to comment.