Fix contest logging locator field length and tab navigation issues

Co-authored-by: magicbug <84308+magicbug@users.noreply.github.com>
这个提交包含在:
copilot-swe-agent[bot] 2025-07-30 15:36:19 +00:00
父节点 9a4a1c858a
当前提交 ae47a5204a
共有 3 个文件被更改,包括 69 次插入9 次删除

查看文件

@ -102,48 +102,48 @@
<div class="row">
<div class="mb-3 col-md-3">
<label for="callsign"><?php echo lang('gen_hamradio_callsign'); ?></label>
<input type="text" class="form-control form-control-sm" id="callsign" name="callsign" required pattern="\S+" title="Whitespace is not allowed">
<input type="text" class="form-control form-control-sm" id="callsign" name="callsign" required pattern="\S+" title="Whitespace is not allowed" tabindex="1">
<small id="callsign_info" class="badge text-bg-danger"></small>
</div>
<div class="mb-3 col-md-1">
<label for="rst_sent"><?php echo lang('gen_hamradio_rsts'); ?></label>
<input type="text" class="form-control form-control-sm" name="rst_sent" id="rst_sent" value="59">
<input type="text" class="form-control form-control-sm" name="rst_sent" id="rst_sent" value="59" tabindex="2">
</div>
<div style="display:none" class="mb-3 col-md-1 serials">
<label for="exch_serial_s"><?php echo lang('contesting_exchange_serial_s'); ?></label>
<input type="number" class="form-control form-control-sm" name="exch_serial_s" id="exch_serial_s" value="">
<input type="number" class="form-control form-control-sm" name="exch_serial_s" id="exch_serial_s" value="" tabindex="3">
</div>
<div style="display:none" class="mb-3 col-md-1 exchanges">
<label for="exch_sent"><?php echo lang('gen_hamradio_exchange_sent_short'); ?></label>
<input type="text" class="form-control form-control-sm" name="exch_sent" id="exch_sent" value="">
<input type="text" class="form-control form-control-sm" name="exch_sent" id="exch_sent" value="" tabindex="3">
</div>
<div style="display:none" class="mb-3 col-md-2 gridsquares">
<label for="exch_gridsquare_s"><?php echo lang('contesting_exchange_gridsquare_s'); ?></label>
<input disabled type="text" class="form-control form-control-sm" name="exch_gridsquare_s" id="exch_gridsquare_s" value="<?php echo $my_gridsquare;?>">
<input disabled type="text" class="form-control form-control-sm" name="exch_gridsquare_s" id="exch_gridsquare_s" value="<?php echo $my_gridsquare;?>" tabindex="-1">
</div>
<div class="mb-3 col-md-1">
<label for="rst_rcvd"><?php echo lang('gen_hamradio_rstr'); ?></label>
<input type="text" class="form-control form-control-sm" name="rst_rcvd" id="rst_rcvd" value="59">
<input type="text" class="form-control form-control-sm" name="rst_rcvd" id="rst_rcvd" value="59" tabindex="4">
</div>
<div style="display:none" class="mb-3 col-md-1 serialr">
<label for="exch_serial_r"><?php echo lang('contesting_exchange_serial_r'); ?></label>
<input type="number" class="form-control form-control-sm" name="exch_serial_r" id="exch_serial_r" value="">
<input type="number" class="form-control form-control-sm" name="exch_serial_r" id="exch_serial_r" value="" tabindex="5">
</div>
<div style="display:none" class="mb-3 col-md-1 exchanger">
<label for="exch_rcvd"><?php echo lang('gen_hamradio_exchange_rcvd_short'); ?></label>
<input type="text" class="form-control form-control-sm" name="exch_rcvd" id="exch_rcvd" value="">
<input type="text" class="form-control form-control-sm" name="exch_rcvd" id="exch_rcvd" value="" tabindex="5">
</div>
<div style="display:none" class="mb-3 col-md-2 gridsquarer">
<label for="exch_gridsquare_r"><?php echo lang('contesting_exchange_gridsquare_r'); ?></label>
<input type="text" class="form-control form-control-sm" name="locator" id="exch_gridsquare_r" value="">
<input type="text" class="form-control form-control-sm" name="locator" id="exch_gridsquare_r" value="" maxlength="8" tabindex="6">
</div>
</div>

查看文件

@ -0,0 +1,54 @@
describe('Contest Logging', () => {
beforeEach(() => {
// Navigate to contest logging page
// Note: This test assumes the application is already set up and accessible
cy.visit('/index.php/contesting?manual=1');
// Wait for page to load and set exchange type to Serialgridsquare
cy.get('#exchangetype').select('Serialgridsquare');
});
it('should allow 6-character locator input in gridsquare field', () => {
// Test that the locator field accepts 6-character locators like JO42JA
cy.get('#exch_gridsquare_r').should('be.visible');
cy.get('#exch_gridsquare_r').type('JO42JA');
cy.get('#exch_gridsquare_r').should('have.value', 'JO42JA');
// Test that it also accepts 8-character locators
cy.get('#exch_gridsquare_r').clear();
cy.get('#exch_gridsquare_r').type('JO42JA67');
cy.get('#exch_gridsquare_r').should('have.value', 'JO42JA67');
});
it('should support proper tab navigation through contest fields for Serialgridsquare exchange', () => {
// Start from callsign field
cy.get('#callsign').focus();
// Tab through fields and verify the order
cy.get('#callsign').tab();
cy.focused().should('have.id', 'rst_sent');
cy.focused().tab();
cy.focused().should('have.id', 'exch_serial_s');
cy.focused().tab();
cy.focused().should('have.id', 'rst_rcvd');
cy.focused().tab();
cy.focused().should('have.id', 'exch_serial_r');
cy.focused().tab();
cy.focused().should('have.id', 'exch_gridsquare_r');
});
it('should show correct fields for Serialgridsquare exchange type', () => {
// Verify that the correct fields are visible for Serialgridsquare exchange
cy.get('.serials').should('be.visible');
cy.get('.serialr').should('be.visible');
cy.get('.gridsquarer').should('be.visible');
// Verify that other exchange type fields are hidden
cy.get('.exchanges').should('not.be.visible');
cy.get('.exchanger').should('not.be.visible');
});
});

查看文件

@ -12,3 +12,9 @@ Cypress.Commands.add("waitForSelectOptions", (selector, minOptions = 1) => {
cy.get(selector).should('be.visible');
cy.get(`${selector} option`).should('have.length.greaterThan', minOptions);
});
// Custom command to simulate tab key press
Cypress.Commands.add("tab", { prevSubject: 'element' }, (subject) => {
cy.wrap(subject).trigger('keydown', { key: 'Tab', code: 'Tab', keyCode: 9 });
return cy.focused();
});