Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mainpage e2e test #820

Merged
merged 22 commits into from
Jun 24, 2024
Merged

Mainpage e2e test #820

merged 22 commits into from
Jun 24, 2024

Conversation

dati18
Copy link
Contributor

@dati18 dati18 commented Jun 3, 2024

No description provided.

Copy link

github-actions bot commented Jun 3, 2024

Deployment previews on netlify for branch refs/pull/820/merge will be at the following locations (when build is done):

it('should open and render with some buttons', () => {

it('should open and render with Login button', async () => {
const navLogin = await $('#nav-login')
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be helpful to keep all of these in the page object class.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 on this, if we store some selectors on the page object class, let's store all of them there.

})

it('should collapse Login and Signup buttons into a dots-button icon when screen width < 600px', async () => {
await browser.setWindowSize(599, 800)
Copy link
Contributor

Choose a reason for hiding this comment

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

This will cause any subsequent tests to also be run while in the mobile view. You could set a default browser size in beforeEach to prevent this for happening. For example:

beforeEach(async () => {
  await browser.setWindowSize(1360, 973)
)}

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 on this, which should still be adressed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this (line 4-7)

})

it('should have a button linking to Discovery page', async () => {
App.open()
Copy link
Contributor

Choose a reason for hiding this comment

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

It might help to move this to beforeEach to make each test is a little less dependent on what happened in prior tests. For example:

beforeEach(async () => {
  App.open()
})

But you will likely need more of these:

waitForDisplayed({ timeout: 2000 })

Comment on lines 46 to 56
await browser.waitUntil(
async () => (await browser.getUrl()).includes('/discovery'),
{
timeout: 5000,
timeoutMsg: 'expected to be redirected to /discovery within 5s'
}
)

// Assert the new URL
const discoveryUrl = await browser.getUrl()
expect(discoveryUrl).toContain('/discovery')
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this can be simplified down to:

await expect(browser).toHaveUrlContaining('/discovery', { wait: 5000 })

@@ -1,5 +1,5 @@
<template>
<footer class="footer">
<footer id="footer" class="footer">
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: A good pattern I've seen used elsewhere is using data-test-id attributes instead of id proper which reduces the risk of inadvertent side effects (this now creates window.footer) and also makes it very clear what the attribute is about, i.e.

<footer data-test-id="footer" class="footer">

and then lateron you select the element using $('[data-test-id="footer"]')

This comment also applies to all other places where ids are introduced.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea. I also think that it could be troublesome...

ports:
- 8081:8081
healthcheck:
test: curl --fail http://ui:8081 || exit 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: Is || exit 1 needed when curl --fail is used? I would think this already exits non-zero on failure, so there's no need to repeat this.

- uses: actions/checkout@v4.1.6
- run: cp .env.development.prod .env
- run: sudo chown -R 1000:1000 ${GITHUB_WORKSPACE}
- run: docker compose run ui npm install
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- run: docker compose run ui npm install
- run: docker compose run --rm ui npm install

No need to keep the dangling container post-install.

})

it('should collapse Login and Signup buttons into a dots-button icon when screen width < 600px', async () => {
await browser.setWindowSize(599, 800)
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 on this, which should still be adressed.

it('should open and render with some buttons', () => {

it('should open and render with Login button', async () => {
const navLogin = await $('#nav-login')
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 on this, if we store some selectors on the page object class, let's store all of them there.


jobs:
browser-tests:
runs-on: ubuntu-latest
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: should we pin the ubuntu version here, so we don't get surprise updates at some point in the future?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

which version you suggested? Or I just use the current one because it works?

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems 24.04 is the latest one available https://github.com/actions/runner-images

@@ -28,7 +28,7 @@
</v-menu>
<template v-if="($vuetify.breakpoint.width >= 600) && !isLoggedIn">
<v-btn
id="nav-login"
data-test-id="nav-login"
Copy link
Contributor

Choose a reason for hiding this comment

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

While it's good to use the data-test-ids for testing, I'm not sure it's safe to remove existing id attributes. We'd better leave them in here so code that expects them to exist (in case it exists?) keeps finding them.

@dati18 dati18 merged commit 52d3977 into main Jun 24, 2024
8 checks passed
@dati18 dati18 deleted the main-page-e2e branch June 24, 2024 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants