From 3d3034c0afc9f8a1b458f0a724862d0a2ac25208 Mon Sep 17 00:00:00 2001 From: John Sickels Date: Fri, 19 Nov 2021 10:27:45 -0500 Subject: [PATCH 1/3] failing suites --- flagpole.json | 2 +- tests/src/dangle.ts | 8 ++++++++ tests/src/findAll.ts | 12 ++++++++++++ tests/src/schema.ts | 42 ++++++++++++++++++++++++++++++++++++++++++ tests/src/timeout.ts | 17 +++++++++++++++++ 5 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 tests/src/dangle.ts create mode 100644 tests/src/findAll.ts create mode 100644 tests/src/timeout.ts diff --git a/flagpole.json b/flagpole.json index 87c7c1aa..ea59d728 100644 --- a/flagpole.json +++ b/flagpole.json @@ -174,7 +174,7 @@ "currentUrl": { "id": "", "name": "currentUrl", - "tags,": [] + "tags": [] }, "repro": { "id": "", diff --git a/tests/src/dangle.ts b/tests/src/dangle.ts new file mode 100644 index 00000000..e0d0b474 --- /dev/null +++ b/tests/src/dangle.ts @@ -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"); diff --git a/tests/src/findAll.ts b/tests/src/findAll.ts new file mode 100644 index 00000000..a08d923e --- /dev/null +++ b/tests/src/findAll.ts @@ -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); + }); +}); diff --git a/tests/src/schema.ts b/tests/src/schema.ts index aa46329c..4c5c503e 100644 --- a/tests/src/schema.ts +++ b/tests/src/schema.ts @@ -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) @@ -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"); + // }); }); diff --git a/tests/src/timeout.ts b/tests/src/timeout.ts new file mode 100644 index 00000000..58963b95 --- /dev/null +++ b/tests/src/timeout.ts @@ -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"); + }); From 36778bdc06192fd7b3c9276903c3bee139bbf66e Mon Sep 17 00:00:00 2001 From: John Sickels Date: Fri, 19 Nov 2021 12:52:00 -0500 Subject: [PATCH 2/3] production false --- .github/workflows/test.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 9ed11e2e..f2e63688 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -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: @@ -34,6 +33,6 @@ jobs: key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-build-${{ env.cache-name }}- - - run: npm install --no-save + - 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 }} From 3c07dbd406838d12492644240631f859c172ad43 Mon Sep 17 00:00:00 2001 From: John Sickels Date: Fri, 19 Nov 2021 12:54:34 -0500 Subject: [PATCH 3/3] uncache node modules --- .github/workflows/test.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index f2e63688..2d2bdbdd 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -24,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 }}- + # - 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 }}