feat: add tests for feature

pull/237/head
Louis Delbosc 2 years ago
parent 531ea1a4b5
commit a82d02ebcc

@ -57,7 +57,10 @@ export function buildPageDom(name: Observable<string>, actions: PageActions, ...
domComputed(isRenaming, (isrenaming) => ( domComputed(isRenaming, (isrenaming) => (
isrenaming ? isrenaming ?
cssPageItem( cssPageItem(
cssPageInitial(dom.text((use) => Array.from(use(name))[0])), cssPageInitial(
testId('initial'),
dom.text((use) => Array.from(use(name))[0])
),
cssEditorInput( cssEditorInput(
{ {
initialValue: name.get() || '', initialValue: name.get() || '',
@ -73,7 +76,10 @@ export function buildPageDom(name: Observable<string>, actions: PageActions, ...
// firefox. // firefox.
) : ) :
cssPageItem( cssPageItem(
cssPageInitial(dom.text((use) => Array.from(use(name))[0])), cssPageInitial(
testId('initial'),
dom.text((use) => Array.from(use(name))[0]),
),
cssPageName( cssPageName(
dom.text(name), dom.text(name),
testId('label'), testId('label'),
@ -129,6 +135,7 @@ const cssPageName = styled('div', `
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
flex-grow: 1;
.${treeViewContainer.className}-close & { .${treeViewContainer.className}-close & {
display: none; display: none;
} }

@ -68,13 +68,13 @@ describe('Pages', function() {
await gu.waitForServer(); await gu.waitForServer();
// Click on a page; check the URL, selected item, and the title of the view section. // Click on a page; check the URL, selected item, and the title of the view section.
await driver.findContent('.test-treeview-itemHeader', /Documents/).doClick(); await clickPage(/Documents/)
assert.match(await driver.getCurrentUrl(), /\/p\/3/); assert.match(await driver.getCurrentUrl(), /\/p\/3/);
assert.match(await driver.find('.test-treeview-itemHeader.selected').getText(), /Documents/); assert.match(await driver.find('.test-treeview-itemHeader.selected').getText(), /Documents/);
assert.match(await gu.getActiveSectionTitle(), /Documents/i); assert.match(await gu.getActiveSectionTitle(), /Documents/i);
// Click on another page; check the URL, selected item, and the title of the view section. // Click on another page; check the URL, selected item, and the title of the view section.
await driver.findContent('.test-treeview-itemHeader', /People/).doClick(); await clickPage(/People/)
assert.match(await driver.getCurrentUrl(), /\/p\/2/); assert.match(await driver.getCurrentUrl(), /\/p\/2/);
assert.match(await driver.find('.test-treeview-itemHeader.selected').getText(), /People/); assert.match(await driver.find('.test-treeview-itemHeader.selected').getText(), /People/);
assert.match(await gu.getActiveSectionTitle(), /People/i); assert.match(await gu.getActiveSectionTitle(), /People/i);
@ -107,6 +107,24 @@ describe('Pages', function() {
assert.deepEqual(await gu.getPageNames(), ['Interactions', 'Documents', 'People', 'User & Leads', 'Overview']); assert.deepEqual(await gu.getPageNames(), ['Interactions', 'Documents', 'People', 'User & Leads', 'Overview']);
}); });
it('should allow renaming table when click on page selected label', async () => {
// do rename
await clickPage(/People/)
await driver.findContent('.test-treeview-label', 'People').doClick();
await driver.find('.test-docpage-editor').sendKeys('PeopleRenamed', Key.ENTER);
await gu.waitForServer();
assert.deepEqual(
await gu.getPageNames(),
['Interactions', 'Documents', 'PeopleRenamed', 'User & Leads', 'Overview']
);
// revert changes
await gu.undo(2);
assert.deepEqual(await gu.getPageNames(), ['Interactions', 'Documents', 'People', 'User & Leads', 'Overview']);
})
it('should not allow blank page name', async () => { it('should not allow blank page name', async () => {
// Begin renaming of People page // Begin renaming of People page
await gu.openPageMenu('People'); await gu.openPageMenu('People');
@ -196,7 +214,7 @@ describe('Pages', function() {
} }
// goto page 'Interactions' // goto page 'Interactions'
await driver.findContent('.test-treeview-itemHeader', /Interactions/).doClick(); await clickPage(/Interactions/);
// check selected page // check selected page
assert.match(await selectedPage(), /Interactions/); assert.match(await selectedPage(), /Interactions/);
@ -231,14 +249,15 @@ describe('Pages', function() {
it('undo/redo should update url', async () => { it('undo/redo should update url', async () => {
// goto page 'Interactions' and send keys // goto page 'Interactions' and send keys
await driver.findContent('.test-treeview-itemHeader', /Interactions/).doClick(); await clickPage(/Interactions/);
assert.match(await driver.find('.test-treeview-itemHeader.selected').getText(), /Interactions/);
await driver.findContentWait('.gridview_data_row_num', /1/, 2000); await driver.findContentWait('.gridview_data_row_num', /1/, 2000);
await driver.sendKeys(Key.ENTER, 'Foo', Key.ENTER); await driver.sendKeys(Key.ENTER, 'Foo', Key.ENTER);
await gu.waitForServer(); await gu.waitForServer();
assert.deepEqual(await gu.getVisibleGridCells(0, [1]), ['Foo']); assert.deepEqual(await gu.getVisibleGridCells(0, [1]), ['Foo']);
// goto page 'People' and click undo // goto page 'People' and click undo
await driver.findContent('.test-treeview-itemHeader', /People/).doClick(); await clickPage(/People/);
await gu.waitForDocToLoad(); await gu.waitForDocToLoad();
await gu.waitForUrl(/\/p\/2\b/); // check that url match p/2 await gu.waitForUrl(/\/p\/2\b/); // check that url match p/2
@ -251,11 +270,14 @@ describe('Pages', function() {
// check that undo worked // check that undo worked
assert.deepEqual(await gu.getVisibleGridCells(0, [1]), ['']); assert.deepEqual(await gu.getVisibleGridCells(0, [1]), ['']);
// Click on next test should not trigger renaming input
await driver.findContent('.test-treeview-itemHeader', /People/).doClick();
}); });
it('Add new page should update url', async () => { it('Add new page should update url', async () => {
// goto page 'Interactions' and check that url updated // goto page 'Interactions' and check that url updated
await driver.findContent('.test-treeview-itemHeader', /Interactions/).doClick(); await clickPage(/Interactions/);
await gu.waitForUrl(/\/p\/1\b/); await gu.waitForUrl(/\/p\/1\b/);
// Add new Page, check that url updated and page is selected // Add new Page, check that url updated and page is selected
@ -264,7 +286,7 @@ describe('Pages', function() {
assert.match(await driver.find('.test-treeview-itemHeader.selected').getText(), /Table1/); assert.match(await driver.find('.test-treeview-itemHeader.selected').getText(), /Table1/);
// goto page 'Interactions' and check that url updated and page selectd // goto page 'Interactions' and check that url updated and page selectd
await driver.findContent('.test-treeview-itemHeader', /Interactions/).doClick(); await clickPage(/Interactions/);
await gu.waitForUrl(/\/p\/1\b/); await gu.waitForUrl(/\/p\/1\b/);
assert.match(await driver.find('.test-treeview-itemHeader.selected').getText(), /Interactions/); assert.match(await driver.find('.test-treeview-itemHeader.selected').getText(), /Interactions/);
}); });
@ -449,6 +471,7 @@ describe('Pages', function() {
assert.deepEqual(await gu.getPageNames(), ['Table C', 'Table Last']); assert.deepEqual(await gu.getPageNames(), ['Table C', 'Table Last']);
// Removing page Table C should also show prompt (it is last page for Table1,Table D and TableC) // Removing page Table C should also show prompt (it is last page for Table1,Table D and TableC)
await gu.getPageItem('Table Last').click();
await gu.getPageItem('Table C').click(); await gu.getPageItem('Table C').click();
assert.deepEqual(await gu.getSectionTitles(), ['TABLE C', 'TABLE D', 'TABLE1' ]); assert.deepEqual(await gu.getSectionTitles(), ['TABLE C', 'TABLE D', 'TABLE1' ]);
await gu.removePage("Table C", { expectPrompt : true, tables: ['Table D', 'Table C', 'Table1'] }); await gu.removePage("Table C", { expectPrompt : true, tables: ['Table D', 'Table C', 'Table1'] });
@ -473,3 +496,7 @@ async function movePage(page: RegExp, target: {before: RegExp}|{after: RegExp})
}) })
.release()); .release());
} }
function clickPage(name: string|RegExp) {
return driver.findContent('.test-treeview-itemHeader', name).find(".test-docpage-initial").doClick();
}

Loading…
Cancel
Save