Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/containers/modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Modal extends React.Component {
componentDidMount () {
// Add a history event only if it's not currently for our modal. This
// avoids polluting the history with many entries. We only need one.
this.pushHistory(this.id, history.state === null);
this.pushHistory(this.id, (history.state === null || history.state !== this.id));
}
componentWillUnmount () {
this.removeEventListeners();
Expand Down
5 changes: 5 additions & 0 deletions test/helpers/selenium-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class SeleniumHelper {
'clickText',
'clickButton',
'clickXpath',
'elementIsVisible',
'findByText',
'findByXpath',
'getDriver',
Expand All @@ -24,6 +25,10 @@ class SeleniumHelper {
]);
}

elementIsVisible (element) {
return this.driver.wait(until.elementIsVisible(element));
}

get scope () {
// List of useful xpath scopes for finding elements
return {
Expand Down
24 changes: 24 additions & 0 deletions test/integration/sprites.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import SeleniumHelper from '../helpers/selenium-helper';
const {
clickText,
clickXpath,
elementIsVisible,
findByText,
findByXpath,
getDriver,
Expand Down Expand Up @@ -124,4 +125,27 @@ describe('Working with sprites', () => {
const logs = await getLogs();
await expect(logs).toEqual([]);
});

test('Use browser back button to close library', async () => {
await driver.get('https://www.google.com');
await loadUri(uri);
await clickXpath('//button[@title="Try It"]');
await clickText('Costumes');
await clickXpath('//button[@aria-label="Choose a Sprite"]');
const abbyElement = await findByText('Abby'); // Should show editor for new costume
await elementIsVisible(abbyElement);
await driver.navigate().back();
try {
// should throw error because library is no longer visible
await elementIsVisible(abbyElement);
throw 'ShouldNotGetHere'; // eslint-disable-line no-throw-literal
} catch (e) {
expect(e.constructor.name).toEqual('StaleElementReferenceError');
}
const costumesElement = await findByText('Costumes'); // Should show editor for new costume
await elementIsVisible(costumesElement);
const logs = await getLogs();
await expect(logs).toEqual([]);
});

});