project-state.test.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import path from 'path';
  2. import SeleniumHelper from '../helpers/selenium-helper';
  3. const {
  4. clickText,
  5. clickXpath,
  6. findByXpath,
  7. getDriver,
  8. Key,
  9. loadUri
  10. } = new SeleniumHelper();
  11. const uri = path.resolve(__dirname, '../../build/index.html');
  12. let driver;
  13. describe('Project state', () => {
  14. beforeAll(() => {
  15. driver = getDriver();
  16. });
  17. afterAll(async () => {
  18. await driver.quit();
  19. });
  20. test('File->New resets project title', async () => {
  21. const defaultProjectTitle = 'Scratch Project';
  22. await loadUri(uri);
  23. const inputEl = await findByXpath(`//input[@value="${defaultProjectTitle}"]`);
  24. for (let i = 0; i < defaultProjectTitle.length; i++) {
  25. inputEl.sendKeys(Key.BACK_SPACE);
  26. }
  27. inputEl.sendKeys('Changed title of project');
  28. await clickText('Costumes'); // just to blur the input
  29. // verify that project title has changed
  30. await clickXpath('//input[@value="Changed title of project"]');
  31. await clickXpath(
  32. '//div[contains(@class, "menu-bar_menu-bar-item") and ' +
  33. 'contains(@class, "menu-bar_hoverable")][span[text()="File"]]'
  34. );
  35. await clickXpath('//li[span[text()="New"]]');
  36. // project title should be default again
  37. await clickXpath(`//input[@value="${defaultProjectTitle}"]`);
  38. });
  39. });