Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ name: Test

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]
jobs:
build:

runs-on: ubuntu-latest

strategy:
Expand All @@ -25,15 +24,15 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ./node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
- run: npm install --no-save
# - name: Cache node modules
# uses: actions/cache@v2
# env:
# cache-name: cache-node-modules
# with:
# path: ./node_modules
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# ${{ runner.os }}-build-${{ env.cache-name }}-
- run: npm install --no-save --production=false
- run: npm run build --if-present
- run: xvfb-run node /home/runner/work/flagpole/flagpole/dist/cli/main.js run ${{ matrix.flagpoleCommand.command }}
2 changes: 1 addition & 1 deletion flagpole.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
"currentUrl": {
"id": "",
"name": "currentUrl",
"tags,": []
"tags": []
},
"repro": {
"id": "",
Expand Down
8 changes: 8 additions & 0 deletions tests/src/dangle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import flagpole from "../../dist";

const suite = flagpole("Basic Smoke Test of Site");

suite.html("Homepage Loads").open("https://dribbble.com/");
// .next({ statusCode: 200 });

// suite.json("No open method");
12 changes: 12 additions & 0 deletions tests/src/findAll.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import flagpole from "../../dist";

flagpole("Basic Smoke Test of Site", async (suite) => {
suite
.html("Homepage Loads")
.open("https://appium.io/docs/en/drivers/ios-xcuitest/")
.next(async (context) => {
const textViews = await context.findAll("foobar");
context.comment(textViews.length);
context.assert("textViews exists", textViews.length).greaterThan(0);
});
});
42 changes: 42 additions & 0 deletions tests/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,28 @@ flagpole("Test Assertion Schema", async (suite) => {
},
};

const userResponse: HttpResponseOptions = {
status: [200, "OK"],
body: {
user: {
first_name: "Jason",
last_name: "Byrne",
level: 100,
},
},
};

const nullUserResponse: HttpResponseOptions = {
status: [200, "OK"],
body: {
user: {
first_name: "Ima",
last_name: null,
level: null,
},
},
};

suite
.scenario("Matching Schema - File JsonSchema", "json")
.mock(validResponse)
Expand Down Expand Up @@ -87,4 +109,24 @@ flagpole("Test Assertion Schema", async (suite) => {
context.comment(json);
await context.assert(json).schema("@ditto");
});

suite
.scenario("Matching User Schema - String or Null Property - String", "json")
.mock(userResponse)
.next((context) => {
context.assert(context.response.jsonBody).schema("@user");
});

// this fails one property at a time
// we want to get all properties in the first failure
// issue #176
// suite
// .scenario(
// "Matching Null User Schema - String or Null Property - Null",
// "json"
// )
// .mock(nullUserResponse)
// .next((context) => {
// context.assert(context.response.jsonBody).schema("@user");
// });
});
17 changes: 17 additions & 0 deletions tests/src/timeout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import flagpole from "../../dist";

const suite = flagpole("Basic Smoke Test of Site");

const sleep = (ms: number) => {
return new Promise((resolve) => setTimeout(resolve, ms));
};

suite.beforeAll(async () => {
await sleep(999999);
});
suite
.scenario("Homepage Loads", "browser")
.open("https://linuxhint.com/configure-use-aliases-zsh/")
.next(async (context) => {
await context.waitForExists("div");
});