Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.

Conversation

@wssheldon
Copy link
Contributor

@wssheldon wssheldon commented Feb 2, 2023

Tests work great locally, need to brainstorm how to fully automate authentication in CI, and how to run the development server in CI on GH Actions.

I recreated the bug where the "Load More" button did not appear for the Project select button, introduced here. The test will check for the "Load More" text and fail if it can't be found after selecting the Type button, this failed as expected:

    // check that the 'Load More' selector is available upon opening the Type dropdown
    await expect(
      page.getByText("Load More"),
      "The 'Load More' selector should be visibile."
    ).toBeVisible()
Error: The 'Load More' selector should be visibile.

Call log:
  - expect.toBeVisible with timeout 10000ms
  - waiting for getByText('Load More')
  -   unexpected value "hidden"

  35 |       page.getByText("Load More"),
  36 |       "The 'Load More' selector should be visibile."
> 37 |     ).toBeVisible()
     |       ^
  38 |
  39 |     await page.getByText(type, { exact: true }).click()

    at /Users/wshel/Projects/dispatch/tests/e2e/report-submission.spec.ts:37:7

@wssheldon wssheldon added enhancement New feature or request tests javascript Pull requests that update Javascript code labels Feb 2, 2023
@kevgliss
Copy link
Contributor

kevgliss commented Feb 2, 2023

I think you should be able to run these via a github action:

jobs:
  tests_e2e:
    name: Run end-to-end tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
      - name: Install dependencies
        run: npm ci
      - name: Install playwright browsers
        run: npx playwright install --with-deps
      - name: Run tests
        run: npx playwright test

Authentication wise we should be able to leverage basic auth with the default user.

@wssheldon
Copy link
Contributor Author

I think you should be able to run these via a github action:

I think I'll need to use the .devcontainer to be able to run dispatch server develop

)
)
.toBeVisible()
})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to extend this test to validate the submission report card has not regressed in anyway. This pattern will probably come up a lot and it feels very verbose and maybe flakey to do it this way. Maybe a todo could be to investigate using something like this: https://www.thoughtworks.com/en-us/radar/techniques/component-visual-regression-testing

Copy link
Contributor Author

@wssheldon wssheldon Feb 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.7.tgz",
"integrity": "sha512-LhFTglglr63mNXUSRYD8A+ZAIu5sFqNJ4Y2fPuY7UlrySJH87rRRlhtVmMHplmfk5WkoJGmDjE9oiTfyX94CpQ==",
"dev": true,
"peer": true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why that changed


async function login(page: Page): Promise<void> {
let email = (Math.random() + 1).toString(36).substring(7) + "@example.com"
let password = (Math.random() + 1).toString(36).substring(7)

Check failure

Code scanning / CodeQL

Insecure randomness

This uses a cryptographically insecure random number generated at [Math.random()](1) in a security context.
@wssheldon wssheldon changed the title initial work to create a e2e test for report submission on playwright tests/end-to-end-test-for-report-submission-using-playwright-in-ci Feb 3, 2023
@wssheldon wssheldon merged commit 0a81df7 into master Feb 3, 2023
@wssheldon wssheldon deleted the tests/playwright branch February 3, 2023 19:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request javascript Pull requests that update Javascript code tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants