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

Commit ad20115

Browse files
committed
test: Add initial Cypress test for webui diffs page
It's a very simple diff, showing a schema change between two database revisions. Ideally we'll add more comprehensive tests over time.
1 parent 90aca10 commit ad20115

File tree

4 files changed

+46
-14
lines changed

4 files changed

+46
-14
lines changed

cypress/e2e/1-webui/auth0_dialog.cy.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ describe('ensure auth0 dialog is available on all pages', () => {
22

33
/*
44
TODO - These pages still need to be considered, and/or have tests added for
5-
diffs.html
65
discussioncomments.html
76
mergerequestcomments.html
87
mergerequestlist.html

cypress/e2e/1-webui/diff.cy.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
describe('diff databases', () => {
2+
before(() => {
3+
// Seed data
4+
cy.request('/x/test/seed')
5+
6+
// Create new branch
7+
cy.visit('default/Assembly%20Election%202017.sqlite')
8+
cy.get('[data-cy="commitslnk"]').click()
9+
cy.get('[data-cy="createbranchbtn"]').click()
10+
cy.get('[data-cy="nameinput"]').type('{selectall}{backspace}').type('firstBranch')
11+
cy.get('[data-cy="createbtn"]').click()
12+
13+
// Upload database to the new branch
14+
cy.visit('default/Assembly%20Election%202017.sqlite')
15+
cy.get('[data-cy="uploadbtn"]').click()
16+
cy.get('input[type=file]').selectFile('cypress/test_data/Assembly Election 2017 with view.sqlite')
17+
cy.get('[data-cy="uploadbtn"]').click()
18+
})
19+
20+
// Diff between two databases with just a simple schema change (view creation)
21+
it('schema change only diff', () => {
22+
cy.visit('https://localhost:9443/branches/default/Assembly%20Election%202017.sqlite')
23+
cy.get('[data-cy="comparebtn"]').click()
24+
cy.get('[data-cy="objname"]').should('have.text', 'Candidate_Names')
25+
cy.get('[data-cy="objtype"]').should('have.text', 'view')
26+
cy.get('[data-cy="droptype"]').should('have.text', 'Dropped view')
27+
cy.get('[data-cy="dropdetail"]').should('have.text', 'CREATE VIEW "Candidate_Names" AS\n' +
28+
' SELECT Firstname, Surname\n' +
29+
' FROM "Candidate_Information"\n' +
30+
' ORDER BY Surname, Firstname\n' +
31+
' DESC')
32+
})
33+
})

webui/templates/branches.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ <h4 style="color: {{ statusMessageColour }};">&nbsp;{{ statusMessage }}</h4>
6161
<tr ng-repeat-end class="tableRow">
6262
[[ if eq .Meta.Owner .Meta.LoggedInUser ]]
6363
<td style="border-style: none;">
64-
<button ng-if="row.name != meta.DefBranch" class="btn btn-default" ng-click="viewChanges(row.commit)">Compare with {{ meta.DefBranch }}</button>
64+
<button ng-if="row.name != meta.DefBranch" class="btn btn-default" ng-click="viewChanges(row.commit)" data-cy="comparebtn">Compare with {{ meta.DefBranch }}</button>
6565
<button ng-if="row.name != meta.DefBranch" class="btn btn-danger" ng-click="deleteBranch(row.name)" data-cy="delbtn">Delete</button>
6666
</td>
6767
<td style="border-style: none; padding: 0;" colspan="3">

webui/templates/diffs.html

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,29 @@ <h4 style="color: {{ statusMessageColour }};">&nbsp;{{ statusMessage }}</h4>
1616
<div class="row">
1717
<div class="col-md-12" style="padding-bottom: 10px;">
1818
[[ if .Diffs.Diff ]]
19-
<table ng-if="Diffs != null" class="table table-striped table-responsive settingsTable">
19+
<table ng-if="Diffs != null" class="table table-striped table-responsive settingsTable" data-cy="difftbl">
2020
<tbody>
2121
<tr ng-repeat="row in Diffs">
22-
<td style="border-style: none;">
23-
<span style="font-size: x-large; color: #333;">{{ row.object_name }}</span><br />
24-
<span style="color: #333;">{{ row.object_type }}</span>
22+
<td style="border-style: none;" data-cy="objhdr">
23+
<span style="font-size: x-large; color: #333;" data-cy="objname">{{ row.object_name }}</span><br />
24+
<span style="color: #333;" data-cy="objtype">{{ row.object_type }}</span>
2525
<div>
2626
</div>
2727
</td>
2828
<td style="border-style: none;">
29-
<div class="pull-left" style="padding-top: 6px;">
29+
<div class="pull-left" style="padding-top: 6px;" data-cy="objdetail">
3030
<span ng-if="row.schema != null && row.schema.action_type=='add'">
31-
<span style="font-weight: bold;">Created {{ row.object_type }}</span><br />
32-
<span style="background-color: #e6ffed;">{{ row.schema.after }}</span><br/>
31+
<span style="font-weight: bold;" data-cy="addtype">Created {{ row.object_type }}</span><br />
32+
<span style="background-color: #e6ffed;" data-cy="adddetail">{{ row.schema.after }}</span><br/>
3333
</span>
3434
<span ng-if="row.schema != null && row.schema.action_type=='delete'">
35-
<span style="font-weight: bold;">Dropped {{ row.object_type }}</span><br />
36-
<span style="background-color: #fdb8c0;">{{ row.schema.before }}</span><br/>
35+
<span style="font-weight: bold;" data-cy="droptype">Dropped {{ row.object_type }}</span><br />
36+
<span style="background-color: #fdb8c0;" data-cy="dropdetail">{{ row.schema.before }}</span><br/>
3737
</span>
3838
<span ng-if="row.schema != null && row.schema.action_type=='modify'">
39-
<span style="font-weight: bold;">Schema changed</span><br />
40-
<span style="background-color: #fdb8c0;">{{ row.schema.before }}</span><br/>
41-
<span style="background-color: #e6ffed;">{{ row.schema.after }}</span><br/>
39+
<span style="font-weight: bold;" data-cy="mod">Schema changed</span><br />
40+
<span style="background-color: #fdb8c0;" data-cy="modbefore">{{ row.schema.before }}</span><br/>
41+
<span style="background-color: #e6ffed;" data-cy="modafter">{{ row.schema.after }}</span><br/>
4242
</span>
4343
<span ng-if="row.data.length">{{ row.data.length }} rows changed:</span>
4444
</div>

0 commit comments

Comments
 (0)