Skip to content

Commit

Permalink
Adjust system test
Browse files Browse the repository at this point in the history
  • Loading branch information
xenosf committed Nov 5, 2024
1 parent dfd9631 commit 544f54e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/system-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ jobs:
cd client
npm ci
npm run start &
sleep 2
- name: Run Tests
run: xvfb-run --server-args="-screen 0 1024x768x24" npm run test
run: |
sleep 20
xvfb-run --server-args="-screen 0 1024x768x24" npm run test
11 changes: 5 additions & 6 deletions test/HomePage.test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
let utils = require("./utils");
let {TIMEOUT, getWebDriver, URL} = require("./utils");
const {By} = require('selenium-webdriver')

let driver;
const url = "http://localhost:3000"

beforeAll(async () => {
driver = await utils.getWebDriver();
}, 10000);
driver = await getWebDriver();
}, TIMEOUT);

beforeEach(async () => {
await driver.get(url);
await driver.get(URL);
});

afterAll(async () => {
Expand All @@ -20,6 +19,6 @@ test('clicking "PeerPrep" text in toolbar navigates to homepage', async () => {
let link = await driver.findElement(By.linkText("PeerPrep"));
await link.click();
let newUrl = await driver.getCurrentUrl();
expect(newUrl).toMatch(url);
expect(newUrl).toMatch(URL);
});

22 changes: 13 additions & 9 deletions test/utils.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
const {Builder} = require("selenium-webdriver");
const { Builder } = require("selenium-webdriver");

module.exports.TIMEOUT = 30 * 1000;

module.exports.URL = "http://localhost:3000";

module.exports.getWebDriver = async () => {
let browser = process.env.BROWSER;
let driver = await new Builder().forBrowser(browser).build();
console.log(driver)
return driver;
}
let browser = process.env.BROWSER;
let driver = await new Builder().forBrowser(browser).build();
console.log(driver);
return driver;
};

module.exports.scrollTo = async (driver, element) => {
driver.executeScript("arguments[0].scrollIntoView(false)", element);
driver.sleep(300);
}
driver.executeScript("arguments[0].scrollIntoView(false)", element);
driver.sleep(300);
};

0 comments on commit 544f54e

Please sign in to comment.