Skip to content

Commit

Permalink
Merge branch 'main' into 3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt307082 committed Aug 5, 2024
2 parents 809950b + e87d1bf commit 5cd8103
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
var/www/html/node_modules
var/www/html/tests
var/www/html/tests
var/www/html/install-tests.sh
var/www/html/run-tests.sh
6 changes: 6 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ jobs:
run: |
./var/www/html/run-tests.sh ${{ env.imagetag }}
- name: Upload webdriver screenshots
uses: actions/upload-artifact@v4
with:
name: webdriver-screenshots
path: ./var/www/html/tests/screens/

- name: Build and push console:${{ env.imagetag }}
uses: docker/build-push-action@v5
with:
Expand Down
42 changes: 37 additions & 5 deletions var/www/html/tests/console.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const fs = require('fs').promises;
const webdriver = require('selenium-webdriver');
const Chrome = require('selenium-webdriver/chrome');
const options = new Chrome.Options();
Expand All @@ -16,7 +17,8 @@ describe('console service front-end tests', function(){

beforeAll(async function(){
driver = await new webdriver.Builder().forBrowser(webdriver.Browser.CHROME).setChromeOptions(options).build();
});
await driver.manage().window().setRect({ width: 1400, height: 768 });
}, 30000);

afterAll(async function(){
await driver.quit();
Expand Down Expand Up @@ -55,15 +57,19 @@ describe('console service front-end tests', function(){
await driver.get(`${URL}/console`);
let table = await driver.findElement(webdriver.By.className("table"));
expect(table).not.toBeUndefined();
let encodedString = await driver.takeScreenshot();
await fs.writeFile('./tests/screens/desktops-page.png', encodedString, 'base64');
})

it("desktops : click on delete no desktop selected, should display error modal", async function(){
it("desktops : click on delete no desktop selected, should display error toast", async function(){
await driver.findElement(webdriver.By.id("delete-desktop-button")).click();
let failureToastMessage = await driver.findElement(webdriver.By.id("toast-failure-message"));
await driver.wait(webdriver.until.elementIsVisible(failureToastMessage), 2000);
await failureToastMessage.getText().then(function(text){
expect(text).toBe("Error, no desktop selected");
});
let encodedString = await driver.takeScreenshot();
await fs.writeFile('./tests/screens/desktops-page-error-toast.png', encodedString, 'base64');
})

});
Expand Down Expand Up @@ -93,15 +99,19 @@ describe('console service front-end tests', function(){
await driver.get(`${URL}/console/apps.html`);
let table = await driver.findElement(webdriver.By.className("table"));
expect(table).not.toBeUndefined();
let encodedString = await driver.takeScreenshot();
await fs.writeFile('./tests/screens/apps-page.png', encodedString, 'base64');
})

it("apps : click on delete but no apps selected, should display error modal", async function(){
it("apps : click on delete but no apps selected, should display error toast", async function(){
await driver.findElement(webdriver.By.id("delete-app-button")).click();
let failureToastMessage = await driver.findElement(webdriver.By.id("toast-failure-message"));
await driver.wait(webdriver.until.elementIsVisible(failureToastMessage), 2000);
await failureToastMessage.getText().then(function(text){
expect(text).toBe("Error, no apps selected");
});
let encodedString = await driver.takeScreenshot();
await fs.writeFile('./tests/screens/apps-page-error-toast.png', encodedString, 'base64');
})

it("apps : click on add button, modal should appear", async function(){
Expand All @@ -111,6 +121,8 @@ describe('console service front-end tests', function(){
await addAppModal.getAttribute("class").then(function(className){
expect(className.includes("show")).toBe(true);
});
let encodedString = await driver.takeScreenshot();
await fs.writeFile('./tests/screens/apps-page-modal-open.png', encodedString, 'base64');
})

it("apps : click on close button, modal should diseappear", async function(){
Expand All @@ -121,6 +133,8 @@ describe('console service front-end tests', function(){
await addAppModal.getAttribute("class").then(function(className){
expect(className.includes("show")).toBe(false);
});
let encodedString = await driver.takeScreenshot();
await fs.writeFile('./tests/screens/apps-page-modal-close.png', encodedString, 'base64');
}, 10000)

});
Expand Down Expand Up @@ -150,6 +164,8 @@ describe('console service front-end tests', function(){
await driver.get(`${URL}/console/webfront.html`);
let table = await driver.findElement(webdriver.By.className("table"));
expect(table).not.toBeUndefined();
let encodedString = await driver.takeScreenshot();
await fs.writeFile('./tests/screens/webfont-page.png', encodedString, 'base64');
})

it("webfront : dock section should not be visible", async function(){
Expand Down Expand Up @@ -186,15 +202,19 @@ describe('console service front-end tests', function(){
await driver.get(`${URL}/console/banIp.html`);
let table = await driver.findElement(webdriver.By.className("table"));
expect(table).not.toBeUndefined();
let encodedString = await driver.takeScreenshot();
await fs.writeFile('./tests/screens/banIP-page.png', encodedString, 'base64');
})

it("banIp : click on unban but no user selected, should display error modal", async function(){
it("banIp : click on unban but no user selected, should display error toast", async function(){
await driver.findElement(webdriver.By.id("unban-ip-button")).click();
let failureToastMessage = await driver.findElement(webdriver.By.id("toast-failure-message"));
await driver.wait(webdriver.until.elementIsVisible(failureToastMessage), 2000);
await failureToastMessage.getText().then(function(text){
expect(text).toBe("Error, no banned user selected");
});
let encodedString = await driver.takeScreenshot();
await fs.writeFile('./tests/screens/banIP-page-error-toast.png', encodedString, 'base64');
})

it("banIp : click on add button, modal should appear", async function(){
Expand All @@ -204,6 +224,8 @@ describe('console service front-end tests', function(){
await BanIpModal.getAttribute("class").then(function(className){
expect(className.includes("show")).toBe(true);
});
let encodedString = await driver.takeScreenshot();
await fs.writeFile('./tests/screens/banIP-page-modal-open.png', encodedString, 'base64');
})

it("banIp : click on close button, modal should diseappear", async function(){
Expand All @@ -214,6 +236,8 @@ describe('console service front-end tests', function(){
await BanIpModal.getAttribute("class").then(function(className){
expect(className.includes("show")).toBe(false);
});
let encodedString = await driver.takeScreenshot();
await fs.writeFile('./tests/screens/banIP-page-modal-close.png', encodedString, 'base64');
}, 10000)

});
Expand Down Expand Up @@ -243,15 +267,19 @@ describe('console service front-end tests', function(){
await driver.get(`${URL}/console/banLogin.html`);
let table = await driver.findElement(webdriver.By.className("table"));
expect(table).not.toBeUndefined();
let encodedString = await driver.takeScreenshot();
await fs.writeFile('./tests/screens/banLogin-page.png', encodedString, 'base64');
})

it("banLogin : click on unban but no user selected, should display error modal", async function(){
it("banLogin : click on unban but no user selected, should display error toast", async function(){
await driver.findElement(webdriver.By.id("unban-login-button")).click();
let failureToastMessage = await driver.findElement(webdriver.By.id("toast-failure-message"));
await driver.wait(webdriver.until.elementIsVisible(failureToastMessage), 2000);
await failureToastMessage.getText().then(function(text){
expect(text).toBe("Error, no banned user selected");
});
let encodedString = await driver.takeScreenshot();
await fs.writeFile('./tests/screens/banLogin-page-error-toast.png', encodedString, 'base64');
})

it("banLogin : click on add button, modal should appear", async function(){
Expand All @@ -261,6 +289,8 @@ describe('console service front-end tests', function(){
await BanLoginModal.getAttribute("class").then(function(className){
expect(className.includes("show")).toBe(true);
});
let encodedString = await driver.takeScreenshot();
await fs.writeFile('./tests/screens/banLogin-page-mdoal-open.png', encodedString, 'base64');
})

it("banLogin : click on close button, modal should diseappear", async function(){
Expand All @@ -271,6 +301,8 @@ describe('console service front-end tests', function(){
await BanLoginModal.getAttribute("class").then(function(className){
expect(className.includes("show")).toBe(false);
});
let encodedString = await driver.takeScreenshot();
await fs.writeFile('./tests/screens/banLogin-page-modal-close.png', encodedString, 'base64');
}, 10000)

});
Expand Down
Empty file.

0 comments on commit 5cd8103

Please sign in to comment.