Replace UI module with Next.js
This commit is contained in:
parent
8aeff18162
commit
616205fe73
91 changed files with 3570 additions and 722 deletions
13
source/selenium/src/.tsconfig.json
Normal file
13
source/selenium/src/.tsconfig.json
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"moduleResolution": "node",
|
||||
"emitDecoratorMetadata": false,
|
||||
"typeRoots": [
|
||||
"../"
|
||||
]
|
||||
},
|
||||
"ts-node": {
|
||||
"transpileOnly": true
|
||||
}
|
||||
}
|
17
source/selenium/src/common/BasePage.ts
Normal file
17
source/selenium/src/common/BasePage.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import { By } from 'selenium-webdriver';
|
||||
|
||||
export class BasePage {
|
||||
protected url: string;
|
||||
|
||||
public title?: string;
|
||||
public root: By;
|
||||
|
||||
public buttons?: Record<string, By>;
|
||||
public fields?: Record<string, By>;
|
||||
public forms?: Record<string, By>;
|
||||
public messages?: Record<string, By>;
|
||||
|
||||
public getPageUrl() {
|
||||
return `${process.env.HOST_IP}:${process.env.APP_PORT}` + this.url;
|
||||
}
|
||||
}
|
13
source/selenium/src/common/BaseStep.ts
Normal file
13
source/selenium/src/common/BaseStep.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
import { setDefaultTimeout } from '@cucumber/cucumber';
|
||||
import { ThenableWebDriver } from 'selenium-webdriver';
|
||||
|
||||
import { WebDriver } from './WebDriver';
|
||||
|
||||
export class BaseStep {
|
||||
protected driver: ThenableWebDriver;
|
||||
|
||||
public constructor() {
|
||||
this.driver = new WebDriver().getDriver();
|
||||
setDefaultTimeout(10 * 60 * 1000);
|
||||
}
|
||||
}
|
25
source/selenium/src/common/WebDriver.ts
Normal file
25
source/selenium/src/common/WebDriver.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
import { binding } from 'cucumber-tsflow';
|
||||
import { Builder, Capabilities, ThenableWebDriver } from 'selenium-webdriver';
|
||||
|
||||
const capabilities = Capabilities.chrome();
|
||||
capabilities.set('chromeOptions', { w3c: false });
|
||||
|
||||
@binding()
|
||||
export class WebDriver {
|
||||
protected readonly driver: ThenableWebDriver;
|
||||
private static instance: WebDriver;
|
||||
|
||||
public constructor() {
|
||||
if (WebDriver.instance) {
|
||||
return WebDriver.instance;
|
||||
}
|
||||
|
||||
this.driver = new Builder().usingServer(process.env.SELENIUM_SERVER_URL).withCapabilities(capabilities).build();
|
||||
this.driver.manage().setTimeouts({ implicit: 100 });
|
||||
WebDriver.instance = this;
|
||||
}
|
||||
|
||||
public getDriver() {
|
||||
return this.driver;
|
||||
}
|
||||
}
|
5
source/selenium/src/features/home.feature
Normal file
5
source/selenium/src/features/home.feature
Normal file
|
@ -0,0 +1,5 @@
|
|||
Feature: Home page
|
||||
|
||||
Scenario: Verify home page title
|
||||
Given i visit home page
|
||||
Then page title is $(AppName)
|
15
source/selenium/src/pages/HomePage.ts
Normal file
15
source/selenium/src/pages/HomePage.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
import { binding } from 'cucumber-tsflow';
|
||||
import { By } from 'selenium-webdriver';
|
||||
|
||||
import { BasePage } from '../common/BasePage';
|
||||
|
||||
@binding()
|
||||
export class HomePage extends BasePage {
|
||||
protected url = '/';
|
||||
|
||||
// initial div
|
||||
public root = By.xpath('//body');
|
||||
|
||||
// page buttons
|
||||
public buttons = {};
|
||||
}
|
6
source/selenium/src/pages/components/Navigation.ts
Normal file
6
source/selenium/src/pages/components/Navigation.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
import { By } from 'selenium-webdriver';
|
||||
|
||||
export class Navigation {
|
||||
public root = By.xpath('//div[@class="page-top"]');
|
||||
public logoutLink = By.xpath(`${this.root.value}//div[contains(text(), "Odhlásit se")]`);
|
||||
}
|
20
source/selenium/src/steps/common/page.steps.ts
Normal file
20
source/selenium/src/steps/common/page.steps.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import { expect } from 'chai';
|
||||
import { binding, given } from 'cucumber-tsflow';
|
||||
import { ThenableWebDriver } from 'selenium-webdriver';
|
||||
|
||||
import { WebDriver } from '../../common/WebDriver';
|
||||
|
||||
@binding([])
|
||||
export class PageSteps {
|
||||
protected driver: ThenableWebDriver;
|
||||
|
||||
public constructor() {
|
||||
this.driver = new WebDriver().getDriver();
|
||||
}
|
||||
|
||||
@given(/page title is (.*)/)
|
||||
public async thenPageTitleIs(title: string) {
|
||||
const pageTitle = await this.driver.getTitle();
|
||||
expect(pageTitle).to.equal(title);
|
||||
}
|
||||
}
|
24
source/selenium/src/steps/common/session.steps.ts
Normal file
24
source/selenium/src/steps/common/session.steps.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
import { afterAll, binding } from 'cucumber-tsflow';
|
||||
import { until } from 'selenium-webdriver';
|
||||
|
||||
import { WebDriver } from '../../common/WebDriver';
|
||||
import { Navigation } from '../../pages/components/Navigation';
|
||||
|
||||
@binding([])
|
||||
export class SessionSteps {
|
||||
@afterAll()
|
||||
protected async closeBrowser() {
|
||||
const driver = new WebDriver().getDriver();
|
||||
await driver.quit();
|
||||
}
|
||||
|
||||
@afterAll()
|
||||
protected async logout() {
|
||||
const driver = new WebDriver().getDriver();
|
||||
const webElements = await driver.findElements(new Navigation().logoutLink);
|
||||
if (webElements.length > 0) {
|
||||
await webElements[0]?.click?.();
|
||||
await driver.wait(until.urlContains(`${process.env.HOST_IP}:${process.env.APP_PORT}`));
|
||||
}
|
||||
}
|
||||
}
|
16
source/selenium/src/steps/home.steps.ts
Normal file
16
source/selenium/src/steps/home.steps.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
import { binding, given } from 'cucumber-tsflow';
|
||||
|
||||
import { BaseStep } from '../common/BaseStep';
|
||||
import { HomePage } from '../pages/HomePage';
|
||||
|
||||
@binding([HomePage])
|
||||
export class HomePageSteps extends BaseStep {
|
||||
public constructor(public readonly homePage: HomePage) {
|
||||
super();
|
||||
}
|
||||
|
||||
@given(/i visit home page/)
|
||||
public async givenIamOnHomePage() {
|
||||
await this.driver.get(this.homePage.getPageUrl());
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue