Skip to content

Commit

Permalink
feat: End to End tests written
Browse files Browse the repository at this point in the history
More UI tests based on Users flow written.
Secured the tests with using data-cy instead of ID.
  • Loading branch information
BKristenssonAlfsson committed May 30, 2020
1 parent d4a2d85 commit d7fe170
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 9 deletions.
43 changes: 43 additions & 0 deletions cypress/integration/ambianic-tests/navbar.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* This test will only work while the EC2 machines are running.
*/

/// <reference types="cypress" />

context('Check Navbar Items', () => {
before(() => {
// cy.visit('http://18.219.76.94')
cy.visit('http://localhost:8080')
cy.get('[data-cy=settings]').click()
})

it('Should have a search bar', () => {
cy.get('[data-cy=container').find("#searchbar")
})

it('Should be a download off button', () => {
const t = cy.get('[data-cy=download-off]')
expect(t).to.exist
})

it('Should be a heart button', () => {
const t = cy.get('[data-cy=heart]')
expect(t).to.exist
})

it('Should be a bell button', () => {
const t = cy.get('[data-cy=bell]')
expect(t).to.exist
})

it('Should be an about button', () => {
const t = cy.get('[data-cy=about]')
expect(t).to.exist
})

it('Should have a five links', () => {
cy.get('[data-cy=drawer]').then(($result) => {
assert.equal($result.children().children()[0].childElementCount,5,'Five links in the drawer')
})
})
})
8 changes: 4 additions & 4 deletions cypress/integration/ambianic-tests/remote-connection.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ context('RemoteConnections', () => {

it('Should be connected automatically', () => {

cy.get('#btn-settings').click()
cy.get('[data-cy=settings]').click()

cy.wait(8000)

Expand All @@ -20,11 +20,11 @@ context('RemoteConnections', () => {

it('Should switch to a remote Edge', () => {

cy.get('#btn-settings').click()
cy.get('[data-cy=settings]').click()

cy.get('#remotePeerID').type('917d5f0a-6469-4d33-b5c2-efd858118b74')
cy.get('[data-cy=remotePeerID]').type('917d5f0a-6469-4d33-b5c2-efd858118b74')

cy.get('#btn-sendRemotePeerID').click()
cy.get('[data-cy=sendRemotePeerID]').click()

cy.wait(8000)

Expand Down
37 changes: 37 additions & 0 deletions cypress/integration/ambianic-tests/settings.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* This test will only work while the EC2 machines are running.
*/

/// <reference types="cypress" />

context('RemoteConnections', () => {
before(() => {
cy.visit('http://18.219.76.94')
cy.get('[data-cy=settings]').click()
})

it('Should have a title card', () => {
cy.get('[data-cy=titlecard]').contains('Connection details')
})

it('Should have a local ambianic edge title card', () => {
cy.get('[data-cy=localtitlecard]').contains('Connect to local Ambianic Edge')
})

it('Should have a remote ambianic edge title card', () => {
cy.get('[data-cy=remotetitlecard]').contains('Connect to remote Ambianic Edge')
})

it('Should have remote connection button disabled', () => {
cy.get('[data-cy=sendRemotePeerID]').should('be.disabled')
})

it('Should have remote connection button enabled', () => {
cy.get('[data-cy=remotePeerID]').type('917d5f0a-6469-4d33-b5c2-efd858118b74')
cy.get('[data-cy=sendRemotePeerID]').should('be.enabled')
})

it('Should have a row', () => {
cy.get('[data-cy=template-row]').should('exist')
})
})
45 changes: 45 additions & 0 deletions cypress/integration/ambianic-tests/timeline.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* This test will only work while the EC2 machines are running.
*/

/// <reference types="cypress" />

context('RemoteConnections', () => {
beforeEach(() => {
cy.visit('http://18.219.76.94')
})

it('Should browse to timeline', () => {
cy.get('[data-cy=timeline]').click()

cy.url().should('include', '/timeline')
})

it('Should render connection card', () => {
cy.get('[data-cy=timeline]').click()

cy.get('.mx-auto').contains('Connecting to Ambianic Edge device...')
})

/**
* This will be removed once we have decided on the flow
* for future layout/flow in UI / Edge connection
*/
it('Should browse to edgeconnect', () => {
cy.get('[data-cy=timeline]').click()

cy.wait(500)

cy.get('[data-cy=settings]').click()

cy.url().should('include', '/edge-connect')
})

it('Should generate no results in timeline', () => {
cy.get('[data-cy=timeline]').click()

cy.wait(5000)

cy.get('.infinite-status-prompt').contains('No results :(')
})
})
13 changes: 11 additions & 2 deletions src/components/NavBar.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<v-container
class="pa-0 ma-0"
data-cy="container"
fluid
>
<v-app-bar
Expand All @@ -11,10 +12,11 @@
style="width: 300px"
class="ml-0 pl-4"
>
<v-app-bar-nav-icon @click.stop="drawer = !drawer" />
<v-app-bar-nav-icon id="drawer" @click.stop="drawer = !drawer" />
<span class="hidden-sm-and-down">Ambianic</span>
</v-toolbar-title>
<v-text-field
id="searchbar"
flat
solo-inverted
hide-details
Expand All @@ -26,6 +28,7 @@

<amb-button
with-badge
data-cy="download-off"
is-icon
icon="download-off"
v-if="!isEdgeConnected"
Expand All @@ -35,6 +38,7 @@
<!-- test -->
<amb-button
with-badge
data-cy="heart"
is-icon
icon="heart"
:badge-content="newFavorites"
Expand All @@ -43,6 +47,7 @@

<amb-button
with-badge
data-cy="bell"
is-icon
icon="bell"
:badge-content="newAlerts"
Expand All @@ -51,6 +56,7 @@

<amb-button
is-icon
data-cy="about"
to="about"
>
<v-avatar
Expand All @@ -68,12 +74,15 @@
<!-- drawer -->
<v-navigation-drawer
v-model="drawer"
data-cy="drawer"
app
mini-variant
expand-on-hover
>
<v-list dense>
<template v-for="item in items">
<template
v-for="item in items"
>
<v-row
v-if="item.heading"
:key="item.heading"
Expand Down
2 changes: 2 additions & 0 deletions src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
rounded
color="pink darken-4"
dark
data-cy="timeline"
class="ma-2 white--text"
:to="'timeline'"
id="btn-timeline"
Expand All @@ -63,6 +64,7 @@
dark
class="ma-2 white--text"
:to="'settings'"
data-cy="settings"
>
Settings
<v-icon
Expand Down
19 changes: 16 additions & 3 deletions src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
<v-row
align="start"
justify="space-around"
data-cy="template-row"
>
<v-card>
<v-card-title class="light grey">
<v-card-title
class="light grey"
data-cy="titlecard"
>
Connection details
</v-card-title>
<v-container grid-list-sm>
Expand Down Expand Up @@ -156,7 +160,10 @@
</v-card>

<v-card>
<v-card-title class="light grey">
<v-card-title
class="light grey"
data-cy="localtitlecard"
>
Connect to local Ambianic Edge
</v-card-title>
<v-container grid-list-sm>
Expand Down Expand Up @@ -187,7 +194,10 @@
</v-container>
</v-card>
<v-card>
<v-card-title class="light grey">
<v-card-title
class="light grey"
data-cy="remotetitlecard"
>
Connect to remote Ambianic Edge
</v-card-title>
<v-container grid-list-sm>
Expand All @@ -204,9 +214,11 @@
label="Peer ID to Ambianic Network*"
placeholder="Enter Peer ID"
id="remotePeerID"
data-cy="remotePeerID"
outlined
dense
class="mt-4"

/>
</v-card-text>

Expand All @@ -215,6 +227,7 @@
:disabled="!correctEdgeAddress"
@click="sendEdgeAddress"
color="primary"
data-cy="sendRemotePeerID"
id="btn-sendRemotePeerID"
>
REMOTE NETWORK
Expand Down
2 changes: 2 additions & 0 deletions src/views/Timeline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
<v-card-actions>
<v-btn
text
id="btn-settings"
data-cy="settings"
to="/edge-connect"
>
Connection Settings
Expand Down

0 comments on commit d7fe170

Please sign in to comment.