Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

Commit d202bfb3 authored by flothoni's avatar flothoni
Browse files

cypress; add a first script of tests

Use some test of test_list.rb, adapted to cypress
parent 38f4833c
/home/florian/vidjil_issues/vidjil_raw_2/browser/test/data
\ No newline at end of file
/home/florian/vidjil_issues/vidjil_raw_2/doc
\ No newline at end of file
{
"local": {"id":61, "config":2},
"review": {"id":18, "config":2},
"app": {"id":61, "config":2}
}
/// <reference types="cypress" />
var localhost = true
console.log( Cypress.env('workdir') )
var url = "./"+ Cypress.env('workdir')+"/browser/index.html"
console.log( url )
describe('Actions v1', function () {
beforeEach(function () {
cy.fixture('l3.json').then(function (l3data) {
this.l3data = l3data
})
var b = Cypress.browser
this.basename = b.name + "_" + b.majorVersion + "_"
cy.visit(url)
cy.close_disclamer()
cy.close_tips()
})
it('Open a simple vidjil file', function() {
cy.set_browser("doc/analysis-example2.vidjil")
cy.get('#list_clones').children().should('have.length', 8)
cy.get('#listElem_5 > .nameBox').should('have.text', "clone_cluster1")
cy.get('#listElem_5 > .axisBox > .sizeBox').should('have.text', "0.408%")
return
})
it('Open a vidjil file + analysis', function() {
// cy.visit(url)
cy.set_browser("doc/analysis-example2.vidjil", "doc/analysis-example2.analysis")
// cy.get('#list_clones').children().should('have.length', 6)
cy.get('#listElem_5 > .nameBox').should('have.text', "clone_cluster1")
// second sample open with analysis, so size is smaller
// cy.waitForUpdates()
cy.get("body").type("{rightarrow}")
cy.update_icon()
cy.get('#listElem_5 > .axisBox > .sizeBox').should('have.text', "0.014%")
cy.get('#listElem_6 > .nameBox').should('not.visible');
return
})
it('test_00_list_clones', function() {
cy.set_browser("doc/analysis-example2.vidjil", "doc/analysis-example2.analysis")
// # change current sample to start on sample 0 (second in loaded order)
cy.get("body").type("{rightarrow}")
cy.update_icon()
// # declare variables
var lock = cy.get('#div_sortLock')
var listClone = cy.get('#list_clones')
// # tester la presence du lock
cy.get('#div_sortLock')
.should('have.class', "icon-lock-1 list_lock_on")
.and('have.attr', 'title')
.and('include', "Release sort as '-' on sample diag")
cy.get('#list_clones').children().eq(0)
.should("contain", "Main ALL clone")
cy.get('#list_clones').children().eq(1)
.should("contain", "TRG smaller clone")
// // # change order by 'size'
cy.get('#list_sort_select')
.select('size')
.should('have.value', 'size')
cy.get('#list_sort_select')
.should('not.have.value', '-')
cy.update_icon()
cy.waitForUpdates()
cy.get('#div_sortLock').should('have.class', "icon-lock-1 list_lock_on")
.and('have.attr', 'title')
.and('include', "Release sort as 'size' on sample fu1")
cy.get('#list_clones').children().eq(0)
.should("contain", "TRG smaller clone")
cy.get('#list_clones').children().eq(1)
.should("contain", "Main ALL clone")
// Ex test_01_xxx
cy.get("body").type("{rightarrow}")
cy.update_icon()
cy.get('#list_clones').children().eq(0)
.should("contain", "TRG smaller clone")
cy.get('#div_sortLock').should('have.class', "icon-lock-1 list_lock_on")
.and('have.attr', 'title')
.and('include', "Release sort as 'size' on sample fu1")
})
// def test_02_xxx
// # Lock off
// $lock.click
// assert ( $lock.attribute_value("class") == "icon-lock-open list_lock_off"), "lock in good state after click (unlocked)"
// # print "\n"+$lock.attribute_value("title")+"\n"
// assert ( $lock.attribute_value("title") == "Freeze list as '-' on sample fu1"), "lock title show correct effet if click in icon (freeze, size, fu1)"
// # Clone order should NOT have changed (as sort is now '-')
// l0 = $listClone.div(index: 0)
// assert ( l0.id == "listElem_0" ), "opening; correct id of the first element"
// # change order by 'size'
// $b.select(:id => 'list_sort_select').click
// $b.send_keys :arrow_down
// $b.send_keys :enter
// $b.update_icon.wait_while(&:present?)
// # Clone order should have changed (sort 'size')
// l0 = $listClone.div(index: 0)
// assert ( l0.id == "listElem_7" ), "opening; correct id of the first element (clone other)"
// $lock.click # remove lock
// l0 = $listClone.div(index: 0)
// assert ( l0.id == "listElem_7" ), "opening; correct id of the first element (clone other)"
// $b.div(:id => "left-container").click # get out of the select list
// end
// def test_03_xxx
// # Change sample (-> diag)
// $b.send_keys :arrow_right
// $b.update_icon.wait_while(&:present?)
// # clone order
// l0 = $listClone.div(index: 0)
// assert ( l0.id == "listElem_0" ), "opening; correct id of the first element"
// assert ( $lock.attribute_value("title") == "Freeze list as 'size' on sample diag"), "lock title show correct effet if click in icon (freeze, size, diag)"
// end
// def test_04_xxx
// # Lock again
// $lock.click
// $b.update_icon.wait_while(&:present?)
// assert ( $lock.attribute_value("class") == "icon-lock-1 list_lock_on"), "lock in good state after second click (locked)"
// assert ( $lock.attribute_value("title") == "Release sort as 'size' on sample diag"), "lock title showing 'release ...'size' ... diag'"
// # Change sample (-> fu1)
// $b.send_keys :arrow_right
// $b.update_icon.wait_while(&:present?)
// assert ( $lock.attribute_value("title") == "Release sort as 'size' on sample diag"), "lock title showing 'release ...'size' ... diag'"
// # Clone order should be as in case 1
// l0 = $listClone.div(index: 0)
// assert ( l0.id == "listElem_0" ), "opening; correct id of the first element"
// end
// def test_05_xxx
// # Change sort method (size => V/5')
// $b.select(:id => 'list_sort_select').click
// $b.send_keys :arrow_down
// $b.send_keys :arrow_down
// $b.send_keys :enter
// $b.update_icon.wait_while(&:present?)
// # Lock should be open
// assert ( $lock.attribute_value("class") == "icon-lock-1 list_lock_on"), "lock in good state after change of sort method (locked)"
// assert ( $lock.attribute_value("title") == "Release sort as 'V/5'' on sample fu1"), "lock title showing 'release ...'V/5'' ... diag'"
// # clone list should be cha
// l0 = $listClone.div(index: 0)
// assert ( l0.id == "listElem_0" ), "opening; correct id of the first element"
// end
})
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
// import 'cypress-wait-until';
var lil_l3 = {"app": {"id":61, "config":2}, "localhost": {"id":3241, "config":25}}
file:///home/florian/vidjil_issues/vidjil_raw_2/browser/index.html
Cypress.Commands.add('close_disclamer', () => {
cy.get("div.popup_container")
.should('be.visible')
.and('contain', 'The Vidjil Team')
.get('.center > button')
.click()
})
Cypress.Commands.add('close_tips', () => {
cy.get('.tip_1')
.should('be.visible')
.and('contain', 'Tip:')
.get('.tip_1 > .icon-cancel')
.click()
})
Cypress.Commands.add('open_menu_import', () => {
cy.get('#demo_file_menu').click()
})
Cypress.Commands.add("set_browser", (file_vidjil, file_analysis) => {
cy.open_menu_import()
cy.get('#import_data_anchor').click()
cy.log(`file_vidjil: ${file_vidjil}`)
cy.log(`file_analysis: ${file_analysis}`)
cy.get("input[id=upload_json]")
.then(($btn) => { cy.get("input[id=upload_json]").uploadFile(file_vidjil); })
if (file_analysis != undefined) {
cy.get("input[id=upload_pref]")
.then(($btn) => {cy.get("input[id=upload_pref]").uploadFile(file_analysis); })
}
cy.get("button[id=start_import_json]")
.click();
cy.update_icon()
})
Cypress.Commands.add("update_icon", () => {
cy.get('#updateIcon').should("not.visible")
})
Cypress.Commands.add('getById', (input) => {
cy.get(`[data-cy=${input}]`)
})
Cypress.Commands.add('isDbPageVisible', () => {
// return cy.get('.db_div').should("be.visible")
cy.get('.db_div').then($button => {
if ($button.is(':visible')){
return true
} else {
return false
}
})
})
Cypress.Commands.add('goToDBPage', () => {
cy.isDbPageVisible().then((val) => {
console.log( val )
if (val == false){
cy.get('#db_menu').trigger('mouseover')
.contains('open list')
.should('be.visible')
.click()
cy.get('.db_div')
.should('be.visible')
}
})
})
Cypress.Commands.add('goToPatientPage', () => {
cy.goToDBPage().then(() => {
cy.get('#db_menu > .patient_token')
.click()
cy.get('.db_div')
.should('contain', ' + new patients ')
})
})
Cypress.Commands.add('goToRunPage', () => {
cy.goToDBPage().then(() => {
cy.get('#db_menu > .run_token')
.click()
cy.get('.db_div')
.should('contain', ' + new runs ')
})
})
\ No newline at end of file
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './tools'
import './login'
import './commands'
import './db_pages'
const resizeObserverLoopErrRe = /^[^(ResizeObserver loop limit exceeded)]/
Cypress.on('uncaught:exception', (err, runnable) => {
// returning false here prevents Cypress from failing the test
if (resizeObserverLoopErrRe.test(err.message)) { return false }
return false
})
beforeEach(() => {
cy.on("window:before:load", (win) => {
cy.spy(win.console, "log");
})
})
\ No newline at end of file
Cypress.Commands.add('login', (host) => {
if (host=="local"){
cy.visit('https://localhost/browser')
cy.waitForUpdates()
// log in
cy.get('#auth_user_email')
.type('plop@plop.com')
cy.get('#auth_user_password')
.type('foobartest')
cy.get('#submit_record__row > .w2p_fw > input').click()
cy.waitForUpdates()
} else if (host=="review"){
cy.visit('https://localhost/browser')
cy.waitForUpdates()
// log in
cy.get('#auth_user_email')
.type('test@vidjil.org')
cy.get('#auth_user_password')
.type('xxx')
cy.get('#submit_record__row > .w2p_fw > input').click()
cy.waitForUpdates()
} else if (host=="app"){
cy.visit('https://app.vidjil.org/')
cy.waitForUpdates()
// log in
cy.get('#auth_user_email')
.type('demo@vidjil.org')
cy.get('#auth_user_password')
.type('demo')
// .type('demo')
cy.get('#submit_record__row > .w2p_fw > input').click()
cy.waitForUpdates()
}
cy.verifyLogin()
})
Cypress.Commands.add('verifyLogin', (host) => {
cy.get('body').should('not.contain', 'You can request an account')
cy.get('body').should('contain', 'logout')
})
Cypress.Commands.add('waitForUpdates', () => {
cy.wait(1000)
})
//
Cypress.Commands.add("uploadFile",
{ prevSubject: true },
(subject, fileName) => {
cy.fixture(fileName).then(content => {
const el = subject[0];
const testFile = new File([content], fileName);
const dataTransfer = new window.DataTransfer();
dataTransfer.items.add(testFile);
el.files = dataTransfer.files;
cy.wrap(subject).trigger("change", { force: true });
});
}
);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment