Skip to content

Commit

Permalink
initial e2e is working, testing add/delete QSO is working
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickrb committed Apr 4, 2024
1 parent 36f05bd commit 66017f3
Show file tree
Hide file tree
Showing 11 changed files with 2,141 additions and 2 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: End-to-end tests
on: [pull_request]
jobs:
cypress-run:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: cloudlogpassword
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: mbstring, mysql
coverage: xdebug
- name: Validate composer.json and composer.lock
run: composer validate
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest
- name: Start Apache
run: sudo service apache2 start
- name: Run Cypress tests
uses: cypress-io/github-action@v2
with:
start: npm start
wait-on: 'http://localhost'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
/assets/qslcard/*
/assets/sstvimages/*
/assets/js/sections/custom.js
/cypress/screenshots
/node_modules
.idea/*
.DS_Store
sync.sh
Expand Down
2 changes: 1 addition & 1 deletion application/views/view_log/partial/log.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
<?php } ?>

</div>
<a class="dropdown-item" href="javascript:qso_delete(<?php echo $row->COL_PRIMARY_KEY; ?>, '<?php echo $row->COL_CALL; ?>')"><i class="fas fa-trash-alt"></i> <?php echo lang('general_delete_qso'); ?></a>
<a class="dropdown-item" id="qso_delete" href="javascript:qso_delete(<?php echo $row->COL_PRIMARY_KEY; ?>, '<?php echo $row->COL_CALL; ?>')"><i class="fas fa-trash-alt"></i> <?php echo lang('general_delete_qso'); ?></a>
</div>
</td>
<?php } ?>
Expand Down
2 changes: 1 addition & 1 deletion application/views/view_log/qso.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@

<?php if(($this->config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE) { ?>
<br>
<div style="display: inline-block;"><p class="editButton"><a class="btn btn-primary" href="<?php echo site_url('qso/edit'); ?>/<?php echo $row->COL_PRIMARY_KEY; ?>" href="javascript:;"><i class="fas fa-edit"></i> <?php echo lang('qso_btn_edit_qso'); ?></a></p></div>
<div style="display: inline-block;"><p class="editButton"><a class="btn btn-primary" href="javascript:qso_edit(<?php echo $row->COL_PRIMARY_KEY; ?>)"><i class="fas fa-edit"></i> <?php echo lang('qso_btn_edit_qso'); ?></a></p></div>
<div style="display: inline-block;"><form method="POST" action="<?php echo site_url('search'); ?>"><input type="hidden" value="<?php echo strtoupper($row->COL_CALL); ?>" name="callsign"><button class="btn btn-primary" type="submit"><i class="fas fa-eye"></i> <?php echo lang('general_more_qso'); ?></button></form></div>
<?php } ?>

Expand Down
11 changes: 11 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { defineConfig } = require("cypress");

module.exports = defineConfig({
projectId: 'gm8wco',
e2e: {
baseUrl: "http://localhost/",
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
22 changes: 22 additions & 0 deletions cypress/e2e/login.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
describe("Login Test", () => {
it("Should log in successfully", () => {
// Define the username and password
const username = "m0abc";
const password = "demo";

// Visit the login page
cy.visit("/index.php/user/login");

// Type the username and password into the input fields
cy.get('input[name="user_name"]').type(username);
cy.get('input[name="user_password"]').type(password);

// Click the login button
cy.get('button[type="submit"]').click();

// Check if the login was successful
// This could be checking/ for a URL change, looking for a log out button, etc.
cy.url().should("include", "/dashboard");
cy.contains("Logout");
});
});
47 changes: 47 additions & 0 deletions cypress/e2e/qso.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
describe("Post QSO Input Form", () => {
beforeEach(() => {
cy.login();
});

it("Submits a QSO", () => {
cy.visit("index.php/qso?manual=1");

cy.get('select[name="mode"]').select("USB");
cy.get('select[name="band"]').select("20m");
cy.get('#qso_input input[name="callsign"]').first().type("KS3CKC");

// Submit the QSO
cy.get("#qso_input").submit();

// Check if the QSO was added to the log
cy.visit("index.php/dashboard");

cy.get("table > tbody > tr:first").within(() => {
cy.get("td").eq(2).should("contain", "KS3CKC");
cy.get("td").eq(3).should("contain", "USB");
cy.get("td").eq(6).should("contain", "20m");
});
});

it("Delete a QSO", () => {
cy.visit("index.php/dashboard");

// Click the link in the first row of the table to open the modal
cy.get("table > tbody > tr:first").within(() => {
cy.get("a").first().click();
});

// Click the "Edit QSO" button
cy.get("a").contains("Edit QSO").should("be.visible").click();

// Click the delete button
cy.get("a")
.contains("Delete QSO")
.scrollIntoView()
.should("be.visible")
.click();

// Click the confirm delete button
cy.get("button").contains("OK").should("be.visible").click();
});
});
8 changes: 8 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Cypress.Commands.add("login", () => {
const username = "m0abc";
const password = "demo";
cy.visit("/index.php/user/login");
cy.get('input[name="user_name"]').type(username);
cy.get('input[name="user_password"]').type(password);
cy.get('button[type="submit"]').click();
});
20 changes: 20 additions & 0 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.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 './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
Loading

0 comments on commit 66017f3

Please sign in to comment.