Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7123681
D1774.id6028.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Subscribers
None
D1774.id6028.diff
View Options
diff --git a/cypress/integration/visits.spec.js b/cypress/integration/visits.spec.js
new file mode 100644
--- /dev/null
+++ b/cypress/integration/visits.spec.js
@@ -0,0 +1,70 @@
+/**
+ * Copyright (C) 2019 The Software Heritage developers
+ * See the AUTHORS file at the top-level directory of this distribution
+ * License: GNU Affero General Public License version 3, or any later version
+ * See top-level LICENSE file for more information
+ */
+
+import {getTime} from '../utils';
+
+let origin = 'https://github.com/wcoder/highlightjs-line-numbers.js';
+
+function checkTimeLink(element) {
+ expect(element.text()).not.to.be.empty;
+
+ const timeStringLink = element.attr('href').split('visit/')[1].split('/')[0];
+
+ // time in link should be equal to that in text
+ assert.deepEqual(getTime(timeStringLink), getTime(element.text()));
+}
+
+function searchInCalendar(date) {
+ cy.get(`.year${date.year}`)
+ .click({force: true});
+ cy.contains('.month', date.monthName)
+ .find('.day-content')
+ .eq(date.date - 1)
+ .trigger('mouseover')
+ .get('.popover-body')
+ .should('be.visible')
+ .and('contain', `${date.hours}:${date.minutes} UTC`);
+}
+
+describe('Visits tests', function() {
+ beforeEach(function() {
+ cy.visit(this.Urls.browse_origin_visits(origin));
+ });
+
+ it('should display first full visit time', function() {
+ cy.get('#swh-first-full-visit > .swh-visit-full')
+ .then(($el) => {
+ checkTimeLink($el);
+ searchInCalendar(getTime($el.text()));
+ });
+ });
+
+ it('should display last full visit time', function() {
+ cy.get('#swh-last-full-visit > .swh-visit-full')
+ .then(($el) => {
+ checkTimeLink($el);
+ searchInCalendar(getTime($el.text()));
+ });
+ });
+
+ it('should display last visit time', function() {
+ cy.get('#swh-last-visit > .swh-visit-full')
+ .then(($el) => {
+ checkTimeLink($el);
+ searchInCalendar(getTime($el.text()));
+ });
+ });
+
+ it('should display list of visits and mark them on calendar', function() {
+ cy.get('.swh-visits-list-row .swh-visit-full')
+ .should('be.visible')
+ .each(($el) => {
+ checkTimeLink($el);
+ searchInCalendar(getTime($el.text()));
+ });
+ });
+});
diff --git a/cypress/utils/index.js b/cypress/utils/index.js
--- a/cypress/utils/index.js
+++ b/cypress/utils/index.js
@@ -11,3 +11,26 @@
const response = await axios.get(url);
return response.data;
}
+
+/**
+ * Converts string with Time information
+ * to an object with Time information
+ */
+export function getTime(text) {
+ const date = new Date(text);
+
+ function pad(n) {
+ return n < 10 ? '0' + n : n;
+ }
+
+ const time = {
+ date: date.getUTCDate(),
+ month: date.getUTCMonth(),
+ monthName: date.toLocaleString('en', { month: 'long' }),
+ year: date.getUTCFullYear(),
+ hours: pad(date.getUTCHours()),
+ minutes: pad(date.getUTCMinutes())
+ };
+
+ return time;
+}
diff --git a/swh/web/tests/data.py b/swh/web/tests/data.py
--- a/swh/web/tests/data.py
+++ b/swh/web/tests/data.py
@@ -6,7 +6,6 @@
from copy import deepcopy
import os
import random
-import time
from swh.indexer.fossology_license import FossologyLicenseIndexer
from swh.indexer.mimetype import MimetypeIndexer
@@ -141,17 +140,21 @@
'type': 'git',
'url': 'https://github.com/wcoder/highlightjs-line-numbers.js',
'archives': ['highlightjs-line-numbers.js.zip',
- 'highlightjs-line-numbers.js_visit2.zip']
+ 'highlightjs-line-numbers.js_visit2.zip'],
+ 'visit_date': ['Dec 1 2018, 01:00 UTC',
+ 'Jan 20 2019, 15:00 UTC']
},
{
'type': 'git',
'url': 'https://github.com/memononen/libtess2',
- 'archives': ['libtess2.zip']
+ 'archives': ['libtess2.zip'],
+ 'visit_date': ['May 25 2018, 01:00 UTC']
},
{
'type': 'git',
'url': 'repo_with_submodules',
- 'archives': ['repo_with_submodules.tgz']
+ 'archives': ['repo_with_submodules.tgz'],
+ 'visit_date': ['Jan 1 2019, 01:00 UTC']
}
]
@@ -167,14 +170,13 @@
storage = loader.storage
for origin in _TEST_ORIGINS:
- nb_visits = len(origin['archives'])
for i, archive in enumerate(origin['archives']):
origin_repo_archive = \
os.path.join(os.path.dirname(__file__),
'resources/repos/%s' % archive)
- loader.load(origin['url'], origin_repo_archive, None)
- if nb_visits > 1 and i != nb_visits - 1:
- time.sleep(1)
+ loader.load(origin['url'], origin_repo_archive,
+ origin['visit_date'][i])
+
origin.update(storage.origin_get(origin)) # add an 'id' key if enabled
contents = set()
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Dec 19 2024, 6:17 PM (11 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3227179
Attached To
D1774: cypress: Add tests for visits
Event Timeline
Log In to Comment