add test for the creation of file
This commit is contained in:
parent
a02f9899ca
commit
3a6dc8ff51
@ -3,13 +3,13 @@
|
||||
const { Before, BeforeAll, AfterAll, After, setDefaultTimeout } = require("@cucumber/cucumber");
|
||||
const { chromium } = require("playwright");
|
||||
|
||||
setDefaultTimeout(60000)
|
||||
setDefaultTimeout(30000)
|
||||
|
||||
// launch the browser
|
||||
BeforeAll(async function () {
|
||||
global.browser = await chromium.launch({
|
||||
headless: false,
|
||||
slowMo: 1000,
|
||||
slowMo: 500,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
12
frontend/tests/acceptance/features/createFile.feature
Normal file
12
frontend/tests/acceptance/features/createFile.feature
Normal file
@ -0,0 +1,12 @@
|
||||
Feature: Create a file
|
||||
As a user
|
||||
I want to manage a file
|
||||
So that I can save it
|
||||
|
||||
Background:
|
||||
Given the user has browsed to the login page
|
||||
And the user has logged in with username "admin" and password "admin"
|
||||
|
||||
Scenario: create a file
|
||||
When user has added file "demo.txt" with content "hello world"
|
||||
Then for user there should contain files "file.txt"
|
||||
@ -3,7 +3,7 @@ Feature: login
|
||||
I want to login to the system
|
||||
So that I can manage the files and folders
|
||||
|
||||
Scenario: login with valid username and valid password
|
||||
Given the user has browsed to the login page
|
||||
When user logs in with username "admin" and password "admin"
|
||||
Then user should redirect to the homepage
|
||||
Scenario: login with valid username and valid password
|
||||
Given the user has browsed to the login page
|
||||
When user logs in with username "admin" and password "admin"
|
||||
Then user should redirect to the homepage
|
||||
29
frontend/tests/acceptance/pageObjects/CreateFilePage.js
Normal file
29
frontend/tests/acceptance/pageObjects/CreateFilePage.js
Normal file
@ -0,0 +1,29 @@
|
||||
class CreateFilePage {
|
||||
constructor() {
|
||||
//url
|
||||
this.url = 'http://localhost:8080'
|
||||
this.loginUrl = 'http://localhost:8080/login'
|
||||
this.fileUrl = this.url + '/files/'
|
||||
|
||||
//define selectors
|
||||
this.uploadButtonSelector = '//button[@title="Upload"]/i';
|
||||
this.newFileLabelSelector = '//button[@aria-label="New file"]';
|
||||
this.writeNewFileInputSelector = '//input[@class="input input--block"]';
|
||||
this.createButtonSelector = '//button[contains(text(),"Create")]';
|
||||
this.contentBoxSelector = '//textarea[@class="ace_text-input"]';
|
||||
this.saveIconSelector = '//i[contains(text(),"save")]';
|
||||
this.closeIconSelector = '//i[contains(text(),"close")]';
|
||||
}
|
||||
|
||||
async createNewFile(filename,content) {
|
||||
await page.click(this.newFileLabelSelector);
|
||||
await page.fill(this.writeNewFileInputSelector, filename);
|
||||
await page.click(this.createButtonSelector);
|
||||
// await page.getByRole('textbox').fill(content);
|
||||
await page.fill(this.contentBoxSelector,content);
|
||||
await page.click(this.saveIconSelector);
|
||||
await page.click(this.closeIconSelector);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CreateFilePage
|
||||
@ -20,6 +20,10 @@ class LoginPage {
|
||||
await page.fill(this.passwordSelector, password);
|
||||
await page.click(this.loginSelector);
|
||||
}
|
||||
|
||||
// async assertLoginPageIsOpen() {
|
||||
// await expect(this.page).toHaveURL(this.loginUrl);
|
||||
// }
|
||||
}
|
||||
|
||||
module.exports = LoginPage
|
||||
@ -0,0 +1,18 @@
|
||||
const {Given, When, Then} = require('@cucumber/cucumber')
|
||||
// import expect for assertion
|
||||
const { expect } = require("@playwright/test");
|
||||
|
||||
//import assert
|
||||
const assert = require("assert")
|
||||
|
||||
//import page
|
||||
const CreateFilePage = require("../pageObjects/CreateFilePage.js");
|
||||
const createFilePage = new CreateFilePage;
|
||||
|
||||
When('user has added file {string} with content {string}', async function (filename,content) {
|
||||
await createFilePage.createNewFile(filename,content)
|
||||
});
|
||||
|
||||
Then('for user there should contain files {string}', async function (string) {
|
||||
|
||||
});
|
||||
@ -14,6 +14,11 @@ Given('the user has browsed to the login page', async function () {
|
||||
await expect(page).toHaveURL(loginPage.loginUrl);
|
||||
});
|
||||
|
||||
Given('the user has logged in with username {string} and password {string}', async function (username, password) {
|
||||
await loginPage.login(username,password);
|
||||
await expect(page).toHaveURL(loginPage.fileUrl);
|
||||
});
|
||||
|
||||
When('user logs in with username {string} and password {string}', async function (username, password) {
|
||||
await loginPage.login(username,password);
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user