From 18273d4d9adcbf1df8693ccb4d95485369ae7a13 Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Fri, 24 May 2024 13:23:00 +0200 Subject: [PATCH] Add GUI action --- .github/workflows/gui.yml | 40 +++++++++++++++++++++++++++++++++++++++ test/addatest.mjs | 16 ++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 .github/workflows/gui.yml create mode 100644 test/addatest.mjs diff --git a/.github/workflows/gui.yml b/.github/workflows/gui.yml new file mode 100644 index 0000000..63c572a --- /dev/null +++ b/.github/workflows/gui.yml @@ -0,0 +1,40 @@ +name: Test the GUI +on: + push: + branches: + - main + pull_request: + branches: + - main +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.x' + - uses: actions/checkout@v4 + - name: Install Chrome + run: | + wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - + sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' + sudo apt-get update + sudo apt-get --only-upgrade install google-chrome-stable + google-chrome --version + - name: Start dependencies + run: docker-compose -f docker-compose.yml up -d + - name: Start the server + run: | + npm install --prefix server + node server/app.js & + - name: Start the testrunner + run: | + npm install --prefix testrunner + node testrunner/app.js & + - name: Run a test + run: | + git clone https://github.com/sitespeedio/sitespeed.io.git + cd sitespeed.io + npm install + bin/sitespeed.js ../test/addatest.mjs --multi -n 1 --headless \ No newline at end of file diff --git a/test/addatest.mjs b/test/addatest.mjs new file mode 100644 index 0000000..1b2ba5f --- /dev/null +++ b/test/addatest.mjs @@ -0,0 +1,16 @@ +/** + * @param {import('browsertime').BrowsertimeContext} context + * @param {import('browsertime').BrowsertimeCommands} commands + */ +export default async function (context, commands) { + await commands.navigate('http://127.0.0.1:3000'); + await commands.addText.byId('https://www.wikipedia.org', 'url'); + await commands.select.selectByIdAndValue('iterations', 1); + await commands.mouse.singleClick.byXpath('/html/body/section/div/div[2]/ul/li[2]'); + await commands.wait.byId('commandlinearea', 5000); + await commands.addText.byId('--headless', 'commandlinearea'); + await commands.measure.start('RunTest'); + await commands.click.byId('submittest'); + await commands.wait.byXpath('/html/body/div[2]/h1',30000); + return commands.measure.stop(); + } \ No newline at end of file