Skip to content

Commit

Permalink
Cypress - saving artifacts and misc fixes (#2114)
Browse files Browse the repository at this point in the history
  • Loading branch information
ifarzana committed Sep 25, 2023
1 parent 6875c85 commit de55174
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 11 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/test-suite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,15 @@ jobs:
run: |
docker exec --user www-data -t cms-web /bin/bash -c "cd /var/www/cms; php vendor/bin/phpunit --log-junit results.xml"
- name: Run Cypress
continue-on-error: true
run: |
docker exec cms-db mysql -ucms -pjenkins cms -e "INSERT INTO oauth_clients (id, secret, name, userId, authCode, clientCredentials) VALUES ('MrGPc7e3IL1hA6w13l7Ru5giygxmNiafGNhFv89d', 'Pk6DdDgu2HzSoepcMHRabY60lDEvQ9ucTejYvc5dOgNVSNaOJirCUM83oAzlwe0KBiGR2Nhi6ltclyNC1rmcq0CiJZXzE42KfeatQ4j9npr6nMIQAzMal8O8RiYrIoono306CfyvSSJRfVfKExIjj0ZyE4TUrtPezJbKmvkVDzh8aj3kbanDKatirhwpfqfVdfgsqVNjzIM9ZgKHnbrTX7nNULL3BtxxNGgDMuCuvKiJFrLSyIIz1F4SNrHwHz', 'cypress', 1, 0, 1)"
docker exec cms-db mysql -ucms -pjenkins cms -e "INSERT INTO oauth_client_scopes (clientId, scopeId) VALUES ('MrGPc7e3IL1hA6w13l7Ru5giygxmNiafGNhFv89d', 'all') ON DUPLICATE KEY UPDATE scopeId = scopeId"
docker run --ipc=host --name cms-cypress --link=cms-web:web -v $(pwd)/cypress.config.js:/app/cypress.config.js -v $(pwd)/cypress:/app/cypress ghcr.io/xibosignage/xibo-cms:cypress bash -c "CYPRESS_baseUrl=http://web /app/node_modules/.bin/cypress run --config screenshotsFolder=/app/results,video=false --reporter junit --reporter-options 'mochaFile=/app/results/results_cypress_[hash].xml,toConsole=true'"
docker run --ipc=host --name cms-cypress --link=cms-web:web -v $(pwd)/cypress.config.js:/app/cypress.config.js -v $(pwd)/cypress:/app/cypress ghcr.io/xibosignage/xibo-cms:cypress bash -c "CYPRESS_baseUrl=http://web /app/node_modules/.bin/cypress run --config screenshotsFolder=/app/cypress/results,video=false --reporter junit --reporter-options 'mochaFile=/app/cypress/results/results_cypress_[hash].xml,toConsole=true'; chown -R 1001:1001 /app/cypress/results"
- name: Save Cypress test results as an artifact
if: failure()
uses: actions/upload-artifact@v3
with:
name: cypress-test-results
path: cypress/results
run: exit 1
7 changes: 5 additions & 2 deletions cypress/e2e/report_summary.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('Summary by Layout, Media or Event', function() {
});

it('Range: Today, Checks duration and count of a layout stat', () => {
// Create and alias for load layout
// Create alias
cy.intercept({
url: '/display?start=*',
query: {display: display1},
Expand Down Expand Up @@ -57,13 +57,14 @@ describe('Summary by Layout, Media or Event', function() {

// Click on the Apply button
cy.contains('Apply').should('be.visible').click();
// Wait for report data
cy.wait('@reportData');

cy.get('.chart-container').should('be.visible');

// Click on Tabular
cy.contains('Tabular').should('be.visible').click();
cy.contains('Next').should('be.visible').click();
cy.wait('@reportData');

// Should have media stats
cy.get('#summaryTbl tbody tr:nth-child(3) td:nth-child(1)').contains('12:00 PM'); // Period
Expand All @@ -75,6 +76,7 @@ describe('Summary by Layout, Media or Event', function() {
const reportschedule = 'Daily Summary by Layout 1 and Display 1';

// Create and alias for load layout
cy.intercept('/report/reportschedule/form/add*').as('reportScheduleAddForm');
cy.intercept({
url: '/display?start=*',
query: {display: display1},
Expand Down Expand Up @@ -102,6 +104,7 @@ describe('Summary by Layout, Media or Event', function() {
// ------
// Create a Daily Summary Report Schedule
cy.get('#reportAddBtn').click();
cy.wait('@reportScheduleAddForm');
cy.get('#reportScheduleAddForm #name ').type(reportschedule);

// Click on the select2 selection
Expand Down
50 changes: 42 additions & 8 deletions cypress/e2e/schedule.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ describe('Campaigns', function() {
});
});

it.skip('should schedule an event campaign that has no priority, no recurrence', function() {
it('should schedule an event campaign that has no priority, no recurrence', function() {
cy.intercept('GET', '/schedule?draw=2*').as('scheduleLoad');
cy.intercept('GET', '/schedule/form/add?*').as('scheduleAddForm');

// Set up intercepts with aliases
cy.intercept({
url: '/display?start=*',
Expand All @@ -64,8 +67,13 @@ describe('Campaigns', function() {

// Visit the page and click on the Add Event button
cy.visit('/schedule/view');
// Wait for schedule draw 2
cy.wait('@scheduleLoad');
cy.contains('Clear Filters').should('be.visible').click();
cy.contains('Add Event').click();
cy.wait('@scheduleAddForm');

// Fill in Add form
cy.get(':nth-child(3) > .col-sm-10 > .select2 > .selection > .select2-selection > .select2-selection__rendered')
.type(display1);
cy.wait('@loadDisplaygroupAfterSearch');
Expand Down Expand Up @@ -93,6 +101,10 @@ describe('Campaigns', function() {

// Validate - schedule creation should be successful
cy.visit('/schedule/view');
//cy.get('.select2-selection__clear').click();
cy.contains('Clear Filters').should('be.visible').click();


cy.get('#DisplayList + span .select2-selection').click();
// Type the display name
cy.get('.select2-container--open input[type="search"]').type(display1);
Expand All @@ -106,7 +118,9 @@ describe('Campaigns', function() {
cy.get('#schedule-grid').contains(campaignSchedule1);
});

it.skip('should schedule an event layout that has no priority, no recurrence', function() {
it('should schedule an event layout that has no priority, no recurrence', function() {
cy.intercept('GET', '/schedule?draw=2*').as('scheduleLoad');
cy.intercept('GET', '/schedule/form/add?*').as('scheduleAddForm');
cy.intercept({
url: '/displaygroup?*',
query: {displayGroup: display1},
Expand All @@ -123,7 +137,11 @@ describe('Campaigns', function() {

// Click on the Add Event button
cy.visit('/schedule/view');
// Wait for schedule draw 2
cy.wait('@scheduleLoad');
cy.contains('Clear Filters').should('be.visible').click();
cy.contains('Add Event').click();
cy.wait('@scheduleAddForm');

// display
cy.get(':nth-child(3) > .col-sm-10 > .select2 > .selection > .select2-selection > .select2-selection__rendered')
Expand Down Expand Up @@ -154,7 +172,9 @@ describe('Campaigns', function() {
cy.contains('Added Event');
});

it.skip('should schedule an event command/overlay layout that has no priority, no recurrence', function() {
it('should schedule an event command/overlay layout that has no priority, no recurrence', function() {
cy.intercept('GET', '/schedule?draw=2*').as('scheduleLoad');
cy.intercept('GET', '/schedule/form/add?*').as('scheduleAddForm');
cy.intercept({
url: '/displaygroup?*',
query: {displayGroup: display1},
Expand All @@ -167,7 +187,11 @@ describe('Campaigns', function() {

// Click on the Add Event button
cy.visit('/schedule/view');
// Wait for schedule draw 2
cy.wait('@scheduleLoad');
cy.contains('Clear Filters').should('be.visible').click();
cy.contains('Add Event').click();
cy.wait('@scheduleAddForm');

// display
cy.get(':nth-child(3) > .col-sm-10 > .select2 > .selection > .select2-selection > .select2-selection__rendered')
Expand Down Expand Up @@ -209,7 +233,11 @@ describe('Campaigns', function() {
cy.get('.modal .modal-footer').contains('Save').click();
});

it.skip('should edit a scheduled event', function() {
it('should edit a scheduled event', function() {
cy.intercept('GET', '/schedule/data/events?*').as('scheduleDataEvent');
cy.intercept('GET', '/schedule?draw=2*').as('scheduleLoad2');
cy.intercept('GET', '/schedule?draw=3*').as('scheduleLoad3');
cy.intercept('GET', '/schedule/form/add?*').as('scheduleAddForm');
cy.intercept({
url: '/displaygroup?*',
query: {displayGroup: display2},
Expand All @@ -221,6 +249,9 @@ describe('Campaigns', function() {
}).as('loadLayoutSpecificCampaign');

cy.visit('/schedule/view');
// Wait for schedule draw 2
cy.wait('@scheduleLoad2');
cy.contains('Clear Filters').should('be.visible').click();

// ---------
// Edit a schedule - add another display
Expand All @@ -245,11 +276,14 @@ describe('Campaigns', function() {
.click();

cy.get('.modal .modal-footer').contains('Save').click();

cy.get('#schedule-grid tbody').contains('2');

// cy.get('#schedule-grid tbody tr').should('have.length', 2);
// cy.get('#schedule-grid tr:first-child .dropdown-toggle').invoke('show').click();
// cy.get('#schedule-grid tr:first-child .schedule_button_delete').click();
// cy.get('.bootbox .save-button').click();
cy.get('#schedule-grid tbody tr').should('have.length', 2);
cy.wait('@scheduleLoad3');
cy.wait('@scheduleDataEvent');
cy.get('#schedule-grid tr:first-child .dropdown-toggle').click();
cy.get('#schedule-grid tr:first-child .schedule_button_delete').click();
cy.get('.bootbox .save-button').click();
});
});

0 comments on commit de55174

Please sign in to comment.