Replace UI module with Next.js
All checks were successful
forgejo/Procyon/seedling/pipeline/pr-master This commit looks good
forgejo/Procyon/seedling/pipeline/head This commit looks good

This commit is contained in:
Roman Jaroš 2023-12-28 21:58:08 +00:00
parent 8aeff18162
commit 616205fe73
91 changed files with 3570 additions and 722 deletions

View file

@ -0,0 +1,13 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"moduleResolution": "node",
"emitDecoratorMetadata": false,
"typeRoots": [
"../"
]
},
"ts-node": {
"transpileOnly": true
}
}

View 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;
}
}

View 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);
}
}

View 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;
}
}

View file

@ -0,0 +1,5 @@
Feature: Home page
Scenario: Verify home page title
Given i visit home page
Then page title is $(AppName)

View 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 = {};
}

View 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")]`);
}

View 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);
}
}

View 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}`));
}
}
}

View 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());
}
}