Skip to content

Commit

Permalink
initialize input editor
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodingwizard committed Dec 19, 2023
1 parent c16d7e6 commit 5398c10
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
22 changes: 11 additions & 11 deletions e2e/respects_permissions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ test.describe('Respects Permissions', () => {
// test input
await page2.click('[data-test-id="input-editor"]');
await page2.waitForTimeout(200);
await page2.keyboard.type('1 2 3');
await page2.keyboard.type(' 4 5 6');
await page2.waitForTimeout(200);
expect(await page2.$('text="1 2 3"')).toBeFalsy();
expect(await page2.$('text="1 2 3 4 5 6"')).toBeFalsy();

await page.click('[data-test-id="input-editor"]');
await page.waitForTimeout(200);
await page.keyboard.type('1 2 3');
await page.keyboard.type(' 4 5 6');
await page.waitForTimeout(200);
expect(await page.$('text="1 2 3"')).toBeTruthy();
await page2.waitForSelector('text="1 2 3"');
expect(await page.$('text="1 2 3 4 5 6"')).toBeTruthy();
await page2.waitForSelector('text="1 2 3 4 5 6"');

// test scribble
await page2.click('text=scribble');
Expand Down Expand Up @@ -139,8 +139,8 @@ test.describe('Respects Permissions', () => {

// test input: everything should still work right now
await page2.click('[data-test-id="input-editor"]');
await page2.keyboard.type('1 2 3');
await page2.waitForSelector('text="1 2 3"');
await page2.keyboard.type(' 4');
await page2.waitForSelector('text="1 2 3 4"');

// try view only
await page.click('text=File');
Expand All @@ -151,8 +151,8 @@ test.describe('Respects Permissions', () => {

// test input: we shouldn't be able to type anything on page 2
await page2.click('[data-test-id="input-editor"]');
await page2.keyboard.type('4 5 6');
expect(await page2.$('text="4 5 6"')).toBeFalsy();
await page2.keyboard.type(' 0');
expect(await page2.$('text="1 2 3 4 5 6 0"')).toBeFalsy();

// try private
await page.click('text=File');
Expand All @@ -172,9 +172,9 @@ test.describe('Respects Permissions', () => {

// test input: we should be able to type stuff now
await page2.click('[data-test-id="input-editor"]');
await page2.keyboard.type('0 9 8');
await page2.keyboard.type(' 1');
// 1 2 3 from above
await page2.waitForSelector('text="1 2 30 9 8"');
await page2.waitForSelector('text="1 2 3 4 1"');

await page2.close();
await context2.close();
Expand Down
10 changes: 2 additions & 8 deletions e2e/runs_code.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ test.describe('Basic Functionality', () => {
// let monaco load
await page.waitForTimeout(500);

await page.click('[data-test-id="input-editor"]');
await page.keyboard.type('1 2 3');

await forEachLang(page, async () => {
await testRunCode(page);
});
Expand All @@ -32,9 +29,9 @@ test.describe('Basic Functionality', () => {
await page2.waitForTimeout(500);

await page.click('[data-test-id="input-editor"]');
await page.keyboard.type('1 2 3');
await page.keyboard.type(' 4 5 6');

await page2.waitForSelector('text="1 2 3"', { timeout: 2000 });
await page2.waitForSelector('text="1 2 3 4 5 6"', { timeout: 2000 });

await page2.close();
await context2.close();
Expand All @@ -53,9 +50,6 @@ test.describe('Basic Functionality', () => {
await page.waitForTimeout(500);
await page2.waitForTimeout(500);

await page.click('[data-test-id="input-editor"]');
await page.keyboard.type('1 2 3');

await page.click('button:has-text("Run Code")');
expect(await page.$('[data-test-id="run-code-loading"]')).toBeTruthy();
await page2.waitForSelector('[data-test-id="run-code-loading"]');
Expand Down
2 changes: 1 addition & 1 deletion src/components/Workspace/Workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export default function Workspace({
window['TEST_inputCodemirrorEditor'] = view;
setCodemirrorInputEditor(view);
}}
defaultValue=""
defaultValue="1 2 3"
yjsDocumentId={`${fileData.id}.input`}
/>
)}
Expand Down

0 comments on commit 5398c10

Please sign in to comment.