- Refactoring: Make dialog OK button retrievable locale-independently (for testing)
- Testing: Avoid testing being locale-dependent; approve storage (and set locale to English) before each test
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
export const approveStorage = (t) => {
|
||||
return t
|
||||
.click('#dialog_buttons > input[type=button][value=OK]');
|
||||
.click('#dialog_buttons > input[type=button][data-ok]');
|
||||
};
|
||||
|
||||
export const approveStorageAndOpenMainMenu = (t) => {
|
||||
return approveStorage(t).click('#main_icon');
|
||||
export const openMainMenu = (t) => {
|
||||
return t.click('#main_icon');
|
||||
};
|
||||
|
||||
export const approveStorageAndOpenEditorPreferences = (t) => {
|
||||
return approveStorageAndOpenMainMenu(t).click('#tool_prefs_option');
|
||||
export const openEditorPreferences = (t) => {
|
||||
return openMainMenu(t).click('#tool_prefs_option');
|
||||
};
|
||||
|
||||
@@ -3,35 +3,32 @@
|
||||
// https://github.com/helen-dikareva/axe-testcafe
|
||||
import {Selector} from 'testcafe';
|
||||
import {
|
||||
approveStorage, approveStorageAndOpenMainMenu,
|
||||
approveStorageAndOpenEditorPreferences
|
||||
approveStorage, openMainMenu,
|
||||
openEditorPreferences
|
||||
} from '../ui-test-helper.js';
|
||||
|
||||
fixture`TestCafe UI tests`
|
||||
.page`http://localhost:8000/editor/svg-editor.html`;
|
||||
|
||||
// Bogus test to allow us to check starting browser storage state
|
||||
test('Editor - No parameters: save prior locale and set English for tests', async (t) => {
|
||||
await approveStorageAndOpenEditorPreferences(t);
|
||||
t.fixtureCtx.originalLanguage = await Selector('#lang_select').value;
|
||||
// Ensure we test against English
|
||||
return t.click('#lang_select').click('#lang_en').click('#tool_prefs_save');
|
||||
});
|
||||
.page`http://localhost:8000/editor/svg-editor.html`
|
||||
.beforeEach((t) => {
|
||||
// Ensure we test against English regardless of the original locale
|
||||
return openEditorPreferences(approveStorage(t))
|
||||
.click('#lang_select').click('#lang_en').click('#tool_prefs_save');
|
||||
});
|
||||
|
||||
test('Editor - No parameters: Export button', async (t) => {
|
||||
await approveStorageAndOpenMainMenu(t)
|
||||
await openMainMenu(t)
|
||||
.expect(Selector('#tool_export')).ok('Has open button');
|
||||
});
|
||||
|
||||
test('Editor - No parameters: Export button clicking', async (t) => {
|
||||
await approveStorageAndOpenMainMenu(t)
|
||||
await openMainMenu(t)
|
||||
.click('#tool_export')
|
||||
.expect(Selector('#dialog_content select')).ok('Export dialog opens');
|
||||
});
|
||||
|
||||
test('Editor - No parameters: Drag control point of arc path', async (t) => {
|
||||
const randomOffset = () => Math.round(10 + Math.random() * 40);
|
||||
await approveStorage(t)
|
||||
await t
|
||||
.click('#tool_source')
|
||||
.selectTextAreaContent('#svg_source_textarea')
|
||||
.typeText('#svg_source_textarea', `<svg width="640" height="480" xmlns="http://www.w3.org/2000/svg">
|
||||
@@ -47,11 +44,3 @@ test('Editor - No parameters: Drag control point of arc path', async (t) => {
|
||||
.drag('#pathpointgrip_1', randomOffset(), randomOffset(), {offsetX: 2, offsetY: 2})
|
||||
.expect(Selector('#svg_1').getAttribute('d')).notContains('NaN');
|
||||
});
|
||||
|
||||
// Bogus test to allow us to reset browser storage state to starting value
|
||||
test('Editor - No parameters: restore prior locale', async (t) => {
|
||||
await approveStorageAndOpenEditorPreferences(t)
|
||||
.click('#lang_select')
|
||||
.click('#lang_' + t.fixtureCtx.originalLanguage)
|
||||
.click('#tool_prefs_save');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user