Skip to content

Commit

Permalink
refactor: ng-page-object-model (#3195)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescoBorzi authored Dec 16, 2024
1 parent 597541b commit 88cfb31
Show file tree
Hide file tree
Showing 37 changed files with 343 additions and 224 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ describe('CreatureOnkillReputation integration tests', () => {
'`MaxStanding2` = 1, `IsTeamAward2` = 1, `RewOnKillRepValue2` = 7, `TeamDependent` = 1 WHERE (`creature_id` = 1234);';
querySpy.calls.reset();

const MaxStanding1 = page.getDebugElementByCss('#MaxStanding1 select').nativeElement;
const MaxStanding2 = page.getDebugElementByCss('#MaxStanding2 select').nativeElement;
const IsTeamAward1 = page.getDebugElementByCss('#IsTeamAward1 select').nativeElement;
const IsTeamAward2 = page.getDebugElementByCss('#IsTeamAward2 select').nativeElement;
const TeamDependent = page.getDebugElementByCss('#TeamDependent select').nativeElement;
const MaxStanding1 = page.getDebugElementByCss<HTMLSelectElement>('#MaxStanding1 select').nativeElement;
const MaxStanding2 = page.getDebugElementByCss<HTMLSelectElement>('#MaxStanding2 select').nativeElement;
const IsTeamAward1 = page.getDebugElementByCss<HTMLSelectElement>('#IsTeamAward1 select').nativeElement;
const IsTeamAward2 = page.getDebugElementByCss<HTMLSelectElement>('#IsTeamAward2 select').nativeElement;
const TeamDependent = page.getDebugElementByCss<HTMLSelectElement>('#TeamDependent select').nativeElement;
page.setInputValue(MaxStanding1, '1: 1');
page.setInputValue(MaxStanding2, '1: 1');
page.setInputValue(IsTeamAward1, '1: 1');
Expand All @@ -146,7 +146,7 @@ describe('CreatureOnkillReputation integration tests', () => {
'(1234, 0, 1, 0, 0, 0, 0, 0, 0, 0);',
);

const IsTeamAward1 = page.getDebugElementByCss('#IsTeamAward1 select').nativeElement;
const IsTeamAward1 = page.getDebugElementByCss<HTMLSelectElement>('#IsTeamAward1 select').nativeElement;
page.setInputValue(IsTeamAward1, '1: 1');
page.expectDiffQueryToContain(
'UPDATE `creature_onkill_reputation` SET `RewOnKillRepFaction2` = 1, `IsTeamAward1` = 1 WHERE (`creature_id` = 1234);',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ describe('CreatureSpawnAddon integration tests', () => {
expect(page.getInputById('guid').disabled).toBe(true);
expect(page.getInputById('path_id').disabled).toBe(true);
expect(page.getInputById('mount').disabled).toBe(true);
expect(page.getDebugElementByCss('#bytes1 select').nativeElement.disabled).toBe(true);
expect(page.getDebugElementByCss('#bytes2 select').nativeElement.disabled).toBe(true);
expect(page.getDebugElementByCss('#emote select').nativeElement.disabled).toBe(true);
expect(page.getDebugElementByCss<HTMLSelectElement>('#bytes1 select').nativeElement.disabled).toBe(true);
expect(page.getDebugElementByCss<HTMLSelectElement>('#bytes2 select').nativeElement.disabled).toBe(true);
expect(page.getDebugElementByCss<HTMLSelectElement>('#emote select').nativeElement.disabled).toBe(true);
expect(page.getInputById('visibilityDistanceType').disabled).toBe(true);
expect(page.getInputById('auras').disabled).toBe(true);
expect(page.getEditorTableRowsCount()).toBe(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('CreatureSpawn integration tests', () => {
expect(page.getInputById('currentwaypoint').disabled).toBe(true);
expect(page.getInputById('curhealth').disabled).toBe(true);
expect(page.getInputById('curmana').disabled).toBe(true);
expect(page.getDebugElementByCss('#MovementType select').nativeElement.disabled).toBe(true);
expect(page.getDebugElementByCss<HTMLSelectElement>('#MovementType select').nativeElement.disabled).toBe(true);
expect(page.getInputById('npcflag').disabled).toBe(true);
expect(page.getInputById('unit_flags').disabled).toBe(true);
expect(page.getInputById('dynamicflags').disabled).toBe(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('CreatureTemplateModel integration tests', () => {
expect(page.getInputById('Probability').disabled).toBe(true);
expect(page.getInputById('VerifiedBuild').disabled).toBe(true);
expect(page.getEditorTableRowsCount()).toBe(0);
page.removeElement();
page.removeNativeElement();
});

it('should correctly update the unsaved status', () => {
Expand All @@ -93,7 +93,7 @@ describe('CreatureTemplateModel integration tests', () => {
expect(handlerService.isCreatureTemplateModelUnsaved).toBe(true);
page.deleteRow();
expect(handlerService.isCreatureTemplateModelUnsaved).toBe(false);
page.removeElement();
page.removeNativeElement();
});

it('adding new rows and executing the query should correctly work', () => {
Expand All @@ -118,7 +118,7 @@ describe('CreatureTemplateModel integration tests', () => {
page.clickExecuteQuery();
expect(querySpy).toHaveBeenCalledTimes(1);
expect(querySpy.calls.mostRecent().args[0]).toContain(expectedQuery);
page.removeElement();
page.removeNativeElement();
});

it('adding a row and changing its values should correctly update the queries', () => {
Expand Down Expand Up @@ -147,7 +147,7 @@ describe('CreatureTemplateModel integration tests', () => {
'INSERT INTO `creature_template_model` (`CreatureID`, `Idx`, `CreatureDisplayID`, `DisplayScale`, `Probability`, `VerifiedBuild`) VALUES\n' +
'(1234, 28, 0, 1, 0, 0);',
);
page.removeElement();
page.removeNativeElement();
});

it('adding a row changing its values and duplicate it should correctly update the queries', () => {
Expand All @@ -170,7 +170,7 @@ describe('CreatureTemplateModel integration tests', () => {
'(1234, 28, 0, 1, 0, 0),\n' +
'(1234, 0, 0, 1, 0, 0);',
);
page.removeElement();
page.removeNativeElement();
});
});

Expand All @@ -189,7 +189,7 @@ describe('CreatureTemplateModel integration tests', () => {
);
expect(page.getEditorTableRowsCount()).toBe(3);
expect(page.getAllModelViewers().length).toBe(3); // check one model viewer per row
page.removeElement();
page.removeNativeElement();
});

it('deleting rows should correctly work', () => {
Expand All @@ -216,7 +216,7 @@ describe('CreatureTemplateModel integration tests', () => {
expect(page.getEditorTableRowsCount()).toBe(0);
page.expectDiffQueryToContain('DELETE FROM `creature_template_model` WHERE `CreatureID` = 1234;');
page.expectFullQueryToBeEmpty();
page.removeElement();
page.removeNativeElement();
});

it('editing existing rows should correctly work', () => {
Expand All @@ -239,7 +239,7 @@ describe('CreatureTemplateModel integration tests', () => {
'(1234, 1, 1111, 222, 333, 0),\n' +
'(1234, 2, 0, 1, 0, 0);',
);
page.removeElement();
page.removeNativeElement();
});

it('combining add, edit and delete should correctly work', () => {
Expand Down Expand Up @@ -268,7 +268,7 @@ describe('CreatureTemplateModel integration tests', () => {
'(1234, 28, 0, 1, 0, 0),\n' +
'(1234, 3, 0, 1, 0, 0);',
);
page.removeElement();
page.removeNativeElement();
});

it('using the same row id for multiple rows should correctly show an error', () => {
Expand All @@ -277,7 +277,7 @@ describe('CreatureTemplateModel integration tests', () => {
page.setInputValueById('Idx', 0);

page.expectUniqueError();
page.removeElement();
page.removeNativeElement();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ describe('CreatureTemplateResistance integration tests', () => {
expect(page.formError.hidden).toBe(true);
expect(page.addNewRowBtn.disabled).toBe(false);
expect(page.deleteSelectedRowBtn.disabled).toBe(true);
expect(page.getDebugElementByCss('#School select').nativeElement.disabled).toBe(true);
expect(page.getDebugElementByCss<HTMLSelectElement>('#School select').nativeElement.disabled).toBe(true);
expect(page.getInputById('Resistance').disabled).toBe(true);
expect(page.getEditorTableRowsCount()).toBe(0);
page.removeElement();
page.removeNativeElement();
});

it('should correctly update the unsaved status', () => {
Expand All @@ -77,7 +77,7 @@ describe('CreatureTemplateResistance integration tests', () => {
expect(handlerService.isCreatureTemplateResistanceUnsaved).toBe(true);
page.deleteRow();
expect(handlerService.isCreatureTemplateResistanceUnsaved).toBe(false);
page.removeElement();
page.removeNativeElement();
});

it('adding new rows and executing the query should correctly work', () => {
Expand All @@ -101,7 +101,7 @@ describe('CreatureTemplateResistance integration tests', () => {
page.clickExecuteQuery();
expect(querySpy).toHaveBeenCalledTimes(1);
expect(querySpy.calls.mostRecent().args[0]).toContain(expectedQuery);
page.removeElement();
page.removeNativeElement();
});

it('adding a row and changing its values should correctly update the queries', () => {
Expand All @@ -118,7 +118,7 @@ describe('CreatureTemplateResistance integration tests', () => {
'(1234, 1, 0, 0);',
);

const select = page.getDebugElementByCss('#School select').nativeElement;
const select = page.getDebugElementByCss<HTMLSelectElement>('#School select').nativeElement;
page.setInputValue(select, '1: 2');

page.expectDiffQueryToContain(
Expand All @@ -131,14 +131,14 @@ describe('CreatureTemplateResistance integration tests', () => {
'INSERT INTO `creature_template_resistance` (`CreatureID`, `School`, `Resistance`, `VerifiedBuild`) VALUES\n' +
'(1234, 2, 0, 0);',
);
page.removeElement();
page.removeNativeElement();
});

it('adding a row changing its values and duplicate it should correctly update the queries', () => {
const { page } = setup(true);
page.addNewRow();

const select = page.getDebugElementByCss('#School select').nativeElement;
const select = page.getDebugElementByCss<HTMLSelectElement>('#School select').nativeElement;
page.setInputValue(select, '1: 2');

page.duplicateSelectedRow();
Expand All @@ -155,7 +155,7 @@ describe('CreatureTemplateResistance integration tests', () => {
'(1234, 2, 0, 0),\n' +
'(1234, 1, 0, 0);',
);
page.removeElement();
page.removeNativeElement();
});
});

Expand All @@ -173,7 +173,7 @@ describe('CreatureTemplateResistance integration tests', () => {
'(1234, 3, 0, 0);',
);
expect(page.getEditorTableRowsCount()).toBe(3);
page.removeElement();
page.removeNativeElement();
});

it('deleting rows should correctly work', () => {
Expand Down Expand Up @@ -201,7 +201,7 @@ describe('CreatureTemplateResistance integration tests', () => {
expect(page.getEditorTableRowsCount()).toBe(0);
page.expectDiffQueryToContain('DELETE FROM `creature_template_resistance` WHERE `CreatureID` = 1234;');
page.expectFullQueryToBeEmpty();
page.removeElement();
page.removeNativeElement();
});

it('editing existing rows should correctly work', () => {
Expand All @@ -222,7 +222,7 @@ describe('CreatureTemplateResistance integration tests', () => {
'(1234, 2, 1, 0),\n' +
'(1234, 3, 0, 0);',
);
page.removeElement();
page.removeNativeElement();
});

it('combining add, edit and delete should correctly work', () => {
Expand All @@ -231,7 +231,7 @@ describe('CreatureTemplateResistance integration tests', () => {
expect(page.getEditorTableRowsCount()).toBe(4);

page.clickRowOfDatatable(1);
const select = page.getDebugElementByCss('#School select').nativeElement;
const select = page.getDebugElementByCss<HTMLSelectElement>('#School select').nativeElement;
page.setInputValue(select, '4: 5');

expect(page.getEditorTableRowsCount()).toBe(4);
Expand All @@ -252,17 +252,17 @@ describe('CreatureTemplateResistance integration tests', () => {
'(1234, 5, 0, 0),\n' +
'(1234, 4, 0, 0);',
);
page.removeElement();
page.removeNativeElement();
});

it('using the same row id for multiple rows should correctly show an error', () => {
const { page } = setup(false);
page.clickRowOfDatatable(2);
const select = page.getDebugElementByCss('#School select').nativeElement;
const select = page.getDebugElementByCss<HTMLSelectElement>('#School select').nativeElement;
page.setInputValue(select, '1: 2');

page.expectUniqueError();
page.removeElement();
page.removeNativeElement();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('CreatureTemplateSpell integration tests', () => {
expect(page.getInputById('Index').disabled).toBe(true);
expect(page.getInputById('Spell').disabled).toBe(true);
expect(page.getEditorTableRowsCount()).toBe(0);
page.removeElement();
page.removeNativeElement();
});

it('should correctly update the unsaved status', () => {
Expand All @@ -86,7 +86,7 @@ describe('CreatureTemplateSpell integration tests', () => {
expect(handlerService.isCreatureTemplateSpellUnsaved).toBe(true);
page.deleteRow();
expect(handlerService.isCreatureTemplateSpellUnsaved).toBe(false);
page.removeElement();
page.removeNativeElement();
});

it('adding new rows and executing the query should correctly work', () => {
Expand All @@ -110,7 +110,7 @@ describe('CreatureTemplateSpell integration tests', () => {
page.clickExecuteQuery();
expect(querySpy).toHaveBeenCalledTimes(1);
expect(querySpy.calls.mostRecent().args[0]).toContain(expectedQuery);
page.removeElement();
page.removeNativeElement();
});

it('adding a row and changing its values should correctly update the queries', () => {
Expand Down Expand Up @@ -138,7 +138,7 @@ describe('CreatureTemplateSpell integration tests', () => {
'INSERT INTO `creature_template_spell` (`CreatureID`, `Index`, `Spell`, `VerifiedBuild`) VALUES\n' +
'(1234, 1, 0, 0);',
);
page.removeElement();
page.removeNativeElement();
});

it('adding a row and changing its values should correctly update the queries', () => {
Expand All @@ -159,7 +159,7 @@ describe('CreatureTemplateSpell integration tests', () => {
'(1234, 1, 0, 0),\n' +
'(1234, 0, 0, 0);',
);
page.removeElement();
page.removeNativeElement();
});
});

Expand All @@ -177,7 +177,7 @@ describe('CreatureTemplateSpell integration tests', () => {
'(1234, 2, 0, 0);',
);
expect(page.getEditorTableRowsCount()).toBe(3);
page.removeElement();
page.removeNativeElement();
});

it('deleting rows should correctly work', () => {
Expand Down Expand Up @@ -205,7 +205,7 @@ describe('CreatureTemplateSpell integration tests', () => {
expect(page.getEditorTableRowsCount()).toBe(0);
page.expectDiffQueryToContain('DELETE FROM `creature_template_spell` WHERE `CreatureID` = 1234;');
page.expectFullQueryToBeEmpty();
page.removeElement();
page.removeNativeElement();
});

it('editing existing rows should correctly work', () => {
Expand All @@ -225,7 +225,7 @@ describe('CreatureTemplateSpell integration tests', () => {
'(1234, 1, 3, 0),\n' +
'(1234, 2, 0, 0);',
);
page.removeElement();
page.removeNativeElement();
});

it('combining add, edit and delete should correctly work', () => {
Expand Down Expand Up @@ -253,7 +253,7 @@ describe('CreatureTemplateSpell integration tests', () => {
'(1234, 7, 0, 0),\n' +
'(1234, 3, 0, 0);',
);
page.removeElement();
page.removeNativeElement();
});

it('using the same row id for multiple rows should correctly show an error', () => {
Expand All @@ -262,7 +262,7 @@ describe('CreatureTemplateSpell integration tests', () => {
page.setInputValueById('Index', '0: 0');

page.expectUniqueError();
page.removeElement();
page.removeNativeElement();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ describe('CreatureText integration tests', () => {
expect(page.getInputById('GroupID').disabled).toBe(true);
expect(page.getInputById('ID').disabled).toBe(true);
expect(page.getInputById('Text').disabled).toBe(true);
expect(page.getDebugElementByCss('#Type select').nativeElement.disabled).toBe(true);
expect(page.getDebugElementByCss<HTMLSelectElement>('#Type select').nativeElement.disabled).toBe(true);
expect(page.getInputById('Language').disabled).toBe(true);
expect(page.getInputById('Probability').disabled).toBe(true);
expect(page.getDebugElementByCss('#Emote select').nativeElement.disabled).toBe(true);
expect(page.getDebugElementByCss<HTMLSelectElement>('#Emote select').nativeElement.disabled).toBe(true);
expect(page.getInputById('Duration').disabled).toBe(true);
expect(page.getInputById('Sound').disabled).toBe(true);
expect(page.getInputById('BroadcastTextId').disabled).toBe(true);
expect(page.getDebugElementByCss('#TextRange select').nativeElement.disabled).toBe(true);
expect(page.getDebugElementByCss<HTMLSelectElement>('#TextRange select').nativeElement.disabled).toBe(true);
expect(page.getInputById('comment').disabled).toBe(true);
expect(page.getEditorTableRowsCount()).toBe(0);
});
Expand Down
Loading

0 comments on commit 88cfb31

Please sign in to comment.